aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/geopoint
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2011-09-22 12:21:17 +0200
committerSamuel Tardieu <sam@rfc1149.net>2011-09-22 12:24:08 +0200
commitd9d152ad63b107f9a87b10070886c77a987eca5b (patch)
treebdcd09a07a680fe470b66dc382bf2576d542e34f /main/src/cgeo/geocaching/geopoint
parent749626af7807bc61cc0238dfa4ea1036efcb8dc5 (diff)
downloadcgeo-d9d152ad63b107f9a87b10070886c77a987eca5b.zip
cgeo-d9d152ad63b107f9a87b10070886c77a987eca5b.tar.gz
cgeo-d9d152ad63b107f9a87b10070886c77a987eca5b.tar.bz2
Prefer a canonical longitude representation
If -180 is given, use 180 instead. This is arbitrary, and could be changed to -180 without consequences. But it lets each Geopoint be uniquely defined if we except the North and South poles since the longitude has no meaning there.
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint')
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java3
1 files changed, 2 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java
index e82d547..37c9e16 100644
--- a/main/src/cgeo/geocaching/geopoint/Geopoint.java
+++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java
@@ -30,7 +30,8 @@ public final class Geopoint
throw new MalformedCoordinateException("malformed latitude: " + lat);
}
if (lon <= 180 && lon >= -180) {
- longitude = lon;
+ // Prefer 180 degrees rather than the equivalent -180.
+ longitude = lon == -180 ? 180 : lon;
} else {
throw new MalformedCoordinateException("malformed longitude: " + lon);
}