[gdal-dev] Projection Definition String

Francois Maass fieliesm at gmail.com
Sat Jul 10 10:07:46 EDT 2010


Good day!

I am trying to set the Projection Definition for a GDALDataset as follows
(from the GDALWarp API):

 

const char *pszDstWKT = NULL;

OGRSpatialReference oSRS;

oSRS.SetUTM( 11, TRUE );

oSRS.SetWellKnownGeogCS( "WGS84" );

oSRS.exportToWkt( &pszDstWKT );

 

if(GDALSetProjection(srcDataset, pszDstWKT) == CE_Failure)

{ //handle failure

{else

{

            const char *defString = srcDataset->GetProjectionRef();

            cout<<”Length: “<<strlen(defString)<<endl;

cout<<”Projection: ”<<defString<<endl;

};

 

Firstly, I get a compiler error with the oSRS.exportToWKT statement:
invalid conversion from ‘const char**’ to ‘char**’.  

à So I changed the const char* to char*, which bypassed that little error.

à As this was used exactly as the GDALWarp API Tutorial describes, why does
this happen?

 

Secondly, After the GDALSetProjection(
) call succeeds, the projection
information is supposed to be printed out to standard out, along with the
length of the definition string.
However, the output is as follows:
                $ Length: 0

                $ Projection: 

                

Why is the projection string still empty?  

I know that the pszDstWKT contains the projection information as set up,
since when printed out to screen it’s displayed correctly.

 

Thank you in advance!!

 

Warm Regards

Francois Maass

B.IT

University of Pretoria

Cell: 072 397 0294

Email: fieliesm at gmail.com

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100710/a03f0ca5/attachment.html


More information about the gdal-dev mailing list