|
@@ -208,4 +208,30 @@
|
|
|
DROP TABLE "${tableName}"
|
|
|
</delete>
|
|
|
|
|
|
+ <delete id="delElongatedPolygon">
|
|
|
+ DELETE
|
|
|
+ FROM "${tableName}"
|
|
|
+ WHERE public.ST_GeometryType(geom) = 'ST_Polygon'
|
|
|
+ AND ((4 * pi() * public.ST_Area(geom::public.geography)) /
|
|
|
+ (public.ST_Perimeter(geom::public.geography) * public.ST_Perimeter(geom::public.geography)) <
|
|
|
+ #{elongationRatio} and
|
|
|
+ public.ST_Area(geom::public.geography) < #{minArea});
|
|
|
+
|
|
|
+ WITH split_polygons AS (SELECT (public.ST_Dump(geom)).geom AS single_geom
|
|
|
+ FROM "${tableName}"
|
|
|
+ WHERE public.ST_GeometryType(geom) = 'ST_MultiPolygon'
|
|
|
+ )
|
|
|
+ , filtered_polygons AS (
|
|
|
+ SELECT single_geom
|
|
|
+ FROM split_polygons
|
|
|
+ WHERE (4 * pi() * public.ST_Area(single_geom::public.geography)) / (public.ST_Perimeter(single_geom::public.geography) * public.ST_Perimeter(single_geom::public.geography))
|
|
|
+ > #{elongationRatio}
|
|
|
+ OR public.ST_Area(single_geom::public.geography)
|
|
|
+ > #{minArea}
|
|
|
+ )
|
|
|
+ UPDATE "${tableName}"
|
|
|
+ SET geom = (SELECT public.ST_Multi(public.ST_Collect(single_geom))
|
|
|
+ FROM filtered_polygons)
|
|
|
+ WHERE public.ST_GeometryType(geom) = 'ST_MultiPolygon';
|
|
|
+ </delete>
|
|
|
</mapper>
|