X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosGreatCircle.java;h=6e5bd362372f4c633b423594b94cb37e296bb420;hp=9ec808a5ca74e0c3b9e93d6a4a489d224d550448;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=b1a90adac9f6e2a609ce1ccd6749462bb5c9adbe diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 9ec808a5..6e5bd362 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,7 +21,7 @@ package org.altusmetrum.altoslib_11; import java.lang.Math; import java.io.*; -public class AltosGreatCircle implements Cloneable, AltosHashable { +public class AltosGreatCircle implements Cloneable { public double distance; public double bearing; public double range; @@ -71,7 +72,10 @@ public class AltosGreatCircle implements Cloneable, AltosHashable { course = 2 * Math.PI-course; } distance = d * earth_radius; - bearing = course * 180/Math.PI; + if (Double.isNaN(course) || Double.isInfinite(course)) + bearing = 0; + else + bearing = course * 180/Math.PI; double height_diff = end_alt - start_alt; range = Math.sqrt(distance * distance + height_diff * height_diff); @@ -103,31 +107,4 @@ public class AltosGreatCircle implements Cloneable, AltosHashable { 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); - } }