altoslib: Improve AltosState save/restore debugging
[fw/altos] / altoslib / AltosGreatCircle.java
index 9ced17e7c82dd8b8dad66f7a467001ccff1cc111..f2c1783ddda69ac9509b7c2574fc78a48e7f5350 100644 (file)
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_9;
+package org.altusmetrum.altoslib_11;
 
 import java.lang.Math;
 import java.io.*;
 
-public class AltosGreatCircle implements Cloneable, Serializable {
+public class AltosGreatCircle implements Cloneable, AltosJsonable {
        public double   distance;
        public double   bearing;
        public double   range;
@@ -103,4 +103,31 @@ public class AltosGreatCircle implements Cloneable, Serializable {
                range = 0;
                elevation = 0;
        }
+
+       public AltosJson json() {
+               AltosJson j = new AltosJson();
+
+               j.put("distance", distance);
+               j.put("bearing", bearing);
+               j.put("range", range);
+               j.put("elevation", elevation);
+
+               return j;
+       }
+
+       public AltosGreatCircle(AltosJson j) {
+               this();
+
+               distance = j.get_double("distance", distance);
+               bearing = j.get_double("bearing", bearing);
+               range = j.get_double("range", range);
+               elevation = j.get_double("elevation", elevation);
+       }
+
+       public static AltosGreatCircle fromJson(AltosJson j, AltosGreatCircle def) {
+               if (j == null)
+                       return def;
+
+               return new AltosGreatCircle(j);
+       }
 }