[geos-commits] [SCM] GEOS branch main updated. 5ab8087560e2b01273dd2835b502e9a0d033305f
git at osgeo.org
git at osgeo.org
Tue Apr 11 18:34:46 PDT 2023
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 5ab8087560e2b01273dd2835b502e9a0d033305f (commit)
via 98ab44a8251d6a0eba2d7d419580d3226a4a4a77 (commit)
via f8d92f8460dd452292c070c15908ea326a3de559 (commit)
from dd92d34f74fdda129fa0f1c32ee65d323cd471fb (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 5ab8087560e2b01273dd2835b502e9a0d033305f
Author: Mike Taves <mwtoews at gmail.com>
Date: Wed Apr 12 13:34:20 2023 +1200
Add Point::getM() to C++ API and GEOSGeomGetM to C API (#864)
* Add GEOSGeomGetM (and GEOSGeomGetM_r) to C API
* Add Point::getM() to C++ API
* Refactor Point::getZ() to use CoordianteSequence::getOrdinate(0, CoordinateSequence::Z)
* Rename GEOSGeomGetXYZTest.cpp to GEOSGeomGetXYZMTest.cpp
* CoordinateSequence: Fix getOrdinate for XYM-backed sequence
---------
Co-authored-by: Daniel Baston <dbaston at gmail.com>
diff --git a/NEWS.md b/NEWS.md
index f0eac88a8..5cdf51ad1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -17,6 +17,7 @@ xxxx-xx-xx
- CAPI: GEOSEqualsIdentical (GH-810, Dan Baston)
- CAPI: GEOSSTRtree_build (GH-835, Dan Baston)
- CAPI: GEOSConcaveHullByLength (GH-849, Martin Davis)
+ - CAPI: GEOSGeomGetM (GH-864, Mike Taves)
- Voronoi: Add option to create diagram in order consistent with inputs (GH-781, Dan Baston)
- Fixes/Improvements:
diff --git a/capi/geos_c.cpp b/capi/geos_c.cpp
index 7f77e5d3a..f67db11c2 100644
--- a/capi/geos_c.cpp
+++ b/capi/geos_c.cpp
@@ -794,6 +794,16 @@ extern "C" {
return GEOSGeomGetZ_r(handle, g1, z);
}
+ /*
+ * For POINT
+ * returns 0 on exception, otherwise 1
+ */
+ int
+ GEOSGeomGetM(const Geometry* g1, double* m)
+ {
+ return GEOSGeomGetM_r(handle, g1, m);
+ }
+
/*
* Call only on polygon
* Return a copy of the internal Geometry.
diff --git a/capi/geos_c.h.in b/capi/geos_c.h.in
index 40985aa86..a1cb103a0 100644
--- a/capi/geos_c.h.in
+++ b/capi/geos_c.h.in
@@ -1559,6 +1559,12 @@ extern int GEOS_DLL GEOSGeomGetZ_r(
const GEOSGeometry *g,
double *z);
+/** \see GEOSGeomGetM */
+extern int GEOS_DLL GEOSGeomGetM_r(
+ GEOSContextHandle_t handle,
+ const GEOSGeometry *g,
+ double *m);
+
/** \see GEOSGetInteriorRingN */
extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
GEOSContextHandle_t handle,
@@ -2558,6 +2564,17 @@ extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
*/
extern int GEOS_DLL GEOSGeomGetZ(const GEOSGeometry *g, double *z);
+/**
+* Returns the M coordinate, for a Point input, or an
+* exception otherwise.
+* \param[in] g Input Point geometry
+* \param[out] m Pointer to hold return value
+* \returns 1 on success, 0 on exception
+*
+* \since 3.12
+*/
+extern int GEOS_DLL GEOSGeomGetM(const GEOSGeometry *g, double *m);
+
/**
* Returns the N'th ring for a Polygon input.
* \note Returned object is a pointer to internal storage:
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 922eebf23..facefb9e3 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -1862,6 +1862,25 @@ extern "C" {
});
}
+ /*
+ * For POINT
+ * returns 0 on exception, otherwise 1
+ */
+ int
+ GEOSGeomGetM_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* m)
+ {
+ using geos::geom::Point;
+
+ return execute(extHandle, 0, [&]() {
+ const Point* po = dynamic_cast<const Point*>(g1);
+ if(!po) {
+ throw IllegalArgumentException("Argument is not a Point");
+ }
+ *m = po->getM();
+ return 1;
+ });
+ }
+
/*
* Call only on polygon
* Return a pointer to the internal Geometry.
diff --git a/include/geos/geom/Point.h b/include/geos/geom/Point.h
index f03abba45..cc944d972 100644
--- a/include/geos/geom/Point.h
+++ b/include/geos/geom/Point.h
@@ -129,6 +129,7 @@ public:
double getX() const;
double getY() const;
double getZ() const;
+ double getM() const;
std::string getGeometryType() const override;
GeometryTypeId getGeometryTypeId() const override;
diff --git a/src/geom/CoordinateSequence.cpp b/src/geom/CoordinateSequence.cpp
index 237a17145..a0ff67944 100644
--- a/src/geom/CoordinateSequence.cpp
+++ b/src/geom/CoordinateSequence.cpp
@@ -289,7 +289,9 @@ CoordinateSequence::getOrdinate(std::size_t index, std::size_t ordinateIndex) co
case CoordinateSequence::Z:
return hasZ() ? getAt<Coordinate>(index).z : DoubleNotANumber;
case CoordinateSequence::M:
- return hasM() ? (hasZ() ? getAt<CoordinateXYZM>(index).m : getAt<CoordinateXYM>(index).m) : DoubleNotANumber;
+ return getCoordinateType() == CoordinateType::XYZM ? getAt<CoordinateXYZM>(index).m :
+ getCoordinateType() == CoordinateType::XYM ? getAt<CoordinateXYM>(index).m :
+ DoubleNotANumber;
default:
return DoubleNotANumber;
}
diff --git a/src/geom/Point.cpp b/src/geom/Point.cpp
index 897d28a9a..86cf54ccc 100644
--- a/src/geom/Point.cpp
+++ b/src/geom/Point.cpp
@@ -177,7 +177,16 @@ Point::getZ() const
if(isEmpty()) {
throw util::UnsupportedOperationException("getZ called on empty Point\n");
}
- return coordinates.getAt<Coordinate>(0).z;
+ return coordinates.getOrdinate(0, CoordinateSequence::Z);
+}
+
+double
+Point::getM() const
+{
+ if(isEmpty()) {
+ throw util::UnsupportedOperationException("getM called on empty Point\n");
+ }
+ return coordinates.getOrdinate(0, CoordinateSequence::M);
}
std::string
diff --git a/tests/unit/capi/GEOSGeomGetXYZTest.cpp b/tests/unit/capi/GEOSGeomGetXYZMTest.cpp
similarity index 53%
rename from tests/unit/capi/GEOSGeomGetXYZTest.cpp
rename to tests/unit/capi/GEOSGeomGetXYZMTest.cpp
index 5fd07ea81..38c33fc48 100644
--- a/tests/unit/capi/GEOSGeomGetXYZTest.cpp
+++ b/tests/unit/capi/GEOSGeomGetXYZMTest.cpp
@@ -9,12 +9,12 @@ namespace tut {
// Test Group
//
-struct test_geosgeomgetxyz_data : public capitest::utility {};
+struct test_geosgeomgetxyzm_data : public capitest::utility {};
-typedef test_group<test_geosgeomgetxyz_data> group;
+typedef test_group<test_geosgeomgetxyzm_data> group;
typedef group::object object;
-group test_geosgeomgetxyz("capi::GEOSGeomGetXYZ");
+group test_geosgeomgetxyzm("capi::GEOSGeomGetXYZM");
template<>
template<>
@@ -24,55 +24,96 @@ void object::test<1>()
double x = 0;
double y = 0;
double z = 0;
+ double m = 0;
ensure_equals(GEOSGeomGetX(input_, &x), 1);
ensure_equals(GEOSGeomGetY(input_, &y), 1);
ensure_equals(GEOSGeomGetZ(input_, &z), 1);
+ ensure_equals(GEOSGeomGetM(input_, &m), 1);
ensure_equals(x, 1);
ensure_equals(y, 2);
ensure(std::isnan(z));
+ ensure(std::isnan(m));
}
template<>
template<>
void object::test<2>()
{
- input_ = GEOSGeomFromWKT("POINT (1 2 3)");
+ input_ = GEOSGeomFromWKT("POINT Z (1 2 3)");
double z = 0;
+ double m = 0;
ensure_equals(GEOSGeomGetZ(input_, &z), 1);
+ ensure_equals(GEOSGeomGetM(input_, &m), 1);
+
ensure_equals(z, 3);
+ ensure(std::isnan(m));
}
template<>
template<>
void object::test<3>()
+{
+ input_ = GEOSGeomFromWKT("POINT M (1 2 4)");
+ double z = 0;
+ double m = 0;
+
+ ensure_equals(GEOSGeomGetZ(input_, &z), 1);
+ ensure_equals(GEOSGeomGetM(input_, &m), 1);
+
+ ensure(std::isnan(z));
+ ensure_equals(m, 4);
+}
+
+template<>
+template<>
+void object::test<4>()
+{
+ input_ = GEOSGeomFromWKT("POINT ZM (1 2 3 4)");
+ double z = 0;
+ double m = 0;
+
+ ensure_equals(GEOSGeomGetZ(input_, &z), 1);
+ ensure_equals(GEOSGeomGetM(input_, &m), 1);
+
+ ensure_equals(z, 3);
+ ensure_equals(m, 4);
+}
+
+template<>
+template<>
+void object::test<5>()
{
input_ = GEOSGeomFromWKT("POINT EMPTY");
double x = 0;
double y = 0;
double z = 0;
+ double m = 0;
ensure_equals(GEOSGeomGetX(input_, &x), 0);
ensure_equals(GEOSGeomGetY(input_, &y), 0);
ensure_equals(GEOSGeomGetZ(input_, &z), 0);
+ ensure_equals(GEOSGeomGetM(input_, &m), 0);
}
template<>
template<>
-void object::test<4>()
+void object::test<6>()
{
input_ = GEOSGeomFromWKT("LINESTRING (1 1, 2 2)");
double x = 0;
double y = 0;
double z = 0;
+ double m = 0;
ensure_equals(GEOSGeomGetX(input_, &x), 0);
ensure_equals(GEOSGeomGetY(input_, &y), 0);
ensure_equals(GEOSGeomGetZ(input_, &z), 0);
+ ensure_equals(GEOSGeomGetM(input_, &m), 0);
}
diff --git a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
index 57c7e7ffa..9f3eda5a1 100644
--- a/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getCoordinateDimensionTest.cpp
@@ -22,11 +22,11 @@ void object::test<1>
()
{
GEOSGeometry* point = GEOSGeomFromWKT("POINT (4 2 7)");
- GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7, 8 2 9)");
+ GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
GEOSGeometry* poly = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
ensure_equals(GEOSGeom_getCoordinateDimension(point), 3);
- ensure_equals(GEOSGeom_getCoordinateDimension(line), 3);
+ ensure_equals(GEOSGeom_getCoordinateDimension(line), 4);
ensure_equals(GEOSGeom_getCoordinateDimension(poly), 2);
GEOSGeom_destroy(point);
diff --git a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
index 79686b026..d81d1d2d4 100644
--- a/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
+++ b/tests/unit/capi/GEOSGeom_getDimensionsTest.cpp
@@ -22,7 +22,7 @@ void object::test<1>
()
{
GEOSGeometry* point = GEOSGeomFromWKT("POINT (4 2 7)");
- GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7, 8 2 9)");
+ GEOSGeometry* line = GEOSGeomFromWKT("LINESTRING (4 2 7 1, 8 2 9 5)");
GEOSGeometry* poly = GEOSGeomFromWKT("POLYGON ((0 0, 1 0, 1 1, 0 0))");
ensure_equals(GEOSGeom_getDimensions(point), 0);
diff --git a/tests/unit/geom/CoordinateSequenceTest.cpp b/tests/unit/geom/CoordinateSequenceTest.cpp
index 3edce6068..7ec843bad 100644
--- a/tests/unit/geom/CoordinateSequenceTest.cpp
+++ b/tests/unit/geom/CoordinateSequenceTest.cpp
@@ -1258,25 +1258,68 @@ void object::test<47>
ensure_equals(seq.getDimension(), 2u);
}
-// Test getOrinate
+// Test getOrdinate
template<>
template<>
void object::test<48>
()
{
- CoordinateSequence seq{CoordinateXY(1, 2), CoordinateXY(3, 4)};
+ {
+ CoordinateSequence seq_xy{CoordinateXY(1, 2), CoordinateXY(3, 4)};
+
+ ensure_same(seq_xy.getOrdinate(0, CoordinateSequence::X), 1);
+ ensure_same(seq_xy.getOrdinate(0, CoordinateSequence::Y), 2);
+ ensure_same(seq_xy.getOrdinate(0, CoordinateSequence::Z), DoubleNotANumber);
+ ensure_same(seq_xy.getOrdinate(0, CoordinateSequence::M), DoubleNotANumber);
+
+ ensure_same(seq_xy.getOrdinate(1, CoordinateSequence::X), 3);
+ ensure_same(seq_xy.getOrdinate(1, CoordinateSequence::Y), 4);
+ ensure_same(seq_xy.getOrdinate(1, CoordinateSequence::Z), DoubleNotANumber);
+ ensure_same(seq_xy.getOrdinate(1, CoordinateSequence::M), DoubleNotANumber);
+ }
+
+ {
+ CoordinateSequence seq_xym{CoordinateXYM(1, 2, 3), CoordinateXYM(4, 5, 6)};
+
+ ensure_same(seq_xym.getOrdinate(0, CoordinateSequence::X), 1);
+ ensure_same(seq_xym.getOrdinate(0, CoordinateSequence::Y), 2);
+ ensure_same(seq_xym.getOrdinate(0, CoordinateSequence::Z), DoubleNotANumber);
+ ensure_same(seq_xym.getOrdinate(0, CoordinateSequence::M), 3);
- ensure_same(seq.getOrdinate(0, CoordinateSequence::Y), 2);
- ensure_same(seq.getOrdinate(1, CoordinateSequence::X), 3);
- ensure_same(seq.getOrdinate(1, CoordinateSequence::Z), DoubleNotANumber);
- ensure_same(seq.getOrdinate(1, CoordinateSequence::M), DoubleNotANumber);
+ ensure_same(seq_xym.getOrdinate(1, CoordinateSequence::X), 4);
+ ensure_same(seq_xym.getOrdinate(1, CoordinateSequence::Y), 5);
+ ensure_same(seq_xym.getOrdinate(1, CoordinateSequence::Z), DoubleNotANumber);
+ ensure_same(seq_xym.getOrdinate(1, CoordinateSequence::M), 6);
+ }
+
+ {
+ CoordinateSequence seq_xyz{Coordinate(1, 2, 3), Coordinate(4, 5, 6)};
- CoordinateSequence seq2{CoordinateXYZM(1, 2, 3, 4)};
+ ensure_same(seq_xyz.getOrdinate(0, CoordinateSequence::X), 1);
+ ensure_same(seq_xyz.getOrdinate(0, CoordinateSequence::Y), 2);
+ ensure_same(seq_xyz.getOrdinate(0, CoordinateSequence::Z), 3);
+ ensure_same(seq_xyz.getOrdinate(0, CoordinateSequence::M), DoubleNotANumber);
- ensure_same(seq2.getOrdinate(0, CoordinateSequence::X), 1);
- ensure_same(seq2.getOrdinate(0, CoordinateSequence::Y), 2);
- ensure_same(seq2.getOrdinate(0, CoordinateSequence::Z), 3);
- ensure_same(seq2.getOrdinate(0, CoordinateSequence::M), 4);
+ ensure_same(seq_xyz.getOrdinate(1, CoordinateSequence::X), 4);
+ ensure_same(seq_xyz.getOrdinate(1, CoordinateSequence::Y), 5);
+ ensure_same(seq_xyz.getOrdinate(1, CoordinateSequence::Z), 6);
+ ensure_same(seq_xyz.getOrdinate(1, CoordinateSequence::M), DoubleNotANumber);
+ }
+
+ {
+ CoordinateSequence seq_xyzm{CoordinateXYZM(1, 2, 3, 4), CoordinateXYZM(5, 6, 7, 8)};
+
+ ensure_same(seq_xyzm.getOrdinate(0, CoordinateSequence::X), 1);
+ ensure_same(seq_xyzm.getOrdinate(0, CoordinateSequence::Y), 2);
+ ensure_same(seq_xyzm.getOrdinate(0, CoordinateSequence::Z), 3);
+ ensure_same(seq_xyzm.getOrdinate(0, CoordinateSequence::M), 4);
+
+ ensure_same(seq_xyzm.getOrdinate(1, CoordinateSequence::X), 5);
+ ensure_same(seq_xyzm.getOrdinate(1, CoordinateSequence::Y), 6);
+ ensure_same(seq_xyzm.getOrdinate(1, CoordinateSequence::Z), 7);
+ ensure_same(seq_xyzm.getOrdinate(1, CoordinateSequence::M), 8);
+
+ }
}
// Test setOrdinate
commit 98ab44a8251d6a0eba2d7d419580d3226a4a4a77
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Apr 11 15:07:43 2023 -0700
Remove unneeded aliases in CAPI
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 8ed5798a0..922eebf23 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -155,17 +155,18 @@ using geos::geom::Coordinate;
using geos::geom::CoordinateXY;
using geos::geom::CoordinateXYM;
using geos::geom::CoordinateXYZM;
+using geos::geom::CoordinateSequence;
+using geos::geom::Envelope;
using geos::geom::Geometry;
+using geos::geom::GeometryCollection;
+using geos::geom::GeometryFactory;
using geos::geom::LineString;
using geos::geom::LinearRing;
using geos::geom::MultiLineString;
using geos::geom::MultiPolygon;
+using geos::geom::Point;
using geos::geom::Polygon;
using geos::geom::PrecisionModel;
-using geos::geom::CoordinateSequence;
-using geos::geom::GeometryCollection;
-using geos::geom::GeometryFactory;
-using geos::geom::Envelope;
using geos::io::WKTReader;
using geos::io::WKTWriter;
@@ -195,8 +196,6 @@ using geos::simplify::PolygonHullSimplifier;
using geos::util::IllegalArgumentException;
-typedef std::unique_ptr<Geometry> GeomPtr;
-
typedef struct GEOSContextHandle_HS {
const GeometryFactory* geomFactory;
char msgBuffer[1024];
@@ -209,7 +208,7 @@ typedef struct GEOSContextHandle_HS {
uint8_t WKBOutputDims;
int WKBByteOrder;
int initialized;
- std::unique_ptr<geos::geom::Point> point2d;
+ std::unique_ptr<Point> point2d;
GEOSContextHandle_HS()
:
@@ -224,7 +223,7 @@ typedef struct GEOSContextHandle_HS {
{
memset(msgBuffer, 0, sizeof(msgBuffer));
geomFactory = GeometryFactory::getDefaultInstance();
- point2d = geomFactory->createPoint(geos::geom::CoordinateXY{0, 0});
+ point2d = geomFactory->createPoint(CoordinateXY{0, 0});
WKBOutputDims = 2;
WKBByteOrder = getMachineByteOrder();
setNoticeHandler(nullptr);
@@ -1099,8 +1098,6 @@ extern "C" {
GEOSIntersectionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
{
return execute(extHandle, [&]() {
- using geos::geom::PrecisionModel;
-
std::unique_ptr<PrecisionModel> pm;
if(gridSize != 0) {
pm.reset(new PrecisionModel(1.0 / gridSize));
@@ -1515,7 +1512,7 @@ extern "C" {
GEOSUnaryUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
{
return execute(extHandle, [&]() {
- GeomPtr g3(g->Union());
+ std::unique_ptr<Geometry> g3(g->Union());
g3->setSRID(g->getSRID());
return g3.release();
});
@@ -1559,7 +1556,7 @@ extern "C" {
// CascadedUnion is the same as UnaryUnion, except that
// CascadedUnion only works on MultiPolygon, so we just delegate
// now and retain a check on MultiPolygon type.
- const geos::geom::MultiPolygon *p = dynamic_cast<const geos::geom::MultiPolygon *>(g1);
+ const MultiPolygon *p = dynamic_cast<const MultiPolygon *>(g1);
if (!p) {
throw IllegalArgumentException("Invalid argument (must be a MultiPolygon)");
}
@@ -1599,7 +1596,7 @@ extern "C" {
m_callback(p_callback),
m_userdata(p_userdata) {}
- void filter_rw(geos::geom::CoordinateXY* c) const final {
+ void filter_rw(CoordinateXY* c) const final {
if (!m_callback(&(c->x), &(c->y), m_userdata)) {
throw std::runtime_error(std::string("Failed to transform coordinates."));
}
@@ -1717,8 +1714,6 @@ extern "C" {
Geometry*
GEOSGeomGetPointN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
{
- using geos::geom::LineString;
-
return execute(extHandle, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(!ls) {
@@ -1737,8 +1732,6 @@ extern "C" {
Geometry*
GEOSGeomGetStartPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
{
- using geos::geom::LineString;
-
return execute(extHandle, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(!ls) {
@@ -1755,8 +1748,6 @@ extern "C" {
Geometry*
GEOSGeomGetEndPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
{
- using geos::geom::LineString;
-
return execute(extHandle, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(!ls) {
@@ -1773,9 +1764,6 @@ extern "C" {
char
GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry* g1)
{
- using geos::geom::LineString;
- using geos::geom::MultiLineString;
-
return execute(extHandle, 2, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(ls) {
@@ -1798,8 +1786,6 @@ extern "C" {
int
GEOSGeomGetLength_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* length)
{
- using geos::geom::LineString;
-
return execute(extHandle, 0, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(!ls) {
@@ -1816,8 +1802,6 @@ extern "C" {
int
GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1)
{
- using geos::geom::LineString;
-
return execute(extHandle, -1, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g1);
if(!ls) {
@@ -1834,8 +1818,6 @@ extern "C" {
int
GEOSGeomGetX_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* x)
{
- using geos::geom::Point;
-
return execute(extHandle, 0, [&]() {
const Point* po = dynamic_cast<const Point*>(g1);
if(!po) {
@@ -1853,8 +1835,6 @@ extern "C" {
int
GEOSGeomGetY_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* y)
{
- using geos::geom::Point;
-
return execute(extHandle, 0, [&]() {
const Point* po = dynamic_cast<const Point*>(g1);
if(!po) {
@@ -1872,8 +1852,6 @@ extern "C" {
int
GEOSGeomGetZ_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* z)
{
- using geos::geom::Point;
-
return execute(extHandle, 0, [&]() {
const Point* po = dynamic_cast<const Point*>(g1);
if(!po) {
@@ -1937,7 +1915,7 @@ extern "C" {
using geos::shape::fractal::HilbertEncoder;
return execute(extHandle, 0, [&]() {
- geos::geom::Envelope e = *extent->getEnvelopeInternal();
+ Envelope e = *extent->getEnvelopeInternal();
HilbertEncoder encoder(level, e);
*code = encoder.encode(geom->getEnvelopeInternal());
return 1;
@@ -2462,17 +2440,17 @@ extern "C" {
if (hasM) {
// XYZM
assert(coords->getCoordinateType() == geos::geom::CoordinateType::XYZM);
- std::memcpy(coords->data(), buf, size * sizeof(geos::geom::CoordinateXYZM));
+ std::memcpy(coords->data(), buf, size * sizeof(CoordinateXYZM));
} else {
// XYZ
assert(coords->getCoordinateType() == geos::geom::CoordinateType::XYZ);
- std::memcpy(coords->data(), buf, size * sizeof(geos::geom::Coordinate));
+ std::memcpy(coords->data(), buf, size * sizeof(Coordinate));
}
} else {
if (hasM) {
// XYM
for (std::size_t i = 0; i < size; i++) {
- coords->setAt(geos::geom::CoordinateXYM{ *buf, *(buf + 1), *(buf + 2)}, i);
+ coords->setAt(CoordinateXYM{ *buf, *(buf + 1), *(buf + 2)}, i);
buf += stride;
}
} else {
@@ -2497,7 +2475,7 @@ extern "C" {
auto coords = geos::detail::make_unique<geos::geom::CoordinateSequence>(size, hasZ, hasM, false);
- geos::geom::CoordinateXYZM c;
+ CoordinateXYZM c;
for (std::size_t i = 0; i < size; i++) {
c.x = x[i];
c.y = y[i];
@@ -2520,7 +2498,7 @@ extern "C" {
double* x, double* y, double* z, double* m)
{
return execute(extHandle, 0, [&]() {
- geos::geom::CoordinateXYZM c;
+ CoordinateXYZM c;
for (std::size_t i = 0; i < cs->size(); i++) {
cs->getAt(i, c);
x[i] = c.x;
@@ -2750,8 +2728,6 @@ extern "C" {
const CoordinateSequence*
GEOSGeom_getCoordSeq_r(GEOSContextHandle_t extHandle, const Geometry* g)
{
- using geos::geom::Point;
-
return execute(extHandle, [&]() {
const LineString* ls = dynamic_cast<const LineString*>(g);
if(ls) {
@@ -2795,7 +2771,7 @@ extern "C" {
GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
const GeometryFactory* gf = handle->geomFactory;
- geos::geom::CoordinateXY c(x, y);
+ CoordinateXY c(x, y);
return gf->createPoint(c).release();
});
}
@@ -2846,8 +2822,6 @@ extern "C" {
Geometry*
GEOSGeom_createPolygon_r(GEOSContextHandle_t extHandle, Geometry* shell, Geometry** holes, unsigned int nholes)
{
- using geos::geom::LinearRing;
-
return execute(extHandle, [&]() {
GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
const GeometryFactory* gf = handle->geomFactory;
@@ -2901,7 +2875,7 @@ extern "C" {
return execute(extHandle, [&]() {
GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
const GeometryFactory* gf = handle->geomFactory;
- geos::geom::Envelope env(xmin, xmax, ymin, ymax);
+ Envelope env(xmin, xmax, ymin, ymax);
return (gf->toGeometry(&env)).release();
});
}
@@ -3074,8 +3048,6 @@ extern "C" {
WKTReader*
GEOSWKTReader_create_r(GEOSContextHandle_t extHandle)
{
- using geos::io::WKTReader;
-
return execute(extHandle, [&]() {
GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
return new WKTReader((GeometryFactory *) handle->geomFactory);
@@ -3811,7 +3783,6 @@ extern "C" {
int GEOSOrientationIndex_r(GEOSContextHandle_t extHandle,
double Ax, double Ay, double Bx, double By, double Px, double Py)
{
- using geos::geom::Coordinate;
using geos::algorithm::Orientation;
return execute(extHandle, 2, [&]() {
commit f8d92f8460dd452292c070c15908ea326a3de559
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Apr 11 11:58:55 2023 -0700
Fix spelling mistake for "LessThan", inline some STL container support methods
diff --git a/include/geos/geom/Coordinate.h b/include/geos/geom/Coordinate.h
index 220dd7cef..50763083c 100644
--- a/include/geos/geom/Coordinate.h
+++ b/include/geos/geom/Coordinate.h
@@ -32,7 +32,7 @@ namespace geos {
namespace geom { // geos.geom
// Forward declarations
-struct CoordinateLessThen;
+struct CoordinateLessThan;
class CoordinateXYZM;
class CoordinateXYM;
class Coordinate;
@@ -128,8 +128,8 @@ public:
return equals2D(other);
};
- /// TODO: deprecate this, move logic to CoordinateLessThen instead
- int compareTo(const CoordinateXY& other) const
+ /// TODO: deprecate this, move logic to CoordinateLessThan instead
+ inline int compareTo(const CoordinateXY& other) const
{
if(x < other.x) {
return -1;
@@ -175,7 +175,7 @@ public:
struct GEOS_DLL HashCode
{
- std::size_t operator()(const CoordinateXY& c) const
+ inline std::size_t operator()(const CoordinateXY& c) const
{
size_t h = std::hash<double>{}(c.x);
h ^= std::hash<double>{}(c.y) << 1;
@@ -221,7 +221,7 @@ private:
public:
/// A set of const Coordinate pointers
- typedef std::set<const Coordinate*, CoordinateLessThen> ConstSet;
+ typedef std::set<const Coordinate*, CoordinateLessThan> ConstSet;
/// A vector of const Coordinate pointers
typedef std::vector<const Coordinate*> ConstVect;
@@ -425,7 +425,7 @@ CoordinateXYM::operator=(const CoordinateXYZM& other) {
/// Strict weak ordering Functor for Coordinate
-struct GEOS_DLL CoordinateLessThen {
+struct GEOS_DLL CoordinateLessThan {
bool operator()(const CoordinateXY* a, const CoordinateXY* b) const
{
@@ -452,7 +452,7 @@ struct GEOS_DLL CoordinateLessThen {
/// Strict weak ordering operator for Coordinate
inline bool operator<(const CoordinateXY& a, const CoordinateXY& b)
{
- return CoordinateLessThen()(a, b);
+ return CoordinateLessThan()(a, b);
}
diff --git a/include/geos/geom/LineSegment.h b/include/geos/geom/LineSegment.h
index 025e11ba9..21da3212a 100644
--- a/include/geos/geom/LineSegment.h
+++ b/include/geos/geom/LineSegment.h
@@ -517,7 +517,7 @@ public:
};
- using UnorderedSet = std::unordered_set<LineSegment, LineSegment::HashCode>;
+ using UnorderedSet = std::unordered_set<LineSegment, HashCode>;
private:
diff --git a/include/geos/geomgraph/EdgeIntersectionList.h b/include/geos/geomgraph/EdgeIntersectionList.h
index 915bbc84d..428bbd490 100644
--- a/include/geos/geomgraph/EdgeIntersectionList.h
+++ b/include/geos/geomgraph/EdgeIntersectionList.h
@@ -27,7 +27,7 @@
#include <string>
#include <geos/geomgraph/EdgeIntersection.h> // for EdgeIntersectionLessThen
-#include <geos/geom/Coordinate.h> // for CoordinateLessThen
+#include <geos/geom/Coordinate.h> // for CoordinateLessThan
#ifdef _MSC_VER
#pragma warning(push)
diff --git a/include/geos/geomgraph/NodeMap.h b/include/geos/geomgraph/NodeMap.h
index a35ab52e3..e30969a79 100644
--- a/include/geos/geomgraph/NodeMap.h
+++ b/include/geos/geomgraph/NodeMap.h
@@ -26,7 +26,7 @@
#include <vector>
#include <string>
-#include <geos/geom/Coordinate.h> // for CoordinateLessThen
+#include <geos/geom/Coordinate.h> // for CoordinateLessThan
#include <geos/geomgraph/Node.h> // for testInvariant
@@ -50,7 +50,7 @@ namespace geomgraph { // geos.geomgraph
class GEOS_DLL NodeMap {
public:
- typedef std::map<geom::Coordinate*, std::unique_ptr<Node>, geom::CoordinateLessThen> container;
+ typedef std::map<geom::Coordinate*, std::unique_ptr<Node>, geom::CoordinateLessThan> container;
typedef container::iterator iterator;
diff --git a/include/geos/operation/relate/RelateNodeGraph.h b/include/geos/operation/relate/RelateNodeGraph.h
index d409d9712..5a13cc744 100644
--- a/include/geos/operation/relate/RelateNodeGraph.h
+++ b/include/geos/operation/relate/RelateNodeGraph.h
@@ -28,7 +28,7 @@
namespace geos {
namespace geom {
class Coordinate;
-struct CoordinateLessThen;
+struct CoordinateLessThan;
}
namespace geomgraph {
//class EdgeEndStar;
diff --git a/include/geos/planargraph/NodeMap.h b/include/geos/planargraph/NodeMap.h
index e6e3de8b0..aa39db07b 100644
--- a/include/geos/planargraph/NodeMap.h
+++ b/include/geos/planargraph/NodeMap.h
@@ -46,7 +46,7 @@ namespace planargraph { // geos.planargraph
*/
class GEOS_DLL NodeMap {
public:
- typedef std::map<geom::Coordinate, Node*, geom::CoordinateLessThen> container;
+ typedef std::map<geom::Coordinate, Node*, geom::CoordinateLessThan> container;
private:
container nodeMap;
public:
diff --git a/include/geos/util/UniqueCoordinateArrayFilter.h b/include/geos/util/UniqueCoordinateArrayFilter.h
index 89a25a692..17371169a 100644
--- a/include/geos/util/UniqueCoordinateArrayFilter.h
+++ b/include/geos/util/UniqueCoordinateArrayFilter.h
@@ -82,7 +82,7 @@ public:
private:
std::vector<const geom::Coordinate*>& pts; // target set reference
- std::set<const geom::CoordinateXY*, geom::CoordinateLessThen> uniqPts; // unique points set
+ std::set<const geom::CoordinateXY*, geom::CoordinateLessThan> uniqPts; // unique points set
// Declare type as noncopyable
UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other) = delete;
diff --git a/src/triangulate/DelaunayTriangulationBuilder.cpp b/src/triangulate/DelaunayTriangulationBuilder.cpp
index 78c38bc58..424de2a13 100644
--- a/src/triangulate/DelaunayTriangulationBuilder.cpp
+++ b/src/triangulate/DelaunayTriangulationBuilder.cpp
@@ -47,7 +47,7 @@ std::unique_ptr<CoordinateSequence>
DelaunayTriangulationBuilder::unique(const CoordinateSequence* seq)
{
auto sortedSeq = detail::make_unique<CoordinateSequence>(*seq);
- std::sort(sortedSeq->items<Coordinate>().begin(), sortedSeq->items<Coordinate>().end(), geos::geom::CoordinateLessThen());
+ std::sort(sortedSeq->items<Coordinate>().begin(), sortedSeq->items<Coordinate>().end(), geos::geom::CoordinateLessThan());
operation::valid::RepeatedPointTester rpt;
if (rpt.hasRepeatedPoint(sortedSeq.get())) {
-----------------------------------------------------------------------
Summary of changes:
NEWS.md | 1 +
capi/geos_c.cpp | 10 +++
capi/geos_c.h.in | 17 +++++
capi/geos_ts_c.cpp | 82 ++++++++++------------
include/geos/geom/Coordinate.h | 14 ++--
include/geos/geom/LineSegment.h | 2 +-
include/geos/geom/Point.h | 1 +
include/geos/geomgraph/EdgeIntersectionList.h | 2 +-
include/geos/geomgraph/NodeMap.h | 4 +-
include/geos/operation/relate/RelateNodeGraph.h | 2 +-
include/geos/planargraph/NodeMap.h | 2 +-
include/geos/util/UniqueCoordinateArrayFilter.h | 2 +-
src/geom/CoordinateSequence.cpp | 4 +-
src/geom/Point.cpp | 11 ++-
src/triangulate/DelaunayTriangulationBuilder.cpp | 2 +-
...SGeomGetXYZTest.cpp => GEOSGeomGetXYZMTest.cpp} | 51 ++++++++++++--
.../capi/GEOSGeom_getCoordinateDimensionTest.cpp | 4 +-
tests/unit/capi/GEOSGeom_getDimensionsTest.cpp | 2 +-
tests/unit/geom/CoordinateSequenceTest.cpp | 65 ++++++++++++++---
19 files changed, 196 insertions(+), 82 deletions(-)
rename tests/unit/capi/{GEOSGeomGetXYZTest.cpp => GEOSGeomGetXYZMTest.cpp} (53%)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list