[geos-commits] [SCM] GEOS branch main updated. 1c6865422740045de3521cae0622a15ec470f4d2
git at osgeo.org
git at osgeo.org
Fri Mar 20 12:42:15 PDT 2026
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 1c6865422740045de3521cae0622a15ec470f4d2 (commit)
from 09463aeb954524fb11318e1d9934e37b563ddf4b (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 1c6865422740045de3521cae0622a15ec470f4d2
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue Dec 23 10:49:36 2025 -0500
CircularArc: make center and radius calculation orientation-independent
diff --git a/include/geos/geom/CircularArc.h b/include/geos/geom/CircularArc.h
index 067e5ba39..de75334fc 100644
--- a/include/geos/geom/CircularArc.h
+++ b/include/geos/geom/CircularArc.h
@@ -86,7 +86,11 @@ public:
/// Return the center point of the circle associated with this arc
const CoordinateXY& getCenter() const {
if (!m_center_known) {
- m_center = algorithm::CircularArcs::getCenter(p0(), p1(), p2());
+ if (isCCW()) {
+ m_center = algorithm::CircularArcs::getCenter(p0(), p1(), p2());
+ } else {
+ m_center = algorithm::CircularArcs::getCenter(p2(), p1(), p0());
+ }
m_center_known = true;
}
@@ -121,7 +125,11 @@ public:
/// Return the radius of the circle associated with this arc
double getRadius() const {
if (!m_radius_known) {
- m_radius = getCenter().distance(p0());
+ if (isCCW()) {
+ m_radius = getCenter().distance(p0());
+ } else {
+ m_radius = getCenter().distance(p2());
+ }
m_radius_known = true;
}
diff --git a/tests/unit/geom/CircularArcTest.cpp b/tests/unit/geom/CircularArcTest.cpp
index d09c9ae5b..67df5734a 100644
--- a/tests/unit/geom/CircularArcTest.cpp
+++ b/tests/unit/geom/CircularArcTest.cpp
@@ -1,11 +1,15 @@
#include <tut/tut.hpp>
+#include <geos/algorithm/Orientation.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CircularArc.h>
#include <geos/constants.h>
using geos::geom::CoordinateXY;
+using geos::geom::CoordinateXYZM;
using geos::geom::CircularArc;
+using geos::geom::CoordinateSequence;
+
using geos::MATH_PI;
namespace tut {
@@ -31,6 +35,9 @@ struct test_circulararc_data {
auto rev = CircularArc::create(p2, p1, p0);
ensure_equals(p2.toString() + " / " + p1.toString() + " / " + p0.toString(), rev.getLength(), expected, eps);
}
+
+
+
};
using group = test_group<test_circulararc_data>;
@@ -123,4 +130,22 @@ void object::test<5>()
CircularArc::create(CoordinateXY{-5, 0}, {0, 5}, {5, 0}).containsPointOnCircle({5, 0});
}
+template<>
+template<>
+void object::test<6>() {
+ set_test_name("getRadius and getCenter are order-independent");
+ using XY = CoordinateXY;
+
+ CircularArc arc1 = CircularArc::create(XY{71.96, -65.54}, XY{22.2, -18.52}, XY{20, 50});
+ double r1 = arc1.getRadius();
+ CoordinateXY c1 = arc1.getCenter();
+
+ CircularArc arc2 = CircularArc::create(XY{20, 50}, XY{22.2, -18.52}, XY{71.96, -65.54});
+ double r2 = arc1.getRadius();
+ CoordinateXY c2 = arc1.getCenter();
+
+ ensure_equals(r1, r2);
+ ensure_equals(c1, c2);
+}
+
}
-----------------------------------------------------------------------
Summary of changes:
include/geos/geom/CircularArc.h | 12 ++++++++++--
tests/unit/geom/CircularArcTest.cpp | 25 +++++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list