[geos-commits] [SCM] GEOS branch main updated. 32ccf683317a2f649fea96b8a930f6515823a451
git at osgeo.org
git at osgeo.org
Mon Apr 20 09:57:36 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 32ccf683317a2f649fea96b8a930f6515823a451 (commit)
via 4df44620c288e4d892397e6acc62c21bfe54d8c0 (commit)
via 2e8c9c11bba750f70283b5945ee840d3c26335e6 (commit)
via 1a91de165de49f7f37d3975f162731dc1c4fc7a0 (commit)
via 8aa6ee310e49089c5d9e18a0ce7bf6aff1682534 (commit)
from 243b13831a5e8ddc6c3b80822b09452e22c51243 (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 32ccf683317a2f649fea96b8a930f6515823a451
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Apr 9 13:16:21 2026 -0400
WKBReader: Add std::string overload for readHEX
diff --git a/include/geos/io/WKBReader.h b/include/geos/io/WKBReader.h
index 9d410c250..58eeb8f74 100644
--- a/include/geos/io/WKBReader.h
+++ b/include/geos/io/WKBReader.h
@@ -124,6 +124,16 @@ public:
*/
std::unique_ptr<geom::Geometry> readHEX(std::istream& is);
+ /**
+ * \brief Reads a Geometry hex format.
+ *
+ * @param hex the string to read
+ * @return the Geometry read
+ * @throws IOException
+ * @throws ParseException
+ */
+ std::unique_ptr<geom::Geometry> readHEX(const std::string& hex);
+
/**
* \brief Print WKB in HEX form to out stream
*
diff --git a/src/io/WKBReader.cpp b/src/io/WKBReader.cpp
index 5410ab0c7..65ba6c4c1 100644
--- a/src/io/WKBReader.cpp
+++ b/src/io/WKBReader.cpp
@@ -184,6 +184,13 @@ WKBReader::readHEX(std::istream& is)
return this->read(os);
}
+std::unique_ptr<Geometry>
+WKBReader::readHEX(const std::string& hex)
+{
+ std::istringstream ss(hex);
+ return readHEX(ss);
+}
+
void
WKBReader::minMemSize(geom::GeometryTypeId geomType, uint64_t size) const
{
commit 4df44620c288e4d892397e6acc62c21bfe54d8c0
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Apr 9 12:23:04 2026 -0400
Add LinealExtracter
diff --git a/include/geos/geom/util/LinealExtracter.h b/include/geos/geom/util/LinealExtracter.h
new file mode 100644
index 000000000..ff50a357a
--- /dev/null
+++ b/include/geos/geom/util/LinealExtracter.h
@@ -0,0 +1,51 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2026 ISciences LLC
+ *
+ * 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.
+ *
+ **********************************************************************/
+
+#pragma once
+
+#include <geos/export.h>
+#include <geos/geom/Geometry.h>
+#include <vector>
+
+namespace geos {
+namespace geom { // geos.geom
+namespace util { // geos.geom.util
+
+/**
+ * \brief Extracts the lineal (LineString/LinearRing/CircularString/CompoundCurve/MultiLineString/MultiCurve)
+ * elements from a Geometry.
+ */
+class GEOS_DLL LinealExtracter {
+
+public:
+
+ /**
+ * Pushes the lineal elements from a geometry into the provided vector.
+ *
+ * @param geom the geometry to extract from
+ * @param lineals the vector to add the polygonal elements to
+ */
+ static void getLineals(const Geometry& geom, std::vector<const Geometry*>& lineals);
+
+ static void getLineals(const Geometry* geom, std::vector<const Geometry*>& lineals);
+
+ // Declare type as noncopyable
+ LinealExtracter(const LinealExtracter& other) = delete;
+ LinealExtracter& operator=(const LinealExtracter& rhs) = delete;
+};
+
+} // namespace geos.geom.util
+} // namespace geos.geom
+} // namespace geos
+
diff --git a/src/geom/util/LinealExtracter.cpp b/src/geom/util/LinealExtracter.cpp
new file mode 100644
index 000000000..5f62cc85b
--- /dev/null
+++ b/src/geom/util/LinealExtracter.cpp
@@ -0,0 +1,51 @@
+/**********************************************************************
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.osgeo.org
+ *
+ * Copyright (C) 2026 ISciences LLC
+ *
+ * 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.
+ *
+ **********************************************************************/
+
+#include <geos/geom/util/LinealExtracter.h>
+
+#include <geos/geom/LineString.h>
+#include <geos/geom/MultiCurve.h>
+#include <geos/geom/MultiLineString.h>
+
+#include <vector>
+
+
+namespace geos {
+namespace geom { // geos.geom
+namespace util { // geos.geom.util
+
+void
+LinealExtracter::getLineals(const Geometry& geom, std::vector<const Geometry*>& lineals)
+{
+ getLineals(&geom, lineals);
+}
+
+void
+LinealExtracter::getLineals(const Geometry* geom, std::vector<const Geometry*>& lineals)
+{
+ if (dynamic_cast<const Curve*>(geom) != nullptr
+ || dynamic_cast<const MultiLineString*>(geom) != nullptr
+ || dynamic_cast<const MultiCurve*>(geom) != nullptr) {
+ lineals.push_back(geom);
+ }
+ else if (dynamic_cast<const GeometryCollection*>(geom) != nullptr) {
+ for (std::size_t i = 0; i < geom->getNumGeometries(); i++) {
+ getLineals(geom->getGeometryN(i), lineals);
+ }
+ }
+}
+
+}
+}
+}
diff --git a/tests/unit/geom/util/LinealExtracterTest.cpp b/tests/unit/geom/util/LinealExtracterTest.cpp
new file mode 100644
index 000000000..941de32af
--- /dev/null
+++ b/tests/unit/geom/util/LinealExtracterTest.cpp
@@ -0,0 +1,70 @@
+//
+// Test Suite for geos::geom::util::LinealExtracter class.
+
+#include <tut/tut.hpp>
+
+#include <geos/geom/Geometry.h>
+#include <geos/geom/LineString.h>
+#include <geos/geom/util/LinealExtracter.h>
+
+#include "utility.h"
+
+namespace tut {
+
+struct test_linealextracter_data {
+ geos::io::WKTReader reader_;
+};
+
+typedef test_group<test_linealextracter_data> group;
+typedef group::object object;
+
+group test_linealextracter_group("geos::geom::util::LinealExtracter");
+
+template<>
+template<>
+void object::test<1>()
+{
+ auto input = reader_.read(
+ "GEOMETRYCOLLECTION ("
+ "POINT (1 1),"
+ "LINESTRING (0 0, 1 1),"
+ "POLYGON ((0 0, 1 0, 1 1, 0 0)),"
+ "CIRCULARSTRING (0 0, 1 1, 2 0),"
+ "COMPOUNDCURVE(CIRCULARSTRING (0 0, 5 5, 10 0), (10 0, 20 0))"
+ ")");
+
+ std::vector<const Geometry*> lineals;
+ geos::geom::util::LinealExtracter::getLineals(*input, lineals);
+
+ ensure_equals(lineals.size(), 3u);
+ ensure_equals_geometry(lineals[0], input->getGeometryN(1));
+ ensure_equals_geometry(lineals[1], input->getGeometryN(3));
+ ensure_equals_geometry(lineals[2], input->getGeometryN(4));
+}
+
+template<>
+template<>
+void object::test<2>()
+{
+ set_test_name("nested inputs");
+
+ auto input = reader_.read(
+ "GEOMETRYCOLLECTION ("
+ "MULTILINESTRING ((0 0, 1 1), (2 2, 3 3)),"
+ "GEOMETRYCOLLECTION ("
+ "LINESTRING (4 4, 5 5),"
+ "POINT (6 6),"
+ "MULTILINESTRING ((7 7, 8 8))"
+ ")"
+ ")");
+
+ std::vector<const Geometry*> lineals;
+ geos::geom::util::LinealExtracter::getLineals(*input, lineals);
+
+ ensure_equals(lineals.size(), 3u);
+ ensure_equals_geometry(lineals[0], input->getGeometryN(0));
+ ensure_equals_geometry(lineals[1], input->getGeometryN(1)->getGeometryN(0));
+ ensure_equals_geometry(lineals[2], input->getGeometryN(1)->getGeometryN(2));
+}
+
+} // namespace tut
commit 2e8c9c11bba750f70283b5945ee840d3c26335e6
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Apr 9 11:54:38 2026 -0400
DistanceOp: Add nearestLocations(), mark const methods
diff --git a/include/geos/operation/distance/DistanceOp.h b/include/geos/operation/distance/DistanceOp.h
index b4d6fed8b..03d3d2c92 100644
--- a/include/geos/operation/distance/DistanceOp.h
+++ b/include/geos/operation/distance/DistanceOp.h
@@ -104,7 +104,15 @@ public:
double distance);
/**
- * Compute the the nearest points of two geometries.
+ * Report the locations of the nearest points in the input geometries.
+ * The locations are presented in the same order as the input geometries.
+ *
+ * @return a pair of {@link GeometryLocation}s for the nearest points
+ */
+ const std::array<GeometryLocation, 2>& nearestLocations();
+
+ /**
+ * Compute the nearest points of two geometries.
*
* The points are presented in the same order as the input Geometries.
*
diff --git a/include/geos/operation/distance/GeometryLocation.h b/include/geos/operation/distance/GeometryLocation.h
index 1fb443762..6aef5123e 100644
--- a/include/geos/operation/distance/GeometryLocation.h
+++ b/include/geos/operation/distance/GeometryLocation.h
@@ -94,7 +94,7 @@ public:
/**
* Returns the geometry component on (or in) which this location occurs.
*/
- const geom::Geometry* getGeometryComponent();
+ const geom::Geometry* getGeometryComponent() const;
/**
* Returns the segment index for this location.
@@ -104,20 +104,20 @@ public:
*
* @return the segment index for the location, or INSIDE_AREA
*/
- std::size_t getSegmentIndex();
+ std::size_t getSegmentIndex() const;
/**
* Returns the geom::Coordinate of this location.
*/
- geom::CoordinateXY& getCoordinate();
+ const geom::CoordinateXY& getCoordinate() const;
/** \brief
* Tests whether this location represents a point
* inside an area geometry.
*/
- bool isInsideArea();
+ bool isInsideArea() const;
- std::string toString();
+ std::string toString() const;
};
} // namespace geos::operation::distance
diff --git a/src/operation/distance/DistanceOp.cpp b/src/operation/distance/DistanceOp.cpp
index 2eb82eaac..fa25f5be2 100644
--- a/src/operation/distance/DistanceOp.cpp
+++ b/src/operation/distance/DistanceOp.cpp
@@ -68,6 +68,14 @@ DistanceOp::distance(const Geometry& g0, const Geometry& g1)
return distOp.distance();
}
+/*public static*/
+const std::array<GeometryLocation, 2>&
+DistanceOp::nearestLocations()
+{
+ computeMinDistance();
+ return minDistanceLocation;
+}
+
/*public static*/
std::unique_ptr<CoordinateSequence>
DistanceOp::nearestPoints(const Geometry* g0, const Geometry* g1)
diff --git a/src/operation/distance/GeometryLocation.cpp b/src/operation/distance/GeometryLocation.cpp
index 6c46b5e0e..12dafa106 100644
--- a/src/operation/distance/GeometryLocation.cpp
+++ b/src/operation/distance/GeometryLocation.cpp
@@ -54,7 +54,7 @@ GeometryLocation::GeometryLocation(const Geometry* newComponent, const Coordinat
* Returns the geometry associated with this location.
*/
const Geometry*
-GeometryLocation::getGeometryComponent()
+GeometryLocation::getGeometryComponent() const
{
return component;
}
@@ -65,27 +65,27 @@ GeometryLocation::getGeometryComponent()
* @return the segment index for the location, or INSIDE_AREA
*/
size_t
-GeometryLocation::getSegmentIndex()
+GeometryLocation::getSegmentIndex() const
{
return segIndex;
}
/**
* Returns the location.
*/
-CoordinateXY&
-GeometryLocation::getCoordinate()
+const CoordinateXY&
+GeometryLocation::getCoordinate() const
{
return pt;
}
bool
-GeometryLocation::isInsideArea()
+GeometryLocation::isInsideArea() const
{
return inside_area;
}
std::string
-GeometryLocation::toString()
+GeometryLocation::toString() const
{
geos::io::WKTWriter writer;
std::ostringstream ss;
commit 1a91de165de49f7f37d3975f162731dc1c4fc7a0
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Apr 9 10:23:40 2026 -0400
GeometryNoder: Handle CompoundCurve inputs
diff --git a/src/noding/GeometryNoder.cpp b/src/noding/GeometryNoder.cpp
index 0d31dcde9..6c990cbae 100644
--- a/src/noding/GeometryNoder.cpp
+++ b/src/noding/GeometryNoder.cpp
@@ -25,11 +25,13 @@
#include <geos/geom/Geometry.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/geom/CoordinateSequence.h>
+#include <geos/geom/CompoundCurve.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/CircularString.h>
#include <geos/geom/MultiCurve.h>
#include <geos/geom/LineString.h>
+#include <geos/noding/ArcIntersectionAdder.h>
#include <geos/noding/IteratedNoder.h>
#include <geos/noding/NodableArcString.h>
#include <geos/noding/SimpleNoder.h>
@@ -43,7 +45,6 @@
#include <memory> // for unique_ptr
#include <iostream>
-#include "geos/noding/ArcIntersectionAdder.h"
namespace geos {
namespace noding { // geos.noding
@@ -80,6 +81,10 @@ public:
auto as = std::make_unique<NodableArcString>(std::move(arcs), coords, _constructZ, _constructM, nullptr);
_to.push_back(std::move(as));
+ } else if (const auto* cc = dynamic_cast<const geom::CompoundCurve*>(g)) {
+ for (std::size_t i = 0; i < cc->getNumCurves(); i++) {
+ filter_ro(cc->getCurveN(i));
+ }
}
}
private:
commit 8aa6ee310e49089c5d9e18a0ce7bf6aff1682534
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Apr 8 12:23:08 2026 -0400
CoordinateSequence: add setZM method
diff --git a/include/geos/geom/CoordinateSequence.h b/include/geos/geom/CoordinateSequence.h
index b19b0f5ec..e52849e7f 100644
--- a/include/geos/geom/CoordinateSequence.h
+++ b/include/geos/geom/CoordinateSequence.h
@@ -49,7 +49,7 @@ namespace geom { // geos::geom
* stores 2D Coordinates and accesses using the Coordinate type. Sequences used by these parts
* of the code must be created with constructors without `hasz` and `hasm` arguments.
*
- * If a high-dimension Coordinate coordinate is read from a low-dimension CoordinateSequence,
+ * If a high-dimension coordinate is read from a low-dimension CoordinateSequence,
* the higher dimensions will be populated with incorrect values or a segfault may occur.
*
*/
@@ -221,6 +221,13 @@ public:
return m_hasm;
}
+ /**
+ * Set the dimensions of the CoordinateSequence.
+ * May cause a reallocation, invalidating any references to coordinates
+ * within this sequence.
+ */
+ void setZM(bool hasZ, bool hasM);
+
/// Returns true if contains any two consecutive points
bool hasRepeatedPoints() const;
diff --git a/src/geom/CoordinateSequence.cpp b/src/geom/CoordinateSequence.cpp
index cd97014e3..c5d7a9c8b 100644
--- a/src/geom/CoordinateSequence.cpp
+++ b/src/geom/CoordinateSequence.cpp
@@ -630,6 +630,25 @@ CoordinateSequence::setPoints(const std::vector<CoordinateXY>& v)
}
}
+void
+CoordinateSequence::setZM(bool p_hasZ, bool p_hasM)
+{
+ if (p_hasZ != hasZ() || p_hasM != hasM()) {
+ CoordinateSequence newSeq(0, p_hasZ, p_hasM);
+ newSeq.add(*this);
+ *this = std::move(newSeq);
+ }
+
+ // Make sure we don't carry over Z values that were hiding in a
+ // self-declared 2D sequence.
+ if (!p_hasZ && (getCoordinateType() == CoordinateType::XYZ || getCoordinateType() == CoordinateType::XYZM)) {
+ const Coordinate& nullCoord = Coordinate::getNull();
+ for (std::size_t i = 2; i < m_vect.size(); i += stride()) {
+ m_vect[i] = nullCoord.z;
+ }
+ }
+}
+
void
CoordinateSequence::swap(std::size_t i, std::size_t j)
{
diff --git a/tests/unit/geom/CoordinateSequenceTest.cpp b/tests/unit/geom/CoordinateSequenceTest.cpp
index 89c35ba8d..7fae91aec 100644
--- a/tests/unit/geom/CoordinateSequenceTest.cpp
+++ b/tests/unit/geom/CoordinateSequenceTest.cpp
@@ -1642,4 +1642,37 @@ void object::test<62>
ensure_equals_xyzm(seq.getAt<CoordinateXYZM>(1), p2);
ensure_equals_xyzm(seq.getAt<CoordinateXYZM>(2), p1);
}
+
+template<>
+template<>
+void object::test<63>()
+{
+ set_test_name("setZM: add ZM to XY sequence");
+
+ CoordinateSequence seq(0, false, false);
+ seq.add(CoordinateXY{1, 2});
+ seq.add(CoordinateXY{3, 4});
+ seq.setZM(true, true);
+
+ ensure_equals_xyzm(seq.getAt<CoordinateXYZM>(0), CoordinateXYZM(1, 2, DoubleNotANumber, DoubleNotANumber));
+ ensure_equals_xyzm(seq.getAt<CoordinateXYZM>(1), CoordinateXYZM(3, 4, DoubleNotANumber, DoubleNotANumber));
+}
+
+template<>
+template<>
+void object::test<64>()
+{
+ set_test_name("setZM: remove Z from XY sequence with hidden Z value");
+
+ CoordinateSequence seq(0, false, false);
+ seq.add(CoordinateXY{1, 2});
+ seq.add(Coordinate{3, 4, 5});
+
+ seq.setZM(false, false);
+
+ ensure_equals_xyz(seq.getAt<Coordinate>(0), Coordinate(1, 2, DoubleNotANumber));
+ ensure_equals_xyz(seq.getAt<Coordinate>(1), Coordinate(3, 4, DoubleNotANumber));
+}
+
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
include/geos/geom/CoordinateSequence.h | 9 ++-
.../{PolygonalExtracter.h => LinealExtracter.h} | 23 ++++---
include/geos/io/WKBReader.h | 10 ++++
include/geos/operation/distance/DistanceOp.h | 10 +++-
include/geos/operation/distance/GeometryLocation.h | 10 ++--
src/geom/CoordinateSequence.cpp | 19 ++++++
...{PolygonalExtracter.cpp => LinealExtracter.cpp} | 28 +++++----
src/io/WKBReader.cpp | 7 +++
src/noding/GeometryNoder.cpp | 7 ++-
src/operation/distance/DistanceOp.cpp | 8 +++
src/operation/distance/GeometryLocation.cpp | 12 ++--
tests/unit/geom/CoordinateSequenceTest.cpp | 33 ++++++++++
tests/unit/geom/util/LinealExtracterTest.cpp | 70 ++++++++++++++++++++++
13 files changed, 206 insertions(+), 40 deletions(-)
copy include/geos/geom/util/{PolygonalExtracter.h => LinealExtracter.h} (53%)
copy src/geom/util/{PolygonalExtracter.cpp => LinealExtracter.cpp} (52%)
create mode 100644 tests/unit/geom/util/LinealExtracterTest.cpp
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list