[postgis-users] Strange behaviour from ST_MakeValid when holes escape polygon outer ring

Komяpa me at komzpa.net
Tue Oct 11 23:33:54 PDT 2016


There are, for instance, non-OGC-to-OGC data conversions that have to
reinvent which rings are outer and which rings are inner.
OpenStreetMap data schema allows them not marked (so - multipolygon is just
a collection of rings). ST_MakeValid is very useful on processing these, as
users usually don't draw useless lines, and you should guess the
inner/outer the same way usual editor's graphical library guesses them to
get the best result in your database - which ST_MakeValid is good at.

On a globe, all the rings of a polygon are technically outer - consider a
ST_Buffer(equator line, 10) - this polygon technically has two rings on a
globe, both outer, both denote just a single piece of area.. :)

ср, 12 окт. 2016 г. в 1:54, Craig de Stigter <
craig.destigter at koordinates.com>:

> Aha, cheers. In fact I see that's mentioned in the docs too, but I hadn't
> really understood what it meant until you pointed it out.
>
> I'm curious if there's a situation in which that's a useful behaviour? It
> strikes me as a very strange quirk...
>
> On 12 October 2016 at 09:35, Komяpa <me at komzpa.net> wrote:
>
> ST_MakeValid tries to reconstruct geometry without losing vertices.
>
> The only sane way I can think of to do it without losing vertices is to
> stop treating the inner ring as inner ring and mark it as outer.
>
> If you need a geometry fixup function that does processing with losing
> vertices, ST_MakeValid isn't semantically what you need.
>
> вт, 11 окт. 2016 г. в 23:24, Craig de Stigter <
> craig.destigter at koordinates.com>:
>
> Hi folks
>
> We've been using an internal geometry-fixing function for a long time, and
> I'm looking into replacing it with ST_MakeValid().
>
> I've come across a strange edge-case where ST_MakeValid() appears to
> incorrectly treat polygons as a set of linework, rather than a shell and a
> set of holes.
>
> This means that when you give it a shape with a hole that partially
> escapes the exterior ring, instead of that part getting discarded it forms
> the outer ring of a new polygon, thus creating a multipolygon.
>
> I expected it to take the outer ring and ST_Difference() all the inner
> rings from the outer ring.
>
> Here's some screenshots to demonstrate:
>
> Actual:
> https://drive.google.com/file/d/0By4X8bGnhCGET3h1UU1GOW1NTDA/view?usp=sharing
> Expected:
> https://drive.google.com/file/d/0By4X8bGnhCGEQjdzQlpsY0xlelk/view?usp=sharing
>
> Would anyone who knows a bit more about ST_MakeValid() be able to comment
> on this? (If I dug into the source and was able to submit a patch to fix
> this, would it be likely to be accepted?)
>
> --
> Regards,
> Craig
>
> Developer
> Koordinates
>
> +64 21 256 9488 <+64%2021%20256%209488> / koordinates.com / @koordinates
> <https://twitter.com/koordinates>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
>
>
> --
> Regards,
> Craig
>
> Developer
> Koordinates
>
> +64 21 256 9488 <+64%2021%20256%209488> / koordinates.com / @koordinates
> <https://twitter.com/koordinates>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20161012/d90838dc/attachment.html>


More information about the postgis-users mailing list