Skip to content

v0.2.54..v0.2.55 changeset ElementConverter.cpp

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/elements/ElementConverter.cpp b/hoot-core/src/main/cpp/hoot/core/elements/ElementConverter.cpp
index 8dce0d3..8663153 100644
--- a/hoot-core/src/main/cpp/hoot/core/elements/ElementConverter.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/elements/ElementConverter.cpp
@@ -44,7 +44,7 @@
 #include <hoot/core/criterion/AreaCriterion.h>
 #include <hoot/core/criterion/StatsAreaCriterion.h>
 #include <hoot/core/criterion/LinearCriterion.h>
-#include <hoot/core/criterion/CollectionCriterion.h>
+#include <hoot/core/criterion/CollectionRelationCriterion.h>
 #include <hoot/core/elements/ElementConverter.h>
 #include <hoot/core/elements/OsmMap.h>
 #include <hoot/core/schema/OsmSchema.h>
@@ -85,7 +85,7 @@ Meters ElementConverter::calculateLength(const ConstElementPtr &e) const
   }
 
   // if the element is not a point and is not an area.
-  // NOTE: Originally I was using isLinear. This was a bit too strict in that it wants evidence of
+  // NOTE: Originally, I was using isLinear. This was a bit too strict in that it wants evidence of
   // being linear before the length is calculated. Conversely, this wants evidence that is is not
   // linear before it will assume it doesn't have a length.
   if (e->getElementType() != ElementType::Node && AreaCriterion().isSatisfied(e) == false)
@@ -372,13 +372,11 @@ geos::geom::GeometryTypeId ElementConverter::getGeometryType(
       }
       else
       {
-        if (r->isMultiPolygon() || AreaCriterion().isSatisfied(r))
+        if (r->isMultiPolygon() ||
+            // relation type=site was added to fix BadMatchPairTest crashing in Polygon.js.
+            r->getType() == MetadataTags::RelationSite() ||
+            AreaCriterion().isSatisfied(r))
           return GEOS_MULTIPOLYGON;
-        else if (linearCrit.isSatisfied(r))
-          return GEOS_MULTILINESTRING;
-        // an empty geometry, pass back a collection
-        else if (r->getMembers().size() == 0 || CollectionCriterion().isSatisfied(r))
-          return GEOS_GEOMETRYCOLLECTION;
         // Restriction relations are empty geometry
         else if (r->isRestriction())
           return GEOS_GEOMETRYCOLLECTION;
@@ -389,6 +387,12 @@ geos::geom::GeometryTypeId ElementConverter::getGeometryType(
         // MultiPoint comes from GeoJSON
         else if (r->getType() == MetadataTags::RelationMultiPoint())
           return GEOS_MULTIPOINT;
+        //  Restrictions satisfy the linear criterion so test it after restrictions
+        else if (linearCrit.isSatisfied(r))
+          return GEOS_MULTILINESTRING;
+        // an empty geometry, pass back a collection
+        else if (r->getMembers().size() == 0 || CollectionRelationCriterion().isSatisfied(r))
+          return GEOS_GEOMETRYCOLLECTION;
       }
 
       // We are going to throw an error so we save the type of relation
Clone this wiki locally