[OSM-dev] multipolygon relation and non-closed ways

Jukka Rahkonen jukka.rahkonen at latuviitta.fi
Mon Oct 15 06:03:12 BST 2012


sly (sylvain letuffe) wrote:
>> By the way, perhaps there could be WKT presentations about what would be
>> the simple feature solutions of the examples on page
>> http://wiki.openstreetmap.org/wiki/Relation:multipolygon/validity.
>
> Only if OSM multipolygons are still intended to be considered valid if one
> valid OGC WKT representing them exists, else it doesn't matter anymore to
> know
> the WKT presentation.
>
> Also I probably wont take the time to do it (unless really wanted ?) since
> WKT
> is really technically oriented and not for the usual contributorx. And for
> developers, in such simple examples, a quick read of the OGC specification
> should give them easily a valid WKT prestentation if it exists.

Perhaps a useless idea from my side. I would also like to hire you for an
hour or two for quick reading some other OGC specifications for me.

>> Example
>> http://wiki.openstreetmap.org/wiki/File:Multipolygon_Illustration_8_shape_w
>> ith_intesection_point.svg is hard to convert into a valid simple feature
>> if
>> it is drawn as one way ABCDEBF.
>
> It really depends how you are defining "hard" ;-)
> Maybe if you intend to code the algorithm from scratch in C yes, but if
> you
> have access to postgis 2.0 it is as simple as :
> SELECT ST_AsText(ST_MakeValid('
> POLYGON((-1 -1, -1 0, 1 0, 1 1, 0 1, 0 -1, -1 -1))'
> ));
> http://blog.opengeo.org/2012/03/23/postgis-2-0-new-features-st_makevalid/

I think that making geometries valid with PostGIS or Spatialite is one
step too late. Osmium and ogr2ogr and other converters should be able to
send already valid geometries into PostGIS, GML, shapefiles and what ever.
Perhaps they already can.

I tried ST_MakeValid and it seems to be able to convert also the two
touching inner ring case into a valid simple feature


select ST_AsText (ST_MakeValid('
POLYGON ((
        -139 420,
        71 418,
        59 273,
        -156 272,
        -139 420
    ), (
        -89 370,
        -92 313,
        -46 312,
        -46 370,
        -89 370
    ), (
        -46 370,
        -46 312,
        -5 314,
        -4 371,
        -46 370
    ))'
    ));

Result is:
"GEOMETRYCOLLECTION(POLYGON((-139 420,71 418,59 273,-156 272,-139
420),(-46 312,-5 314,-4 371,-46 370,-89 370,-92 313,-46
312)),LINESTRING(-46 312,-46 370))"

>> It can be wrongly interpreted as a single
>> ring polygon with self-intersection. However, it could be transformed
>> into
>> a valid OGC MultiPolygon with two parts ABF and BCDE.
> correct.

Perhaps examples B and F could also contain at least two ways? If there is
only one way, why to make a multipolygon relation at all? But of course it
is possible to make single way multipolygon relations. I guess that those
who make converters would like to have all polygon as relations instead of
the current situation with relations and area=yes polygons and those which
must be interpreted by the tags like natural=water.

-Jukka Rahkonen-




More information about the dev mailing list