diff options
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint')
-rw-r--r-- | main/src/cgeo/geocaching/geopoint/Viewport.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java index 2b76624..981f0c8 100644 --- a/main/src/cgeo/geocaching/geopoint/Viewport.java +++ b/main/src/cgeo/geocaching/geopoint/Viewport.java @@ -2,15 +2,19 @@ package cgeo.geocaching.geopoint; public class Viewport { + public final Geopoint center; public final Geopoint bottomLeft; public final Geopoint topRight; public Viewport(final Geopoint bottomLeft, final Geopoint topRight) { this.bottomLeft = bottomLeft; this.topRight = topRight; + this.center = new Geopoint((bottomLeft.getLatitude() + topRight.getLatitude()) / 2, + (bottomLeft.getLongitude() + topRight.getLongitude()) / 2); } public Viewport(final Geopoint center, final double latSpan, final double lonSpan) { + this.center = center; final double centerLat = center.getLatitude(); final double centerLon = center.getLongitude(); bottomLeft = new Geopoint(centerLat - latSpan / 2, centerLon - lonSpan / 2); @@ -33,6 +37,10 @@ public class Viewport { return topRight.getLongitude(); } + public Geopoint getCenter() { + return center; + } + @Override public String toString() { return "(" + bottomLeft.toString() + "," + topRight.toString() + ")"; |