@Nullable
    private static <T extends ICoordinate> Viewport containing(final Iterable<T> points, final boolean withWaypoints, final Predicate<T> test) {
        final ContainingViewportBuilder cb = new ContainingViewportBuilder();
        for (final T point : points) {
            if (point != null && (test == null || test.test(point))) {
                cb.add(point);
                if (withWaypoints && ((Geocache) point).hasWaypoints()) {
                    for (final Waypoint waypoint : ((Geocache) point).getWaypoints()) {
                        if (waypoint != null) {
                            cb.add(waypoint.getCoords());
                        }
                    }
                }
            }
        }
        return cb.getViewport();
    }
internal worker function for
- containing(Points)
- containingGCLiveCaches(Geocaches)
- containingCachesAndWaypoints(Geocaches)
main/src/main/java/cgeo/geocaching/location/Viewport.java