I have a set of coordinates in lon/lat. There are always at least 3 ordered coordinates that form a poly (if they were projected flat). How can I calculate the minimum bounds for these coordinates as a set of valid longitude and latitude ranges? (by 'valid' I mean ranges that explicitly account for the antimeridian). Its kind of hard to explain what I'm looking for so I have a picture.
The case in the picture is trivial; you just find the absolute minimum and maximum for all the points. This doesn't work for all cases though. Is there a generic solution?
Edit: To clarify what I mean by 'valid', say I had three longitude values in my data set: -76, -135 and 164. The values cross the antimeridian and I'd like the resulting ranges to be split: -76 to -180 AND 164 to 180.
Some more clarification. The points form a polygon, so in certain cases, the required range could be from -180 to +180 (ie, the full 360 degrees):
The image on the left shows the longitude of four coordinates that occur on one 'half' of the Earth. Imagine it as if you were looking down onto the north pole (black dot). The pink shows the minimum longitudinal range that encompasses the polygon (the polygon is shown between the four points in purple). The case on the left would have two longitudinal ranges: [-180 to -120] and [135 to 180] (just visually estimating it)
The image on the right shows another case where the points go all the way around the Earth. This range would be [-180 to 180].