src/main/java/de/blau/android/osm/StorageDelegator.java
/**
     * Ensure that we have consistent backlinks
     */
Ensure that we have consistent backlinks
Ensure that we have consistent backlinks
void fixupBacklinks() {
        for (OsmElement e : currentStorage.getElements()) {
            if (e != null) {
                e.clearParentRelations();
            }
        }
        for (Relation r : currentStorage.getRelations()) {
            final List<RelationMember> members = r.getMembers();
            if (members != null) {
                for (RelationMember rm : r.getMembers()) {
                    OsmElement e = null;
                    final String type = rm.getType();
                    final long ref = rm.getRef();
                    switch (type) {
                    case Node.NAME:
                        e = currentStorage.getNode(ref);
                        break;
                    case Way.NAME:
                        e = currentStorage.getWay(ref);
                        break;
                    case Relation.NAME:
                        e = currentStorage.getRelation(ref);
                        break;
                    default:
                        logUnknownMemberType(r, type);
                    }
                    if (e != null) {
                        e.addParentRelation(r);
                    }
                }
            }
        }
    }
void fixupBacklinks ( ) { for ( OsmElement e : currentStorage . getElements ( ) ) { if ( e != null ) { e . clearParentRelations ( ) ; } } for ( Relation r : currentStorage . getRelations ( ) ) { final List < RelationMember > members = r . getMembers ( ) ; if ( members != null ) { for ( RelationMember rm : r . getMembers ( ) ) { OsmElement e = null ; final String type = rm . getType ( ) ; final long ref = rm . getRef ( ) ; switch ( type ) { case Node . NAME : e = currentStorage . getNode ( ref ) ; break ; case Way . NAME : e = currentStorage . getWay ( ref ) ; break ; case Relation . NAME : e = currentStorage . getRelation ( ref ) ; break ; default : logUnknownMemberType ( r , type ) ; } if ( e != null ) { e . addParentRelation ( r ) ; } } } } }
Ensure that we have consistent backlinks
Ensure that we have consistent backlinks
// first zap all, really all, as referenced relations may have been deleted // a possible alternative would be to check undostorage for any relations // then add them back