[geos-commits] [SCM] GEOS branch main-relate-ng updated. 8cbea4e4af2d631159479e5239984732719e550d
git at osgeo.org
git at osgeo.org
Wed Aug 7 12:46:46 PDT 2024
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-relate-ng has been updated
via 8cbea4e4af2d631159479e5239984732719e550d (commit)
from 4775c8087a7fa9f136bd8bda41ef585e48597194 (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 8cbea4e4af2d631159479e5239984732719e550d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Aug 7 12:46:23 2024 -0700
Wire in NG relate() function in IM matrix generator functions
diff --git a/capi/geos_ts_c.cpp b/capi/geos_ts_c.cpp
index b84c6015e..d16cd0b55 100644
--- a/capi/geos_ts_c.cpp
+++ b/capi/geos_ts_c.cpp
@@ -583,7 +583,7 @@ extern "C" {
GEOSDisjoint_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Disjoint(g1, g2);
+ return RelateNG::disjoint(g1, g2);
});
}
@@ -591,7 +591,7 @@ extern "C" {
GEOSTouches_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Touches(g1, g2);
+ return RelateNG::touches(g1, g2);
});
}
@@ -599,7 +599,7 @@ extern "C" {
GEOSIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Intersects(g1, g2);
+ return RelateNG::intersects(g1, g2);
});
}
@@ -607,7 +607,7 @@ extern "C" {
GEOSCrosses_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Crosses(g1, g2);
+ return RelateNG::crosses(g1, g2);
});
}
@@ -615,7 +615,7 @@ extern "C" {
GEOSWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Within(g1, g2);
+ return RelateNG::within(g1, g2);
});
}
@@ -623,7 +623,7 @@ extern "C" {
GEOSContains_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Contains(g1, g2);
+ return RelateNG::contains(g1, g2);
});
}
@@ -631,7 +631,7 @@ extern "C" {
GEOSOverlaps_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Overlaps(g1, g2);
+ return RelateNG::overlaps(g1, g2);
});
}
@@ -639,7 +639,7 @@ extern "C" {
GEOSCovers_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::Covers(g1, g2);
+ return RelateNG::covers(g1, g2);
});
}
@@ -647,7 +647,7 @@ extern "C" {
GEOSCoveredBy_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::CoveredBy(g1, g2);
+ return RelateNG::coveredBy(g1, g2);
});
}
@@ -655,7 +655,7 @@ extern "C" {
GEOSEquals_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
{
return execute(extHandle, 2, [&]() {
- return RelateNG::EqualsTopo(g1, g2);
+ return RelateNG::equalsTopo(g1, g2);
});
}
@@ -715,19 +715,19 @@ extern "C" {
switch (bnr) {
case GEOSRELATE_BNR_MOD2: /* same as OGC */
- im = RelateOp::relate(g1, g2,
+ im = RelateNG::relate(g1, g2,
BoundaryNodeRule::getBoundaryRuleMod2());
break;
case GEOSRELATE_BNR_ENDPOINT:
- im = RelateOp::relate(g1, g2,
+ im = RelateNG::relate(g1, g2,
BoundaryNodeRule::getBoundaryEndPoint());
break;
case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
- im = RelateOp::relate(g1, g2,
+ im = RelateNG::relate(g1, g2,
BoundaryNodeRule::getBoundaryMultivalentEndPoint());
break;
case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
- im = RelateOp::relate(g1, g2,
+ im = RelateNG::relate(g1, g2,
BoundaryNodeRule::getBoundaryMonovalentEndPoint());
break;
default:
diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 114f4c039..c2378f4c1 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -612,11 +612,7 @@ public:
* @see Geometry#within
* @see Geometry#covers
*/
- bool
- coveredBy(const Geometry* g) const
- {
- return g->covers(this);
- }
+ bool coveredBy(const Geometry* g) const;
/// Returns the Well-known Text representation of this Geometry.
diff --git a/include/geos/operation/relateng/RelateMatrixPredicate.h b/include/geos/operation/relateng/RelateMatrixPredicate.h
index 425884cd5..b54ec2c3b 100644
--- a/include/geos/operation/relateng/RelateMatrixPredicate.h
+++ b/include/geos/operation/relateng/RelateMatrixPredicate.h
@@ -73,8 +73,8 @@ public:
*
* @return the IM matrix
*/
- IntersectionMatrix& getIM() {
- return intMatrix;
+ std::unique_ptr<IntersectionMatrix> getIM() {
+ return std::unique_ptr<IntersectionMatrix>(new IntersectionMatrix(intMatrix));
}
};
diff --git a/include/geos/operation/relateng/RelateNG.h b/include/geos/operation/relateng/RelateNG.h
index b7c0661a5..7106cef9b 100644
--- a/include/geos/operation/relateng/RelateNG.h
+++ b/include/geos/operation/relateng/RelateNG.h
@@ -185,7 +185,7 @@ public:
* @param b the B input geometry
* @return the DE-9IM matrix for the topological relationship
*/
- static IntersectionMatrix relate(const Geometry* a, const Geometry* b);
+ static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b);
/**
* Computes the DE-9IM matrix
@@ -196,7 +196,7 @@ public:
* @param bnRule the Boundary Node Rule to use
* @return the DE-9IM matrix for the relationship
*/
- static IntersectionMatrix relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
+ static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
/**
* Creates a prepared RelateNG instance to optimize the
@@ -225,7 +225,7 @@ public:
* @param b the B geometry to test against
* @return the DE-9IM matrix
*/
- IntersectionMatrix evaluate(const Geometry* b);
+ std::unique_ptr<IntersectionMatrix> evaluate(const Geometry* b);
/**
@@ -250,25 +250,25 @@ public:
*/
bool evaluate(const Geometry* b, TopologyPredicate& predicate);
- static bool Intersects(const Geometry* a, const Geometry* b);
+ static bool intersects(const Geometry* a, const Geometry* b);
- static bool Crosses(const Geometry* a, const Geometry* b);
+ static bool crosses(const Geometry* a, const Geometry* b);
- static bool Disjoint(const Geometry* a, const Geometry* b);
+ static bool disjoint(const Geometry* a, const Geometry* b);
- static bool Touches(const Geometry* a, const Geometry* b);
+ static bool touches(const Geometry* a, const Geometry* b);
- static bool Within(const Geometry* a, const Geometry* b);
+ static bool within(const Geometry* a, const Geometry* b);
- static bool Contains(const Geometry* a, const Geometry* b);
+ static bool contains(const Geometry* a, const Geometry* b);
- static bool Overlaps(const Geometry* a, const Geometry* b);
+ static bool overlaps(const Geometry* a, const Geometry* b);
- static bool Covers(const Geometry* a, const Geometry* b);
+ static bool covers(const Geometry* a, const Geometry* b);
- static bool CoveredBy(const Geometry* a, const Geometry* b);
+ static bool coveredBy(const Geometry* a, const Geometry* b);
- static bool EqualsTopo(const Geometry* a, const Geometry* b);
+ static bool equalsTopo(const Geometry* a, const Geometry* b);
};
diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index 344de042e..7d5f17c6f 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -261,7 +261,7 @@ bool
Geometry::disjoint(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Disjoint(this, g);
+ return operation::relateng::RelateNG::disjoint(this, g);
#else
return !intersects(g);
#endif
@@ -278,7 +278,7 @@ Geometry::touches(const Geometry* g) const
#endif
#if USE_RELATENG
- return operation::relateng::RelateNG::Touches(this, g);
+ return operation::relateng::RelateNG::touches(this, g);
#else
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isTouches(getDimension(), g->getDimension());
@@ -323,7 +323,7 @@ Geometry::intersects(const Geometry* g) const
}
#if USE_RELATENG
- return operation::relateng::RelateNG::Intersects(this, g);
+ return operation::relateng::RelateNG::intersects(this, g);
#else
if (getGeometryTypeId() == GEOS_GEOMETRYCOLLECTION) {
auto im = relate(g);
@@ -340,7 +340,7 @@ bool
Geometry::covers(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Covers(this, g);
+ return operation::relateng::RelateNG::covers(this, g);
#else
// optimization - lower dimension cannot cover areas
if(g->getDimension() == 2 && getDimension() < 2) {
@@ -372,12 +372,22 @@ Geometry::covers(const Geometry* g) const
#endif
}
+/*public*/
+bool
+Geometry::coveredBy(const Geometry* g) const
+{
+#if USE_RELATENG
+ return operation::relateng::RelateNG::coveredBy(this, g);
+#else
+ return covers(g, this);
+#endif
+}
bool
Geometry::crosses(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Crosses(this, g);
+ return operation::relateng::RelateNG::crosses(this, g);
#else
#ifdef SHORTCIRCUIT_PREDICATES
@@ -397,7 +407,7 @@ bool
Geometry::within(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Within(this, g);
+ return operation::relateng::RelateNG::within(this, g);
#else
return g->contains(this);
#endif
@@ -407,7 +417,7 @@ bool
Geometry::contains(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Contains(this, g);
+ return operation::relateng::RelateNG::contains(this, g);
#else
// optimization - lower dimension cannot contain areas
@@ -449,7 +459,7 @@ bool
Geometry::overlaps(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::Overlaps(this, g);
+ return operation::relateng::RelateNG::overlaps(this, g);
#else
#ifdef SHORTCIRCUIT_PREDICATES
@@ -469,8 +479,7 @@ bool
Geometry::relate(const Geometry* g, const std::string& intersectionPattern) const
{
#if USE_RELATENG
- operation::relateng::IMPatternMatcher predicate(intersectionPattern);
- return operation::relateng::RelateNG::relate(this, g, predicate);
+ return operation::relateng::RelateNG::relate(this, g, intersectionPattern);
#else
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->matches(intersectionPattern);
@@ -482,7 +491,7 @@ bool
Geometry::equals(const Geometry* g) const
{
#if USE_RELATENG
- return operation::relateng::RelateNG::EqualsTopo(this, g);
+ return operation::relateng::RelateNG::equalsTopo(this, g);
#else
#ifdef SHORTCIRCUIT_PREDICATES
@@ -508,7 +517,11 @@ Geometry::equals(const Geometry* g) const
std::unique_ptr<IntersectionMatrix>
Geometry::relate(const Geometry* other) const
{
+#if USE_RELATENG
+ return operation::relateng::RelateNG::relate(this, other);
+#else
return RelateOp::relate(this, other);
+#endif
}
std::unique_ptr<IntersectionMatrix>
diff --git a/src/operation/relateng/RelateNG.cpp b/src/operation/relateng/RelateNG.cpp
index ec5a3da3a..90eacd40e 100644
--- a/src/operation/relateng/RelateNG.cpp
+++ b/src/operation/relateng/RelateNG.cpp
@@ -59,92 +59,82 @@ namespace relateng { // geos.operation.relateng
/* public static */
bool
-RelateNG::Intersects(const Geometry* a, const Geometry* b)
+RelateNG::intersects(const Geometry* a, const Geometry* b)
{
RelatePredicate::IntersectsPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Crosses(const Geometry* a, const Geometry* b)
+RelateNG::crosses(const Geometry* a, const Geometry* b)
{
RelatePredicate::CrossesPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Disjoint(const Geometry* a, const Geometry* b)
+RelateNG::disjoint(const Geometry* a, const Geometry* b)
{
RelatePredicate::DisjointPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Touches(const Geometry* a, const Geometry* b)
+RelateNG::touches(const Geometry* a, const Geometry* b)
{
RelatePredicate::TouchesPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Within(const Geometry* a, const Geometry* b)
+RelateNG::within(const Geometry* a, const Geometry* b)
{
RelatePredicate::WithinPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Contains(const Geometry* a, const Geometry* b)
+RelateNG::contains(const Geometry* a, const Geometry* b)
{
RelatePredicate::ContainsPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Overlaps(const Geometry* a, const Geometry* b)
+RelateNG::overlaps(const Geometry* a, const Geometry* b)
{
RelatePredicate::OverlapsPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::Covers(const Geometry* a, const Geometry* b)
+RelateNG::covers(const Geometry* a, const Geometry* b)
{
RelatePredicate::CoversPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::CoveredBy(const Geometry* a, const Geometry* b)
+RelateNG::coveredBy(const Geometry* a, const Geometry* b)
{
RelatePredicate::CoveredByPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
bool
-RelateNG::EqualsTopo(const Geometry* a, const Geometry* b)
+RelateNG::equalsTopo(const Geometry* a, const Geometry* b)
{
RelatePredicate::EqualsTopoPredicate pred;
- RelateNG rng(a, false);
- return rng.evaluate(b, pred);
+ return RelateNG::relate(a, b, pred);
}
/* public static */
@@ -175,7 +165,7 @@ RelateNG::relate(const Geometry* a, const Geometry* b, const std::string& imPatt
/* public static */
-IntersectionMatrix
+std::unique_ptr<IntersectionMatrix>
RelateNG::relate(const Geometry* a, const Geometry* b)
{
RelateNG rng(a, false);
@@ -184,7 +174,7 @@ RelateNG::relate(const Geometry* a, const Geometry* b)
/* public static */
-IntersectionMatrix
+std::unique_ptr<IntersectionMatrix>
RelateNG::relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule)
{
RelateNG rng(a, false, bnRule);
@@ -209,7 +199,7 @@ RelateNG::prepare(const Geometry* a, const BoundaryNodeRule& bnRule)
/* public */
-IntersectionMatrix
+std::unique_ptr<IntersectionMatrix>
RelateNG::evaluate(const Geometry* b)
{
RelateMatrixPredicate rel;
diff --git a/tests/unit/operation/relateng/RelateNGTest.h b/tests/unit/operation/relateng/RelateNGTest.h
index 8e21f5ac1..36a0d0e9a 100644
--- a/tests/unit/operation/relateng/RelateNGTest.h
+++ b/tests/unit/operation/relateng/RelateNGTest.h
@@ -78,7 +78,7 @@ struct test_relateng_support {
RelateMatrixPredicate pred;
// TopologyPredicate predTrace = trace(pred);
RelateNG::relate(a.get(), b.get(), pred);
- std::string actualVal = pred.getIM().toString();
+ std::string actualVal = pred.getIM()->toString();
if (actualVal != expectedValue) {
std::cerr << std::endl << w.write(*a) << " relate " << w.write(*b) << " = " << actualVal << std::endl;
}
-----------------------------------------------------------------------
Summary of changes:
capi/geos_ts_c.cpp | 28 +++++------
include/geos/geom/Geometry.h | 6 +--
.../operation/relateng/RelateMatrixPredicate.h | 4 +-
include/geos/operation/relateng/RelateNG.h | 26 +++++-----
src/geom/Geometry.cpp | 35 +++++++++-----
src/operation/relateng/RelateNG.cpp | 56 +++++++++-------------
tests/unit/operation/relateng/RelateNGTest.h | 2 +-
7 files changed, 78 insertions(+), 79 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list