[geos-commits] [SCM] GEOS branch main updated. 756021b91ce734f471cea8a7d007340816526273

git at osgeo.org git at osgeo.org
Sat Oct 30 14:54:14 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  756021b91ce734f471cea8a7d007340816526273 (commit)
       via  f63cfeffce584945c2e1827d342cc884a732b084 (commit)
      from  07a27b6173daf842948465faedb540a1258e3490 (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 756021b91ce734f471cea8a7d007340816526273
Merge: 07a27b617 f63cfeffc
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Sat Oct 30 14:54:09 2021 -0700

    Merge branch 'main-cmath' into main


commit f63cfeffce584945c2e1827d342cc884a732b084
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Sat Oct 30 14:32:08 2021 -0700

    Use cmath and std::sqrt exclusively

diff --git a/include/geos/triangulate/quadedge/Vertex.h b/include/geos/triangulate/quadedge/Vertex.h
index a34f63eeb..5e6d19f78 100644
--- a/include/geos/triangulate/quadedge/Vertex.h
+++ b/include/geos/triangulate/quadedge/Vertex.h
@@ -19,7 +19,7 @@
 #ifndef GEOS_TRIANGULATE_QUADEDGE_VERTEX_H
 #define GEOS_TRIANGULATE_QUADEDGE_VERTEX_H
 
-#include <math.h>
+#include <cmath>
 #include <memory>
 #include <cstring>
 
@@ -234,8 +234,8 @@ private:
     inline double
     distance(const Vertex& v1, const Vertex& v2)
     {
-        return sqrt(pow(v2.getX() - v1.getX(), 2.0)
-                    + pow(v2.getY() - v1.getY(), 2.0));
+        return std::sqrt(pow(v2.getX() - v1.getX(), 2.0) +
+                         pow(v2.getY() - v1.getY(), 2.0));
     }
 
     /**
diff --git a/include/geos/util.h b/include/geos/util.h
index fd4f1ee46..8e1d662d9 100644
--- a/include/geos/util.h
+++ b/include/geos/util.h
@@ -21,15 +21,10 @@
 #ifndef GEOS_UTIL_H
 #define GEOS_UTIL_H
 
-//#include <geos/util/AssertionFailedException.h>
 #include <geos/util/GEOSException.h>
 #include <geos/util/IllegalArgumentException.h>
 #include <geos/util/TopologyException.h>
-//#include <geos/util/UnsupportedOperationException.h>
-//#include <geos/util/CoordinateArrayFilter.h>
-//#include <geos/util/UniqueCoordinateArrayFilter.h>
 #include <geos/util/GeometricShapeFactory.h>
-//#include <geos/util/math.h>
 
 #include <memory>
 #include <type_traits>
diff --git a/src/algorithm/Distance.cpp b/src/algorithm/Distance.cpp
index a8c6e6cbb..2c8503601 100644
--- a/src/algorithm/Distance.cpp
+++ b/src/algorithm/Distance.cpp
@@ -75,7 +75,7 @@ Distance::pointToSegment(const geom::Coordinate& p,
     double s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y)) /
                ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
 
-    return fabs(s) * sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
+    return std::fabs(s) * std::sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
 }
 
 /*public static*/
@@ -97,7 +97,7 @@ Distance::pointToLinePerpendicular(const geom::Coordinate& p,
     double s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y))
                /
                ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));
-    return fabs(s) * sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
+    return std::fabs(s) * std::sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
 }
 
 /*public static*/
diff --git a/src/algorithm/LineIntersector.cpp b/src/algorithm/LineIntersector.cpp
index 154de20b4..10c729b9e 100644
--- a/src/algorithm/LineIntersector.cpp
+++ b/src/algorithm/LineIntersector.cpp
@@ -229,7 +229,7 @@ LineIntersector::interpolateZ(const Coordinate& p,
     xoff = (p.x - p1.x);
     yoff = (p.y - p1.y);
     double pdist = (xoff * xoff + yoff * yoff);
-    double fract = sqrt(pdist / seglen);
+    double fract = std::sqrt(pdist / seglen);
     double zoff = zgap * fract;
     //double interpolated = p1.z < p2.z ? p1.z+zoff : p1.z-zoff;
     double interpolated = p1.z + zoff;
@@ -600,7 +600,7 @@ LineIntersector::zInterpolate(const Coordinate& p, const Coordinate& p1, const C
     double xoff = (p.x - p1.x);
     double yoff = (p.y - p1.y);
     double plen = (xoff * xoff + yoff * yoff);
-    double frac = sqrt(plen / seglen);
+    double frac = std::sqrt(plen / seglen);
     double zoff = dz * frac;
     double zInterpolated = p1z + zoff;
 #if GEOS_DEBUG
diff --git a/src/algorithm/MinimumBoundingCircle.cpp b/src/algorithm/MinimumBoundingCircle.cpp
index 5506b7989..87b7acc33 100644
--- a/src/algorithm/MinimumBoundingCircle.cpp
+++ b/src/algorithm/MinimumBoundingCircle.cpp
@@ -31,7 +31,7 @@
 #include <geos/geom/Triangle.h>
 #include <geos/util/GEOSException.h>
 
-#include <math.h> // sqrt
+#include <cmath>  // sqrt
 #include <memory> // for unique_ptr
 #include <typeinfo>
 #include <vector>
@@ -316,7 +316,7 @@ MinimumBoundingCircle::pointWitMinAngleWithX(std::vector<Coordinate>& pts, Coord
         if(dy < 0) {
             dy = -dy;
         }
-        double len = sqrt(dx * dx + dy * dy);
+        double len = std::sqrt(dx * dx + dy * dy);
         double sin = dy / len;
 
         if(sin < minSin) {
diff --git a/src/geom/LineSegment.cpp b/src/geom/LineSegment.cpp
index 0d17fdd9f..ee475cd7a 100644
--- a/src/geom/LineSegment.cpp
+++ b/src/geom/LineSegment.cpp
@@ -279,7 +279,7 @@ LineSegment::pointAlongOffset(double segmentLengthFraction,
 
     double dx = p1.x - p0.x;
     double dy = p1.y - p0.y;
-    double len = sqrt(dx * dx + dy * dy);
+    double len = std::sqrt(dx * dx + dy * dy);
 
     double ux = 0.0;
     double uy = 0.0;
diff --git a/src/geom/util/Densifier.cpp b/src/geom/util/Densifier.cpp
index 15f77fd0a..769c90094 100644
--- a/src/geom/util/Densifier.cpp
+++ b/src/geom/util/Densifier.cpp
@@ -18,7 +18,7 @@
  *
  **********************************************************************/
 
-#include <math.h>
+#include <cmath>
 
 #include <geos/geom/util/Densifier.h>
 #include <geos/geom/CoordinateSequenceFactory.h>
diff --git a/src/triangulate/VoronoiDiagramBuilder.cpp b/src/triangulate/VoronoiDiagramBuilder.cpp
index 5adfbd623..0005700a5 100644
--- a/src/triangulate/VoronoiDiagramBuilder.cpp
+++ b/src/triangulate/VoronoiDiagramBuilder.cpp
@@ -19,7 +19,7 @@
 #include <geos/triangulate/VoronoiDiagramBuilder.h>
 
 #include <algorithm>
-#include <math.h>
+#include <cmath>
 #include <vector>
 #include <iostream>
 
diff --git a/tests/unit/capi/GEOSDistanceTest.cpp b/tests/unit/capi/GEOSDistanceTest.cpp
index fceb19977..84f44e259 100644
--- a/tests/unit/capi/GEOSDistanceTest.cpp
+++ b/tests/unit/capi/GEOSDistanceTest.cpp
@@ -11,7 +11,7 @@
 #include <cstdlib>
 #include <fenv.h>
 #include <memory>
-#include <math.h>
+#include <cmath>
 
 #include "capi_test_utils.h"
 
@@ -134,7 +134,7 @@ void object::test<4>
     int status = GEOSDistance(g1, g2, &d);
 
     ensure_equals(status, 1);
-    ensure_equals(d, sqrt(2));
+    ensure_equals(d, std::sqrt(2));
 
     // check for floating point overflow exceptions
     int raised = fetestexcept(FE_OVERFLOW);
@@ -160,7 +160,7 @@ void object::test<5>
     int status = GEOSDistance(g1, g2, &d);
 
     ensure_equals(status, 1);
-    // ensure_equals(d, sqrt(2));
+    // ensure_equals(d, std::sqrt(2));
 
     // check for floating point overflow exceptions
     int raised = fetestexcept(FE_OVERFLOW);
diff --git a/tests/unit/capi/GEOSFrechetDistanceTest.cpp b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
index b40b18c20..a3b438c0b 100644
--- a/tests/unit/capi/GEOSFrechetDistanceTest.cpp
+++ b/tests/unit/capi/GEOSFrechetDistanceTest.cpp
@@ -9,7 +9,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <memory>
-#include <math.h>
+#include <cmath>
 
 #include "capi_test_utils.h"
 
diff --git a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
index 8a530819c..b56888c8a 100644
--- a/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
+++ b/tests/unit/capi/GEOSHausdorffDistanceTest.cpp
@@ -9,7 +9,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <memory>
-#include <math.h>
+#include <cmath>
 
 #include "capi_test_utils.h"
 
diff --git a/tests/unit/capi/GEOSSTRtreeTest.cpp b/tests/unit/capi/GEOSSTRtreeTest.cpp
index 3a5be832a..8540a244a 100644
--- a/tests/unit/capi/GEOSSTRtreeTest.cpp
+++ b/tests/unit/capi/GEOSSTRtreeTest.cpp
@@ -38,7 +38,7 @@ INTPOINT_dist(const void* a, const void* b, double* distance, void*)
     int dx = p2->x - p1->x;
     int dy = p2->y - p1->y;
 
-    *distance = sqrt(static_cast<double>(dx * dx) + dy * dy);
+    *distance = std::sqrt(static_cast<double>(dx * dx) + dy * dy);
     return 1;
 }
 

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

Summary of changes:
 include/geos/triangulate/quadedge/Vertex.h    | 6 +++---
 include/geos/util.h                           | 5 -----
 src/algorithm/Distance.cpp                    | 4 ++--
 src/algorithm/LineIntersector.cpp             | 4 ++--
 src/algorithm/MinimumBoundingCircle.cpp       | 4 ++--
 src/geom/LineSegment.cpp                      | 2 +-
 src/geom/util/Densifier.cpp                   | 2 +-
 src/triangulate/VoronoiDiagramBuilder.cpp     | 2 +-
 tests/unit/capi/GEOSDistanceTest.cpp          | 6 +++---
 tests/unit/capi/GEOSFrechetDistanceTest.cpp   | 2 +-
 tests/unit/capi/GEOSHausdorffDistanceTest.cpp | 2 +-
 tests/unit/capi/GEOSSTRtreeTest.cpp           | 2 +-
 12 files changed, 18 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list