[GRASS-dev] [bug #5454] (grass) ps.map scaling not correct when projection units are feet

Paul Kelly paul-grass at stjohnspoint.co.uk
Tue Jan 30 11:18:31 EST 2007


On Tue, 30 Jan 2007, Glynn Clements wrote:

>
> Hamish wrote:
>
>> Create new locn from EPSG code is in general/g.proj/output.c,
>> but I don't really follow it.
>
> AFAICT, the problem is with GPJ_osr_to_grass(); lib/proj/convert.c:
>
> 592        dfToMeters = OSRGetLinearUnits( hSRS, &pszUnitsName );
> 593
> 594        /* Workaround for the most obvious case when unit name is unknown */
> 595        if( (strcasecmp(pszUnitsName, "unknown") == 0) && (dfToMeters == 1.) )
> 596            G_asprintf( &pszUnitsName, "meter" );
> 597
> 598        G_set_key_value( "unit", pszUnitsName, *projunits );
> 599        sprintf( szFormatBuf, "%ss", pszUnitsName );
> 600        G_set_key_value( "units", szFormatBuf, *projunits );
>
> AFAICT, the OGR API doesn't provide a mechanism to get the plural
> name, so the code will need to handle it as a special case, e.g.:

Yes that's exactly the reason - the WKT format used for import only 
contains the singular, and when I originally wrote that function I 
couldn't see a programmatically convenient way of accounting for irregular 
plurals. But...

> 	if (G_strcasecmp(pszUnitsName, "foot") == 0)
> 		strcpy( szFormatBuf, "feet" );
> 	else
> 		sprintf( szFormatBuf, "%ss", pszUnitsName );

I thought of something like this at the time, but that wouldn't have 
handled this particular case, where the full string was "US survey foot". 
I have also seen variations on this, e.g. "U.S. Survey Foot". But I had an 
idea which I think should be moderately robust - just do the comparison on 
the last 4 characters in the string.

It seems to have work and have committed it to CVS - also handles inches 
now ;)

Out of interest, here's the two sets of PROJ_INFO/PROJ_UNITS files for a 
central Mexico State Plane location created using (a) EPSG code and 
g.proj and (b) selecting the stp projection and following the prompts in 
g.setproj:

(a) Created by g.setproj (State Plane)
-PROJ_INFO-------------------------------------------------
name       : State Plane
datum      : nad83
towgs84    : 0.000,0.000,0.000
proj       : tmerc
a          : 0.6378137e+07
es         : 0.66943800229e-02
x_0        : 0.5e+06
y_0        : 0
k          : 0.9999e+00
lon_0      : 106d15'w
lat_0      : 31dn
-PROJ_UNITS------------------------------------------------
unit       : USfoot
units      : USfeet
meters     : 0.30480060960121920243

(b) Created by g.proj using EPSG code
-PROJ_INFO-------------------------------------------------
name       : Transverse Mercator
proj       : tmerc
datum      : nad83
towgs84    : 0.000,0.000,0.000
ellps      : grs80
lat_0      : 31
lon_0      : -106.25
k          : 0.999900
x_0        : 500000.0001016001
y_0        : 0
no_defs    : defined
-PROJ_UNITS------------------------------------------------
unit       : US survey foot
units      : US survey feet
meters     : 0.3048006096012192

For (a) the "projection" key value in the WIND region file, raster headers 
etc. will be 2 (i.e. State Plane) while for (b) it will be 99 (i.e. 
Other). I think Maciek was asking recently about cases where this could be 
different yet the two projections equivalent, or something along those 
lines.

Paul




More information about the grass-dev mailing list