[geos-commits] [SCM] GEOS branch master updated. 76e23a266acf72314ae1c659f8c472ffd95262b4
git at osgeo.org
git at osgeo.org
Thu Sep 26 11:04:41 PDT 2019
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, master has been updated
via 76e23a266acf72314ae1c659f8c472ffd95262b4 (commit)
from 60583394172397a47e444443175d06d7dbb17f1c (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 76e23a266acf72314ae1c659f8c472ffd95262b4
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Sep 26 11:04:10 2019 -0700
Preserve SRID in constructive geometry functions called via CAPI
Closes #896
diff --git a/NEWS b/NEWS
index 40c9961..c1cff26 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,10 @@ Changes in 3.8.0
test running (Paul Ramsey)
- CMake modernization (Mateusz Loskot)
+- Changes:
+ - Constructive geometry functions in CAPI now preserve SRID
+ of input arguments in output (#896)
+
Changes in 3.7.2
2019-05-02
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index 828f01e..edaea13 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -1679,6 +1679,7 @@ extern "C" {
try {
Geometry* g3 = g1->getEnvelope().release();
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1705,7 +1706,9 @@ extern "C" {
}
try {
- return g1->intersection(g2).release();
+ Geometry* g3 = g1->intersection(g2).release();
+ g3->setSRID(g1->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -1732,6 +1735,7 @@ extern "C" {
try {
Geometry* g3 = g1->buffer(width, quadrantsegments).release();
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1782,6 +1786,7 @@ extern "C" {
bp.setMitreLimit(mitreLimit);
BufferOp op(g1, bp);
Geometry* g3 = op.getResultGeometry(width);
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1828,7 +1833,7 @@ extern "C" {
}
BufferBuilder bufBuilder(bp);
Geometry* g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
-
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1872,7 +1877,7 @@ extern "C" {
bool isLeftSide = leftSide == 0 ? false : true;
BufferBuilder bufBuilder(bp);
Geometry* g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
-
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1900,6 +1905,7 @@ extern "C" {
try {
Geometry* g3 = g1->convexHull().release();
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -1928,8 +1934,9 @@ extern "C" {
try {
geos::algorithm::MinimumDiameter m(g);
-
- return m.getMinimumRectangle().release();
+ Geometry* g3 = m.getMinimumRectangle().release();
+ g3->setSRID(g->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -1956,8 +1963,9 @@ extern "C" {
try {
geos::algorithm::MinimumDiameter m(g);
-
- return m.getDiameter().release();
+ Geometry* g3 = m.getDiameter().release();
+ g3->setSRID(g->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -1984,7 +1992,9 @@ extern "C" {
try {
geos::precision::MinimumClearance mc(g);
- return mc.getLine().release();
+ Geometry *g3 = mc.getLine().release();
+ g3->setSRID(g->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -2040,7 +2050,9 @@ extern "C" {
}
try {
- return g1->difference(g2).release();
+ Geometry *g3 = g1->difference(g2).release();
+ g3->setSRID(g1->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -2067,6 +2079,7 @@ extern "C" {
try {
Geometry* g3 = g1->getBoundary().release();
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -2093,7 +2106,9 @@ extern "C" {
}
try {
- return g1->symDifference(g2).release();
+ Geometry *g3 = g1->symDifference(g2).release();
+ g3->setSRID(g1->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -2120,7 +2135,9 @@ extern "C" {
}
try {
- return g1->Union(g2).release();
+ Geometry *g3 = g1->Union(g2).release();
+ g3->setSRID(g1->getSRID());
+ return g3;
}
catch(const std::exception& e) {
#if VERBOSE_EXCEPTIONS
@@ -2153,7 +2170,9 @@ extern "C" {
}
try {
- return geos::operation::geounion::CoverageUnion::Union(g).release();
+ Geometry *g3 = geos::operation::geounion::CoverageUnion::Union(g).release();
+ g3->setSRID(g->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -2180,6 +2199,7 @@ extern "C" {
try {
GeomPtr g3(g->Union());
+ g3->setSRID(g->getSRID());
return g3.release();
}
catch(const std::exception& e) {
@@ -2214,6 +2234,7 @@ extern "C" {
try {
std::unique_ptr<Geometry> g3 = geos::noding::GeometryNoder::node(*g);
+ g3->setSRID(g->getSRID());
return g3.release();
}
catch(const std::exception& e) {
@@ -2254,7 +2275,9 @@ extern "C" {
}
using geos::operation::geounion::CascadedPolygonUnion;
- return CascadedPolygonUnion::Union(p);
+ Geometry *g3 = CascadedPolygonUnion::Union(p);
+ g3->setSRID(g1->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -2286,6 +2309,7 @@ extern "C" {
// return an empty point
return gf->createPoint().release();
}
+ ret->setSRID(g1->getSRID());
return ret.release();
}
catch(const std::exception& e) {
@@ -2316,6 +2340,7 @@ extern "C" {
using geos::operation::intersection::RectangleIntersection;
Rectangle rect(xmin, ymin, xmax, ymax);
std::unique_ptr<Geometry> g3 = RectangleIntersection::clip(*g, rect);
+ g3->setSRID(g->getSRID());
return g3.release();
}
catch(const std::exception& e) {
@@ -2987,6 +3012,7 @@ extern "C" {
const GeometryFactory* gf = handle->geomFactory;
return gf->createPoint().release();
}
+ ret->setSRID(g->getSRID());
return ret;
}
catch(const std::exception& e) {
@@ -3217,24 +3243,26 @@ extern "C" {
Geometry*
GEOSPolygonize_valid_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
{
- if(0 == extHandle) {
- return 0;
+ if(nullptr == extHandle) {
+ return nullptr;
}
- GEOSContextHandleInternal_t* handle = 0;
+ GEOSContextHandleInternal_t* handle = nullptr;
handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
if(0 == handle->initialized) {
- return 0;
+ return nullptr;
}
- Geometry* out = 0;
+ Geometry* out = nullptr;
try {
// Polygonize
using geos::operation::polygonize::Polygonizer;
Polygonizer plgnzr(true);
+ int srid = 0;
for(std::size_t i = 0; i < ngeoms; ++i) {
plgnzr.add(g[i]);
+ srid = g[i]->getSRID();
}
auto polys = plgnzr.getPolygons();
@@ -3250,6 +3278,7 @@ extern "C" {
out = handle->geomFactory->createMultiPolygon(geoms);
}
+ out->setSRID(srid);
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -3281,6 +3310,7 @@ extern "C" {
using geos::operation::polygonize::BuildArea;
BuildArea builder;
out = builder.build(g).release();
+ out->setSRID(g->getSRID());
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -3312,6 +3342,7 @@ extern "C" {
using geos::operation::valid::MakeValid;
MakeValid makeValid;
out = makeValid.build(g).release();
+ out->setSRID(g->getSRID());
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -3342,8 +3373,10 @@ extern "C" {
// Polygonize
using geos::operation::polygonize::Polygonizer;
Polygonizer plgnzr;
+ int srid = 0;
for(std::size_t i = 0; i < ngeoms; ++i) {
plgnzr.add(g[i]);
+ srid = g[i]->getSRID();
}
#if GEOS_DEBUG
@@ -3372,6 +3405,7 @@ extern "C" {
// The below takes ownership of the passed vector,
// so we must *not* delete it
out = gf->createGeometryCollection(linevec);
+ out->setSRID(srid);
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -3455,7 +3489,9 @@ extern "C" {
(*polyvec)[i] = (*polys)[i].release();
}
- return gf->createGeometryCollection(polyvec);
+ Geometry* out = gf->createGeometryCollection(polyvec);
+ out->setSRID(g->getSRID());
+ return out;
}
catch(const std::exception& e) {
@@ -3504,6 +3540,7 @@ extern "C" {
const GeometryFactory* gf = handle->geomFactory;
out = gf->buildGeometry(geoms);
+ out->setSRID(g->getSRID());
// XXX: old version
//out = gf->createGeometryCollection(geoms);
@@ -3534,7 +3571,9 @@ extern "C" {
}
try {
- return g->reverse().release();
+ Geometry* g3 = g->reverse().release();
+ g3->setSRID(g->getSRID());
+ return g3;
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -4706,8 +4745,9 @@ extern "C" {
try {
using namespace geos::simplify;
- Geometry::Ptr g(DouglasPeuckerSimplifier::simplify(g1, tolerance));
- return g.release();
+ Geometry::Ptr g3(DouglasPeuckerSimplifier::simplify(g1, tolerance));
+ g3->setSRID(g1->getSRID());
+ return g3.release();
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -4734,8 +4774,9 @@ extern "C" {
try {
using namespace geos::simplify;
- Geometry::Ptr g(TopologyPreservingSimplifier::simplify(g1, tolerance));
- return g.release();
+ Geometry::Ptr g3(TopologyPreservingSimplifier::simplify(g1, tolerance));
+ g3->setSRID(g1->getSRID());
+ return g3.release();
}
catch(const std::exception& e) {
handle->ERROR_MESSAGE("%s", e.what());
@@ -6206,6 +6247,7 @@ extern "C" {
geos::geom::Coordinate coord = lil.extractPoint(d);
const GeometryFactory* gf = handle->geomFactory;
Geometry* point = gf->createPoint(coord);
+ point->setSRID(g->getSRID());
return point;
}
catch(const std::exception& e) {
@@ -6274,7 +6316,9 @@ extern "C" {
}
/* 3: create a multipoint */
- return factory->createMultiPoint(points);
+ Geometry* out = factory->createMultiPoint(points);
+ out->setSRID(g->getSRID());
+ return out;
}
catch(const std::exception& e) {
@@ -6392,6 +6436,7 @@ extern "C" {
factory->createGeometryCollection(out.release())
);
+ outg->setSRID(g1->getSRID());
return outg.release();
}
@@ -6414,6 +6459,7 @@ extern "C" {
try {
GeometrySnapper snapper(*g1);
std::unique_ptr<Geometry> ret = snapper.snapTo(*g2, tolerance);
+ ret->setSRID(g1->getSRID());
return ret.release();
}
catch(const std::exception& e) {
@@ -6624,6 +6670,7 @@ extern "C" {
try {
BufferOp op(g1, *bp);
Geometry* g3 = op.getResultGeometry(width);
+ g3->setSRID(g1->getSRID());
return g3;
}
catch(const std::exception& e) {
@@ -6657,10 +6704,14 @@ extern "C" {
builder.setSites(*g1);
if(onlyEdges) {
- return builder.getEdges(*g1->getFactory()).release();
+ Geometry* out = builder.getEdges(*g1->getFactory()).release();
+ out->setSRID(g1->getSRID());
+ return out;
}
else {
- return builder.getTriangles(*g1->getFactory()).release();
+ Geometry* out = builder.getTriangles(*g1->getFactory()).release();
+ out->setSRID(g1->getSRID());
+ return out;
}
}
@@ -6697,10 +6748,14 @@ extern "C" {
builder.setClipEnvelope(env->getEnvelopeInternal());
}
if(onlyEdges) {
- return builder.getDiagramEdges(*g1->getFactory()).release();
+ Geometry* out = builder.getDiagramEdges(*g1->getFactory()).release();
+ out->setSRID(g1->getSRID());
+ return out;
}
else {
- return builder.getDiagram(*g1->getFactory()).release();
+ Geometry* out = builder.getDiagram(*g1->getFactory()).release();
+ out->setSRID(g1->getSRID());
+ return out;
}
}
catch(const std::exception& e) {
-----------------------------------------------------------------------
Summary of changes:
NEWS | 4 ++
capi/geos_ts_c.cpp | 113 +++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 88 insertions(+), 29 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list