开发者

Left or Right Hand Side of a Polyline

Quite a tricky one this, as the title suggests I need to work our which side of a polyline a point is.

I have done this in the past using angles and fair bit of preprocessing, but unfo开发者_如何学Pythonrtunately need a fairly quick solution.

Any one with any clever ideas?

EDIT:

The aim is to calculate which side of a hurricane path a series of locations are.


If you have a table with a structure of the following form

| Point_Data |
+------------+
| id   | int |
| lon  | int |
| lat  | int |

You could have a stored procedure defined as follows:

create procedure getPoints (@lat0 int, @lon0 int, @lat1 int, @lon1 int)
as
    select id, lon, lat
           isLeft = (lat1 - lat0) * (lon - lon0)
                  - (lat - lat0) * (lon1 - lon0)
      from Point_Data
GO

Where isLeft would be >0 if it is left, 0 if on the line or <0 if to the right of the line. This is taken from Area of 2D and 3D Triangles and Polygons.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜