Search code examples
javaandroidosmdroid

Getting new GPS coordinates by adding metric distances


I have been trying to find samples of codes in Java where I am able to add a metric distance to a particular coordinate point.

For example, by adding 2 kilometers to Point A's latitude, and subtracting 2 kilometers to Point B's longitude, I would want to obtain a new coordinate point (Point B) that is north west of Point A.

Are there any sample source codes for such a function out there?


Solution

  • If you don't need high accuracy and the distances are small you may assume the Earth is a sphere with approximately R = 6370 km radius. The difference in latitude in radians is then simply dNorth / R, the difference in longitude is dEast / R / cos(lat).

    For higher accuracy you have to take into account that the shape of the Earth is more like an ellipsoid.