diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-14 12:12:23 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-14 12:12:23 +0200 |
commit | 81687dd215a3cbeb4b00da7af74b18fb6a96c403 (patch) | |
tree | eace7e851975fc421a09d28407578117b2823c3f /main/src/cgeo/geocaching/geopoint | |
parent | 3b952c829e5b50057e18a0700c6b7ca3963c404d (diff) | |
download | cgeo-81687dd215a3cbeb4b00da7af74b18fb6a96c403.zip cgeo-81687dd215a3cbeb4b00da7af74b18fb6a96c403.tar.gz cgeo-81687dd215a3cbeb4b00da7af74b18fb6a96c403.tar.bz2 |
Refactoring: rename isInViewport() to contains()
This is a better name from the point of a viewport.
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint')
-rw-r--r-- | main/src/cgeo/geocaching/geopoint/Viewport.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java index 18c8342..478aa7b 100644 --- a/main/src/cgeo/geocaching/geopoint/Viewport.java +++ b/main/src/cgeo/geocaching/geopoint/Viewport.java @@ -59,8 +59,14 @@ public class Viewport { return getLongitudeMax() - getLongitudeMin(); } - public boolean isInViewport(final Geopoint coords) { - + /** + * Check whether a point is contained in this viewport. + * + * @param coords + * the coordinates to check + * @return true if the point is contained in this viewport, false otherwise + */ + public boolean contains(final Geopoint coords) { return coords.getLongitudeE6() >= bottomLeft.getLongitudeE6() && coords.getLongitudeE6() <= topRight.getLongitudeE6() && coords.getLatitudeE6() >= bottomLeft.getLatitudeE6() @@ -80,7 +86,7 @@ public class Viewport { * @return true if the vp is fully included into this one, false otherwise */ public boolean includes(final Viewport vp) { - return isInViewport(vp.bottomLeft) && isInViewport(vp.topRight); + return contains(vp.bottomLeft) && contains(vp.topRight); } /** @@ -103,7 +109,7 @@ public class Viewport { // when CGeoMap.java gets rewritten public static boolean isCacheInViewPort(int centerLat, int centerLon, int spanLat, int spanLon, final Geopoint coords) { final Viewport viewport = new Viewport(new Geopoint(centerLat / 1e6, centerLon / 1e6), spanLat / 1e6, spanLon / 1e6); - return viewport.isInViewport(coords); + return viewport.contains(coords); } /** |