@NonNull
    private static SearchResult loadInViewport(final boolean stored, final Viewport viewport, final GeocacheFilter filter) {

        try (ContextLogger cLog = new ContextLogger("DataStore.loadInViewport()")) {
            cLog.add("stored=%b,vp=%s", stored, viewport);

            final Set<String> geocodes = new HashSet<>();

            // if not stored only, get codes from CacheCache as well
            if (!stored) {
                geocodes.addAll(cacheCache.getInViewport(viewport));
            }

            geocodes.addAll(
                loadBatchOfStoredGeocodes(filter, stored ? PseudoList.ALL_LIST.id : -1, viewport, null, false, null, 500));

            cLog.add("gc" + cLog.toStringLimited(geocodes, 10));

            final SearchResult sr = new SearchResult(geocodes);
            cLog.addReturnValue(sr.getCount());
            return sr;
        }
    }
Loads the geocodes of caches in a viewport from CacheCache and/or Database

@param stored   {@code true} to query caches stored in the database, {@code false} to also use the CacheCache
@param viewport the viewport defining the area to scan
@return the matching caches
main/src/main/java/cgeo/geocaching/storage/DataStore.java