Calculating the union of 2 longitudal intervals (that may wrap around 180 degrees)

Posted by timpatt on Stack Overflow See other posts from Stack Overflow or by timpatt
Published on 2011-01-07T05:45:59Z Indexed on 2011/01/07 5:53 UTC
Read the original article Hit count: 279

Filed under:
|
|
|

The story:

I have a LatLongBounds class that represents an area on the surface of the earth by a latitudinal interval (bounded by north & south - not important to this question) and a longitudinal interval (bounded by east and west; both normalized to a range [-180, 180] - negative being a westerly direction).

In order to be able to represent an area that straddles the 180 degree meridian the value of west may be set to be greater than east (eg. the range west = 170, east = -170 will straddle said meridian). In effect the longitudinal interval may wrap around at 180 degrees (or equivalently -180 degrees).

My Question:

Does anyone have any suggestions as to how I can calculate the union of two longitudinal intervals that may wrap around at 180 degrees.

Thanks.

© Stack Overflow or respective owner

Related posts about union

Related posts about geospatial