[gdal-dev] Cannot read UTM Ozi .map file

Nik Sands nixanz at nixanz.com
Wed Nov 28 13:54:45 PST 2012


Hi Jean-Claude,

After applying the suggested patch, it no longer errors out in the same way, however, I now get another error just a little further on in my code.

CODE:
---------------------------------
	char *srcWKT = (char *)GDALGetProjectionRef( hDataset );
	
	if ( srcWKT == NULL || strlen(srcWKT) <= 0 )
	{
		NSLog(@"Failed to get WKT (%s) from file:  %@", srcWKT, [path lastPathComponent]);
		
		return NULL;
	}
	
	OGRSpatialReferenceH srcSRS = OSRNewSpatialReference(srcWKT);
	OGRSpatialReferenceH llSRS = OSRCloneGeogCS(srcSRS);
	
	if ( ! llSRS )
	{
		NSLog(@"Failed to get geographic node of source spatial reference system:");
		printf("\n%s\n\n", srcWKT);
		NSLog(@"(path:  %@", path);
		
		return nil;
	}
	
	OGRCoordinateTransformationH ct = OCTNewCoordinateTransformation( srcSRS, llSRS );
	
	if ( ! ct )
	{
		char *srcWKT;
		char *llWKT;
		OSRExportToWkt(srcSRS, &srcWKT);
		OSRExportToWkt(llSRS, &llWKT);
		
		NSLog(@"Failed to create coordinate transformation between source and lat/lon spatial reference systems:");
		printf("\n%s\n\n", srcWKT);
		printf("\n%s\n\n", llWKT);
		
		return nil;
	}
	
	double gt[6];
	CPLErr err = GDALGetGeoTransform( hDataset, gt );
	
	if ( err != CE_None )
	{
		NSLog(@"Failed to get geo-transform (error %d) for file:  %@", err, [path lastPathComponent]);
		return NULL;
	}
---------------------------------

OUTPUT:
---------------------------------
Failed to get geo-transform (error 3) for file:  Cradle Mountain_ozf.map
---------------------------------

I'm afraid this is a bit beyond me, so if you can help, I'd be very grateful.

(The ozf/map files are at:  https://dl.dropbox.com/u/12436846/Cradle%20Mountain.zip .)

Cheers,
Nik.


On 29/11/2012, at 3:54 AM, Jean-Claude Repetto <jrepetto at free.fr> wrote:

> Le 28/11/2012 05:16, Nik Sands a écrit :
>> Hi GDAL-dev,
>> 
>> I've recently re-compiled GDAL from the trunk after the patch to fix UTM ozi files was applied.  This has worked well for most UTM files I've tried so far, but I've come across one that produces a strange error in my code, but works OK with gdalinfo.  The following code fails for a dataset generated from this .map file and debugging indicates that 'srcWKT' is an empty string (""), and not NULL.
> 
> Hi Nik,
> 
> Try to apply the following patch :
> 
> 
> Index: frmts/ozi/ozidataset.cpp
> ===================================================================
> --- frmts/ozi/ozidataset.cpp	(révision 25261)
> +++ frmts/ozi/ozidataset.cpp	(copie de travail)
> @@ -746,7 +746,8 @@
> 
> const char* OZIDataset::GetProjectionRef()
> {
> -    return (pszWKT && nGCPCount == 0) ? pszWKT : "";
> +//    return (pszWKT && nGCPCount == 0) ? pszWKT : "";
> +    return pszWKT;
> }
> 
> /************************************************************************/
> 
> 
> Jean-Claude
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list