[英]How to find if a point is one of the vertices of a line using postgresSQL query
如何使用PostgreSQL查詢和PostGis函數查找一個點是否是直線的頂點之一?
謝謝!
要檢查一個點是否是多線的一部分,可以使用類似
SELECT
/* this will count the number of occurrences of the point in the linestring */
count(
/* this will be NULL if the point is not equal to the n-th point */
CASE WHEN st_pointn(g.geom, n) = st_geomfromtext('POINT(10 0)')
THEN 1
END
) > 0 /* result is TRUE if the point is on the multiline */
FROM (VALUES(st_geomfromtext('LINESTRING(0 0,10 0,10 10)'))) g(geom)
/* this is a table containing all vertex numbers of the linestring */
CROSS JOIN LATERAL generate_series(1, st_numpoints(geom)) n(n);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.