Get bounded cell from lat / lon polygon

I have a list of boundaries (polygons) and a list of ways represented by latitudes and longitudes. I would like to know if there is one path inside the polygon. I am doing this in perl but cannot find anything useful to calculate. Math :: Polygon (:: Calc) has interesting features, but not for lat / lon only for x / y.

So, I'm thinking about making it simpler and creating a bounding box for each polygon, so it's easier for me to check if one path point is in the bounding box.

Does anyone know what the algorithm looks like to get the bounding box. pseudocode would be enough, so I can code it in perl.

It would be even better to check for the presence inside the polygon without converting the polygon to its bounding rectangle, but I couldn't find anything useful on the net. There are some simple 2d x / y based coordinate systems, but not for spherical lat / lon.

+3


source to share


1 answer


First, place the start and end points of each of the polygon line segments into the pattern. Then we iterate over the array to find MinX, MinY, MaxX, and MaxY. Then the point (MinX, MinY) is in the lower left corner of your box and (MaxX, MaxY) is in the upper right corner.



+3


source







All Articles