[Gdal-dev] OGRSpatialReference::exportToProj4 causes
segmentationerror
Xiaodong Zhang
zhang at aero.und.edu
Wed Jul 28 13:55:22 EDT 2004
Hi Frank,
Thanks but please see my comments below:
Quoting Frank Warmerdam <warmerdam at pobox.com>:
> Xiaodong Zhang wrote:
> > Hi,
> >
> > One of our code, which works with Gdal 1.1.8 causes a segmentation fault
> with
> > newer version of Gdal 1.1.9 and Gdal 1.2.1. It seemed that the following
> part
> > causes the problem.
> >
> > char ** ppProj;
> > ....
> > proj = srcDataset->GetProjectionRef();
> > /* so far is OK after open an image with GDALOpen and get the projection
> info
> >
> > OGRSpatialReference hProj(proj); // it is still OK up to here
> > hProj.exportToProj4 (ppProj); // it crashes here
> >
> > Also the OGR documentation says to de-allocate ppProj using CPLfree(), how
> to
> > use it exactly?
>
> Hi,
>
> You need to pass a pointer to a pointer where the resulting string can be
> assigned. I'm not sure why it would work with 1.1.8 unless it was just a
> coincidental thing about where the unitialized ppProj pointed.
>
> It should be something like:
>
> char **pszProjWKT = NULL;
It has to be 'char *pszProjWKT' instead of double pointers, otherwise the
compile gives the following error
`OGRSpatialReference::exportToProj4 (char ***)'
/usr/local/include/ogr_spatialref.h:209: candidates are: OGRErr
OGRSpatialReference::exportToProj4
(char **) const
Is this what to be expected?
Thanks
>
> OGRSpatialReferenceh oProj( srcDataset->GetProjectionRef() );
>
> oProj.exportToProj4( &pszProjWKT );
>
> printf( "%s", pszProjWKT );
>
> CPLFree( pszProjWKT );
>
> Best regards,
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush | Geospatial Programmer for Rent
>
More information about the Gdal-dev
mailing list