Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4894 closed defect (fixed)

Cannot read Ozi Explorer .map files with UTM projection

Reported by: nsands Owned by: jcrepetto
Priority: normal Milestone: 1.10.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords: Ozi Explorer .map .ozf2
Cc: Even Rouault

Description (last modified by nsands)

OziExplorer .map files that have a projection specified as "(UTM) Universal Transverse Mercator" cannot be read by GDAL.

The following code results in the WKT displayed below the code, and no spatial reference can be formed from it.

UTM is of course a very common projection, so this affects a large number of Ozi .map files.

CODE:

	char *srcWKT = (char *)GDALGetProjectionRef( hSrcDS );
	
	if ( srcWKT == NULL || strlen(srcWKT) <= 0 )
		return NO;
	
	printf("srcWKT:\n\n%s\n\n", srcWKT);

	OGRSpatialReferenceH srcSRS = OSRNewSpatialReference(srcWKT);
	
	if ( ! srcSRS )
	{
		printf("FAILED TO GET SOURCE SPATIAL REFERENCE SYSTEM.\n");
	}

WKT:

LOCAL_CS[""Ozi" projection "(UTM) Universal Transverse Mercator"",UNIT["Meter",1]]

Some example .map files are attached. (They can be paired with any .ozf2 file by changing the extension of the file name at the end of the path in the .map file to .ozf2 and changing the name of the .ozf2 file to match that in the .map file.)

Attachments (3)

UTM dot map files.zip (12.7 KB ) - added by nsands 11 years ago.
Some example .map files with UTM projection
R2355A.ozf2 (129.7 KB ) - added by nsands 11 years ago.
Sample .ozf2 file. Rename it to match the file name in the path of the .map file (and change the extension in the .map file to .ozf2)
gdal_utm.patch.gz (4.2 KB ) - added by jcrepetto 11 years ago.
Patch for UTM support in OziExplorer .map files

Download all attachments as: .zip

Change History (11)

by nsands, 11 years ago

Attachment: UTM dot map files.zip added

Some example .map files with UTM projection

comment:1 by warmerdam, 11 years ago

Cc: Even Rouault added
Component: defaultGDAL_Raster
Description: modified (diff)

comment:2 by warmerdam, 11 years ago

I took a brief look, but I don't have any ozi files to pair the map's with, so I gave up.

comment:3 by nsands, 11 years ago

Description: modified (diff)

by nsands, 11 years ago

Attachment: R2355A.ozf2 added

Sample .ozf2 file. Rename it to match the file name in the path of the .map file (and change the extension in the .map file to .ozf2)

comment:4 by jcrepetto, 11 years ago

I have looked at the GDAL source code, and found that the "(UTM) Universal Transverse Mercator" projection is not supported. If nobody else is interested, I can implement it and submit a patch.

comment:5 by jcrepetto, 11 years ago

Owner: changed from warmerdam to jcrepetto
Status: newassigned

by jcrepetto, 11 years ago

Attachment: gdal_utm.patch.gz added

Patch for UTM support in OziExplorer .map files

comment:6 by jcrepetto, 11 years ago

I have attached to this ticket a patch to add the UTM support. Note that I had to create a new function :

OGRErr OGRSpatialReference::importFromOzi( char **papszLines, int nLines )

because this one :

OGRErr OGRSpatialReference::importFromOzi( const char *pszDatum,
                                           const char *pszProj,
                                           const char *pszProjParms )

was missing necessary data from the .map file (for example the UTM zone).

I have not removed the old function, because it would break the API. It will be possible to remove it in GDAL 2.0.

comment:7 by Even Rouault, 11 years ago

Milestone: 1.10.0
Resolution: fixed
Status: assignedclosed

Jean-Claude,

I've committed your patch in r25256 with a few changes.

For consistency with the rest of similar GDAL/OGR API, the signature of the new function is OGRErr OGRSpatialReference::importFromOzi( const char * const* papszLines ) (removal of nLines parameter, assuming the array is NULL terminated). And I've remapped the implementation of the old method to the new one by forging a fake array.

Question: is the removal of the following lines in gcore/gdal_misc.cpp really intended ? I assumed yes.

                if ( EQUAL(papszTok[16], "S") )
                    dfLat = -dfLat;

comment:8 by jcrepetto, 11 years ago

Yes, the change was intended. Northings are not necessarily negative in the southern hemisphere.

Note: See TracTickets for help on using tickets.