[geos-commits] [SCM] GEOS branch master updated. 88f21460756bb1eec852ac70f981581755fe07a0

git at osgeo.org git at osgeo.org
Wed Nov 14 11:06:08 PST 2018


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, master has been updated
       via  88f21460756bb1eec852ac70f981581755fe07a0 (commit)
      from  30c710a1a97b8bac64c275f56480eaf1fbb3ca04 (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 88f21460756bb1eec852ac70f981581755fe07a0
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Nov 14 09:49:13 2018 -0800

    Update Centroid algorithm to match JTS, and accompanying test file

diff --git a/include/geos/algorithm/Centroid.h b/include/geos/algorithm/Centroid.h
index 16b7ae8..9f7d268 100644
--- a/include/geos/algorithm/Centroid.h
+++ b/include/geos/algorithm/Centroid.h
@@ -113,7 +113,7 @@ private:
    */
   void add(const geom::Geometry& geom);
 
-  void setBasePoint(const geom::Coordinate& basePt);
+  void setAreaBasePoint(const geom::Coordinate& basePt);
 
   void add(const geom::Polygon& poly);
 
diff --git a/src/algorithm/Centroid.cpp b/src/algorithm/Centroid.cpp
index 727e98a..c5f31ab 100644
--- a/src/algorithm/Centroid.cpp
+++ b/src/algorithm/Centroid.cpp
@@ -88,10 +88,9 @@ Centroid::add(const Geometry& geom)
 
 /* private */
 void
-Centroid::setBasePoint(const Coordinate& basePt)
+Centroid::setAreaBasePoint(const Coordinate& basePt)
 {
-  if ( ! areaBasePt.get() )
-      areaBasePt.reset( new Coordinate(basePt) );
+  areaBasePt.reset( new Coordinate(basePt) );
 }
 
 /* private */
@@ -110,7 +109,7 @@ Centroid::addShell(const CoordinateSequence& pts)
 {
   size_t len = pts.size();
   if (len > 0)
-    setBasePoint(pts[0]);
+    setAreaBasePoint(pts[0]);
   bool isPositiveArea = ! CGAlgorithms::isCCW(&pts);
   for (size_t i = 0; i < len - 1; ++i) {
     addTriangle(*areaBasePt, pts[i], pts[i+1], isPositiveArea);
diff --git a/tests/xmltester/tests/general/TestCentroid.xml b/tests/xmltester/tests/general/TestCentroid.xml
index 40a6846..068b617 100644
--- a/tests/xmltester/tests/general/TestCentroid.xml
+++ b/tests/xmltester/tests/general/TestCentroid.xml
@@ -26,6 +26,12 @@
 </case>
 
 <case>
+  <desc>mP - repeated points</desc>
+  <a>    MULTIPOINT((10 10), (10 10), (10 10), (18 18))  </a>
+<test><op name="getCentroid" arg1="A" >    POINT(12 12)   </op></test>
+</case>
+
+<case>
   <desc>L - single segment</desc>
   <a>    LINESTRING(10 10, 20 20)  </a>
 <test><op name="getCentroid" arg1="A" >    POINT(15 15)   </op></test>
@@ -236,6 +242,30 @@
 <test><op name="getCentroid" arg1="A" >    POINT (56.52883333335 25.21033333335)  </op></test>
 </case>
 
-
+<case>
+  <desc>A - almost degenerate MultiPolygon</desc>
+  <a>
+    MULTIPOLYGON (((
+     -92.661322 36.58994900000003,
+     -92.66132199999993 36.58994900000005,
+     -92.66132199999993 36.589949000000004,
+     -92.661322 36.589949,
+     -92.661322 36.58994900000003)),
+    ((
+     -92.65560500000008 36.58708800000005,
+     -92.65560499999992 36.58708800000005,
+     -92.65560499998745 36.587087999992576,
+     -92.655605 36.587088,
+     -92.65560500000008 36.58708800000005
+    )),
+    ((
+     -92.65512450000065 36.586800000000466,
+      -92.65512449999994 36.58680000000004,
+     -92.65512449998666 36.5867999999905,
+      -92.65512450000065 36.586800000000466
+    )))
+  </a>
+  <test><op name="getCentroid" arg1="A" >POINT (-92.6553838608954 36.58695407733924)</op></test>
+</case>
 
 </run>

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

Summary of changes:
 include/geos/algorithm/Centroid.h              |  2 +-
 src/algorithm/Centroid.cpp                     |  7 +++---
 tests/xmltester/tests/general/TestCentroid.xml | 32 +++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list