src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Safely remove data that is not in/intersects with the provided BoundingBox
     * 
     * Skips selected elements, removes BoundingBoxes
     * 
     * @param logic the current Logic instance if null element selection will not be tested
     * @param box the BoundingBox
     */
Safely remove data that is not in/intersects with the provided BoundingBox

Skips selected elements, removes BoundingBoxes

@param logic the current Logic instance if null element selection will not be tested
@param box the BoundingBox
Safely remove data that is not in / intersects with the provided BoundingBox Skips selected elements removes BoundingBoxes @param logic the current Logic instance if null element selection will not be tested @param box the BoundingBox
protected void prune(@Nullable Logic logic, @NonNull BoundingBox box) {
        LongHashSet keepNodes = new LongHashSet();
        boolean noLogic = logic == null;
        for (Way w : currentStorage.getWays()) {
            if (apiStorage.getWay(w.getOsmId()) == null && !box.intersects(w.getBounds()) && (noLogic || !logic.isSelected(w)) && !hasModifiedNodes(w)) {
                currentStorage.removeWay(w);
                removeReferenceFromParents(logic, w);
            } else { 
                for (Node n : w.getNodes()) {
                    keepNodes.put(n.getOsmId());
                }
            }
        }
        for (Node n : currentStorage.getNodes()) {
            long nodeId = n.getOsmId();
            if (apiStorage.getNode(nodeId) == null && !box.contains(n.getLon(), n.getLat()) && !keepNodes.contains(nodeId)
                    && (noLogic || !logic.isSelected(n))) {
                currentStorage.removeNode(n);
                removeReferenceFromParents(logic, n);
            }
        }
        for (Relation r : currentStorage.getRelations()) {
            long relationId = r.getOsmId();
            if (apiStorage.getRelation(relationId) == null && (noLogic || !logic.isSelected(r)) && !r.hasDownloadedMembers()) {
                currentStorage.removeRelation(r);
                removeReferenceFromParents(logic, r);
            }
        }
        BoundingBox.prune(this, box);
        dirty();
    }
protected void prune ( @ Nullable Logic logic , @ NonNull BoundingBox box ) { LongHashSet keepNodes = new LongHashSet ( ) ; boolean noLogic = logic == null ; for ( Way w : currentStorage . getWays ( ) ) { if ( apiStorage . getWay ( w . getOsmId ( ) ) == null && ! box . intersects ( w . getBounds ( ) ) && ( noLogic || ! logic . isSelected ( w ) ) && ! hasModifiedNodes ( w ) ) { currentStorage . removeWay ( w ) ; removeReferenceFromParents ( logic , w ) ; } else { for ( Node n : w . getNodes ( ) ) { keepNodes . put ( n . getOsmId ( ) ) ; } } } for ( Node n : currentStorage . getNodes ( ) ) { long nodeId = n . getOsmId ( ) ; if ( apiStorage . getNode ( nodeId ) == null && ! box . contains ( n . getLon ( ) , n . getLat ( ) ) && ! keepNodes . contains ( nodeId ) && ( noLogic || ! logic . isSelected ( n ) ) ) { currentStorage . removeNode ( n ) ; removeReferenceFromParents ( logic , n ) ; } } for ( Relation r : currentStorage . getRelations ( ) ) { long relationId = r . getOsmId ( ) ; if ( apiStorage . getRelation ( relationId ) == null && ( noLogic || ! logic . isSelected ( r ) ) && ! r . hasDownloadedMembers ( ) ) { currentStorage . removeRelation ( r ) ; removeReferenceFromParents ( logic , r ) ; } } BoundingBox . prune ( this , box ) ; dirty ( ) ; }
Safely remove data that is not in/intersects with the provided BoundingBox
Safely remove data that is not in / intersects with the provided BoundingBox
// keeping so we need to keep the nodes // Note: this will not remove already processed relations that had this as a member however further // prune passes will eventually delete them, which is good enough and so we don't rerun this explicitly // here