Distance between point and polygon

时间:2016-08-31 17:39:34

标签: algorithm geometry polygon distance great-circle

Task

Calculate the distance d in meters between a query-point q and a polygon P.

The query-point q is defined as tuple (latitudeq, longitudeq), the polygon P as ordered list of tuples [(latitude1, longitude1), ..., (latituden, longituden)].

Problem

I can't handle latitude and longitude as if they were x- and y-coordinates of a plane as this leads to huge errors if the polygon is not small and not near (0, 0).

Tools

I know how to calculate the distance between two points given each points latitude and longitude. I do also know how to calculate the distance between a point and a great circle. But for this task I'd need to know how to calculate the distance dist(q, 1—2) between a point q and and part of a great-circle 1—2. The distance of q would be simply min(dist(q, ab)) ∀ ab in P.

Question

Can you provide me a formula how to calculate the distance between a query-point q defined by a tuple (latitudeq, longitudeq) and a great-circle-arc defined by pair of latitude-longitude-tuples [(latitude1, longitude1),(latitude2, longitude2)]?

Example

Query-point *q* and polygon *P* defined by eight points). What is the distance *d* in meters?

1 个答案:

答案 0 :(得分:0)

如果你有代码来计算一个点 x 和一个测地线之间的距离 分段 s ,你可以为你的测地多边形的每个边重复这个。

s =( a b )。 s 是一个大圆弧。旋转球体,使其 s 位于赤道上, x 跟随球体旋转。 然后 x 的纬度基本上告诉你到 s 的距离:它要么是 从 x a x b 的距离,或者,如果 x 位于 s 上方/下方的扇区中,它是纬度的一个简单因子(2πr)。