src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Remove all unchanged elements, retaining parent Relations for changed ones
     * 
     * Note this doesn't handle selected elements and should only be called when nothing is selected
     */
Remove all unchanged elements, retaining parent Relations for changed ones

Note this doesn't handle selected elements and should only be called when nothing is selected
Remove all unchanged elements retaining parent Relations for changed ones Note this doesn ' t handle selected elements and should only be called when nothing is selected
public synchronized void pruneAll() {
        LongHashSet keepNodes = new LongHashSet();
        LongHashSet keepRelations = new LongHashSet();
        for (Way w : currentStorage.getWays()) {
            if (apiStorage.getWay(w.getOsmId()) == null) {
                currentStorage.removeWay(w);
            } else { 
                for (Node n : w.getNodes()) {
                    keepNodes.put(n.getOsmId());
                }
                keepParents(keepRelations, w);
            }
        }
        for (Node n : currentStorage.getNodes()) {
            long nodeId = n.getOsmId();
            if (apiStorage.getNode(nodeId) == null && !keepNodes.contains(nodeId)) {
                currentStorage.removeNode(n);
            } else {
                keepNodes.put(nodeId);
                keepParents(keepRelations, n);
            }
        }
        for (Relation r : currentStorage.getRelations()) {
            long relationId = r.getOsmId();
            if (apiStorage.getRelation(relationId) != null) {
                keepRelations.put(relationId);
                keepParents(keepRelations, r);
            }
        }
        for (Relation r : currentStorage.getRelations()) {
            if (!keepRelations.contains(r.getOsmId())) {
                currentStorage.removeRelation(r);
            }
        }
        fixupBacklinks();
        dirty();
    }
public synchronized void pruneAll ( ) { LongHashSet keepNodes = new LongHashSet ( ) ; LongHashSet keepRelations = new LongHashSet ( ) ; for ( Way w : currentStorage . getWays ( ) ) { if ( apiStorage . getWay ( w . getOsmId ( ) ) == null ) { currentStorage . removeWay ( w ) ; } else { for ( Node n : w . getNodes ( ) ) { keepNodes . put ( n . getOsmId ( ) ) ; } keepParents ( keepRelations , w ) ; } } for ( Node n : currentStorage . getNodes ( ) ) { long nodeId = n . getOsmId ( ) ; if ( apiStorage . getNode ( nodeId ) == null && ! keepNodes . contains ( nodeId ) ) { currentStorage . removeNode ( n ) ; } else { keepNodes . put ( nodeId ) ; keepParents ( keepRelations , n ) ; } } for ( Relation r : currentStorage . getRelations ( ) ) { long relationId = r . getOsmId ( ) ; if ( apiStorage . getRelation ( relationId ) != null ) { keepRelations . put ( relationId ) ; keepParents ( keepRelations , r ) ; } } for ( Relation r : currentStorage . getRelations ( ) ) { if ( ! keepRelations . contains ( r . getOsmId ( ) ) ) { currentStorage . removeRelation ( r ) ; } } fixupBacklinks ( ) ; dirty ( ) ; }
Remove all unchanged elements, retaining parent Relations for changed ones
Remove all unchanged elements retaining parent Relations for changed ones
// keeping so we need to keep the nodes