Skip to content

v0.2.54..v0.2.55 changeset OsmSchema.cpp

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/schema/OsmSchema.cpp b/hoot-core/src/main/cpp/hoot/core/schema/OsmSchema.cpp
index 09544ca..3e36c7e 100644
--- a/hoot-core/src/main/cpp/hoot/core/schema/OsmSchema.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/schema/OsmSchema.cpp
@@ -41,20 +41,20 @@
 #endif
 
 // Hoot
+#include <hoot/core/conflate/address/AddressParser.h>
+#include <hoot/core/elements/Node.h>
 #include <hoot/core/elements/Relation.h>
+#include <hoot/core/elements/Tags.h>
 #include <hoot/core/elements/Way.h>
-#include <hoot/core/elements/Node.h>
 #include <hoot/core/schema/OsmSchema.h>
+#include <hoot/core/schema/OsmSchemaLoader.h>
 #include <hoot/core/schema/OsmSchemaLoaderFactory.h>
+#include <hoot/core/util/ConfigOptions.h>
 #include <hoot/core/util/ConfPath.h>
+#include <hoot/core/util/FileUtils.h>
 #include <hoot/core/util/HootException.h>
 #include <hoot/core/util/Log.h>
-#include <hoot/core/elements/Tags.h>
-#include <hoot/core/schema/OsmSchemaLoader.h>
-#include <hoot/core/util/ConfigOptions.h>
-#include <hoot/core/util/FileUtils.h>
 #include <hoot/core/util/StringUtils.h>
-#include <hoot/core/conflate/address/AddressParser.h>
 
 // Qt
 #include <QDomDocument>
@@ -1591,7 +1591,7 @@ OsmSchema& OsmSchema::getInstance()
       const QString errorMsg = "Unable to write schema graphviz file to " + graphvizPath;
       try
       {
-        if (QDir().mkpath("tmp"))
+        if (FileUtils::makeDir("tmp"))
         {
           FileUtils::writeFully(graphvizPath, _theInstance->toGraphvizString());
           LOG_TRACE("Wrote schema graph viz file to: " << graphvizPath);
@@ -1875,8 +1875,8 @@ bool OsmSchema::explicitTypeMismatch(const Tags& tags1, const Tags& tags2,
 {
   // TODO: We may need to take category into account here as well.
 
-  LOG_VARD(tags1);
-  LOG_VARD(tags2);
+  LOG_VART(tags1);
+  LOG_VART(tags2);
 
   bool featuresHaveExplicitTypeMismatch = false;
 
@@ -1896,13 +1896,13 @@ bool OsmSchema::explicitTypeMismatch(const Tags& tags1, const Tags& tags2,
           if (typeScore < minTypeScore)
           {
             featuresHaveExplicitTypeMismatch = true;
-            LOG_DEBUG(
+            LOG_TRACE(
               "explicit type mismatch: " << getFirstType(tags1, false) << " and " <<
               getFirstType(tags2, false));
           }
           else
           {
-            LOG_DEBUG(
+            LOG_TRACE(
               "explicit type match: " << getFirstType(tags1, false) << " and " <<
               getFirstType(tags2, false));
           }
@@ -1911,7 +1911,7 @@ bool OsmSchema::explicitTypeMismatch(const Tags& tags1, const Tags& tags2,
     }
   }
 
-  LOG_VARD(featuresHaveExplicitTypeMismatch);
+  LOG_VART(featuresHaveExplicitTypeMismatch);
   return featuresHaveExplicitTypeMismatch;
 }
 
@@ -1929,6 +1929,25 @@ bool OsmSchema::hasType(const Tags& tags)
   return false;
 }
 
+QString OsmSchema::mostSpecificType(const Tags& tags)
+{
+  QString mostSpecificType;
+  for (Tags::const_iterator tagsItr = tags.begin(); tagsItr != tags.end(); ++tagsItr)
+  {
+    const QString key = tagsItr.key();
+    const QString val = tagsItr.value();
+    const QString kvp = toKvp(key, val);
+    LOG_VART(kvp);
+    LOG_VART(isTypeKey(tagsItr.key()));
+
+    if (isTypeKey(key) && (mostSpecificType.isEmpty() || !isAncestor(kvp, mostSpecificType)))
+    {
+      mostSpecificType = kvp;
+    }
+  }
+  return mostSpecificType;
+}
+
 bool OsmSchema::hasMoreThanOneType(const Tags& tags)
 {
   int count = 0;
Clone this wiki locally