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 11ed4eb9c238e887669fe38ad9d64d1814ea2091..7615c83b3f530b79f3189c8ac34552e584aa8e38 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;
+       }
 }