diff options
author | Keith Packard <keithp@keithp.com> | 2015-07-11 19:13:37 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-07-11 19:13:37 -0700 |
commit | afa37e4667ace42c1f43b01b613e639772cfeb75 (patch) | |
tree | 9732d92cc1e5ee00d8fd6a21f7e3ff9ef3b74b8f | |
parent | 1b6f3de0a547fa452d5c40775bcf59c49b229e5e (diff) |
altoslib: Convert longitude from distance in AltosMapTransform
This computes the longitude cooresponding to a specific distance at a
specific latitude.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | altoslib/AltosMapTransform.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java index 11ed4eb9..7615c83b 100644 --- a/altoslib/AltosMapTransform.java +++ b/altoslib/AltosMapTransform.java @@ -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; + } } |