[geos-commits] [SCM] GEOS branch main-relate-ng updated. aefc338ce9b60c6cff52b2bb7b2cb3a17cc31dde
git at osgeo.org
git at osgeo.org
Wed Jul 31 14:51:25 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 aefc338ce9b60c6cff52b2bb7b2cb3a17cc31dde (commit)
from ebd1e124d7e3a95df872c6c1120f87310d269abe (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 aefc338ce9b60c6cff52b2bb7b2cb3a17cc31dde
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Jul 31 14:50:57 2024 -0700
Add #define in Geometry to turn on RelateNG for standard predicates
diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index 8a18f2f93..ffc1a0c02 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -45,6 +45,8 @@
#include <geos/operation/predicate/RectangleContains.h>
#include <geos/operation/predicate/RectangleIntersects.h>
#include <geos/operation/relate/RelateOp.h>
+#include <geos/operation/relateng/RelateNG.h>
+#include <geos/operation/relateng/RelatePredicate.h>
#include <geos/operation/valid/IsValidOp.h>
#include <geos/operation/union/UnaryUnionOp.h>
#include <geos/operation/buffer/BufferOp.h>
@@ -71,6 +73,7 @@
#define SHORTCIRCUIT_PREDICATES 1
//#define USE_RECTANGLE_INTERSECTION 1
+#define USE_RELATENG 1
using namespace geos::algorithm;
using namespace geos::operation::valid;
@@ -257,7 +260,12 @@ Geometry::getEnvelope() const
bool
Geometry::disjoint(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::DisjointPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
return !intersects(g);
+#endif
}
bool
@@ -269,9 +277,15 @@ Geometry::touches(const Geometry* g) const
return false;
}
#endif
+
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::TouchesPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isTouches(getDimension(), g->getDimension());
return res;
+#endif
}
bool
@@ -310,6 +324,10 @@ Geometry::intersects(const Geometry* g) const
return predicate::RectangleIntersects::intersects(*p, *this);
}
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::IntersectsPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
if (getGeometryTypeId() == GEOS_GEOMETRYCOLLECTION) {
auto im = relate(g);
bool res = im->isIntersects();
@@ -317,12 +335,17 @@ Geometry::intersects(const Geometry* g) const
} else {
return prep::PreparedGeometryFactory::prepare(this)->intersects(g);
}
+#endif
}
/*public*/
bool
Geometry::covers(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::CoversPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
// optimization - lower dimension cannot cover areas
if(g->getDimension() == 2 && getDimension() < 2) {
return false;
@@ -350,12 +373,18 @@ Geometry::covers(const Geometry* g) const
std::unique_ptr<IntersectionMatrix> im(relate(g));
return im->isCovers();
+#endif
}
bool
Geometry::crosses(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::CrossesPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
+
#ifdef SHORTCIRCUIT_PREDICATES
// short-circuit test
if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
@@ -365,17 +394,29 @@ Geometry::crosses(const Geometry* g) const
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isCrosses(getDimension(), g->getDimension());
return res;
+
+#endif
}
bool
Geometry::within(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::WithinPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
return g->contains(this);
+#endif
}
bool
Geometry::contains(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::ContainsPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
+
// optimization - lower dimension cannot contain areas
if(g->getDimension() == 2 && getDimension() < 2) {
return false;
@@ -408,11 +449,17 @@ Geometry::contains(const Geometry* g) const
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isContains();
return res;
+#endif
}
bool
Geometry::overlaps(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::OverlapsPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
+
#ifdef SHORTCIRCUIT_PREDICATES
// short-circuit test
if(! getEnvelopeInternal()->intersects(g->getEnvelopeInternal())) {
@@ -422,19 +469,31 @@ Geometry::overlaps(const Geometry* g) const
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isOverlaps(getDimension(), g->getDimension());
return res;
+
+#endif
}
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);
+#else
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->matches(intersectionPattern);
return res;
+#endif
}
bool
Geometry::equals(const Geometry* g) const
{
+#if USE_RELATENG
+ operation::relateng::RelatePredicate::EqualsTopoPredicate predicate;
+ return operation::relateng::RelateNG::relate(this, g, predicate);
+#else
+
#ifdef SHORTCIRCUIT_PREDICATES
// short-circuit test
if(! getEnvelopeInternal()->equals(g->getEnvelopeInternal())) {
@@ -452,6 +511,7 @@ Geometry::equals(const Geometry* g) const
std::unique_ptr<IntersectionMatrix> im(relate(g));
bool res = im->isEquals(getDimension(), g->getDimension());
return res;
+#endif
}
std::unique_ptr<IntersectionMatrix>
diff --git a/tests/unit/operation/relateng/RelateNGTest.cpp b/tests/unit/operation/relateng/RelateNGTest.cpp
index f8be3171b..50c2da633 100644
--- a/tests/unit/operation/relateng/RelateNGTest.cpp
+++ b/tests/unit/operation/relateng/RelateNGTest.cpp
@@ -839,7 +839,16 @@ void object::test<60> ()
checkRelate(a, b, "212F01FF2");
}
+//================ Empty Points ==============
+template<>
+template<>
+void object::test<61> ()
+{
+ std::string a = "POINT EMPTY";
+ std::string b = "POINT EMPTY";
+ checkEquals(a, b, true);
+}
diff --git a/tests/unit/tut/tut.hpp b/tests/unit/tut/tut.hpp
index 01bb978fc..f8d464819 100644
--- a/tests/unit/tut/tut.hpp
+++ b/tests/unit/tut/tut.hpp
@@ -149,7 +149,7 @@ struct tests_registerer<Test, Group, 0>
* each new test since we have to have reinitialized
* Data base class.
*/
-template <class Data, int MaxTestsInGroup = 50>
+template <class Data, int MaxTestsInGroup = 100>
class test_group : public group_base, public test_group_posix
{
test_group(const test_group&);
-----------------------------------------------------------------------
Summary of changes:
src/geom/Geometry.cpp | 60 ++++++++++++++++++++++++++
tests/unit/operation/relateng/RelateNGTest.cpp | 9 ++++
tests/unit/tut/tut.hpp | 2 +-
3 files changed, 70 insertions(+), 1 deletion(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list