aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/geopoint/Viewport.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint/Viewport.java')
-rw-r--r--main/src/cgeo/geocaching/geopoint/Viewport.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java
index ba0e040..a48b0a1 100644
--- a/main/src/cgeo/geocaching/geopoint/Viewport.java
+++ b/main/src/cgeo/geocaching/geopoint/Viewport.java
@@ -79,6 +79,22 @@ public final class Viewport {
&& coords.getLatitudeE6() <= topRight.getLatitudeE6();
}
+ /**
+ * Count the number of points present in the viewport.
+ *
+ * @param points a collection of (possibly null) points
+ * @return the number of non-null points in the viewport
+ */
+ public int count(final @NonNull Collection<? extends ICoordinates> points) {
+ int total = 0;
+ for (ICoordinates point: points) {
+ if (point != null && contains(point)) {
+ total += 1;
+ }
+ }
+ return total;
+ }
+
@Override
public String toString() {
return "(" + bottomLeft.toString() + "," + topRight.toString() + ")";