在 KML 多边形上查找最近的点

Find nearest points on KML polygon

图中:

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

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