[Gdal-dev] Re: OGR Spatial Questions

Peter von Gaza pvg at pixelmapper.com
Tue Jan 18 13:29:11 EST 2005


Frank,
Thanks! Everything works now. I was hoping for a simple solution.
I'm just starting to work with your OGR projection code but have
to say that I am VERY impressed how easily I was able to compile
an "ogr.dll" in Borland BCB5 and get it link and working in my
program. Amazing stuff.

Thanks,
Peter


Frank Warmerdam wrote:
>  
> 
>>Works fine. Then I load a geotiff and try the following:
>>
>>    char *pszProjection = GTIFGetOGISDefn(gtif, &defn );
>>    // string looks like it should
>>
>>    OGRSpatialReference oSRS;
>>    OGRErr i = oSRS.SetProjection( pszProjection );
> 
> 
> Here lies your problem.  The SetProjection() method is used to
> set the projection method to be used, such as "Transverse_Mercator".
> To import a complete WKT coordinate system definition you should
> use the importFromWkt() method.  
> 
> eg. 
> 
> char *pszProjectionCopy = pszProjection;
> OGRSpatialReference oSRS;
> 
> if( oSRS.importFromWkt( &pszProjectionCopy ) != OGRERR_NONE )
>   return;
> 
> The setting up of a duplicate pointer to the WKT definition
> is because importFromWkt() updates to pointer to point to the
> next character past the imported definition.  The approach was
> intended to let me process WKT out of a larger string, but in 
> practice I have never used that ability and the method has been
> clumsy to use (as above). 
> 
> Best regards,
> 




More information about the Gdal-dev mailing list