Skip to content

v0.2.53..v0.2.54 changeset RecursiveElementRemover.cpp

Garret Voltz edited this page Mar 31, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/ops/RecursiveElementRemover.cpp b/hoot-core/src/main/cpp/hoot/core/ops/RecursiveElementRemover.cpp
index 2118d30..deba7be 100644
--- a/hoot-core/src/main/cpp/hoot/core/ops/RecursiveElementRemover.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/ops/RecursiveElementRemover.cpp
@@ -22,7 +22,7 @@
  * This will properly maintain the copyright information. DigitalGlobe
  * copyrights will be updated automatically.
  *
- * @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
  */
 #include "RecursiveElementRemover.h"
 
@@ -54,6 +54,7 @@ void RecursiveElementRemover::apply(const std::shared_ptr<OsmMap>& map)
   _numAffected = 0;
 
   assert(_eid.isNull() == false);
+  LOG_VART(map->containsElement(_eid));
   if (map->containsElement(_eid) == false)
   {
     return;
@@ -81,14 +82,20 @@ void RecursiveElementRemover::apply(const std::shared_ptr<OsmMap>& map)
       // go through each of the child's direct parents
       for (set<ElementId>::const_iterator jt = parents.begin(); jt != parents.end(); ++jt)
       {
+        LOG_TRACE("Checking parent: " << *jt << " of child: " << *it << "...");
         if (toErase.find(*jt) == toErase.end())
         {
           // remove the child b/c it is owned by an element outside _eid.
+          LOG_TRACE("Removing child: " << *it);
           toErase.erase(it++);
           erased = true;
           foundOne = true;
           break;
         }
+        else
+        {
+          LOG_TRACE("Not removing child: " << *it);
+        }
       }
 
       // if we didn't erase the element then move the iterator forward
@@ -127,11 +134,13 @@ void RecursiveElementRemover::_remove(const std::shared_ptr<OsmMap>& map, Elemen
   // if this element isn't being removed
   if (removeSet.find(eid) == removeSet.end() || map->containsElement(eid) == false)
   {
+    LOG_TRACE("Not removing " << eid);
+    LOG_VART(removeSet);
+    LOG_VART(map->containsElement(eid));
     return;
   }
 
   LOG_TRACE("Removing: " << eid << "...");
-
   if (eid.getType() == ElementType::Relation)
   {
     const RelationPtr& r = map->getRelation(eid.getId());
@@ -145,6 +154,7 @@ void RecursiveElementRemover::_remove(const std::shared_ptr<OsmMap>& map, Elemen
     }
 
     RemoveRelationByEid::removeRelation(map, eid.getId());
+    LOG_VART(map->getRelation(eid.getId()));
     _numAffected++;
   }
   else if (eid.getType() == ElementType::Way)
@@ -152,6 +162,7 @@ void RecursiveElementRemover::_remove(const std::shared_ptr<OsmMap>& map, Elemen
     const WayPtr& w = map->getWay(eid.getId());
 
     std::vector<long> nodes = w->getNodeIds();
+    LOG_VART(nodes);
     w->clear();
     for (size_t i = 0; i < nodes.size(); i++)
     {
@@ -159,11 +170,14 @@ void RecursiveElementRemover::_remove(const std::shared_ptr<OsmMap>& map, Elemen
     }
 
     RemoveWayByEid::removeWay(map, w->getId());
+    //RemoveWayByEid::removeWayFully(map, w->getId());
+    LOG_VART(map->getWay(w->getId()));
     _numAffected++;
   }
   else if (eid.getType() == ElementType::Node)
   {
     RemoveNodeByEid::removeNodeNoCheck(map, eid.getId());
+    LOG_VART(map->getNode(eid.getId()));
     _numAffected++;
   }
   else
Clone this wiki locally