diff options
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint/Geopoint.java')
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/Geopoint.java | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java index 00dec7f..a4821b9 100644 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java @@ -23,6 +23,8 @@ public final class Geopoint implements ICoordinates, Parcelable { public static final double rad2deg = 180 / Math.PI; public static final float erad = 6371.0f; + public static final Geopoint ZERO = new Geopoint(0.0, 0.0); + private final double latitude; private final double longitude; @@ -140,7 +142,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * @param lonSecFrac */ public Geopoint(final String latDir, final String latDeg, final String latMin, final String latSec, final String latSecFrac, - final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) { + final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) { this(latDir + " " + latDeg + " " + latMin + " " + latSec + "." + addZeros(latSecFrac, 3), lonDir + " " + lonDeg + " " + lonMin + " " + lonSec + "." + addZeros(lonSecFrac, 3)); } @@ -253,7 +255,7 @@ public final class Geopoint implements ICoordinates, Parcelable { if (this == obj) { return true; } - if (obj == null || !(obj instanceof Geopoint)) { + if (!(obj instanceof Geopoint)) { return false; } final Geopoint gp = (Geopoint) obj; @@ -274,8 +276,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * tolerance in km * @return true if similar, false otherwise */ - public boolean isEqualTo(Geopoint gp, double tolerance) - { + public boolean isEqualTo(Geopoint gp, double tolerance) { return null != gp && distanceTo(gp) <= tolerance; } @@ -287,42 +288,35 @@ public final class Geopoint implements ICoordinates, Parcelable { * @see GeopointFormatter * @return formatted coordinates */ - public String format(GeopointFormatter.Format format) - { + public String format(GeopointFormatter.Format format) { return GeopointFormatter.format(format, this); } /** * Returns formatted coordinates with default format. * Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456 - * + * * @return formatted coordinates */ @Override - public String toString() - { + public String toString() { return format(GeopointFormatter.Format.LAT_LON_DECMINUTE); } - abstract public static class GeopointException - extends RuntimeException - { + abstract public static class GeopointException extends NumberFormatException { private static final long serialVersionUID = 1L; - public GeopointException(String msg) + protected GeopointException(String msg) { super(msg); } } - public static class ParseException - extends GeopointException - { + public static class ParseException extends GeopointException { private static final long serialVersionUID = 1L; public final int resource; - public ParseException(final String msg, final GeopointParser.LatLon faulty) - { + public ParseException(final String msg, final GeopointParser.LatLon faulty) { super(msg); resource = faulty == GeopointParser.LatLon.LAT ? R.string.err_parse_lat : R.string.err_parse_lon; } @@ -350,7 +344,7 @@ public final class Geopoint implements ICoordinates, Parcelable { return result.getDouble("elevation"); } } catch (Exception e) { - Log.w("cgBase.getElevation: " + e.toString()); + Log.w("cgBase.getElevation", e); } return null; |
