开发者

For a multiline intersecting several polygons, get the respective lengths

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜