|
@@ -202,31 +202,35 @@
|
|
|
</insert>
|
|
|
<insert id="getHeightLimit">
|
|
|
CREATE TABLE "${newTableName}" AS
|
|
|
- WITH intersected AS (SELECT ta.id AS a_id,
|
|
|
- ta.geom AS a_geom,
|
|
|
- ta.height AS a_height,
|
|
|
- tb.id AS b_id,
|
|
|
- tb.geom AS b_geom,
|
|
|
- tb.hight AS b_hight,
|
|
|
- public.ST_Intersection(ta.geom, tb.geom) AS intersect_geom
|
|
|
- FROM "${tableNameA}" as ta
|
|
|
+ WITH intersected AS (SELECT ROW_NUMBER() OVER () AS ID, ta.ID AS a_id,
|
|
|
+ ta.geom AS a_geom,
|
|
|
+ ta.height AS a_height,
|
|
|
+ tb.ID AS b_id,
|
|
|
+ tb.geom AS b_geom,
|
|
|
+ tb.hight AS b_hight,
|
|
|
+ PUBLIC.ST_Intersection(ta.geom, tb.geom) AS intersect_geom
|
|
|
+ FROM "${tableNameA}" AS ta
|
|
|
JOIN
|
|
|
- "${tableNameB}" as tb
|
|
|
+ "${tableNameB}" AS tb
|
|
|
ON
|
|
|
- public.ST_Intersects(ta.geom, tb.geom))
|
|
|
- SELECT a_id as id,
|
|
|
- intersect_geom AS geom,
|
|
|
- a_height AS height
|
|
|
- FROM intersected
|
|
|
- WHERE a_height <= b_hight
|
|
|
+ PUBLIC.ST_Intersects(ta.geom, tb.geom)),
|
|
|
+ intersected_result AS (SELECT a_id AS id,
|
|
|
+ PUBLIC.ST_Union(intersect_geom) AS geom,
|
|
|
+ MAX(a_height) AS height
|
|
|
+ FROM intersected
|
|
|
+ WHERE a_height <= b_hight
|
|
|
+ GROUP BY a_id),
|
|
|
+ non_intersected_result AS (SELECT ta.ID AS id,
|
|
|
+ ta.geom AS geom,
|
|
|
+ ta.height AS height
|
|
|
+ FROM "${tableNameA}" AS ta
|
|
|
+ WHERE NOT EXISTS (SELECT 1
|
|
|
+ FROM "${tableNameB}" AS tb
|
|
|
+ WHERE PUBLIC.ST_Intersects(ta.geom, tb.geom)))
|
|
|
+ SELECT *
|
|
|
+ FROM intersected_result
|
|
|
UNION ALL
|
|
|
- SELECT ta.id AS id,
|
|
|
- ta.geom AS geom,
|
|
|
- ta.height AS height
|
|
|
- FROM "${tableNameA}" as ta
|
|
|
- WHERE NOT EXISTS (SELECT 1
|
|
|
- FROM "${tableNameB}" as tb
|
|
|
- WHERE public.ST_Intersects(ta.geom, tb.geom));
|
|
|
-
|
|
|
+ SELECT *
|
|
|
+ FROM non_intersected_result;
|
|
|
</insert>
|
|
|
</mapper>
|