[postgis-users] Projection help (please)
Frank Warmerdam
warmerdam at pobox.com
Wed Oct 27 08:18:12 PDT 2004
Chapman, Martin wrote:
> Brent,
>
> #include "ogrsf_frmts.h"
> #include "gdal_priv.h"
>
> char* pszWks = "the text from the .prj file goes here";
> OGRSpatialReference spatialReference(pszWks);
> OGRErr err = spatialReference.morphToESRI(); // needed if the using an
> esri .prj file
> if (err != OGRERR_NONE) throw (char*) CPLGetLastErrorMsg();
>
> char* pszProj4 = NULL;
> spatialReference.exportToProj4(&pszProj4);
Folks,
I think you should be using "morphFromESRI()" not "morphToESRI()". The
FromESRI() version converts ESRI style WKT into OGR style WKT. It
may not matter much for a given WKT value of course since they are pretty
similar.
Something similar can also be implemented in Python for the C++ adverse.
> -- there you go
> -- p.s I think the pszProj4 variable should be freed with
> CPLFree(pszProj4); -- not sure though, see the on-line docs for that
Yes, it should be freed with CPLFree(), though free() would actually
work fine *most* of the time.
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 postgis-users
mailing list