用于识别不间断线串的查询(PGSQL 和 POSTGIS)

问题描述 投票:0回答:1

我需要一个查询来标识在另一条线的点找到时不会中断的线串,示例如下:

在这种情况下,线条在点处相交和断裂:
Here in this case, the lines meet and break at the points

我需要一个选择来查找行继续且不中断的情况:
I need a select that finds cases when the line continues and does not break

或者像这样:
enter image description here

这可能吗?

我尝试过类似的方法,但效果不太好

SELECT a.id, a.geom
FROM mapeamento_urbano.hid_trecho_drenagem_l AS a
WHERE NOT EXISTS (
    SELECT 1
    FROM mapeamento_urbano.hid_trecho_drenagem_l AS b
    WHERE a.id != b.id
    AND ST_Touches(a.geom, b.geom)
    AND ST_Equals(ST_EndPoint(b.geom), ST_Intersection(a.geom, b.geom))
);

返回的案例如下:
Image:

sql postgresql postgis
1个回答
0
投票

您可以利用线条不

contain
点位于其末端的微妙属性(相关帖子)。

WITH src(id,geom) as (values 
    (1, 'linestring(0 0, 0 10)'::geometry),
    (2, 'linestring(0 10, 0 11)'::geometry),
    (3, 'linestring(1 1, 0 5)'::geometry),
    (4, 'linestring(1 1, 2 2)'::geometry))
SELECT a.id, b.id, st_asText(st_intersection(a.geom,b.geom))
FROM src AS a
JOIN src AS B on st_intersects(a.geom, b.geom)
WHERE a.id != b.id 
 AND st_contains(a.geom, st_intersection(a.geom,b.geom));

 id | id | st_astext
----+----+------------
  1 |  3 | POINT(0 5)
(1 row)
© www.soinside.com 2019 - 2024. All rights reserved.