altosui: Add AltosGreatCircle constructors
authorKeith Packard <keithp@keithp.com>
Fri, 27 Aug 2010 06:43:00 +0000 (23:43 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 27 Aug 2010 06:43:00 +0000 (23:43 -0700)
This adds constructurs from AltosGPS pairs and also one from empty
args (which defines both distance and bearing as 0).

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosGreatCircle.java

index 878da03e2b6a7ad2ade1e87fc97a19fa80055315..07c02c16c34c17d665335ff3c657482a289a4a62 100644 (file)
@@ -17,6 +17,8 @@
 
 package altosui;
 
 
 package altosui;
 
+import altosui.AltosGPS;
+
 import java.lang.Math;
 
 public class AltosGreatCircle {
 import java.lang.Math;
 
 public class AltosGreatCircle {
@@ -28,8 +30,8 @@ public class AltosGreatCircle {
        static final double rad = Math.PI / 180;
        static final double earth_radius = 6371.2 * 1000;       /* in meters */
 
        static final double rad = Math.PI / 180;
        static final double earth_radius = 6371.2 * 1000;       /* in meters */
 
-       AltosGreatCircle (double start_lat, double start_lon,
-                         double end_lat, double end_lon)
+       public AltosGreatCircle (double start_lat, double start_lon,
+                                double end_lat, double end_lon)
        {
                double lat1 = rad * start_lat;
                double lon1 = rad * -start_lon;
        {
                double lat1 = rad * start_lat;
                double lon1 = rad * -start_lon;
@@ -63,4 +65,13 @@ public class AltosGreatCircle {
                distance = d * earth_radius;
                bearing = course * 180/Math.PI;
        }
                distance = d * earth_radius;
                bearing = course * 180/Math.PI;
        }
+
+       public AltosGreatCircle(AltosGPS start, AltosGPS end) {
+               this(start.lat, start.lon, end.lat, end.lon);
+       }
+
+       public AltosGreatCircle() {
+               distance = 0;
+               bearing = 0;
+       }
 }
 }