[geos-commits] [SCM] GEOS branch main updated. 13a3bbb015f82c4458fb7768fd24fc6231a11367

git at osgeo.org git at osgeo.org
Wed Jul 14 15:17:12 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, main has been updated
       via  13a3bbb015f82c4458fb7768fd24fc6231a11367 (commit)
      from  67a1b10487bbbe3df8d746fd44ec42d3f91eb949 (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 13a3bbb015f82c4458fb7768fd24fc6231a11367
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Jul 14 15:17:07 2021 -0700

    Reorganize isCCW assignments a little

diff --git a/src/algorithm/Orientation.cpp b/src/algorithm/Orientation.cpp
index a36c9f2..e32a550 100644
--- a/src/algorithm/Orientation.cpp
+++ b/src/algorithm/Orientation.cpp
@@ -62,12 +62,10 @@ Orientation::isCCW(const geom::CoordinateSequence* ring)
      * Note this relies on the convention that
      * rings have the same start and end point.
      */
-    geom::Coordinate upHiPt;
-    ring->getAt(0, upHiPt);
+    geom::Coordinate upHiPt(ring->getAt(0));
+    geom::Coordinate upLowPt(geom::Coordinate::getNull());
+
     double prevY = upHiPt.y;
-    geom::Coordinate upLowPt;
-    upLowPt.setNull();
-    // const geom::Coordinate& upLowPt = nullptr;
     uint32_t iUpHi = 0;
     for (uint32_t i = 1; i <= nPts; i++) {
         double py = ring->getY(i);
@@ -75,9 +73,9 @@ Orientation::isCCW(const geom::CoordinateSequence* ring)
         * If segment is upwards and endpoint is higher, record it
         */
         if (py > prevY && py >= upHiPt.y) {
-            ring->getAt(i, upHiPt);
             iUpHi = i;
-            ring->getAt(i-1, upLowPt);
+            upHiPt = ring->getAt(i);
+            upLowPt = ring->getAt(i-1);
         }
         prevY = py;
     }
@@ -110,29 +108,29 @@ Orientation::isCCW(const geom::CoordinateSequence* ring)
      *    The ring orientation is given by the direction of the flat segment
      */
     if (upHiPt.equals2D(downHiPt)) {
-      /**
-       * Check for the case where the cap has configuration A-B-A.
-       * This can happen if the ring does not contain 3 distinct points
-       * (including the case where the input array has fewer than 4 elements), or
-       * it contains coincident line segments.
-       */
-      if (upLowPt.equals2D(upHiPt) || downLowPt.equals2D(upHiPt) || upLowPt.equals2D(downLowPt))
-        return false;
-
-      /**
-       * It can happen that the top segments are coincident.
-       * This is an invalid ring, which cannot be computed correctly.
-       * In this case the orientation is 0, and the result is false.
-       */
-      int orientationIndex = index(upLowPt, upHiPt, downLowPt);
-      return orientationIndex == COUNTERCLOCKWISE;
+        /**
+        * Check for the case where the cap has configuration A-B-A.
+        * This can happen if the ring does not contain 3 distinct points
+        * (including the case where the input array has fewer than 4 elements), or
+        * it contains coincident line segments.
+        */
+        if (upLowPt.equals2D(upHiPt) || downLowPt.equals2D(upHiPt) || upLowPt.equals2D(downLowPt))
+            return false;
+
+        /**
+        * It can happen that the top segments are coincident.
+        * This is an invalid ring, which cannot be computed correctly.
+        * In this case the orientation is 0, and the result is false.
+        */
+        int orientationIndex = index(upLowPt, upHiPt, downLowPt);
+        return orientationIndex == COUNTERCLOCKWISE;
     }
     else {
-      /**
-       * Flat cap - direction of flat top determines orientation
-       */
-      double delX = downHiPt.x - upHiPt.x;
-      return delX < 0;
+        /**
+        * Flat cap - direction of flat top determines orientation
+        */
+        double delX = downHiPt.x - upHiPt.x;
+        return delX < 0;
     }
 }
 

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

Summary of changes:
 src/algorithm/Orientation.cpp | 54 +++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list