RelateNG.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (c) 2024 Martin Davis
* Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Coordinate.h>
#include <geos/noding/MCIndexSegmentSetMutualIntersector.h>
#include <geos/operation/relateng/RelateGeometry.h>
#include <string>
#include <sstream>
// Forward declarations
namespace geos {
namespace algorithm {
class BoundaryNodeRule;
}
namespace geom {
class Geometry;
}
namespace noding {
}
namespace operation {
namespace relateng {
class TopologyPredicate;
class TopologyComputer;
class EdgeSegmentIntersector;
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace relateng { // geos.operation.relateng
class GEOS_DLL RelateNG {
using CoordinateXY = geos::geom::CoordinateXY;
using Geometry = geos::geom::Geometry;
using BoundaryNodeRule = geos::algorithm::BoundaryNodeRule;
using MCIndexSegmentSetMutualIntersector = geos::noding::MCIndexSegmentSetMutualIntersector;
using LinearRing = geos::geom::LinearRing;
using Envelope = geos::geom::Envelope;
using SegmentString = geos::noding::SegmentString;
using IntersectionMatrix = geos::geom::IntersectionMatrix;
private:
// Members
const BoundaryNodeRule& boundaryNodeRule;
RelateGeometry geomA;
std::unique_ptr<MCIndexSegmentSetMutualIntersector> edgeMutualInt = nullptr;
// Methods
RelateNG(const Geometry* inputA, bool isPrepared, const BoundaryNodeRule& bnRule)
: boundaryNodeRule(bnRule)
, geomA(inputA, isPrepared, bnRule)
{}
RelateNG(const Geometry* inputA, bool isPrepared)
: RelateNG(inputA, isPrepared, BoundaryNodeRule::getBoundaryRuleMod2())
{}
bool hasRequiredEnvelopeInteraction(const Geometry* b, TopologyPredicate& predicate);
bool finishValue(TopologyPredicate& predicate);
void computePP(RelateGeometry& geomB, TopologyComputer& topoComputer);
void computeAtPoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
bool computePoints(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
void computePoint(bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
bool computeLineEnds(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
bool computeLineEnd(RelateGeometry& geom, bool isA, const CoordinateXY* pt, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
bool computeAreaVertex(RelateGeometry& geom, bool isA, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
bool computeAreaVertex(RelateGeometry& geom, bool isA, const LinearRing* ring, RelateGeometry& geomTarget, TopologyComputer& topoComputer);
void computeAtEdges(RelateGeometry& geomB, TopologyComputer& topoComputer);
void computeEdgesAll(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
void computeEdgesMutual(std::vector<const SegmentString*>& edgesB, const Envelope* envInt, EdgeSegmentIntersector& intersector);
public:
static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred);
static bool relate(const Geometry* a, const Geometry* b, TopologyPredicate& pred, const BoundaryNodeRule& bnRule);
static bool relate(const Geometry* a, const Geometry* b, const std::string& imPattern);
static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b);
static std::unique_ptr<IntersectionMatrix> relate(const Geometry* a, const Geometry* b, const BoundaryNodeRule& bnRule);
static std::unique_ptr<RelateNG> prepare(const Geometry* a);
static std::unique_ptr<RelateNG> prepare(const Geometry* a, const BoundaryNodeRule& bnRule);
std::unique_ptr<IntersectionMatrix> evaluate(const Geometry* b);
bool evaluate(const Geometry* b, const std::string& imPattern);
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& pat);
std::unique_ptr<IntersectionMatrix> relate(const Geometry* a);
};
} // namespace geos.operation.relateng
} // namespace geos.operation
} // namespace geos
geos::algorithm::BoundaryNodeRule
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:52
geos::algorithm::BoundaryNodeRule::getBoundaryRuleMod2
static const BoundaryNodeRule & getBoundaryRuleMod2()
The Mod-2 Boundary Node Rule (which is the rule specified in the OGC SFS).
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::IntersectionMatrix
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:51
geos::geom::LinearRing
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
geos::noding::MCIndexSegmentSetMutualIntersector
Intersects two sets of SegmentStrings using a index based on MonotoneChains and a SpatialIndex.
Definition MCIndexSegmentSetMutualIntersector.h:47
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::operation::relateng::RelateNG::relate
static bool relate(const Geometry *a, const Geometry *b, TopologyPredicate &pred)
geos::operation::relateng::RelateNG::relate
static bool relate(const Geometry *a, const Geometry *b, TopologyPredicate &pred, const BoundaryNodeRule &bnRule)
geos::operation::relateng::RelateNG::prepare
static std::unique_ptr< RelateNG > prepare(const Geometry *a, const BoundaryNodeRule &bnRule)
geos::operation::relateng::RelateNG::evaluate
bool evaluate(const Geometry *b, const std::string &imPattern)
geos::operation::relateng::RelateNG::evaluate
bool evaluate(const Geometry *b, TopologyPredicate &predicate)
geos::operation::relateng::RelateNG::relate
static std::unique_ptr< IntersectionMatrix > relate(const Geometry *a, const Geometry *b)
geos::operation::relateng::RelateNG::prepare
static std::unique_ptr< RelateNG > prepare(const Geometry *a)
geos::operation::relateng::RelateNG::evaluate
std::unique_ptr< IntersectionMatrix > evaluate(const Geometry *b)
geos::operation::relateng::RelateNG::relate
static bool relate(const Geometry *a, const Geometry *b, const std::string &imPattern)
geos::operation::relateng::RelateNG::relate
static std::unique_ptr< IntersectionMatrix > relate(const Geometry *a, const Geometry *b, const BoundaryNodeRule &bnRule)
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos::operation::predicate
Classes which implement topological predicates optimized for particular kinds of geometries.
Definition namespaces.h:236
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38