查找KML多边形上的最近点

时间:2019-04-02 12:43:10

标签: algorithm geometry kml

在图中:

  • 红色为GEO点(来自GEO位置)
  • 蓝色是KML多边形
  • 绿色是检查最近点的半径
  • 棕点是半径内KML上最接近的点

如何在数学上找到这些最近的点?

Graphic

1 个答案:

答案 0 :(得分:1)

result = an empty list of points

for each edge of the KML polygon:
    if the edge is completely inside the green circle:
        append to result the point on the edge that is closest to the green circle center (see https://math.stackexchange.com/questions/2193720/find-a-point-on-a-line-segment-which-is-the-closest-to-other-point-not-on-the-li) 
    else:
        if the edge has two different intersections with the green circle:
            find the two intersection P1 and P2
            append to result the point (P1+P2)/2
        else:
            if the edge has one intersection with the green circle:
                append to result the intersection
            endif
        endif
    endif
endfor