Moritz,<br><br>Did you compile GDAL/OGR with GEOS library support? IsValid() will fail without this.<br><br>I can't tell why get_Area() crashes.<br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 3:03 PM, moritzzz <span dir="ltr"><<a href="mailto:spam@kolix.de">spam@kolix.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>
Hey guys,<br>
<br>
I just started using gdal/ogr and am running into a lot of problems. The<br>
main one right now comes up when I'm trying to create a geometry from a<br>
string that I read from a file. The line I'm reading looks like this:<br>
MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2)),((6 3,9 2,9 4,6<br>
3)))<br>
<br>
Now I wrote some c++ code that's supposed to create a OGRMultipolygon in<br>
which line is the mentioned line from the file:<br>
<br>
double* kdTreeMgmtServer::process_polygon(string line, string path) {<br>
char* lineArr = (char*) line.c_str();<br>
<br>
OGRGeometry* new_geom;<br>
OGRGeometryFactory::createFromWkt(&lineArr, NULL, &new_geom);<br>
if (wkbFlatten(new_geom->getGeometryType()) != wkbMultiPolygon) {<br>
log_error("not a multipolygon! geometrytype =<br>
%d\n",new_geom->getGeometryType());<br>
return NULL;<br>
}<br>
if (!new_geom->IsValid()) {<br>
log_debug("line is invalid: '%s'\n", line.c_str());<br>
}<br>
OGRMultiPolygon* poly = (OGRMultiPolygon*) new_geom;<br>
poly->get_Area();<br>
}<br>
<br>
The first part seems to work fine, as the geometry is recognized as a<br>
multipolygon but the validation always fails and poly->get_Area(); causes a<br>
crash of the code. What am I doing wrong?<br>
<br>
Cheers<br>
<br>
Moritz<br>
<font color="#888888">--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/Reading-Geometry-from-text-file-tp5602472p5602472.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/Reading-Geometry-from-text-file-tp5602472p5602472.html</a><br>
Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9494447584<br>17.2416N 80.1426E<br>