@Nullable
    public static Viewport getBounds(final Set<String> geocodes, final boolean withWaypoints) {
        if (CollectionUtils.isEmpty(geocodes)) {
            return null;
        }
        return withAccessLock(() -> {

            final Set<Geocache> caches = loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB);

            Viewport result = null;
            if (!withWaypoints) {
                result = Viewport.containing(caches);
            }
            //if we have no 'withWaypoints' but don't get any viewport without them then try with waypoints as a fallback
            if (result == null) {
                result = Viewport.containingCachesAndWaypoints(caches);
            }
            return result;
        });
    }
Retrieve coordinates from a Cursor

@param cursor   a Cursor representing a row in the database
@param indexLat index of the latitude column
@param indexLon index of the longitude column
@return the coordinates, or null if latitude or longitude is null or the coordinates are invalid
main/src/main/java/cgeo/geocaching/storage/DataStore.java