Skip to content

v0.2.54..v0.2.55 changeset HighwayMatchCreator.cpp

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/conflate/highway/HighwayMatchCreator.cpp b/hoot-core/src/main/cpp/hoot/core/conflate/highway/HighwayMatchCreator.cpp
index 3556aa0..a47cc18 100644
--- a/hoot-core/src/main/cpp/hoot/core/conflate/highway/HighwayMatchCreator.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/conflate/highway/HighwayMatchCreator.cpp
@@ -47,6 +47,7 @@
 #include <hoot/core/util/NotImplementedException.h>
 #include <hoot/core/schema/TagAncestorDifferencer.h>
 #include <hoot/core/util/StringUtils.h>
+#include <hoot/core/util/MemoryUsageChecker.h>
 
 // Standard
 #include <fstream>
@@ -114,6 +115,7 @@ public:
     _numElementsVisited = 0;
     _numMatchCandidatesVisited = 0;
     _taskStatusUpdateInterval = opts.getTaskStatusUpdateInterval();
+    _memoryCheckUpdateInterval = opts.getMemoryUsageCheckerInterval();
   }
 
   ~HighwayMatchVisitor()
@@ -179,8 +181,8 @@ public:
 
       // Don't want sidewalks matching with roads. Tried very hard to make this work in the schema
       // instead of adding this but could not due to the many interrelations between road types.
-      // There should be a way to do it in the schema, though, and will try again later. Until then,
-      // we may find other minor highway types that will be proven to need this treatment as well.
+      // There should be a way to do it in the schema, however. Until that can be figured out, we
+      // may find other minor highway types that will be proven to need this treatment as well.
       if (Tags::onlyOneContainsKvp(e1->getTags(), e2->getTags(), "footway=sidewalk"))
       {
         // This value still may need some tweaking after testing against additional datasets. Basing
@@ -234,17 +236,24 @@ public:
       if (_numMatchCandidatesVisited % (_taskStatusUpdateInterval * 10) == 0)
       {
         PROGRESS_DEBUG(
-          "Processed " << _numMatchCandidatesVisited << " match candidates / " <<
-          _map->getElementCount() << " total elements.");
+          "Processed " << StringUtils::formatLargeNumber(_numMatchCandidatesVisited) <<
+          " match candidates / " <<
+          StringUtils::formatLargeNumber(_map->getWayCount() + _map->getRelationCount()) <<
+          " elements.");
       }
     }
 
     _numElementsVisited++;
-    if (_numElementsVisited % (_taskStatusUpdateInterval * 10) == 0)
+    if (_numElementsVisited % (_taskStatusUpdateInterval /* 10*/) == 0)
     {
       PROGRESS_INFO(
         "Processed " << StringUtils::formatLargeNumber(_numElementsVisited) << " / " <<
-        StringUtils::formatLargeNumber(_map->getElementCount()) << " elements.");
+        StringUtils::formatLargeNumber(_map->getWayCount() + _map->getRelationCount()) <<
+        " elements.");
+    }
+    if (_numElementsVisited % _memoryCheckUpdateInterval == 0)
+    {
+      MemoryUsageChecker::getInstance().check();
     }
   }
 
@@ -320,6 +329,7 @@ private:
   long _numElementsVisited;
   long _numMatchCandidatesVisited;
   int _taskStatusUpdateInterval;
+  int _memoryCheckUpdateInterval;
 };
 
 HighwayMatchCreator::HighwayMatchCreator()
@@ -342,8 +352,10 @@ HighwayMatchCreator::HighwayMatchCreator()
 
 MatchPtr HighwayMatchCreator::createMatch(const ConstOsmMapPtr& map, ElementId eid1, ElementId eid2)
 {
-  return HighwayMatchVisitor::createMatch(map, _classifier, _sublineMatcher, getMatchThreshold(),
-    _tagAncestorDiff, map->getElement(eid1), map->getElement(eid2));
+  return
+    HighwayMatchVisitor::createMatch(
+      map, _classifier, _sublineMatcher, getMatchThreshold(), _tagAncestorDiff,
+      map->getElement(eid1), map->getElement(eid2));
 }
 
 void HighwayMatchCreator::createMatches(
Clone this wiki locally