[gdal-dev] OGR_G_ExportToWkt make MEX crash
Joaquim Luis
jluis at ualg.pt
Tue Sep 6 11:10:49 EDT 2011
Hi,
I wrote a OGR C MEX wrapper to use in Matlab which already works in many
cases.
However, I had a situation when trying to fetch the reference info. The
chunk of code below now works, but if I use the commented line that calls
OGR_G_ExportToWkt
than Matlab crashes at that line. However, using the OSRExportTo...
functions works fine.
I'm I doing something forbidden or ...
heers
Joaquim
hSRS = OGR_L_GetSpatialRef(hLayer); /* Do not free it later */
if (hSRS) {
char *pszWKT = NULL, *pszProj4 = NULL;
mxArray *mxPrjRef;
/*OGR_G_ExportToWkt (hSRS, &pszWKT); */ <====== THIS
CALL MAKE THE MEX CRASH
if (OSRExportToProj4(hSRS, &pszProj4) == OGRERR_NONE) {
mxPrjRef = mxCreateString (pszProj4);
mxSetField (out_struct, 0, "SRSProj4", mxPrjRef);
}
if (OSRExportToPrettyWkt(hSRS, &pszWKT, 1) == OGRERR_NONE) {
mxPrjRef = mxCreateString (pszWKT);
mxSetField (out_struct, 0, "SRSWkt", mxPrjRef);
}
}
More information about the gdal-dev
mailing list