Skip to content

Commit

Permalink
Add support for bnRule testing relates
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Aug 20, 2024
1 parent d9422f5 commit 8c550f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions tests/unit/operation/relateng/RelateNGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,5 +875,16 @@ void object::test<62> ()
checkRelate(a, b, "212101212");
}

// Boundary node
// template<>
// template<>
// void object::test<63> ()
// {
// std::string a = "POLYGON((0 0,140 0,140 140,0 140,0 0))";
// std::string b = "POLYGON((140 0,0 0,0 140,140 140,140 0))";
// checkRelateRule(a, b, "2FFF0FFF2", geos::algorithm::BoundaryNodeRule::getBoundaryMultivalentEndPoint());
// }



} // namespace tut
10 changes: 8 additions & 2 deletions tests/unit/operation/relateng/RelateNGTest.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

// geos
#include <geos/algorithm/BoundaryNodeRule.h>
#include <geos/io/WKTReader.h>
#include <geos/io/WKTWriter.h>
#include <geos/geom/Geometry.h>
Expand Down Expand Up @@ -94,13 +95,13 @@ struct test_relateng_support {
checkPredicate(*RelatePredicate::equalsTopo(), wktb, wkta, expectedValue);
}

void checkRelate(const std::string& wkta, const std::string& wktb, const std::string expectedValue)
void checkRelateRule(const std::string& wkta, const std::string& wktb, const std::string expectedValue, const BoundaryNodeRule& bnRule)
{
std::unique_ptr<Geometry> a = r.read(wkta);
std::unique_ptr<Geometry> b = r.read(wktb);
RelateMatrixPredicate pred;
// TopologyPredicate predTrace = trace(pred);
RelateNG::relate(a.get(), b.get(), pred);
RelateNG::relate(a.get(), b.get(), pred, bnRule);
std::string actualVal = pred.getIM()->toString();
if (actualVal != expectedValue) {
std::cerr << std::endl << w.write(*a) << " relate " << w.write(*b) << " = " << actualVal << std::endl;
Expand All @@ -109,6 +110,11 @@ struct test_relateng_support {
checkPrepared(a.get(), b.get());
}

void checkRelate(const std::string& wkta, const std::string& wktb, const std::string expectedValue)
{
checkRelateRule(wkta, wktb, expectedValue, BoundaryNodeRule::getBoundaryRuleMod2());
}

void checkRelateMatches(const std::string& wkta, const std::string& wktb, const std::string pattern, bool expectedValue)
{
auto pred = RelatePredicate::matches(pattern);
Expand Down

0 comments on commit 8c550f7

Please sign in to comment.