Moritz, Did you compile GDAL/OGR with GEOS library support? IsValid() will fail without this.
I can't tell why get_Area() crashes. On Tue, Oct 5, 2010 at 3:03 PM, moritzzz <[email protected]> wrote: > > Hey guys, > > I just started using gdal/ogr and am running into a lot of problems. The > main one right now comes up when I'm trying to create a geometry from a > string that I read from a file. The line I'm reading looks like this: > 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 > 3))) > > Now I wrote some c++ code that's supposed to create a OGRMultipolygon in > which line is the mentioned line from the file: > > double* kdTreeMgmtServer::process_polygon(string line, string path) { > char* lineArr = (char*) line.c_str(); > > OGRGeometry* new_geom; > OGRGeometryFactory::createFromWkt(&lineArr, NULL, &new_geom); > if (wkbFlatten(new_geom->getGeometryType()) != wkbMultiPolygon) { > log_error("not a multipolygon! geometrytype = > %d\n",new_geom->getGeometryType()); > return NULL; > } > if (!new_geom->IsValid()) { > log_debug("line is invalid: '%s'\n", line.c_str()); > } > OGRMultiPolygon* poly = (OGRMultiPolygon*) new_geom; > poly->get_Area(); > } > > The first part seems to work fine, as the geometry is recognized as a > multipolygon but the validation always fails and poly->get_Area(); causes a > crash of the code. What am I doing wrong? > > Cheers > > Moritz > -- > View this message in context: > http://osgeo-org.1803224.n2.nabble.com/Reading-Geometry-from-text-file-tp5602472p5602472.html > Sent from the GDAL - Dev mailing list archive at Nabble.com. > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9494447584 17.2416N 80.1426E
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
