Skip to content

v0.2.54..v0.2.55 changeset WayJoinerAdvanced.cpp

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/algorithms/WayJoinerAdvanced.cpp b/hoot-core/src/main/cpp/hoot/core/algorithms/WayJoinerAdvanced.cpp
index d9ab30b..5ddef1e 100644
--- a/hoot-core/src/main/cpp/hoot/core/algorithms/WayJoinerAdvanced.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/algorithms/WayJoinerAdvanced.cpp
@@ -34,7 +34,8 @@
 #include <hoot/core/criterion/HighwayCriterion.h>
 #include <hoot/core/criterion/OneWayCriterion.h>
 #include <hoot/core/elements/NodeToWayMap.h>
-#include <hoot/core/elements/OsmUtils.h>
+#include <hoot/core/conflate/highway/HighwayUtils.h>
+#include <hoot/core/criterion/CriterionUtils.h>
 #include <hoot/core/index/OsmMapIndex.h>
 #include <hoot/core/io/OsmMapWriterFactory.h>
 #include <hoot/core/ops/RecursiveElementRemover.h>
@@ -43,6 +44,7 @@
 #include <hoot/core/schema/TagMergerFactory.h>
 #include <hoot/core/util/Factory.h>
 #include <hoot/core/util/ConfigOptions.h>
+#include <hoot/core/util/StringUtils.h>
 
 #include <unordered_set>
 #include <vector>
@@ -84,6 +86,7 @@ void WayJoinerAdvanced::_joinParentChild()
   LOG_INFO("\tJoining parent ways to children...");
 
   WayMap ways = _map->getWays();
+  _totalWays = ways.size();
   vector<long> ids;
   //  Find all ways that have a split parent id
   for (WayMap::const_iterator it = ways.begin(); it != ways.end(); ++it)
@@ -125,7 +128,7 @@ void WayJoinerAdvanced::_joinParentChild()
 
     // don't try to join if there are explicitly conflicting names; fix for #2888
     Tags wayTags = way->getTags();
-    // TODO: use OsmUtils::nameConflictExists here instead
+    // TODO: use TagUtils::nameConflictExists here instead
     const bool strictNameMatch = ConfigOptions().getWayJoinerAdvancedStrictNameMatch();
     if (parent && parentTags.hasName() && wayTags.hasName() &&
         !Tags::haveMatchingName(parentTags, wayTags, strictNameMatch))
@@ -142,6 +145,13 @@ void WayJoinerAdvanced::_joinParentChild()
       _callingMethod = "_joinParentChild";
       _joinWays(parent, way);
     }
+
+    if (_numProcessed % (_taskStatusUpdateInterval / 10) == 0)
+    {
+      PROGRESS_INFO(
+        "\tRejoined " << StringUtils::formatLargeNumber(_numJoined) << " pairs of ways / " <<
+        StringUtils::formatLargeNumber(_totalWays) << " total ways.");
+    }
   }
 }
 
@@ -245,7 +255,7 @@ void WayJoinerAdvanced::_joinAtNode()
             // don't try to join if there are explicitly conflicting names; fix for #2888
             const bool parentHasName = pTags.hasName();
             const bool childHasName = cTags.hasName();
-            // TODO: use OsmUtils::nameConflictExists here instead
+            // TODO: use TagUtils::nameConflictExists here instead
             const bool strictNameMatch = ConfigOptions().getWayJoinerAdvancedStrictNameMatch();
             if ((!parentHasName && childHasName) || (!childHasName && parentHasName) ||
                 Tags::haveMatchingName(pTags, cTags, strictNameMatch))
@@ -265,6 +275,13 @@ void WayJoinerAdvanced::_joinAtNode()
           }
         }
       }
+
+      if (_numProcessed % (_taskStatusUpdateInterval / 10) == 0)
+      {
+        PROGRESS_INFO(
+          "\tRejoined " << StringUtils::formatLargeNumber(_numJoined) << " pairs of ways / " <<
+          StringUtils::formatLargeNumber(_totalWays) << " total ways.");
+      }
     }
     numIterations++;
   }
@@ -398,7 +415,7 @@ void WayJoinerAdvanced::_rejoinSiblings(deque<long>& way_ids)
       }
       const Tags parentTags = parent->getTags();
       const bool parentHasName = parentTags.hasName();
-      // TODO: use OsmUtils::nameConflictExists here instead
+      // TODO: use TagUtils::nameConflictExists here instead
       const bool strictNameMatch = ConfigOptions().getWayJoinerAdvancedStrictNameMatch();
       if ((!parentHasName && childHasName) || (!childHasName && parentHasName) ||
           Tags::haveMatchingName(parentTags, childTags, strictNameMatch))
@@ -423,6 +440,8 @@ void WayJoinerAdvanced::_rejoinSiblings(deque<long>& way_ids)
 
 bool WayJoinerAdvanced::_joinWays(const WayPtr& parent, const WayPtr& child)
 {
+  _numProcessed++;
+
   if (!parent || !child)
     return false;
 
@@ -511,7 +530,8 @@ bool WayJoinerAdvanced::_joinWays(const WayPtr& parent, const WayPtr& child)
   std::vector<ConstElementPtr> elements;
   elements.push_back(wayWithTagsToKeep);
   elements.push_back(wayWithTagsToLose);
-  const bool onlyOneIsABridge = OsmUtils::isSatisfied<BridgeCriterion>(elements, 1, true);
+  const bool onlyOneIsABridge =
+    CriterionUtils::containsSatisfyingElements<BridgeCriterion>(elements, 1, true);
   if (ConfigOptions().getAttributeConflationAllowRefGeometryChangesForBridges() &&
       onlyOneIsABridge)
   {
@@ -522,7 +542,7 @@ bool WayJoinerAdvanced::_joinWays(const WayPtr& parent, const WayPtr& child)
   }
 
   // don't try to join streets with conflicting one way info
-  if (OsmUtils::oneWayConflictExists(wayWithTagsToKeep, wayWithTagsToLose))
+  if (HighwayUtils::oneWayConflictExists(wayWithTagsToKeep, wayWithTagsToLose))
   {
     LOG_TRACE(
       "Conflicting one way street tags between " << wayWithIdToKeep->getElementId() << " and " <<
@@ -533,7 +553,7 @@ bool WayJoinerAdvanced::_joinWays(const WayPtr& parent, const WayPtr& child)
   // If two roads disagree in highway type and aren't generic, don't join back up.
   HighwayCriterion highwayCrit(_map);
   if (highwayCrit.isSatisfied(wayWithTagsToKeep) && highwayCrit.isSatisfied(wayWithTagsToLose) &&
-      OsmUtils::nonGenericHighwayConflictExists(wayWithTagsToKeep, wayWithTagsToLose))
+      HighwayUtils::nonGenericHighwayConflictExists(wayWithTagsToKeep, wayWithTagsToLose))
   {
     LOG_TRACE(
       "Conflicting highway type tags between " << wayWithIdToKeep->getElementId() << " and " <<
@@ -674,6 +694,13 @@ void WayJoinerAdvanced::_joinUnsplitWaysAtNode()
         }
       }
     }
+
+    if (_numProcessed % (_taskStatusUpdateInterval / 10) == 0)
+    {
+      PROGRESS_INFO(
+        "\tRejoined " << StringUtils::formatLargeNumber(_numJoined) << " pairs of ways / " <<
+        StringUtils::formatLargeNumber(_totalWays) << " total ways.");
+    }
   }
   LOG_TRACE(
     "Successfully joined " << successfulJoins << " unsplit ways on " << joinAttempts <<
Clone this wiki locally