From 8be0cfc3caabaac3a48b9202eabefcfaced4647d Mon Sep 17 00:00:00 2001 From: Frederik Ramm Date: Fri, 20 Apr 2012 07:04:27 +0000 Subject: [PATCH] avoid building invalid geometries --- build_geometry.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/build_geometry.cpp b/build_geometry.cpp index 832b86dad..765c79bb1 100644 --- a/build_geometry.cpp +++ b/build_geometry.cpp @@ -475,20 +475,26 @@ size_t build_geometry(osmid_t osm_id, struct osmNode **xnodes, int *xcount, int if ((toplevelpolygons > 1) && enable_multi) { std::auto_ptr multipoly(gf.createMultiPolygon(polygons.release())); - std::string text = writer.write(multipoly.get()); - wkts.push_back(text); - areas.push_back(multipoly->getArea()); - wkt_size++; + if (multipoly->isValid()) + { + std::string text = writer.write(multipoly.get()); + wkts.push_back(text); + areas.push_back(multipoly->getArea()); + wkt_size++; + } } else { for(unsigned i=0; i(polygons->at(i));; - std::string text = writer.write(poly); - wkts.push_back(text); - areas.push_back(poly->getArea()); - wkt_size++; + if (poly->isValid()) + { + std::string text = writer.write(poly); + wkts.push_back(text); + areas.push_back(poly->getArea()); + wkt_size++; + } delete(poly); } }