I have a polygon that contains latitude and longitude as:
polygon= [[latitude1, longitude1], [[latitude2, longitude2]]....[latitudeN, longitudeN]]
The result of the shape is a circle, I want to calculate the distance from a point to the polygon. I know how to find the distance from one point to another, so I can iterate over all points in the polygon and find distance against my point to find minimum distance but is there another way?
Edit-1: I have some satellites footprints over a map, those footprints are presented as a polygons. I have some other points (locations) and I want to see which satellite is closer to each point and calculate the distance to that satellite
CodePudding user response:
In the case that the polygon indeed describes a circle, you could save the polygon as a center location (x,y) coordinate and the radius of the circle. The distane of a point to the polygon can be computed as the distance from the center of the circle to the wanted point, and then reduce the raidus size. As a bonus, if the resulted distance is negative, your point is inside the circle.