Opened 8 years ago

Closed 8 months ago

#3590 closed enhancement (fixed)

Enhance mitab_coordsys.cpp to handle unit numbers

Reported by: kfaschoway Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords: mitab
Cc:

Description

MapInfo? coordsys units can be numerical but I don't think these are handled in OGR.

Ex: coordsys earth projection 8,74,8,-81,24.3333333333,0.9999411765,656166.6667,0

The MapInfo? Pro 10 User Documentation (page 416-417) list the units for coordsys as:

6 Centimeters

31 Chains

3 Feet (also called International Feet)* 2 Inches 1 Kilometers

30 Links

7 Meters 0 Miles 5 Millimeters 9 Nautical Miles†

32 Rods

8 US Survey Feet (used for 1927 State Plane)‡ 4 Yards

But the ImportFromMICoordSys (MITABCoordSys2SpatialRef function of mitab_coordsys.cpp) only checks for the unit name (km, cm etc)

if( nProjection == 1
pszMIFUnits == NULL )

/* do nothing */;

else if( EQUAL(pszMIFUnits,"km") ) {

pszUnitsName = "Kilometer"; dfUnitsConv = 1000.0;

} else if( EQUAL(pszMIFUnits, "in" ) ) {

pszUnitsName = "IINCH"; dfUnitsConv = 0.0254;

} ...

Consider adding checks for the unit number also:

if( nProjection == 1
pszMIFUnits == NULL )

/* do nothing */;

else if( EQUAL(pszMIFUnits,"km")
EQUAL(pszMIFUnits,"1") )

{

pszUnitsName = "Kilometer"; dfUnitsConv = 1000.0;

}

else if( EQUAL(pszMIFUnits, "in" )
EQUAL(pszMIFUnits,"2") )

{

pszUnitsName = "IINCH"; dfUnitsConv = 0.0254;

}

else if( EQUAL(pszMIFUnits, "ft" )
EQUAL(pszMIFUnits,"3") )

{

pszUnitsName = SRS_UL_FOOT; dfUnitsConv = atof(SRS_UL_FOOT_CONV);

}

else if( EQUAL(pszMIFUnits, "yd" )
EQUAL(pszMIFUnits,"4") )

{

pszUnitsName = "IYARD"; dfUnitsConv = 0.9144;

}

else if( EQUAL(pszMIFUnits, "mm" )
EQUAL(pszMIFUnits,"5") )

{

pszUnitsName = "Millimeter"; dfUnitsConv = 0.001;

}

else if( EQUAL(pszMIFUnits, "cm" )
EQUAL(pszMIFUnits,"6") )

{

pszUnitsName = "Centimeter"; dfUnitsConv = 0.01;

}

else if( EQUAL(pszMIFUnits, "m" )
EQUAL(pszMIFUnits,"7") )

{

pszUnitsName = SRS_UL_METER; dfUnitsConv = 1.0;

} else if( EQUAL(pszMIFUnits, "survey foot" )

EQUAL(pszMIFUnits, "survey ft" ) EQUAL(pszMIFUnits,"8") )

{

pszUnitsName = SRS_UL_US_FOOT; dfUnitsConv = atof(SRS_UL_US_FOOT_CONV);

}

else if( EQUAL(pszMIFUnits, "nmi" )
EQUAL(pszMIFUnits,"9") )

{

pszUnitsName = SRS_UL_NAUTICAL_MILE; dfUnitsConv = atof(SRS_UL_NAUTICAL_MILE_CONV);

}

else if( EQUAL(pszMIFUnits, "li" )
EQUAL(pszMIFUnits,"30") )

{

pszUnitsName = SRS_UL_LINK; dfUnitsConv = atof(SRS_UL_LINK_CONV);

}

else if( EQUAL(pszMIFUnits, "ch" )
EQUAL(pszMIFUnits,"31") )

{

pszUnitsName = SRS_UL_CHAIN; dfUnitsConv = atof(SRS_UL_CHAIN_CONV);

}

else if( EQUAL(pszMIFUnits, "rd" )
EQUAL(pszMIFUnits,"32") )

{

pszUnitsName = SRS_UL_ROD; dfUnitsConv = atof(SRS_UL_ROD);

}

else if( EQUAL(pszMIFUnits, "mi" )
EQUAL(pszMIFUnits,"0") )

{

pszUnitsName = "Mile"; dfUnitsConv = 1609.344;

}

Change History (2)

comment:1 Changed 4 years ago by Jukka Rahkonen

Keywords: mitab added

This enhancement is not applied yet in GDAL 1.11.1

comment:2 Changed 8 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 40845:

MITAB: support units as code instead of string when reading a coordsys string from a .mif (fixes #3590)

Note: See TracTickets for help on using tickets.