[postgis-users] St_makevalid issue
Paul van der Linden
paul.doskabouter at gmail.com
Wed Apr 1 08:17:52 PDT 2020
Noticed that the message containing the query wasn't coupled to my latest
post, so here it is again:
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 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 ne_10m_admin_1_states_provinces_lakes
) natearth
) foo
) foo2
) as fff
WHERE NOT ST_isvalid(simplifiedgeo2)
P.S. when replying, could you also include my mail address?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200401/c9a3c5e4/attachment.html>
More information about the postgis-users
mailing list