[postgis-users] St_makevalid issue

Martin Davis mtnclimb at gmail.com
Thu Mar 26 08:54:08 PDT 2020


That's a pretty complicated query to try and understand, let alone
reproduce and debug.

You could capture the full output from a few runs and provide that (with
geometry as WKB). That might allow seeing if the discrepancy is real and
why it is happening.



On Thu, Mar 26, 2020 at 7:55 AM Paul van der Linden <
paul.doskabouter at gmail.com> wrote:

> Doesn't anybody have an idea? Or is at least curious?
>
> Especially the select st_isvalid(geo) where not st_valid returning a
> "true" row?
>
> >I have a query that gives inconsistent results.
> >It almost seems like st_makevalid doesn't always produce the same results
> >given the same input, and sometimes even returns invalid geometries...
> >
> >Results are
> >f;1159320407;"Bangladesh"
> >f;1159321073;"Mozambique"
> >f;1159316737;"Nord"
> >f;1159314827;"Uusimaa"
> >
> >second run:
> >f;1159321073;"Mozambique"
> >t;1159315455;"Syddanmark"
> >t;1159314827;"Uusimaa"
> >t;1159317795;"Gerona"
> >
> >third run:
> >f;1159321073;"Mozambique"
> >t;1159315455;"Syddanmark"
> >
> >note the 't' in the second and third run...
> >
> >Query:
> >
> >SELECT ST_isvalid(simplifiedgeo2),* FROM (
> >SELECT
> >    foo2.ne_id,
> >    foo2.name,
> >    CASE
> >        WHEN ST_isvalid(foo2.simplifiedgeo) THEN foo2.simplifiedgeo
> >        ELSE ST_makevalid(foo2.simplifiedgeo)
> >    END AS simplifiedgeo2
> >   FROM (
> >     SELECT
> >       ST_simplifypreservetopology(foo.geom,
> >         LEAST(
> >           ST_xmax(foo.shiftedgeo::box3d) -
> ST_xmin(foo.shiftedgeo::box3d),
> >ST_ymax(foo.shiftedgeo::box3d) - ST_ymin(foo.shiftedgeo::box3d))
> >         ) AS simplifiedgeo,
> >       foo.ne_id,
> >       foo.name,
> >       foo.geom
> >     FROM (
> >        SELECT
> >          natearth.ne_id,
> >          natearth.geom,
> >          natearth.name,
> >          CASE
> >              WHEN (
> >                ST_xmax(ST_shiftlongitude(natearth.geom)::box3d) -
> >ST_xmin(ST_shiftlongitude(natearth.geom)::box3d))
> >                <
> >                (ST_xmax(natearth.geom::box3d) -
> >ST_xmin(natearth.geom::box3d)
> >              ) THEN ST_shiftlongitude(natearth.geom)
> >              ELSE natearth.geom
> >          END AS shiftedgeo
> >          FROM (
> >             SELECT
> >                ne_10m_admin_0_countries_lakes.ne_id,
> >                ne_10m_admin_0_countries_lakes.geom,
> >                ne_10m_admin_0_countries_lakes.name
> >              FROM natural_earth.ne_10m_admin_0_countries_lakes
> >          UNION ALL
> >             SELECT
> >                ne_10m_admin_1_states_provinces_lakes.ne_id,
> >                ne_10m_admin_1_states_provinces_lakes.geom,
> >                ne_10m_admin_1_states_provinces_lakes.name
> >             FROM natural_earth.ne_10m_admin_1_states_provinces_lakes
> >          ) natearth
> >     ) foo
> >   ) foo2
> >) as fff
> >WHERE NOT ST_isvalid(simplifiedgeo2)
> >
> >Any advice on how to further debug this?
> >
> >"POSTGIS="2.5.1 r17027" [EXTENSION] PGSQL="110" GEOS="3.7.0-CAPI-1.11.0
> >3.7.1" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.4, released
> >2018/03/19 GDAL_DATA not found" LIBXML="2.7.8" LIBJSON="0.12"
> >LIBPROTOBUF="1.2.1" (core procs from "2.5.0 r16836" nee (...)"
> >"PostgreSQL 11.2, compiled by Visual C++ build 1914, 64-bit"
> >
> >Running on windows 64-bit.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200326/11c2886e/attachment.html>


More information about the postgis-users mailing list