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);
            }
        }

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to