Skip to content

v0.2.54..v0.2.55 changeset Area.js

Garret Voltz edited this page Aug 14, 2020 · 1 revision
diff --git a/rules/Area.js b/rules/Area.js
index 9c39112..cc0e8a1 100644
--- a/rules/Area.js
+++ b/rules/Area.js
@@ -6,18 +6,23 @@
 
 exports.candidateDistanceSigma = 1.0; // 1.0 * (CE95 + Worst CE95);
 exports.description = "Matches areas";
+
 // This matcher only sets match/miss/review values to 1.0, therefore the score thresholds aren't used. 
 // If that ever changes, then the generic score threshold configuration options used below should 
 // be replaced with custom score threshold configuration options.
 exports.matchThreshold = parseFloat(hoot.get("conflate.match.threshold.default"));
 exports.missThreshold = parseFloat(hoot.get("conflate.miss.threshold.default"));
 exports.reviewThreshold = parseFloat(hoot.get("conflate.review.threshold.default"));
+
 exports.searchRadius = parseFloat(hoot.get("search.radius.area"));
 exports.tagThreshold = parseFloat(hoot.get("area.tag.threshold"));
 exports.experimental = true;
 exports.baseFeatureType = "Area";
 exports.writeMatchedBy = hoot.get("writer.include.matched.by.tag");
 exports.geometryType = "polygon";
+
+// This is needed for disabling superfluous conflate ops. In the future, it may also
+// be used to replace exports.isMatchCandidate (see #3047).
 exports.matchCandidateCriterion = "hoot::AreaCriterion";
 
 var sublineMatcher = new hoot.MaximalSublineStringMatcher();
@@ -38,9 +43,6 @@ nodes and polygons or a school polygon which encloses school buildings on the ca
  * Returns true if e is a candidate for a match. Implementing this method is
  * optional, but may dramatically increase speed if you can cull some features
  * early on. E.g. no need to check nodes for a polygon to polygon match.
- *
- * exports.matchCandidateCriterion takes precedence over this function and must
- * be commented out before using it.
  */
 exports.isMatchCandidate = function(map, e)
 {
@@ -89,12 +91,12 @@ exports.matchScore = function(map, e1, e2)
     hoot.trace("e2 note: " + e2.getTags().get("note"));
   }
 
-  // The geometry matching model was derived against only one dataset using Weka, so likely needs 
-  // more refinement. The tag matching was derived manually after the fact outside of Weka and is 
-  // the same that is used with Generic Conflation. The original geometry matching model from Weka 
-  // has been updated to account for the fact that buffered overlap, edge distance, and overlap 
-  // are processing intensive (roughly in order from most to least). You can see the original 
-  // geometry matching model by looking at the revision history for this file.
+  // The geometry matching model was derived against only one training dataset using Weka and 
+  // another without using Weka (review generation logic portion), so likely still needs more refinement. 
+  // The tag matching was derived manually after the fact outside of Weka and is the same that is used 
+  // with Generic Conflation. The original geometry matching model from Weka has been updated to account 
+  // for the fact that buffered overlap, edge distance, and overlap are processing intensive (roughly 
+  // in order from most to least).
 
   // TODO: Should we do anything with names?
 
@@ -108,19 +110,23 @@ exports.matchScore = function(map, e1, e2)
   }
   
   var angleHist = angleHistogramExtractor.extract(map, e1, e2);
-  var edgeDist;
-  var bufferedOverlap;
-  var smallerOverlap;
-  var overlap;
+  hoot.trace("angleHist: " + angleHist);
+  var edgeDist = -1;
+  var bufferedOverlap = -1;
+  var smallerOverlap = -1;
+  var overlap = -1;
 
   if (angleHist >= 0.98 || angleHist < 0.4)
   {
     edgeDist = edgeDistanceExtractor.extract(map, e1, e2);
+    hoot.trace("edgeDist: " + edgeDist);
     if (edgeDist < 0.97)
     {
       bufferedOverlap = bufferedOverlapExtractor.extract(map, e1, e2);
+      hoot.trace("bufferedOverlap: " + bufferedOverlap);
       if (bufferedOverlap >= 0.57)
       {
+        hoot.trace("match");
         result = { match: 1.0, miss: 0.0, review: 0.0 };
         return result;
       }
@@ -129,14 +135,18 @@ exports.matchScore = function(map, e1, e2)
   else if (angleHist >= 0.4)
   {
     smallerOverlap = smallerOverlapExtractor.extract(map, e1, e2);
+    hoot.trace("smallerOverlap: " + smallerOverlap);
     if (smallerOverlap < 0.89)
     {
       edgeDist = edgeDistanceExtractor.extract(map, e1, e2);
+      hoot.trace("edgeDist: " + edgeDist);
       if (edgeDist < 0.97)
       {
         bufferedOverlap = bufferedOverlapExtractor.extract(map, e1, e2);
+        hoot.trace("bufferedOverlap: " + bufferedOverlap);
         if (bufferedOverlap >= 0.57)
         {
+          hoot.trace("match");
           result = { match: 1.0, miss: 0.0, review: 0.0 };
           return result;
         }
@@ -145,14 +155,18 @@ exports.matchScore = function(map, e1, e2)
   }
 
   overlap = overlapExtractor.extract(map, e1, e2);
+  hoot.trace("overlap: " + overlap);
   if (overlap >= 0.18)
   {
     edgeDist = edgeDistanceExtractor.extract(map, e1, e2);
+    hoot.trace("edgeDist: " + edgeDist);
     if (edgeDist >= 0.99)
     {
       bufferedOverlap = bufferedOverlapExtractor.extract(map, e1, e2);
+      hoot.trace("bufferedOverlap: " + bufferedOverlap);
       if (bufferedOverlap < 0.57)
       {
+        hoot.trace("match");
         result = { match: 1.0, miss: 0.0, review: 0.0 };
         return result;
       }
@@ -160,16 +174,40 @@ exports.matchScore = function(map, e1, e2)
   }
 
   edgeDist = edgeDistanceExtractor.extract(map, e1, e2);
+  hoot.trace("edgeDist: " + edgeDist);
   if (edgeDist >= 0.97)
   {
     bufferedOverlap = bufferedOverlapExtractor.extract(map, e1, e2);
+    hoot.trace("bufferedOverlap: " + bufferedOverlap);
     if (bufferedOverlap >= 0.57)
     {
+      hoot.trace("match");
       result = { match: 1.0, miss: 0.0, review: 0.0 };
       return result;
     }
   }
 
+  // Here, we're attempting to handle the many to one scenario for diff conflate and will mark 
+  // this as a review which will cause these features to drop out of the diff in the default 
+  // config. Keeping the type matching strict for this until there is a reason to do otherwie. 
+  // The original test scenario for this involved only landuse=residential.
+  hoot.trace("mostSpecificType(e1): " + mostSpecificType(e1));
+  hoot.trace("mostSpecificType(e2): " + mostSpecificType(e2));
+  if (mostSpecificType(e1) == mostSpecificType(e2))
+  {
+    if (smallerOverlap == -1) // don't calc it if it already has been
+    {
+      smallerOverlap = smallerOverlapExtractor.extract(map, e1, e2);
+      hoot.trace("smallerOverlap: " + smallerOverlap);
+    }
+    if (smallerOverlap > 0.835)
+    {
+      hoot.trace("review");
+      result = { match: 0.0, miss: 0.0, review: 1.0 };
+      return result;
+    }
+  }
+
   return result;
 };
 
Clone this wiki locally