<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>This works:</tt>
<p>char * f()
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp; WKTReader *r = new WKTReader(GeometryFactory(PrecisionModel(),10));</tt>
<br><tt>&nbsp;&nbsp; Geometry *g;</tt>
<br><tt>&nbsp;&nbsp; string s,ss;</tt>
<br><tt>&nbsp;&nbsp; char *cc;</tt>
<br>&nbsp;
<p><tt>&nbsp;&nbsp;&nbsp; s = "POINT(0 0)";</tt>
<p><tt>&nbsp;&nbsp;&nbsp; g =r->read(s);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; ss= g->toString();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; cc= (char *)&nbsp; ss.c_str();</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return cc;</tt>
<p><tt>}</tt>
<p><tt>But this doesnt :</tt>
<p>char *f()
<br><tt>{</tt>
<br><tt>&nbsp;Coordinate *c = new Coordinate(0,0,0);</tt>
<br><tt>&nbsp;Geometry result;</tt>
<br><tt>&nbsp;string s,ss;</tt>
<br><tt>&nbsp;geomFactory = new GeometryFactory();</tt>
<p><tt>&nbsp;result =&nbsp; geomFactory->createPoint(*c);&nbsp; // this
works</tt>
<p><tt>&nbsp;s = result.toString();&nbsp; // crashes here</tt>
<br><tt>}</tt>
<p><tt>Here's a test program:</tt>
<br>&nbsp;<tt></tt>
<p><tt>#include &lt;stdio.h></tt><tt></tt>
<p><tt>#include &lt;string></tt>
<br><tt>#include &lt;iostream></tt>
<br><tt>#include &lt;fstream></tt>
<br><tt>#include "util.h"</tt>
<br><tt>#include "graph.h"</tt>
<br><tt>#include "io.h"</tt>
<br><tt>#include "opRelate.h"</tt>
<br><tt></tt>&nbsp;<tt></tt>
<p><tt>int main(int argc, char** argv)</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp; Coordinate *c = new Coordinate(0,0,0);</tt>
<br><tt>&nbsp;&nbsp; Geometry result;</tt>
<br><tt>&nbsp;&nbsp; string s,ss;</tt>
<br><tt>&nbsp;&nbsp; GeometryFactory&nbsp;&nbsp; * geomFactory = new GeometryFactory();</tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "make point\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; result =&nbsp; geomFactory->createPoint(*c);&nbsp;
// this works</tt><tt></tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "to string\n";</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp; s = result.toString();&nbsp; // crashes
here</tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "done\n";</tt>
<br><tt>}</tt>
<p>It appears to die in the WKTWriter ...
<p>dave</html>