[Gdal-dev] OGRSpatialReference::SetUTM bug?

Frank Warmerdam warmerdam at pobox.com
Sat Oct 15 20:31:47 EDT 2005


On 10/15/05, Ray Gardener <rayg at daylongraphics.com> wrote:
> I was modifying an OGRSpatialReference to use UTM, but if its current
> linear units were not meters, OGRSpatialReference::SetUTM() would set
> the false_easting param to 500000, then GetUTMZone() would read back a
> scaled value causing the comparison to 500000 to fail.
>
> Is SetUTM() supposed to assume that the linear units are already meters,
> or should it force the units to meters? And should GetUTM test that the
> units are meters?

Ray,

I see that SetUTM() sets the false easting and northing using
SetNormProjParm().  This method is supposed to set the
projection parameters in "normalized" form, that is meters
and degrees.  If a non-meter linear unit had already been set
then the easting and northing should be translated on the fly.

If you set an alternate linear unit after calling SetUTM() you
would need to call SetLinearUnitsAndUpdateParameters()
instead of SetLinearUnits() so that the false easting and northing
will get updated.

Likewise GetUTMZone() uses GetNormProjParm() which converts
the values to meters on the fly.  In theory this should mean it
would work, even for UTM in feet but in practice the false easting
is exactly compared to 500000.  After translating it is unlikely to be
an exact match.

So, generally if you are careful I think things are in pretty decent
shape.

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