テーブルとの自己結合を実行し、線の間のすべての交点を出力する次のクエリがあります。
insert into road_intersection
select nextval('road_intersection_id_seq'), a.road_id, b.road_id, st_intersection(a.road, b.road), st_centroid(st_intersection(a.road, b.road))
from polygon_road a, polygon_road b
where st_intersects(a.road, b.road) AND a.road_id!=b.road_id
ただし、各道路の交点を計算するため、交点ごとに重複する値が出力されます。例えば:
70;71;POINT_OF_INTERSECTION
71;70;POINT_OF_INTERSECTION
70
AND71
は、両方ともid
2つの異なる道路の値です。ご覧のとおり、交差点は同じ2つの道路に対して2回計算されています。
この問題を解決する方法と、1つの交点のみが計算される提案はありますか?