Skip to content

Commit

Permalink
avoid building invalid geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
woodpeck committed Apr 20, 2012
1 parent 3e88fc6 commit 8be0cfc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions build_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MultiPolygon> 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<toplevelpolygons; i++)
{
Polygon* poly = dynamic_cast<Polygon*>(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);
}
}
Expand Down

0 comments on commit 8be0cfc

Please sign in to comment.