[geos-commits] [SCM] GEOS branch master updated. 19b855acb843ca745aaa6f46c1791c2ac30c4ee8
git at osgeo.org
git at osgeo.org
Wed Nov 28 11:25:54 PST 2018
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 19b855acb843ca745aaa6f46c1791c2ac30c4ee8 (commit)
from c8244b4e8e25cc3eac65481d1fff97f4748569a7 (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 19b855acb843ca745aaa6f46c1791c2ac30c4ee8
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Nov 28 11:25:26 2018 -0800
Implement updated JTS hole assignment code, and associated tests.
diff --git a/src/operation/overlay/PolygonBuilder.cpp b/src/operation/overlay/PolygonBuilder.cpp
index 87ce0b8..739fcff 100644
--- a/src/operation/overlay/PolygonBuilder.cpp
+++ b/src/operation/overlay/PolygonBuilder.cpp
@@ -21,6 +21,7 @@
#include <geos/operation/overlay/OverlayOp.h>
#include <geos/operation/overlay/MaximalEdgeRing.h>
#include <geos/operation/overlay/MinimalEdgeRing.h>
+#include <geos/operation/polygonize/EdgeRing.h>
#include <geos/geomgraph/Node.h>
#include <geos/geomgraph/NodeMap.h>
#include <geos/geomgraph/DirectedEdgeStar.h>
@@ -44,7 +45,6 @@ using namespace geos::geomgraph;
using namespace geos::algorithm;
using namespace geos::geom;
-
namespace geos {
namespace operation { // geos.operation
namespace overlay { // geos.operation.overlay
@@ -331,30 +331,34 @@ PolygonBuilder::findEdgeRingContaining(EdgeRing *testEr,
{
LinearRing *testRing=testEr->getLinearRing();
const Envelope *testEnv=testRing->getEnvelopeInternal();
- const Coordinate& testPt=testRing->getCoordinateN(0);
+ Coordinate testPt=testRing->getCoordinateN(0);
EdgeRing *minShell=nullptr;
- const Envelope *minEnv=nullptr;
+ const Envelope *minShellEnv=nullptr;
for(size_t i=0, n=newShellList.size(); i<n; i++)
{
- LinearRing *lr=nullptr;
EdgeRing *tryShell=newShellList[i];
- LinearRing *tryRing=tryShell->getLinearRing();
- const Envelope *tryEnv=tryRing->getEnvelopeInternal();
- if (minShell!=nullptr) {
- lr=minShell->getLinearRing();
- minEnv=lr->getEnvelopeInternal();
- }
+ LinearRing *tryShellRing=tryShell->getLinearRing();
+ const Envelope *tryShellEnv=tryShellRing->getEnvelopeInternal();
+ // the hole envelope cannot equal the shell envelope
+ // (also guards against testing rings against themselves)
+ if (tryShellEnv->equals(testEnv)) continue;
+ // hole must be contained in shell
+ if (!tryShellEnv->contains(testEnv)) continue;
+
+ const CoordinateSequence *tsrcs = tryShellRing->getCoordinatesRO();
+ testPt = operation::polygonize::EdgeRing::ptNotInList(testRing->getCoordinatesRO(), tsrcs);
bool isContained=false;
- const CoordinateSequence *rcl = tryRing->getCoordinatesRO();
- if (tryEnv->contains(testEnv)
- && CGAlgorithms::isPointInRing(testPt,rcl))
- isContained=true;
+
+ if(CGAlgorithms::isPointInRing(testPt, tsrcs))
+ isContained=true;
+
// check if this new containing ring is smaller than
// the current minimum ring
if (isContained) {
if (minShell==nullptr
- || minEnv->contains(tryEnv)) {
+ || minShellEnv->contains(tryShellEnv)) {
minShell=tryShell;
+ minShellEnv=minShell->getLinearRing()->getEnvelopeInternal();
}
}
}
diff --git a/tests/xmltester/tests/general/TestFunctionAA.xml b/tests/xmltester/tests/general/TestFunctionAA.xml
index d0d713a..ef006bd 100644
--- a/tests/xmltester/tests/general/TestFunctionAA.xml
+++ b/tests/xmltester/tests/general/TestFunctionAA.xml
@@ -630,4 +630,34 @@
</test>
</case>
+<case>
+ <desc>AA - Polygons which stress hole assignment</desc>
+ <a>
+POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 1, 1 1), (1 2, 1 3, 2 3, 1 2), (2 3, 3 3, 3 2, 2 3))
+ </a>
+ <b>
+POLYGON ((2 1, 3 1, 3 2, 2 1))
+ </b>
+<test>
+ <op name="intersection" arg1="A" arg2="B">
+POLYGON ((3 2, 3 1, 2 1, 3 2))
+ </op>
+</test>
+<test>
+ <op name="union" arg1="A" arg2="B">
+POLYGON ((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 1 2), (1 2, 2 3, 1 3, 1 2), (2 3, 3 2, 3 3, 2 3))
+ </op>
+</test>
+<test>
+ <op name="difference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+ </op>
+</test>
+<test>
+ <op name="symdifference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+ </op>
+</test>
+</case>
+
</run>
-----------------------------------------------------------------------
Summary of changes:
src/operation/overlay/PolygonBuilder.cpp | 34 +++++++++++++-----------
tests/xmltester/tests/general/TestFunctionAA.xml | 30 +++++++++++++++++++++
2 files changed, 49 insertions(+), 15 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list