Skip to content

v0.2.52..v0.2.53 changeset BuildingMatchCreator.cpp

Garret Voltz edited this page Feb 12, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMatchCreator.cpp b/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMatchCreator.cpp
index 23f6ef6..565b333 100644
--- a/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMatchCreator.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/conflate/polygon/BuildingMatchCreator.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 "BuildingMatchCreator.h"
 
@@ -39,7 +39,7 @@
 #include <hoot/core/util/ConfPath.h>
 #include <hoot/core/util/Factory.h>
 #include <hoot/core/util/Settings.h>
-#include <hoot/core/visitors/IndexElementsVisitor.h>
+#include <hoot/core/visitors/SpatialIndexer.h>
 #include <hoot/core/util/StringUtils.h>
 #include <hoot/core/util/CollectionUtils.h>
 #include <hoot/core/algorithms/extractors/OverlapExtractor.h>
@@ -104,6 +104,7 @@ public:
     _numElementsVisited = 0;
     _numMatchCandidatesVisited = 0;
     _taskStatusUpdateInterval = ConfigOptions().getTaskStatusUpdateInterval();
+    _searchRadius = ConfigOptions().getSearchRadiusBuilding();
   }
 
   ~BuildingMatchVisitor()
@@ -124,7 +125,7 @@ public:
 
     // find other nearby candidates
     std::set<ElementId> neighbors =
-      IndexElementsVisitor::findNeighbors(*env, getIndex(), _indexToEid, getMap());
+      SpatialIndexer::findNeighbors(*env, getIndex(), _indexToEid, getMap());
 
     ElementId from(e->getElementType(), e->getId());
 
@@ -190,8 +191,17 @@ public:
 
   Meters getSearchRadius(const std::shared_ptr<const Element>& e) const
   {
-    LOG_VART(e->getCircularError());
-    return e->getCircularError();
+    Meters searchRadius;
+    if (_searchRadius >= 0)
+    {
+      searchRadius = _searchRadius;
+    }
+    else
+    {
+      searchRadius = e->getCircularError();
+    }
+    LOG_VART(searchRadius);
+    return searchRadius;
   }
 
   virtual void visit(const ConstElementPtr& e)
@@ -232,6 +242,8 @@ public:
   {
     if (!_index)
     {
+      LOG_INFO("Creating building feature index...");
+
       // No tuning was done, I just copied these settings from OsmMapIndex.
       // 10 children - 368 - see #3054
       std::shared_ptr<MemoryPageStore> mps(new MemoryPageStore(728));
@@ -243,7 +255,7 @@ public:
       std::shared_ptr<ArbitraryCriterion> pCrit(new ArbitraryCriterion(f));
 
       // Instantiate our visitor
-      IndexElementsVisitor v(_index,
+      SpatialIndexer v(_index,
                              _indexToEid,
                              pCrit,
                              std::bind(
@@ -274,6 +286,7 @@ private:
   int _neighborCountSum;
   int _elementsEvaluated;
   size_t _maxGroupSize;
+  Meters _searchRadius;
   /// reject any manipulation with a miss score >= _rejectScore
   double _rejectScore;
 
@@ -411,13 +424,32 @@ void BuildingMatchCreator::createMatches(const ConstOsmMapPtr& map,
 {
   QElapsedTimer timer;
   timer.start();
-  LOG_INFO("Looking for matches with: " << className() << "...");
+
+  QString searchRadiusStr;
+  const double searchRadius = ConfigOptions().getSearchRadiusBuilding();
+  if (searchRadius < 0)
+  {
+    searchRadiusStr = "within a feature dependent search radius";
+  }
+  else
+  {
+    searchRadiusStr =
+      "within a search radius of " + QString::number(searchRadius, 'g', 2) + " meters";
+  }
+  LOG_STATUS("Looking for matches with: " << className() << " " << searchRadiusStr << "...");
   LOG_VARD(*threshold);
+  const int matchesSizeBefore = matches.size();
+
   BuildingMatchVisitor v(map, matches, _getRf(), threshold, _filter, Status::Unknown1);
-  map->visitRo(v);
-  LOG_INFO(
+  map->visitWaysRo(v);
+  map->visitRelationsRo(v);
+  const int matchesSizeAfter = matches.size();
+
+  LOG_STATUS(
     "Found " << StringUtils::formatLargeNumber(v.getNumMatchCandidatesFound()) <<
-    " building match candidates in: " << StringUtils::millisecondsToDhms(timer.elapsed()) << ".");
+    " building match candidates and " <<
+    StringUtils::formatLargeNumber(matchesSizeAfter - matchesSizeBefore) <<
+    " total matches in: " << StringUtils::millisecondsToDhms(timer.elapsed()) << ".");
 }
 
 std::vector<CreatorDescription> BuildingMatchCreator::getAllCreators() const
Clone this wiki locally