[Tile-serving] [openstreetmap/osm2pgsql] Import of changes failing because of TopologyException (#787)

Christoph Hormann notifications at github.com
Sun Sep 24 17:43:05 UTC 2017


I just checked and relation 2823696 as assembled by osmium correctly converts from EPSG:4326 to EPSG:3857 without becoming invalid.  So whatever happens here is probably the result of some other error in processing and not inherent to the coordinate conversion.

The safest and cleanest way to avoid coordinate conversion problems with web mercator would be to clip the polygons at or slightly beyond the nominal web mercator limit (85.05 degrees latitude) *before* converting to mercator.  This way you'd get rid of any geometries that might really cause trouble (i.e. stuff near the pole).  Doing this in a generic way that also works for other projections is not trivial though.

In any case you will have to do a proper clipping, just skipping nodes outside the bounding box will not work (and i assume this is the reason why you have problems here).

There can still be extreme cases of _borderline self intersecting polygons_ that are valid in geographic coordinates and invalid in projected coordinates but this is rare for mercator and ultimately only means you cannot completely rely on the database being free of self intersections.  Completely avoiding this is a hard problem and the only reasonable way to do this i could think of would be to subdivide the edges involved in the self intersection until the problem vanishes.

For the vast majority of geometries you would probably - in case of web mercator - also be safe to just convert them without clipping or skipping nodes if they cross the edge like relation 2823696 and skip the whole geometry in case it is fully outside the map area (like a building near the south pole).  This will however fail for some geometries like the boundary relations of Antarctic claim sectors which all start at 60 degrees latitude and include the south pole so they cannot be converted to mercator without clipping before reprojection.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/787#issuecomment-331726353
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20170924/e8094cae/attachment.html>


More information about the Tile-serving mailing list