TopologyComputer.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/operation/relateng/NodeSections.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/Location.h>
#include <geos/export.h>
// Forward declarations
namespace geos {
namespace operation {
namespace relateng {
class NodeSection;
class RelateGeometry;
class RelateNode;
class TopologyPredicate;
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace relateng { // geos.operation.relateng
class GEOS_DLL TopologyComputer {
using CoordinateXY = geos::geom::CoordinateXY;
using Location = geos::geom::Location;
using NodeSection = geos::operation::relateng::NodeSection;
using NodeSections = geos::operation::relateng::NodeSections;
using RelateGeometry = geos::operation::relateng::RelateGeometry;
using RelateNode = geos::operation::relateng::RelateNode;
using TopologyPredicate = geos::operation::relateng::TopologyPredicate;
private:
// Members
TopologyPredicate& predicate;
RelateGeometry& geomA;
RelateGeometry& geomB;
std::map<CoordinateXY, NodeSections*> nodeMap;
std::deque<std::unique_ptr<NodeSections>> nodeSectionsStore;
// Methods
void initExteriorDims();
void initExteriorEmpty(bool geomNonEmpty);
inline RelateGeometry& getGeometry(bool isA) const {
return isA ? geomA : geomB;
};
void updateDim(Location locA, Location locB, int dimension);
void updateDim(bool isAB, Location loc1, Location loc2, int dimension);
void updateIntersectionAB(const NodeSection* a, const NodeSection* b);
void updateAreaAreaCross(const NodeSection* a, const NodeSection* b);
void updateNodeLocation(const NodeSection* a, const NodeSection* b);
void addNodeSections(NodeSection* ns0, NodeSection* ns1);
void addLineEndOnLine(bool isLineA, Location locLineEnd, Location locLine, const CoordinateXY* pt);
void addLineEndOnArea(bool isLineA, Location locLineEnd, Location locArea, const CoordinateXY* pt);
void addAreaVertexOnPoint(bool isAreaA, Location locArea, const CoordinateXY* pt);
void addAreaVertexOnLine(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
void evaluateNode(NodeSections* nodeSections);
void evaluateNodeEdges(const RelateNode* node);
NodeSections* getNodeSections(const CoordinateXY& nodePt);
public:
TopologyComputer(
TopologyPredicate& p_predicate,
RelateGeometry& p_geomA,
RelateGeometry& p_geomB)
: predicate(p_predicate)
, geomA(p_geomA)
, geomB(p_geomB)
{
initExteriorDims();
};
int getDimension(bool isA) const;
bool isAreaArea() const;
bool isSelfNodingRequired() const;
bool isExteriorCheckRequired(bool isA) const;
bool isResultKnown() const;
bool getResult() const;
void finish();
void addIntersection(NodeSection* a, NodeSection* b);
void addPointOnPointInterior(const CoordinateXY* pt);
void addPointOnPointExterior(bool isGeomA, const CoordinateXY* pt);
void addPointOnGeometry(bool isA, Location locTarget, int dimTarget, const CoordinateXY* pt);
void addLineEndOnGeometry(bool isLineA, Location locLineEnd, Location locTarget, int dimTarget, const CoordinateXY* pt);
void addAreaVertex(bool isAreaA, Location locArea, Location locTarget, int dimTarget, const CoordinateXY* pt);
void addAreaVertexOnArea(bool isAreaA, Location locArea, Location locTarget, const CoordinateXY* pt);
void evaluateNodes();
TopologyComputer(const TopologyComputer&) = delete;
TopologyComputer& operator=(const TopologyComputer&) = delete;
};
} // namespace geos.operation.relateng
} // namespace geos.operation
} // namespace geos
geos::operation::relateng::NodeSection
Definition NodeSection.h:50
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38