[gdal-dev] Reading Geometry from text file
Chaitanya kumar CH
chaitanya.ch at gmail.com
Tue Oct 5 06:43:33 EDT 2010
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 <spam at kolix.de> 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
> gdal-dev at lists.osgeo.org
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20101005/fee1a1b7/attachment-0001.html
More information about the gdal-dev
mailing list