[Tile-serving] [osm2pgsql] Don't let invalid geometries into the database (#428)

Paul Norman notifications at github.com
Mon Aug 10 09:43:40 UTC 2015


> its -G flag and which map layers on osm.org use it

-G isn't really relevant here. The code goes through different functions, but the isvalid/buffer/`--exclude-invalid-polygon` logic is the same with and without it.

> Perhaps a way forward would be to create a bunch of "invalid but potentially meaningful to humans and/or mapnik" multipolygons

This is about geometries, not OSM objects. There's more ways to screw up a multipolygon, but I suspect that you could generate an invalid POLYGON with just a way.

> "inner hole outside outer way" is an obvious one that's easy to describe but I suspect there are others too and without going through the code mappers won't know about them.

That example would be unchanged, the buffer(0) call will fix that geometry.

> Because there are people created and "correcting" invalid geometries all the time "what's currently invalid in the planet" is always going to be a bit of a finger-in-the-air test.

Across a planet and two larged-sized extracts, I found a total of one POLYGON which was GEOS/PostGIS invalid. That establishes it is possible, but also that it is extremely infrequent. The one example, which is in this PR, is invalid in web mercator but valid in latlong, which makes me suspect there's some rounding oddness going on too.

Before I saw this example, I thought it was impossible for buffer(0) to create an invalid polygon.

-----

> If osm2pgsql already has code to somehow magically correct these polygons, then perhaps this change really affects just a few edge cases and doesn't require much discussion.

Yes, buffer(0) will fix **almost** anything.

> If on the other hand the suggestion were to stop importing and/or auto-fixing all these broken polygons altogether, then I would be very much in favour of this as it would lead to better data, but it would certainly lead to a short-term drop in colourful areas

Osm2pgsql supports this with the `--exclude-invalid-polygon` which will reject non-valid geometries instead of trying to correct them. 

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/428#issuecomment-129384464
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20150810/2a214fc7/attachment.html>


More information about the Tile-serving mailing list