[geos-commits] [SCM] GEOS branch master updated. 253367029a7e04db52b6828836676dd28cdbfe72

git at osgeo.org git at osgeo.org
Wed Jan 23 10:30:08 PST 2019


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  253367029a7e04db52b6828836676dd28cdbfe72 (commit)
      from  669d86fa16a1a3ec33be73723e14640182504cd7 (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 253367029a7e04db52b6828836676dd28cdbfe72
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Jan 23 10:29:55 2019 -0800

    Confirm Polygon.normalize
    JTS 3500a912c40cee7fd7ad706a8ae3b412fa3e4452

diff --git a/include/geos/algorithm/Orientation.h b/include/geos/algorithm/Orientation.h
index d051da2..1dea230 100644
--- a/include/geos/algorithm/Orientation.h
+++ b/include/geos/algorithm/Orientation.h
@@ -64,8 +64,8 @@ public:
     * ( {@link #Orientation::COUNTERCLOCKWISE},
     * {@link #Orientation::CLOCKWISE}, or {@link #Orientation::STRAIGHT} )
     */
-    static int index(const geom::Coordinate &p1,
-                     const geom::Coordinate &p2, const geom::Coordinate &q);
+    static int index(const geom::Coordinate &p1, const geom::Coordinate &p2,
+                     const geom::Coordinate &q);
 
     /**
     * Computes whether a ring defined by an array of {@link Coordinate}s is
@@ -86,8 +86,6 @@ public:
     */
     static bool isCCW(const geom::CoordinateSequence* ring);
 
-
-
 };
 
 
diff --git a/src/algorithm/Orientation.cpp b/src/algorithm/Orientation.cpp
index 13a7215..de1d7bd 100644
--- a/src/algorithm/Orientation.cpp
+++ b/src/algorithm/Orientation.cpp
@@ -31,8 +31,8 @@ namespace algorithm { // geos.algorithm
 
 /* public static */
 int
-Orientation::index(const geom::Coordinate &p1,
-                   const geom::Coordinate &p2, const geom::Coordinate &q)
+Orientation::index(const geom::Coordinate &p1, const geom::Coordinate &p2,
+                   const geom::Coordinate &q)
 {
     return CGAlgorithmsDD::orientationIndex(p1, p2, q);
 }
@@ -42,20 +42,18 @@ bool
 Orientation::isCCW(const geom::CoordinateSequence *ring)
 {
     // sanity check
-    if (ring->getSize() < 4)
-    {
-        throw util::IllegalArgumentException("Ring has fewer than 3 points, so orientation cannot be determined");
+    if (ring->getSize() < 4) {
+        throw util::IllegalArgumentException("Ring has fewer than 4 points, so orientation cannot be determined");
     }
 
     // # of points without closing endpoint
-    const std::size_t nPts=ring->getSize()-1;
+    const std::size_t nPts = ring->getSize()-1;
 
     // find highest point
-    const geom::Coordinate *hiPt=&ring->getAt(0);
+    const geom::Coordinate *hiPt = &ring->getAt(0);
     size_t hiIndex = 0;
-    for (std::size_t i = 1; i <= nPts; ++i)
-    {
-        const geom::Coordinate *p=&ring->getAt(i);
+    for (std::size_t i = 1; i <= nPts; ++i) {
+        const geom::Coordinate *p = &ring->getAt(i);
         if (p->y > hiPt->y) {
             hiPt = p;
             hiIndex = i;
@@ -68,13 +66,15 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
         if (iPrev == 0)
             iPrev = nPts;
         iPrev = iPrev - 1;
-    } while (ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
+    }
+    while (ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
 
     // find distinct point after highest point
     auto iNext = hiIndex;
     do {
         iNext = (iNext + 1) % nPts;
-    } while (ring->getAt(iNext)==*hiPt && iNext != hiIndex);
+    }
+    while (ring->getAt(iNext)==*hiPt && iNext != hiIndex);
 
     const geom::Coordinate *prev=&ring->getAt(iPrev);
     const geom::Coordinate *next=&ring->getAt(iNext);
@@ -86,19 +86,15 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
      * (including the case where the input array has fewer than 4 elements),
      * or it contains coincident line segments.
      */
-    if ( prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
-        prev->equals2D(*next) )
-    {
+    if (prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
+        prev->equals2D(*next)) {
         return false;
         // MD - don't bother throwing exception,
         // since this isn't a complete check for ring validity
         //throw  IllegalArgumentException("degenerate ring (does not contain 3 distinct points)");
     }
 
-    // New DD high precision implementation
     int disc = Orientation::index(*prev, *hiPt, *next);
-    // Old double implementation
-    // int disc = CGAlgorithms::computeOrientation(*prev, *hiPt, *next);
 
     /**
      *  If disc is exactly 0, lines are collinear.
@@ -110,12 +106,13 @@ Orientation::isCCW(const geom::CoordinateSequence *ring)
      *  (2) should never happen, so we're going to ignore it!
      *  (Might want to assert this)
      */
-    bool isCCW=false;
+    bool isCCW = false;
 
     if (disc == 0) {
         // poly is CCW if prev x is right of next x
         isCCW = (prev->x > next->x);
-    } else {
+    }
+    else {
         // if area is positive, points are ordered CCW
         isCCW = (disc > 0);
     }
diff --git a/src/geom/Polygon.cpp b/src/geom/Polygon.cpp
index 7d5dfbf..8211b91 100644
--- a/src/geom/Polygon.cpp
+++ b/src/geom/Polygon.cpp
@@ -341,12 +341,12 @@ Polygon::normalize(LinearRing *ring, bool clockwise)
 	if (ring->isEmpty()) {
 		return;
 	}
-	CoordinateSequence* uniqueCoordinates=ring->getCoordinates();
+	CoordinateSequence* uniqueCoordinates = ring->getCoordinates();
 	uniqueCoordinates->deleteAt(uniqueCoordinates->getSize()-1);
-	const Coordinate* minCoordinate=CoordinateSequence::minCoordinate(uniqueCoordinates);
+	const Coordinate* minCoordinate = CoordinateSequence::minCoordinate(uniqueCoordinates);
 	CoordinateSequence::scroll(uniqueCoordinates, minCoordinate);
 	uniqueCoordinates->add(uniqueCoordinates->getAt(0));
-	if (algorithm::Orientation::isCCW(uniqueCoordinates)==clockwise) {
+	if (algorithm::Orientation::isCCW(uniqueCoordinates) == clockwise) {
 		CoordinateSequence::reverse(uniqueCoordinates);
 	}
 	ring->setPoints(uniqueCoordinates);

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

Summary of changes:
 include/geos/algorithm/Orientation.h |  6 ++----
 src/algorithm/Orientation.cpp        | 37 +++++++++++++++++-------------------
 src/geom/Polygon.cpp                 |  6 +++---
 3 files changed, 22 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list