I am using a map that allows selecting a bounding box on a map and returns (lat, lon) for top right, and bottom left.
I am using couchbase geo spatial queries and they only support top_left bottom_right coordinates.
What's the formula to convert latitude and longitude values of two opposite corners from a rectangle from top_right bottom_left to top_left bottom_right?
A self explanatory diagram
lat2 lon1 (top left) ----- lat2 lon2 (top right)
| |
| |
lat1 lon1 (bottom left) ----- lat1 lon2 (bottom right)
Input coordinates (lat1, lon1) (lat2, lon2)
Output coordinates (lat2, lon1) (lat1 lon2)
As you can see there is no formula involved. All the necessary values are available. It's just a matter of correctly setting the coordinates variables.