[geos-commits] [SCM] GEOS branch master updated. e0cc6ad090738fce5e954c24073f85c0d43d9aaa

git at osgeo.org git at osgeo.org
Mon Dec 21 17:43:13 PST 2020


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  e0cc6ad090738fce5e954c24073f85c0d43d9aaa (commit)
      from  4c0a3939972280f449833f4450e6ebc1a34a5950 (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 e0cc6ad090738fce5e954c24073f85c0d43d9aaa
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Dec 21 19:38:59 2020 -0500

    Inline CGAlgorithmsDD::orientationIndexFilter

diff --git a/include/geos/algorithm/CGAlgorithmsDD.h b/include/geos/algorithm/CGAlgorithmsDD.h
index df62696..ba4bf0c 100644
--- a/include/geos/algorithm/CGAlgorithmsDD.h
+++ b/include/geos/algorithm/CGAlgorithmsDD.h
@@ -19,6 +19,7 @@
 #ifndef GEOS_ALGORITHM_CGALGORITHMDD_H
 #define GEOS_ALGORITHM_CGALGORITHMDD_H
 #include <geos/export.h>
+#include <geos/inline.h>
 #include <geos/math/DD.h>
 
 // Forward declarations
@@ -155,4 +156,8 @@ protected:
 } // namespace geos::algorithm
 } // namespace geos
 
+#ifdef GEOS_INLINE
+#include "geos/algorithm/CGAlgorithmsDD.inl"
+#endif
+
 #endif // GEOS_ALGORITHM_CGALGORITHM_H
diff --git a/include/geos/algorithm/CGAlgorithmsDD.inl b/include/geos/algorithm/CGAlgorithmsDD.inl
new file mode 100644
index 0000000..9dc9f10
--- /dev/null
+++ b/include/geos/algorithm/CGAlgorithmsDD.inl
@@ -0,0 +1,72 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2014 Mateusz Loskot <mateusz at loskot.net>
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ **********************************************************************
+ *
+ * Last port: algorithm/CGAlgorithmsDD.java r789 (JTS-1.14)
+ *
+ **********************************************************************/
+
+#ifndef GEOS_ALGORITHM_CGALGORITHMDD_INL
+#define GEOS_ALGORITHM_CGALGORITHMDD_INL
+
+namespace geos {
+namespace algorithm {
+
+INLINE int
+CGAlgorithmsDD::orientationIndexFilter(double pax, double pay,
+                                       double pbx, double pby,
+                                       double pcx, double pcy)
+{
+    /**
+     * A value which is safely greater than the relative round-off
+     * error in double-precision numbers
+     */
+    double constexpr DP_SAFE_EPSILON =  1e-15;
+
+    double detsum;
+    double const detleft = (pax - pcx) * (pby - pcy);
+    double const detright = (pay - pcy) * (pbx - pcx);
+    double const det = detleft - detright;
+
+    if(detleft > 0.0) {
+        if(detright <= 0.0) {
+            return orientation(det);
+        }
+        else {
+            detsum = detleft + detright;
+        }
+    }
+    else if(detleft < 0.0) {
+        if(detright >= 0.0) {
+            return orientation(det);
+        }
+        else {
+            detsum = -detleft - detright;
+        }
+    }
+    else {
+        return orientation(det);
+    }
+
+    double const errbound = DP_SAFE_EPSILON * detsum;
+        if((det >= errbound) || (-det >= errbound)) {
+            return orientation(det);
+        }
+        return CGAlgorithmsDD::FAILURE;
+    }
+
+
+}
+}
+
+#endif
diff --git a/include/geos/algorithm/Makefile.am b/include/geos/algorithm/Makefile.am
index ccebd53..1d1360f 100644
--- a/include/geos/algorithm/Makefile.am
+++ b/include/geos/algorithm/Makefile.am
@@ -15,6 +15,7 @@ geos_HEADERS = \
 	Area.h \
 	BoundaryNodeRule.h \
 	CGAlgorithmsDD.h \
+	CGAlgorithmsDD.inl \
 	CentralEndpointIntersector.h \
 	Centroid.h \
 	ConvexHull.h \
diff --git a/src/algorithm/CGAlgorithmsDD.cpp b/src/algorithm/CGAlgorithmsDD.cpp
index a3f0e31..89bd709 100644
--- a/src/algorithm/CGAlgorithmsDD.cpp
+++ b/src/algorithm/CGAlgorithmsDD.cpp
@@ -28,12 +28,6 @@ using namespace geos::algorithm;
 
 namespace {
 
-/**
- * A value which is safely greater than the relative round-off
- * error in double-precision numbers
- */
-double constexpr DP_SAFE_EPSILON =  1e-15;
-
 inline int
 OrientationDD(const DD &dd)
 {
@@ -86,6 +80,7 @@ CGAlgorithmsDD::orientationIndex(double p1x, double p1y,
 }
 
 
+// inlining this method worsened performance slighly
 int
 CGAlgorithmsDD::orientationIndex(const Coordinate& p1,
                                  const Coordinate& p2,
@@ -118,43 +113,6 @@ CGAlgorithmsDD::signOfDet2x2(double dx1, double dy1, double dx2, double dy2)
     return CGAlgorithmsDD::signOfDet2x2(x1, y1, x2, y2);
 }
 
-int
-CGAlgorithmsDD::orientationIndexFilter(double pax, double pay,
-                                       double pbx, double pby,
-                                       double pcx, double pcy)
-{
-    double detsum;
-    double const detleft = (pax - pcx) * (pby - pcy);
-    double const detright = (pay - pcy) * (pbx - pcx);
-    double const det = detleft - detright;
-
-    if(detleft > 0.0) {
-        if(detright <= 0.0) {
-            return orientation(det);
-        }
-        else {
-            detsum = detleft + detright;
-        }
-    }
-    else if(detleft < 0.0) {
-        if(detright >= 0.0) {
-            return orientation(det);
-        }
-        else {
-            detsum = -detleft - detright;
-        }
-    }
-    else {
-        return orientation(det);
-    }
-
-    double const errbound = DP_SAFE_EPSILON * detsum;
-    if((det >= errbound) || (-det >= errbound)) {
-        return orientation(det);
-    }
-    return CGAlgorithmsDD::FAILURE;
-}
-
 Coordinate
 CGAlgorithmsDD::intersection(const Coordinate& p1, const Coordinate& p2,
                              const Coordinate& q1, const Coordinate& q2)
@@ -230,6 +188,10 @@ CGAlgorithmsDD::detDD(const DD& x1, const DD& y1, const DD& x2, const DD& y2)
     return (x1 * y2) - (y1 * x2);
 }
 
+#ifndef GEOS_INLINE
+#include "geos/algorithm/CGAlgorithmsDD.inl"
+#endif
+
 } // namespace geos::algorithm
 } // namespace geos
 
diff --git a/src/algorithm/Orientation.cpp b/src/algorithm/Orientation.cpp
index 4d5eb9e..e15966d 100644
--- a/src/algorithm/Orientation.cpp
+++ b/src/algorithm/Orientation.cpp
@@ -32,6 +32,7 @@ namespace geos {
 namespace algorithm { // geos.algorithm
 
 /* public static */
+// inlining this method worsened performance slightly
 int
 Orientation::index(const geom::Coordinate& p1, const geom::Coordinate& p2,
                    const geom::Coordinate& q)

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

Summary of changes:
 include/geos/algorithm/CGAlgorithmsDD.h   |  5 +++
 include/geos/algorithm/CGAlgorithmsDD.inl | 72 +++++++++++++++++++++++++++++++
 include/geos/algorithm/Makefile.am        |  1 +
 src/algorithm/CGAlgorithmsDD.cpp          | 48 +++------------------
 src/algorithm/Orientation.cpp             |  1 +
 5 files changed, 84 insertions(+), 43 deletions(-)
 create mode 100644 include/geos/algorithm/CGAlgorithmsDD.inl


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list