[geos-commits] [SCM] GEOS branch 3.9 updated. 4e0008c232831d95c909982b2981e3556111760b

git at osgeo.org git at osgeo.org
Fri Sep 17 14:50:16 PDT 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, 3.9 has been updated
       via  4e0008c232831d95c909982b2981e3556111760b (commit)
      from  2d9cfd05594fdacc53a818f353f90c55b7b3ab9a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4e0008c232831d95c909982b2981e3556111760b
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Fri Sep 17 14:50:10 2021 -0700

    Fix DiscreteFrechetDistance initialization problem

diff --git a/NEWS b/NEWS
index 1e29d50..8a066d0 100644
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,7 @@ Changes in 3.9.2
   - Declare parameterless functions in geos_c.h as func(void) (Paul Ramsey)
   - Performance improvement in SegmentNodeList (Even Rouault)
   - Catch memory leaks on createPolygon failure (#1111, Paul Ramsey)
-
+  - Fix DiscreteFrechetDistance to use initial points of input lines (#1128, Martin Davis)
 
 Changes in 3.9.1
 2021-02-10
diff --git a/src/algorithm/distance/DiscreteFrechetDistance.cpp b/src/algorithm/distance/DiscreteFrechetDistance.cpp
index b41225f..4e5cc66 100644
--- a/src/algorithm/distance/DiscreteFrechetDistance.cpp
+++ b/src/algorithm/distance/DiscreteFrechetDistance.cpp
@@ -91,7 +91,7 @@ DiscreteFrechetDistance::getFrecheDistance(std::vector< std::vector<PointPairDis
     }
     p_ptDist.initialize(getSegementAt(p, i), getSegementAt(q, j));
     if(i == 0 && j == 0) {
-        ca[i][j] = ptDist;
+        ca[i][j] = p_ptDist;
     }
     else if(i > 0 && j == 0) {
         PointPairDistance nextDist = getFrecheDistance(ca, i - 1, 0, p, q);
diff --git a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
index 203657d..effe5a8 100644
--- a/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
+++ b/tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp
@@ -132,4 +132,13 @@ void object::test<4>
     runTest("LINESTRING (0 0, 100 0)", "LINESTRING (0 0, 50 50, 100 0)", 0.5, 50.0);
 }
 
+// 5 - test Line Segments revealing distance intialization bug
+template<>
+template<>
+void object::test<5>
+()
+{
+    runTest("LINESTRING (1 1, 2 2)", "LINESTRING (1 4, 2 3)", 3);
+}
+
 } // namespace tut

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                                          | 2 +-
 src/algorithm/distance/DiscreteFrechetDistance.cpp            | 2 +-
 tests/unit/algorithm/distance/DiscreteFrechetDistanceTest.cpp | 9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list