4

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 :

haversine formula

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

hades
  • 1,077
  • 3
  • 11
  • 19
  • 2
    The concept of a square on the surface of a sphere is not well-defined. On the surface of an approximate sphere the definition is perhaps even less well-defined. As the angular measure of a 'square' gets larger the definition becomes even more vague. Can you explain precisely the geometric relationship(s) between the four corners of your square ? – High Performance Mark Apr 14 '13 at 17:04
  • better whould be to get quad coordinates as intersection between elipsoid(earth) and 4 rays from your camera (distorted from its axis by half of x and y view angles) so they are also edges of your frustrum. Problem is when you get too far from surface then simple quad is not enough (if you do not adding depth texture to it of course) – Spektre Sep 04 '13 at 10:04

0 Answers0