开发者

For a multiline intersecting several polygons, get the respective lengths

开发者 https://www.devze.com 2023-02-13 08:56 出处:网络
I have one table containing polygons and another containing multilines. For a given multiline, I can get just the intersecting polygons, like so:

I have one table containing polygons and another containing multilines. For a given multiline, I can get just the intersecting polygons, like so:

SELECT p.geo, p.id
FROM polygons p, lines l
WHERE p.geo.STIntersects(l.geo) = 1 AND l.id = @lineID

To开发者_Go百科 also get the line itself, I add:

UNION ALL
SELECT l.geo, l.id
FROM lines l
WHERE l.id = @lineID

How, though, do I get the respective length of the portion of the line that intersects the given polygon, as a third column?


As simple as it should be, really.

SELECT p.geo, p.id, p.geo.STIntersection(l.geo).STLength()
FROM polygons p, lines l
WHERE p.geo.STIntersects(l.geo) = 1 AND l.id = @lineID
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号