Skip to content

v0.2.52..v0.2.53 changeset AreaCriterion.cpp

Garret Voltz edited this page Feb 12, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/criterion/AreaCriterion.cpp b/hoot-core/src/main/cpp/hoot/core/criterion/AreaCriterion.cpp
index a58d4ef..6e82ae8 100644
--- a/hoot-core/src/main/cpp/hoot/core/criterion/AreaCriterion.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/criterion/AreaCriterion.cpp
@@ -22,7 +22,7 @@
  * This will properly maintain the copyright information. DigitalGlobe
  * copyrights will be updated automatically.
  *
- * @copyright Copyright (C) 2016, 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2016, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
  */
 #include "AreaCriterion.h"
 
@@ -41,6 +41,11 @@ AreaCriterion::AreaCriterion()
 {
 }
 
+AreaCriterion::AreaCriterion(ConstOsmMapPtr map) :
+_map(map)
+{
+}
+
 bool AreaCriterion::isSatisfied(const ConstElementPtr& e) const
 {
   return isSatisfied(e->getTags(), e->getElementType());
@@ -57,19 +62,20 @@ bool AreaCriterion::isSatisfied(const Tags& tags, const ElementType& elementType
     return false;
   }
 
-  LOG_VART( BuildingCriterion().isSatisfied(tags, elementType));
+  LOG_VART(BuildingCriterion(_map).isSatisfied(tags, elementType));
   LOG_VART(tags.isTrue(MetadataTags::BuildingPart()));
   LOG_VART(tags.isTrue("area"));
 
-  result |= BuildingCriterion().isSatisfied(tags, elementType);
+  result |= BuildingCriterion(_map).isSatisfied(tags, elementType);
   result |= tags.isTrue(MetadataTags::BuildingPart());
   result |= tags.isTrue("area");
 
-  // if at least one of the tags is marked as an area, but not a linestring tag then we consider
+  // If at least one of the tags is marked as an area, but not a linestring tag then we consider
   // this to be an area feature.
   for (Tags::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
   {
-    const SchemaVertex& tv = OsmSchema::getInstance().getTagVertex(it.key() + "=" + it.value());
+    const QString kvp = OsmSchema::getInstance().toKvp(it.key(), it.value());
+    const SchemaVertex& tv = OsmSchema::getInstance().getTagVertex(kvp);
     LOG_VART(tv.toString());
 
     uint16_t g = tv.geometries;
@@ -80,12 +86,15 @@ bool AreaCriterion::isSatisfied(const Tags& tags, const ElementType& elementType
 
     if (g & OsmGeometries::Area && !(g & (OsmGeometries::LineString | OsmGeometries::ClosedWay)))
     {
-      LOG_TRACE("Area: " << it.key() << "=" << it.value());
+      LOG_TRACE(
+        "Found area geometry (non-linestring or closed way) from kvp: " << kvp <<
+        "; crit satisfied.");
       result = true;
       break;
     }
   }
 
+  LOG_VART(result);
   return result;
 }
 
Clone this wiki locally