<div dir="ltr">Hi all,<br clear="all"><div><div><br></div>
<div dir="ltr"><div><div><div><div><div><div><div><div>Thanks to Tamas Szekeres we are now using his binaries from <a href="http://www.gisinternals.com/sdk/">http://www.gisinternals.com/sdk/</a> with MapWinGIS, our mapping ActiveX.<br>
</div>This has drastically simplified our build process and we are very grateful for Tamas' help.<br><br></div>We're now struggling with some minor issues regarding our 'old' C++ code and the new binaries for GDAL, GEOS, Proj4, etc.<br>
</div>Several of them I managed to solve, but I'm struggling with this one.<br></div>We have code to read a prj file and get the Proj4 string:<br><br><span style="font-family:courier new,monospace"> void ProjectionTools::GetProj4FromPRJFile(char * prjfileName, char ** prj4)<br>
{<br> FILE * pFile;<br> pFile = fopen (prjfileName,"r");<br> if (pFile == NULL)<br> {<br> // Doesn't exist<br> return;<br> }<br> fclose(pFile);<br>
pFile = NULL;<br> OGRSpatialReference* oSRS = new OGRSpatialReference();<br><br> char **papszPrj = CSLLoad(prjfileName);<br> if (papszPrj == NULL)<br> {<br> return;<br> }<br>
<br> OGRErr eErr = oSRS->importFromESRI(papszPrj);<br> if (eErr != OGRERR_NONE)<br> {<br> OGRErr eErr = oSRS->importFromProj4(*papszPrj);<br> }<br><br> CSLDestroy( papszPrj );<br>
char * pszProj4 = NULL;<br> eErr = oSRS->exportToProj4( &pszProj4 );<br> delete oSRS; <-- going wrong now<br><br> *prj4 = new char[_tcslen(pszProj4)+1];<br> strcpy(*prj4, pszProj4);<br>
CPLFree(pszProj4);<br> }</span><br><br></div>This code was working for years, but now it crashes on <span style="font-family:courier new,monospace">delete oSRS;</span>.<br></div>I've been searching for examples of how to use <span style="font-family:courier new,monospace">exportToProj4()</span> in C++ but can only find Python examples.<br>
</div>And I'm not a C++ developer, just a C# developer :)<br></div>How should I now free <span style="font-family:courier new,monospace">oSRS</span>?<br><div><div><div><div><div><div><div><div><div><div><br></div><div>
Thanks for any advice.<br></div><div><br>
Paul<br>
<div><div style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif"><div style="border:1px solid rgb(229,229,229);background-color:rgb(248,248,248);padding:0.8em 0.8em 0.3em"><div style="margin:0px 0px 8px">
<p style="margin:0px"><span><b><img style="float: left; margin-left: 5px; margin-right: 5px;" src="http://www.bontepaarden.nl/bontepaarden/images/newButton.png" alt="" height="120" width="160">Paul Meems </b><br><span>Release manager, configuration manager</span><br>
<span>and forum moderator of MapWindow GIS.</span><br><a href="http://www.mapwindow.org/" target="_blank"><span>www.mapwindow.org</span></a><br><br><span>Owner of MapWindow.nl - Support for</span><br><span>Dutch speaking users.</span><br>
<a href="http://www.mapwindow.nl/" target="_blank"><span>www.mapwindow.nl</span></a><br></span></p>
<p style="margin:0px"><b><br></b></p></div></div><img src="http://p1.wisestamp.com/pixel.png?p=mozilla&v=3.9.12&t=1322134056890&u=482737fd0c4ca423" height="1" width="1"></div>
</div></div>
</div></div></div></div></div></div></div></div></div></div></div></div>