I'm trying to calculate bounds for square with particular radius and when center of square is known(longitude, latitude). But I'm getting into troubles with it.
I've tried to use haversine formula from here :
But I'm getting into troubles when radius is pretty big.
Currently to find 1). latitude delta in radians I use:
- radiusInMeters / EARTH_RADIUS_METERS
2). longitude delta in radians I use:
- 2.0 * | arcsin( |sin(radiusInMeters/(EARTH_RADIUS_METERS*2.0)) / |cos(latitudeStart)| | ) |
These formulas I got from haversine formula.
Could please someone point me to the exact generic formula for calculations which will be good for big and small distances for my case.
Also how should be handled situations when radius exceeds -180˚/180˚ on longitude or -90˚/90˚ on latitude?
UPDATE
Some clarifications. Let's say that I'm staying in some particular point with coordinates (lon, lat), where lon is -113˚ and lat 50˚.
I would like to query points in some radius of interest from database. For that I need to calculate bounds of a "square". (Then filter-out stuff that's not in interesting radius). Formula above works fine on small distances(let's say 'till 100 kilometers(63 miles). But the more I go from equatorial point the poles, the more rounding errors I get.)
Thanks in advance