[Gdal-dev] Comparing Barely-Different SpatialRef Objects with .IsSame

Frank Warmerdam warmerdam at pobox.com
Sat Oct 15 18:11:23 EDT 2005


On 10/14/05, Christopher Michaelis <cmichaelis at happysquirrel.com> wrote:
> Hi there,
>
> I'm trying to compare two proj4 strings by loading each one into an
> OGRSpatialReference object using .ImportFromProj4(), then comparing them
> using .IsSame().
>
> The problem that's arising is that the two are just barely off
> (.0000000001 off on the y_0 parameter). Therefore, .IsSame() is
> returning false.
>
> So, my question for the crowd is, how can I detect this condition and
> actually catch these two as equivalent?
>
> The two strings in question are:
> "+proj=lcc +lat_1=38.33333333333334 +lat_2=39.83333333333334
> +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000.0000000001
> +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
>
> "+proj=lcc +lat_1=38.33333333333334 +lat_2=39.83333333333334
> +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000.0000000002
> +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
>
> Any thoughts? BTW, I'm using GDAL 1.3.0.

Chris,

This is just one of a variety of limitations of
OGRSpatialReference::IsSame().   If you want to make serious
use of the method it will need some parameter type sensitive
epsilon testing as well as lots of other logic.

Short of rolling up your sleeves and implementing such logic
I have no advice.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list