Esempio n. 1
0
void Network::consolidateRelations(bool discard_if_missing_reference) {
   std::map<unsigned long long int, RelationPtr>::iterator relIt = relations.begin();
   //loop through the relations
   while (relIt != relations.end()) {
      RelationPtr relation = relIt->second;
      try {
         relation->consolidate(this);
         relIt++;
      } catch (RefNotFoundException e) {
         //the relation references a node, way or relation that doesn't exist
         if (discard_if_missing_reference) {
            //discard relations referencing this relation
            std::map<unsigned long long int, RelationPtr>::iterator relIt2 = relations.begin();
            while (relIt2 != relations.end() && relIt2 != relIt) {
               if (relIt2->second->contains(relation)) {
                  relations.erase(relIt2++);
               } else {
                  relIt2++;
               }
            }

            //discard the relation itself
            std::map<unsigned long long int, RelationPtr>::iterator rel_to_delete = relIt++;
            relations.erase(rel_to_delete);
         } else {
            relIt++;
         }
      }
   }
}