diff options
author | Keith Packard <keithp@keithp.com> | 2016-05-12 23:33:53 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-05-12 23:41:55 -0700 |
commit | b1a90adac9f6e2a609ce1ccd6749462bb5c9adbe (patch) | |
tree | 107b6491d8ffc507609f9923353d5454c0664323 /altoslib/AltosGreatCircle.java | |
parent | b13037fad0905c5933d1ff579122ba1357b02eea (diff) |
altoslib: Store saved state in version-independent format
Use AltosHashSet for AltosState so that AltosDroid doesn't lose
tracker information when the application is upgraded.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosGreatCircle.java')
-rw-r--r-- | altoslib/AltosGreatCircle.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 03e05678..9ec808a5 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -20,7 +20,7 @@ package org.altusmetrum.altoslib_11; import java.lang.Math; import java.io.*; -public class AltosGreatCircle implements Cloneable, Serializable { +public class AltosGreatCircle implements Cloneable, AltosHashable { public double distance; public double bearing; public double range; @@ -103,4 +103,31 @@ public class AltosGreatCircle implements Cloneable, Serializable { range = 0; elevation = 0; } + + public AltosHashSet hashSet() { + AltosHashSet h = new AltosHashSet(); + + h.putDouble("distance", distance); + h.putDouble("bearing", bearing); + h.putDouble("range", range); + h.putDouble("elevation", elevation); + + return h; + } + + public AltosGreatCircle(AltosHashSet h) { + this(); + + distance = h.getDouble("distance", distance); + bearing = h.getDouble("bearing", bearing); + range = h.getDouble("range", range); + elevation = h.getDouble("elevation", elevation); + } + + public static AltosGreatCircle fromHashSet(AltosHashSet h, AltosGreatCircle def) { + if (h == null) + return def; + + return new AltosGreatCircle(h); + } } |