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