[OSM-dev] Multipolygon processing (was: osm2spatialite!)
Frederik Ramm
frederik at remote.org
Fri Feb 18 07:22:54 GMT 2011
Hi,
On 02/18/11 04:35, Daniel Sabo wrote:
>> Makes sense. Do you do anything about touching inner rings?
>
> No, and I haven't thought of a good way to handle it. If you have an algorithm that works well I'd be interested it it :).
I use the GEOS library and I test all pairs of inner rings for
intersections. Then if I find a pair with an intersection, I check if
that intersection is a line (rather than just a point). If it is a line,
then I compute the "SymDifference" between the two and throw the result
of that into the polygonizer which hopefully will be able to make one
ring from it. You can look at my algorithm here
https://github.com/joto/osmium/blob/91b80cfa639b944408d25dd8e294381cf4dc3b8d/src/OsmMultipolygon.cpp
(line 702ff for the bit described above).
Also see comment on line 611ff where it will emit extra polygons for
tagged inner rings - i.e. one multipolygon relation might yield more
than one polygon feature on output.
All this is probably only halfway there. I'd be very interested in ideas
how to fix broken multipolygons. There is some code there (line 117ff
tries to repair self-intersections and 343ff tries to fill gaps in
rings) but still OSM users come up with ever more invalid polygons ;)
Bye
Frederik
More information about the dev
mailing list