diff schema/isrs_functions.sql @ 5559:ce9a9a1bf92f

Make invalid output of ISRSrange_area() less likely, next try Since ST_MakeValid() might return a collection of lower-to-equal dimension geometries, distill only the polygons from it. This should prevent respective errors when trying to save the result to a column of type MultiPolygon.
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Dec 2021 12:37:33 +0100
parents 3cfbc5769e8b
children
line wrap: on
line diff
--- a/schema/isrs_functions.sql	Mon Nov 22 17:02:38 2021 +0100
+++ b/schema/isrs_functions.sql	Thu Dec 02 12:37:33 2021 +0100
@@ -198,8 +198,8 @@
                 FROM rotated_ends)
         -- From the polygons returned by the last CTE, select only those
         -- around the clipped axis
-        SELECT ST_Multi(ST_MakeValid(ST_Transform(
-                ST_Union(range_area.geom), ST_SRID(area))))
+        SELECT ST_Multi(ST_CollectionExtract(ST_MakeValid(ST_Transform(
+                ST_Union(range_area.geom), ST_SRID(area))), 3))
             INTO result_geom
             FROM range_area
             WHERE ST_Intersects(ST_Buffer(range_area.geom, -0.0001), axis);