Skip to content

Commit

Permalink
Add non-static methods for boolean predicates, for when we have prepa…
Browse files Browse the repository at this point in the history
…red calls
  • Loading branch information
pramsey committed Aug 8, 2024
1 parent 01c8fbc commit 324cd19
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 16 deletions.
4 changes: 1 addition & 3 deletions include/geos/geom/prep/BasicPreparedGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
#pragma once

#include <geos/geom/prep/PreparedGeometry.h> // for inheritance
//#include <geos/algorithm/PointLocator.h>
//#include <geos/geom/util/ComponentCoordinateExtracter.h>
#include <geos/geom/Coordinate.h>
//#include <geos/geom/Location.h>
//#include <geos/operation/relateng/RelateNG.h>

#include <vector>
#include <string>
Expand Down
22 changes: 13 additions & 9 deletions include/geos/operation/relateng/RelateNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,29 @@ class GEOS_DLL RelateNG {
bool evaluate(const Geometry* b, TopologyPredicate& predicate);

static bool intersects(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 touches(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 overlaps(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 equalsTopo(const Geometry* a, const Geometry* b);

bool intersects(const Geometry* a);
bool crosses(const Geometry* a);
bool disjoint(const Geometry* a);
bool touches(const Geometry* a);
bool within(const Geometry* a);
bool contains(const Geometry* a);
bool overlaps(const Geometry* a);
bool covers(const Geometry* a);
bool coveredBy(const Geometry* a);
bool equalsTopo(const Geometry* a);
bool relate(const Geometry* a, const std::string& imPattern);


};

} // namespace geos.operation.relateng
Expand Down
97 changes: 93 additions & 4 deletions src/operation/relateng/RelateNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace relateng { // geos.operation.relateng
#define GEOM_B RelateGeometry::GEOM_B


/************************************************************************/

/* public static */
bool
RelateNG::intersects(const Geometry* a, const Geometry* b)
Expand Down Expand Up @@ -145,7 +147,6 @@ RelateNG::relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred)
return rng.evaluate(b, pred);
}


/* public static */
bool
RelateNG::relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred, const BoundaryNodeRule& bnRule)
Expand All @@ -154,7 +155,6 @@ RelateNG::relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred,
return rng.evaluate(b, pred);
}


/* public static */
bool
RelateNG::relate(const Geometry* a, const Geometry* b, const std::string& imPattern)
Expand All @@ -163,7 +163,6 @@ RelateNG::relate(const Geometry* a, const Geometry* b, const std::string& imPatt
return rng.evaluate(b, imPattern);
}


/* public static */
std::unique_ptr<IntersectionMatrix>
RelateNG::relate(const Geometry* a, const Geometry* b)
Expand All @@ -172,7 +171,6 @@ RelateNG::relate(const Geometry* a, const Geometry* b)
return rng.evaluate(b);
}


/* public static */
std::unique_ptr<IntersectionMatrix>
RelateNG::relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule)
Expand All @@ -181,6 +179,96 @@ RelateNG::relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& b
return rng.evaluate(b);
}

/************************************************************************/

/* public */
bool
RelateNG::intersects(const Geometry* a)
{
RelatePredicate::IntersectsPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::crosses(const Geometry* a)
{
RelatePredicate::CrossesPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::disjoint(const Geometry* a)
{
RelatePredicate::DisjointPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::touches(const Geometry* a)
{
RelatePredicate::TouchesPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::within(const Geometry* a)
{
RelatePredicate::WithinPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::contains(const Geometry* a)
{
RelatePredicate::ContainsPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::overlaps(const Geometry* a)
{
RelatePredicate::OverlapsPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::covers(const Geometry* a)
{
RelatePredicate::CoversPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::coveredBy(const Geometry* a)
{
RelatePredicate::CoveredByPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::equalsTopo(const Geometry* a)
{
RelatePredicate::EqualsTopoPredicate pred;
return evaluate(a, pred);
}

/* public */
bool
RelateNG::relate(const Geometry* a, const std::string& imPattern)
{
return evaluate(b, imPattern);
}

/************************************************************************/

/* public static */
std::unique_ptr<RelateNG>
Expand All @@ -197,6 +285,7 @@ RelateNG::prepare(const Geometry* a, const BoundaryNodeRule& bnRule)
return std::unique_ptr<RelateNG>(new RelateNG(a, true, bnRule));
}

/************************************************************************/

/* public */
std::unique_ptr<IntersectionMatrix>
Expand Down

0 comments on commit 324cd19

Please sign in to comment.