This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to draw invalid polygons?

2

I want to use Mapnik to draw custom styled maps from OSM. I have used Osmosis to import the Europe extract (from geofabric). I used the database schema with linestrings geometries for ways. Now, for performance and convinience reasons (work in QGIS) I want to build materialized views for polygon features, such as water areas. So, for example, for riverbanks I am trying something like this:

SELECT st_buildarea(st_collect(w.linestring)) AS geom
FROM relations r
JOIN relation_members rm ON r.id = rm.relation_id AND rm.member_type = 'W' AND rm.member_role IN ('outer', 'inner')
JOIN ways w ON w.id = rm.member_id
WHERE r.tags->'waterway'='riverbank'
GROUP BY r.id

And the result is:

LWGEOM_GEOS_buildArea: TopologyException: Input geom 1 is invalid: Self-intersection at or near point 0.68302757542791204 46.349042878781603 at 0.68302757542791204 46.349042878781603

And the PostGIS is right, the relation 1085106 is self-intersecting ("inner" way intersects "outer" way). But OSM got it drawn anyway: https://www.openstreetmap.org/#map=20/46.34904/0.68303 As far as I know, Mapnik needs polygons, so the official map have to "fix" these data somehow to draw them. How is this done?

asked 29 Jun '16, 09:01

rouen_sk's gravatar image

rouen_sk
51114
accept rate: 0%

Why not use osm2pgsql which already does the polygon processing?

(29 Jun '16, 14:27) SK53 ♦

Source code available on GitHub .