altoslib: Convert longitude from distance in AltosMapTransform
authorKeith Packard <keithp@keithp.com>
Sun, 12 Jul 2015 02:13:37 +0000 (19:13 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 12 Jul 2015 02:13:37 +0000 (19:13 -0700)
This computes the longitude cooresponding to a specific distance at a
specific latitude.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosMapTransform.java

index 11ed4eb..7615c83 100644 (file)
@@ -117,4 +117,12 @@ public class AltosMapTransform {
                offset_x = centre_pt.x - width / 2.0;
                offset_y = centre_pt.y - height / 2.0;
        }
+
+       public static double lon_from_distance(double lat, double distance) {
+               double c = AltosGreatCircle.earth_radius * Math.cos(lat * Math.PI / 180) * 2 * Math.PI;
+
+               if (c < 10)
+                       return 0;
+               return distance/c * 360.0;
+       }
 }