[gdal-dev] Re: Reading Geometry from text file

moritzzz spam at kolix.de
Tue Oct 5 09:50:28 EDT 2010


So I now changed the code to just use the geos library and it works:

Point* kdTreeMgmtServer::process_polygon(string line, string path) {
	WKTReader* wkt_reader = new WKTReader();
	Geometry* geom = wkt_reader->read(line);

	if(!geom->isValid()) {
		log_error("not a valid geometry: %s\n", line.c_str());
		return NULL;
	}
	if(geom->getGeometryTypeId() != GEOS_MULTIPOLYGON) {
		log_error("geometry is not a multipolygon! geometrytype = %s\n",
geom->getGeometryType().c_str());
		return NULL;
	}
	MultiPolygon* poly = (MultiPolygon*) geom;
	Point* centroid = poly->getCentroid();

	log_debug("centroid: %lf %lf\n", centroid->getX(), centroid->getY());

	return centroid;
}

This code is now calculating the good centroid etc and the geos library
should offer enough functionality for my purpose. As soon as I have some
time I'll enable the debug and check out what's wrong with the gdal/ogr
stuff.
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Reading-Geometry-from-text-file-tp5602472p5603175.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list