Skip to content

v0.2.53..v0.2.54 changeset MaximalSublineStringMatcher.cpp

Garret Voltz edited this page Mar 31, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/algorithms/subline-matching/MaximalSublineStringMatcher.cpp b/hoot-core/src/main/cpp/hoot/core/algorithms/subline-matching/MaximalSublineStringMatcher.cpp
index c0c856c..f65404d 100644
--- a/hoot-core/src/main/cpp/hoot/core/algorithms/subline-matching/MaximalSublineStringMatcher.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/algorithms/subline-matching/MaximalSublineStringMatcher.cpp
@@ -22,7 +22,7 @@
  * This will properly maintain the copyright information. DigitalGlobe
  * copyrights will be updated automatically.
  *
- * @copyright Copyright (C) 2015, 2017, 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2015, 2017, 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
  */
 #include "MaximalSublineStringMatcher.h"
 
@@ -157,12 +157,12 @@ WaySublineMatchString MaximalSublineStringMatcher::findMatch(const ConstOsmMapPt
 
   if ((ways1.size() > 4 && ways2.size() > 4) || (ways1.size() + ways2.size() > 7))
   {
-    throw NeedsReviewException("Elements contain too many ways and the computational complexity "
-                               "is unreasonable.");
+    throw NeedsReviewException(
+      "Elements contain too many ways and the computational complexity is unreasonable.");
   }
 
   // Try with all combinations of forward and reversed ways. This is very expensive for
-  // multilinestrings with lots of ways in them. Though those shouldn't be common.
+  // multilinestrings with lots of ways in them. However, those shouldn't be common.
   vector<bool> reversed1(ways1.size(), false), reversed2(ways2.size(), false);
   LOG_TRACE("Finding best match...");
   ScoredMatch scoredResult =
@@ -180,8 +180,9 @@ WaySublineMatchString MaximalSublineStringMatcher::findMatch(const ConstOsmMapPt
   }
   catch (const OverlappingMatchesException& /*e*/)
   {
-    throw NeedsReviewException("Internal Error: Multiple overlapping way matches were found within "
-      "one set of ways.  Please report this to https://github.com/ngageoint/hootenanny.");
+    throw NeedsReviewException(
+      "Internal Error: Multiple overlapping way matches were found within one set of ways.  "
+      "Please report this to https://github.com/ngageoint/hootenanny.");
   }
 }
 
@@ -350,27 +351,36 @@ void MaximalSublineStringMatcher::_validateElement(const ConstOsmMapPtr& map, El
 
   ConstElementPtr e = map->getElement(eid);
 
-  if (e->getElementType() == ElementType::Relation)
-  {
-    ConstRelationPtr r = std::dynamic_pointer_cast<const Relation>(e);
-
-    if (MultiLineStringCriterion().isSatisfied(r) == false)
-    {
-      throw NeedsReviewException("Internal Error: When matching sublines expected a multilinestring "
-        "relation not a " + r->getType() + ".  A non-multilinestring should never be found here.  "
-        "Please report this to  https://github.com/ngageoint/hootenanny.");
-    }
+//  if (e->getElementType() == ElementType::Relation)
+//  {
+//    ConstRelationPtr r = std::dynamic_pointer_cast<const Relation>(e);
+
+//    // Don't know the complete history behind this, but while working on #3815 came across an
+//    // example of a type=route relation. After removing this restriction, hoot seems to be able
+//    // to conflate it correctly. Therefore, disabling this. Leaving it commented out in case at
+//    // some point in the near future we come across data in a relation with type other than
+//    // multilinestring that hoot can't conflate.
+
+//    if (MultiLineStringCriterion().isSatisfied(r) == false)
+//    {
+//      throw NeedsReviewException("Internal Error: When matching sublines expected a multilinestring "
+//        "relation not a " + r->getType() + ".  A non-multilinestring should never be found here.  "
+//        "Please report this to  https://github.com/ngageoint/hootenanny.");
+//    }
+
+//    // See relation type=route message above.
+
+//    const vector<RelationData::Entry>& entries = r->getMembers();
+//    for (size_t i = 0; i < entries.size(); i++)
+//    {
+//      if (entries[i].getElementId().getType() != ElementType::Way)
+//      {
+//        throw NeedsReviewException("MultiLineString relations can only contain ways when matching "
+//                                   "sublines.");
+//      }
+//    }
+//  }
 
-    const vector<RelationData::Entry>& entries = r->getMembers();
-    for (size_t i = 0; i < entries.size(); i++)
-    {
-      if (entries[i].getElementId().getType() != ElementType::Way)
-      {
-        throw NeedsReviewException("MultiLineString relations can only contain ways when matching "
-                                   "sublines.");
-      }
-    }
-  }
   if (e->getElementType() == ElementType::Way)
   {
     ConstWayPtr w = std::dynamic_pointer_cast<const Way>(e);
Clone this wiki locally