[geos-commits] [SCM] GEOS branch main updated. a02e30f462676831a6241630c87c98ab6c1c2d12
git at osgeo.org
git at osgeo.org
Tue Jan 20 05:33:35 PST 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 a02e30f462676831a6241630c87c98ab6c1c2d12 (commit)
via bf9238fbe0db7473b087492d4de055d936314569 (commit)
via 4e50c4d3c4f5d4b864881930112de7f985624b22 (commit)
from 3dde4d59eb6fc1d142378642e2affde328e57f0d (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 a02e30f462676831a6241630c87c98ab6c1c2d12
Author: Daniel Baston <dbaston at gmail.com>
Date: Mon Jan 19 21:25:56 2026 -0500
GeometryFactory: support curved types in createEmpty, createMulti
diff --git a/src/geom/GeometryFactory.cpp b/src/geom/GeometryFactory.cpp
index 4abc59aac..152dd39a2 100644
--- a/src/geom/GeometryFactory.cpp
+++ b/src/geom/GeometryFactory.cpp
@@ -774,9 +774,14 @@ GeometryFactory::createEmpty(GeometryTypeId typeId) const
case GEOS_POINT: return createPoint();
case GEOS_LINESTRING: return createLineString();
case GEOS_POLYGON: return createPolygon();
+ case GEOS_CIRCULARSTRING: return createCircularString(false, false);
+ case GEOS_COMPOUNDCURVE: return createCompoundCurve();
+ case GEOS_CURVEPOLYGON: return createCurvePolygon(false, false);
case GEOS_MULTIPOINT: return createMultiPoint();
case GEOS_MULTILINESTRING: return createMultiLineString();
case GEOS_MULTIPOLYGON: return createMultiPolygon();
+ case GEOS_MULTICURVE: return createMultiCurve();
+ case GEOS_MULTISURFACE: return createMultiSurface();
case GEOS_GEOMETRYCOLLECTION: return createGeometryCollection();
default:
throw geos::util::IllegalArgumentException("Invalid GeometryTypeId");
@@ -807,6 +812,11 @@ GeometryFactory::createMulti(std::unique_ptr<Geometry> && geom) const
return gf->createMultiLineString(std::move(subgeoms));
case GEOS_POLYGON:
return gf->createMultiPolygon(std::move(subgeoms));
+ case GEOS_CIRCULARSTRING:
+ case GEOS_COMPOUNDCURVE:
+ return gf->createMultiCurve(std::move(subgeoms));
+ case GEOS_CURVEPOLYGON:
+ return gf->createMultiSurface(std::move(subgeoms));
default:
throw geos::util::IllegalArgumentException("Unsupported GeometryTypeId");
}
diff --git a/tests/unit/geom/GeometryFactoryTest.cpp b/tests/unit/geom/GeometryFactoryTest.cpp
index 279ff3580..a0773b21b 100644
--- a/tests/unit/geom/GeometryFactoryTest.cpp
+++ b/tests/unit/geom/GeometryFactoryTest.cpp
@@ -1418,6 +1418,41 @@ void object::test<41>
g2 = reader_.read("MULTIPOINT((1 1))");
ensure_equals_geometry(g2.get(), mg1.get());
ensure_equals_geometry(g2.get(), mg2.get());
+
+ // CircularString
+ {
+ auto cs = factory_->createEmpty(geos::geom::GEOS_CIRCULARSTRING);
+ ensure_equals(cs->getGeometryTypeId(), geos::geom::GEOS_CIRCULARSTRING);
+ ensure_equals(factory_->createMulti(std::move(cs))->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ }
+
+ // CompoundCurve
+ {
+ auto cc = factory_->createEmpty(geos::geom::GEOS_COMPOUNDCURVE);
+ ensure_equals(cc->getGeometryTypeId(), geos::geom::GEOS_COMPOUNDCURVE);
+ ensure_equals(factory_->createMulti(std::move(cc))->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ }
+
+ // CurvePolygon
+ {
+ auto cp = factory_->createEmpty(geos::geom::GEOS_CURVEPOLYGON);
+ ensure_equals(cp->getGeometryTypeId(), geos::geom::GEOS_CURVEPOLYGON);
+ ensure_equals(factory_->createMulti(std::move(cp))->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ }
+
+ // MultiCurve
+ {
+ auto mc = factory_->createEmpty(geos::geom::GEOS_MULTICURVE);
+ ensure_equals(mc->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ ensure_equals(factory_->createMulti(std::move(mc))->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ }
+
+ // MultiSurface
+ {
+ auto ms = factory_->createEmpty(geos::geom::GEOS_MULTISURFACE);
+ ensure_equals(ms->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ ensure_equals(factory_->createMulti(std::move(ms))->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ }
}
commit bf9238fbe0db7473b087492d4de055d936314569
Author: Daniel Baston <dbaston at gmail.com>
Date: Mon Jan 19 21:25:37 2026 -0500
MultiCurve/MultiSurface: fix isCollection result
diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 4701c762e..dedf10022 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -389,7 +389,9 @@ public:
return t == GEOS_GEOMETRYCOLLECTION ||
t == GEOS_MULTIPOINT ||
t == GEOS_MULTILINESTRING ||
- t == GEOS_MULTIPOLYGON;
+ t == GEOS_MULTIPOLYGON ||
+ t == GEOS_MULTICURVE ||
+ t == GEOS_MULTISURFACE;
}
static GeometryTypeId multiTypeId(GeometryTypeId typeId) {
@@ -397,6 +399,9 @@ public:
case GEOS_POINT: return GEOS_MULTIPOINT;
case GEOS_LINESTRING: return GEOS_MULTILINESTRING;
case GEOS_POLYGON: return GEOS_MULTIPOLYGON;
+ case GEOS_CIRCULARSTRING:
+ case GEOS_COMPOUNDCURVE: return GEOS_MULTICURVE;
+ case GEOS_CURVEPOLYGON: return GEOS_MULTISURFACE;
default: return typeId;
}
}
diff --git a/tests/unit/geom/MultiCurveTest.cpp b/tests/unit/geom/MultiCurveTest.cpp
index ec7844c8b..09c79fd12 100644
--- a/tests/unit/geom/MultiCurveTest.cpp
+++ b/tests/unit/geom/MultiCurveTest.cpp
@@ -92,7 +92,7 @@ void object::test<2>()
// Geometry type functions
ensure_equals("getGeometryType", mc_->getGeometryType(), "MultiCurve");
ensure_equals("getGeometryTypdId", mc_->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
- ensure("isCollection", !mc_->isCollection());
+ ensure("isCollection", mc_->isCollection());
// Geometry size functions
ensure("isEmpty", !mc_->isEmpty());
diff --git a/tests/unit/geom/MultiSurfaceTest.cpp b/tests/unit/geom/MultiSurfaceTest.cpp
index 1492f2279..58c6ae524 100644
--- a/tests/unit/geom/MultiSurfaceTest.cpp
+++ b/tests/unit/geom/MultiSurfaceTest.cpp
@@ -81,7 +81,7 @@ void object::test<2>()
// Geometry type functions
ensure_equals("getGeometryType", ms_->getGeometryType(), "MultiSurface");
ensure_equals("getGeometryTypdId", ms_->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
- ensure("isCollection", !ms_->isCollection());
+ ensure("isCollection", ms_->isCollection());
// Geometry size functions
ensure("isEmpty", !ms_->isEmpty());
commit 4e50c4d3c4f5d4b864881930112de7f985624b22
Author: Daniel Baston <dbaston at gmail.com>
Date: Mon Jan 19 20:49:06 2026 -0500
GeometryFactory: support curved types in buildGeometry()
diff --git a/include/geos/geom/GeometryFactory.h b/include/geos/geom/GeometryFactory.h
index 4dfe6b593..4b5dba01f 100644
--- a/include/geos/geom/GeometryFactory.h
+++ b/include/geos/geom/GeometryFactory.h
@@ -197,6 +197,10 @@ public:
/// Construct an EMPTY MultiCurve
std::unique_ptr<MultiCurve> createMultiCurve() const;
+ /// Construct a MultiCurve with a deep-copy of given arguments
+ std::unique_ptr<MultiCurve> createMultiCurve(
+ const std::vector<const Geometry*>& from) const;
+
/// Construct a MultiCurve taking ownership of given arguments
std::unique_ptr<MultiCurve> createMultiCurve(
std::vector<std::unique_ptr<Geometry>> && fromCurves) const;
@@ -221,6 +225,10 @@ public:
/// Construct an EMPTY MultiSurface
std::unique_ptr<MultiSurface> createMultiSurface() const;
+ /// Construct a MultiSurface with a deep-copy of given arguments
+ std::unique_ptr<MultiSurface> createMultiSurface(
+ const std::vector<const Geometry*>& from) const;
+
/// Construct a MultiSurface taking ownership of given arguments
std::unique_ptr<MultiSurface> createMultiSurface(
std::vector<std::unique_ptr<Geometry>> && from) const;
diff --git a/src/geom/GeometryFactory.cpp b/src/geom/GeometryFactory.cpp
index 458fbe8e1..4abc59aac 100644
--- a/src/geom/GeometryFactory.cpp
+++ b/src/geom/GeometryFactory.cpp
@@ -321,6 +321,20 @@ GeometryFactory::createMultiCurve() const {
return createMultiCurve(std::vector<std::unique_ptr<Curve>>());
}
+/*public*/
+std::unique_ptr<MultiCurve>
+GeometryFactory::createMultiCurve(const std::vector<const Geometry*>& fromCurves)
+const
+{
+ std::vector<std::unique_ptr<Geometry>> newGeoms(fromCurves.size());
+
+ for(std::size_t i = 0; i < fromCurves.size(); i++) {
+ newGeoms[i]= fromCurves[i]->clone(); // MultiCurve constructor will check that it's actually a Curve
+ }
+
+ return createMultiCurve(std::move(newGeoms));
+}
+
std::unique_ptr<MultiCurve>
GeometryFactory::createMultiCurve(std::vector<std::unique_ptr<Curve>> && fromCurves) const {
// Can't use make_unique because constructor is protected
@@ -433,6 +447,19 @@ GeometryFactory::createMultiSurface(std::vector<std::unique_ptr<Surface>> && new
return std::unique_ptr<MultiSurface>(new MultiSurface(std::move(newSurfaces), *this));
}
+/*public*/
+std::unique_ptr<MultiSurface>
+GeometryFactory::createMultiSurface(const std::vector<const Geometry*>& from) const
+{
+ std::vector<std::unique_ptr<Geometry>> newGeoms(from.size());
+
+ for(std::size_t i = 0; i < from.size(); i++) {
+ newGeoms[i] = from[i]->clone(); // MultiSurface constructor will check that it's actually a Surface
+ }
+
+ return createMultiSurface(std::move(newGeoms));
+}
+
/*public*/
std::unique_ptr<LinearRing>
GeometryFactory::createLinearRing(std::size_t coordinateDimension) const
@@ -795,18 +822,25 @@ GeometryTypeId commonType(const T& geoms) {
return geoms[0]->getGeometryTypeId();
}
- GeometryTypeId type = geoms[0]->getGeometryTypeId();
+ bool hasCurvedComponents = geoms[0]->hasCurvedComponents();
+
+ const Dimension::DimensionType dim = geoms[0]->getDimension();
for (std::size_t i = 1; i < geoms.size(); i++) {
- if (geoms[i]->getGeometryTypeId() != type) {
+ hasCurvedComponents |= geoms[i]->hasCurvedComponents();
+
+ if (geoms[i]->getDimension() != dim) {
return GEOS_GEOMETRYCOLLECTION;
}
}
switch(geoms[0]->getGeometryTypeId()) {
case GEOS_POINT: return GEOS_MULTIPOINT;
+ case GEOS_COMPOUNDCURVE:
+ case GEOS_CIRCULARSTRING: return GEOS_MULTICURVE;
case GEOS_LINEARRING:
- case GEOS_LINESTRING: return GEOS_MULTILINESTRING;
- case GEOS_POLYGON: return GEOS_MULTIPOLYGON;
+ case GEOS_LINESTRING: return hasCurvedComponents ? GEOS_MULTICURVE : GEOS_MULTILINESTRING;
+ case GEOS_CURVEPOLYGON: return GEOS_MULTISURFACE;
+ case GEOS_POLYGON: return hasCurvedComponents ? GEOS_MULTISURFACE : GEOS_MULTIPOLYGON;
default: return GEOS_GEOMETRYCOLLECTION;
}
}
@@ -826,8 +860,10 @@ GeometryFactory::buildGeometry(std::vector<std::unique_ptr<Geometry>> && geoms)
switch(resultType) {
case GEOS_MULTIPOINT: return createMultiPoint(std::move(geoms));
+ case GEOS_MULTICURVE: return createMultiCurve(std::move(geoms));
case GEOS_MULTILINESTRING: return createMultiLineString(std::move(geoms));
case GEOS_MULTIPOLYGON: return createMultiPolygon(std::move(geoms));
+ case GEOS_MULTISURFACE: return createMultiSurface(std::move(geoms));
default: return createGeometryCollection(std::move(geoms));
}
}
@@ -890,8 +926,10 @@ GeometryFactory::buildGeometry(const std::vector<const Geometry*>& fromGeoms) co
switch(resultType) {
case GEOS_MULTIPOINT: return createMultiPoint(fromGeoms);
+ case GEOS_MULTICURVE: return createMultiCurve(fromGeoms);
case GEOS_MULTILINESTRING: return createMultiLineString(fromGeoms);
case GEOS_MULTIPOLYGON: return createMultiPolygon(fromGeoms);
+ case GEOS_MULTISURFACE: return createMultiSurface(fromGeoms);
default: return createGeometryCollection(fromGeoms);
}
}
diff --git a/tests/unit/geom/GeometryFactoryTest.cpp b/tests/unit/geom/GeometryFactoryTest.cpp
index 9cc8b659a..279ff3580 100644
--- a/tests/unit/geom/GeometryFactoryTest.cpp
+++ b/tests/unit/geom/GeometryFactoryTest.cpp
@@ -1092,24 +1092,128 @@ void object::test<33>
//inform("Test not implemented!");
}
-// Test of buildGeometry(std::vector<Geometry*>* geoms) const
template<>
template<>
void object::test<34>
()
{
- // TODO - mloskot
- //inform("Test not implemented!");
+ set_test_name("GeometryFactory::buildGeometry(std::vector<std::unique_ptr<Geometry>>&&)");
+
+ auto line = reader_.read("LINESTRING(0 0, 10 10)");
+ auto point = reader_.read("POINT (3 2)");
+ auto poly = reader_.read("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+ auto circstring = reader_.read("CIRCULARSTRING(0 0, 1 1, 2 0)");
+ auto curvepoly = reader_.read("CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 2 0), (2 0, 0 0)))");
+
+ // GeometryCollection
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(line->clone());
+ geoms.push_back(point->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION);
+ }
+
+ // MultiPoint
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(point->clone());
+ geoms.push_back(point->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+ }
+
+ // MultiCurve
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(line->clone());
+ geoms.push_back(circstring->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ }
+
+ // MultiLineString
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(line->clone());
+ geoms.push_back(line->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+ }
+
+ // MultiPolygon
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(poly->clone());
+ geoms.push_back(poly->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_MULTIPOLYGON);
+ }
+
+ // MultiSurface
+ {
+ std::vector<std::unique_ptr<Geometry>> geoms;
+ geoms.push_back(poly->clone());
+ geoms.push_back(curvepoly->clone());
+ ensure_equals(factory_->buildGeometry(std::move(geoms))->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ }
}
-// Test of buildGeometry(const std::vector<Geometry*>& geoms)
template<>
template<>
void object::test<35>
()
{
- // TODO - mloskot
- //inform("Test not implemented!");
+ set_test_name("GeometryFactory::buildGeometry(const std::vector<const Geometry*>&)");
+
+ auto line = reader_.read("LINESTRING(0 0, 10 10)");
+ auto point = reader_.read("POINT (3 2)");
+ auto poly = reader_.read("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+ auto circstring = reader_.read("CIRCULARSTRING(0 0, 1 1, 2 0)");
+ auto curvepoly = reader_.read("CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 2 0), (2 0, 0 0)))");
+
+ // GeometryCollection
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(line.get());
+ geoms.push_back(point.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION);
+ }
+
+ // MultiPoint
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(point.get());
+ geoms.push_back(point.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_MULTIPOINT);
+ }
+
+ // MultiCurve
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(line.get());
+ geoms.push_back(circstring.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_MULTICURVE);
+ }
+
+ // MultiLineString
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(line.get());
+ geoms.push_back(line.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING);
+ }
+
+ // MultiPolygon
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(poly.get());
+ geoms.push_back(poly.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_MULTIPOLYGON);
+ }
+
+ // MultiSurface
+ {
+ std::vector<const Geometry*> geoms;
+ geoms.push_back(poly.get());
+ geoms.push_back(curvepoly.get());
+ ensure_equals(factory_->buildGeometry(geoms)->getGeometryTypeId(), geos::geom::GEOS_MULTISURFACE);
+ }
}
// Test of
-----------------------------------------------------------------------
Summary of changes:
include/geos/geom/Geometry.h | 7 +-
include/geos/geom/GeometryFactory.h | 8 ++
src/geom/GeometryFactory.cpp | 56 +++++++++++-
tests/unit/geom/GeometryFactoryTest.cpp | 151 ++++++++++++++++++++++++++++++--
tests/unit/geom/MultiCurveTest.cpp | 2 +-
tests/unit/geom/MultiSurfaceTest.cpp | 2 +-
6 files changed, 213 insertions(+), 13 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list