[geos-commits] [SCM] GEOS branch master updated. 3e299be627d3243be8d55ba0d10afd84a3d8ca2f

git at osgeo.org git at osgeo.org
Tue Dec 11 12:32:38 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  3e299be627d3243be8d55ba0d10afd84a3d8ca2f (commit)
      from  837a661ae5c899a1daca3b169e438eeb5f1ad51e (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 3e299be627d3243be8d55ba0d10afd84a3d8ca2f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Tue Dec 11 12:32:15 2018 -0800

    Small clean-ups preparatory for aping the JTS refactor around DD
    computation.

diff --git a/include/geos/algorithm/CGAlgorithms.h b/include/geos/algorithm/CGAlgorithms.h
index 9c88f3d..203890c 100644
--- a/include/geos/algorithm/CGAlgorithms.h
+++ b/include/geos/algorithm/CGAlgorithms.h
@@ -50,14 +50,14 @@ public:
 
 	enum {
 		CLOCKWISE=-1,
-		COLLINEAR,
-		COUNTERCLOCKWISE
+		COLLINEAR=0,
+		COUNTERCLOCKWISE=1
 	};
 
 	enum {
 		RIGHT=-1,
-		LEFT,
-		STRAIGHT
+		LEFT=1,
+		STRAIGHT=0
 	};
 
 	CGAlgorithms(){}
diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h
index 20fd985..2b581b7 100644
--- a/include/geos/algorithm/CGAlgorithmsDD.h
+++ b/include/geos/algorithm/CGAlgorithmsDD.h
@@ -45,6 +45,18 @@ class GEOS_DLL CGAlgorithmsDD {
 
 public:
 
+	enum {
+		CLOCKWISE=-1,
+		COLLINEAR=0,
+		COUNTERCLOCKWISE=1
+	};
+
+	enum {
+		RIGHT=-1,
+		LEFT=1,
+		STRAIGHT=0
+	};
+
     /**
      * Returns the index of the direction of the point <code>q</code> relative to
      * a vector specified by <code>p1-p2</code>.
diff --git a/src/algorithm/CGAlgorithmsDD.cpp b/src/algorithm/CGAlgorithmsDD.cpp
index 01023e2..ecc95d3 100644
--- a/src/algorithm/CGAlgorithmsDD.cpp
+++ b/src/algorithm/CGAlgorithmsDD.cpp
@@ -24,25 +24,25 @@
 using namespace geos::geom;
 
 namespace {
-double const DP_SAFE_EPSILON =  1e-15;
 
+	double const DP_SAFE_EPSILON =  1e-15;
 
-inline int SigNumDD(DD const& dd)
-{
-    static DD const zero(0.0);
-    if (dd < zero) {
-        return -1;
-    }
-    if (dd > zero) {
-        return 1;
-    }
-    return 0;
-}
+	inline int SigNumDD(DD const& dd)
+	{
+	    static DD const zero(0.0);
+	    if (dd < zero)
+	        return -1;
 
-inline std::string ToStringDD(DD const& dd)
-{
-    return dd.ToString();
-}
+	    if (dd > zero)
+	        return 1;
+
+	    return 0;
+	}
+
+	inline std::string ToStringDD(DD const& dd)
+	{
+	    return dd.ToString();
+	}
 }
 
 namespace geos {
@@ -52,11 +52,6 @@ int CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
                                      const Coordinate& p2,
                                      const Coordinate& q)
 {
-    // fast filter for orientation index
-    // avoids use of slow extended-precision arithmetic in many cases
-    //int index = orientationIndexFilter(p1, p2, q);
-    //if (index <= 1) return index;
-    // normalize coordinates
     DD dx1 = DD(p2.x) + DD(-p1.x);
     DD dy1 = DD(p2.y) + DD(-p1.y);
     DD dx2 = DD(q.x) + DD(-p2.x);
@@ -64,8 +59,6 @@ int CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
     DD mx1y2(dx1 * dy2);
     DD my1x2(dy1 * dx2);
     DD d = mx1y2 - my1x2;
-    // sign of determinant - unrolled for performance
-    //std::cout << ToStringDD(d) << std::endl;
     return SigNumDD(d);
 }
 
@@ -155,48 +148,6 @@ void CGAlgorithmsDD::intersection(const Coordinate& p1, const Coordinate& p2,
     return;
 }
 
-#if 0
-public static Coordinate intersection(
-    Coordinate p1, Coordinate p2,
-    Coordinate q1, Coordinate q2)
-{
-    DD denom1 = DD.valueOf(q2.y).selfSubtract(q1.y)
-                .selfMultiply(DD.valueOf(p2.x).selfSubtract(p1.x));
-    DD denom2 = DD.valueOf(q2.x).selfSubtract(q1.x)
-                .selfMultiply(DD.valueOf(p2.y).selfSubtract(p1.y));
-    DD denom = denom1.subtract(denom2);
-
-    /**
-     * Cases:
-     * - denom is 0 if lines are parallel
-     * - intersection point lies within line segment p if fracP is between 0 and 1
-     * - intersection point lies within line segment q if fracQ is between 0 and 1
-     */
-
-    DD numx1 = DD.valueOf(q2.x).selfSubtract(q1.x)
-               .selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
-    DD numx2 = DD.valueOf(q2.y).selfSubtract(q1.y)
-               .selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
-    DD numx = numx1.subtract(numx2);
-    double fracP = numx.selfDivide(denom).doubleValue();
-
-    double x = DD.valueOf(p1.x).selfAdd(DD.valueOf(p2.x).selfSubtract(p1.x).selfMultiply(fracP)).doubleValue();
-
-    DD numy1 = DD.valueOf(p2.x).selfSubtract(p1.x)
-               .selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
-    DD numy2 = DD.valueOf(p2.y).selfSubtract(p1.y)
-               .selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
-    DD numy = numy1.subtract(numy2);
-    double fracQ = numy.selfDivide(denom).doubleValue();
-
-    double y = DD.valueOf(q1.y).selfAdd(DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(fracQ)).doubleValue();
-
-    return new Coordinate(x,y);
-}
-}
-
-#endif
-
 
 } // namespace geos::algorithm
 } // namespace geos

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

Summary of changes:
 include/geos/algorithm/CGAlgorithms.h   |  8 ++--
 include/geos/algorithm/CGAlgorithmsDD.h | 12 +++++
 src/algorithm/CGAlgorithmsDD.cpp        | 81 +++++++--------------------------
 3 files changed, 32 insertions(+), 69 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list