GeometryGraph.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* 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.
*
**********************************************************************
*
* Last port: geomgraph/GeometryGraph.java r428 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <map>
#include <unordered_map>
#include <vector>
#include <memory>
#include <geos/geom/Coordinate.h>
#include <geos/geom/CoordinateSequence.h> // for unique_ptr<CoordinateSequence>
#include <geos/geomgraph/PlanarGraph.h>
#include <geos/geomgraph/index/SegmentIntersector.h>
#include <geos/geom/LineString.h> // for LineStringLT
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class LineString;
class LinearRing;
class Polygon;
class Geometry;
class GeometryCollection;
class Point;
class Envelope;
}
namespace algorithm {
class LineIntersector;
class BoundaryNodeRule;
}
namespace geomgraph {
class Edge;
class Node;
namespace index {
class EdgeSetIntersector;
}
}
}
namespace geos {
namespace geomgraph { // geos.geomgraph
class GEOS_DLL GeometryGraph final: public PlanarGraph {
using PlanarGraph::add;
using PlanarGraph::findEdge;
private:
const geom::Geometry* parentGeom;
std::unordered_map<const geom::LineString*, Edge*> lineEdgeMap;
bool useBoundaryDeterminationRule;
const algorithm::BoundaryNodeRule& boundaryNodeRule;
uint8_t argIndex;
std::unique_ptr< geom::CoordinateSequence > boundaryPoints;
std::unique_ptr< std::vector<Node*> > boundaryNodes;
bool hasTooFewPointsVar;
geom::Coordinate invalidPoint;
index::EdgeSetIntersector* createEdgeSetIntersector();
void add(const geom::Geometry* g);
// throw(UnsupportedOperationException);
void addCollection(const geom::GeometryCollection* gc);
void addPoint(const geom::Point* p);
void addPolygonRing(const geom::LinearRing* lr,
geom::Location cwLeft, geom::Location cwRight);
void addPolygon(const geom::Polygon* p);
void addLineString(const geom::LineString* line);
void insertPoint(uint8_t p_argIndex, const geom::Coordinate& coord,
geom::Location onLocation);
void insertBoundaryPoint(uint8_t p_argIndex, const geom::Coordinate& coord);
void addSelfIntersectionNodes(uint8_t p_argIndex);
void addSelfIntersectionNode(uint8_t p_argIndex,
const geom::Coordinate& coord, geom::Location loc);
// Declare type as noncopyable
GeometryGraph(const GeometryGraph& other) = delete;
GeometryGraph& operator=(const GeometryGraph& rhs) = delete;
public:
static bool isInBoundary(int boundaryCount);
static geom::Location determineBoundary(int boundaryCount);
static geom::Location determineBoundary(
const algorithm::BoundaryNodeRule& boundaryNodeRule,
int boundaryCount);
GeometryGraph(uint8_t newArgIndex, const geom::Geometry* newParentGeom);
GeometryGraph(uint8_t newArgIndex, const geom::Geometry* newParentGeom,
const algorithm::BoundaryNodeRule& boundaryNodeRule);
~GeometryGraph() override {};
const geom::Geometry* getGeometry()
{
return parentGeom;
};
void getBoundaryNodes(std::vector<Node*>& bdyNodes)
{
nodes->getBoundaryNodes(static_cast<uint8_t>(argIndex), bdyNodes);
};
std::vector<Node*>* getBoundaryNodes();
geom::CoordinateSequence* getBoundaryPoints();
Edge* findEdge(const geom::LineString* line) const;
void computeSplitEdges(std::vector<Edge*>* edgelist);
void addEdge(Edge* e);
void addPoint(geom::Coordinate& pt);
std::unique_ptr<index::SegmentIntersector>
computeSelfNodes(
algorithm::LineIntersector* li,
bool computeRingSelfNodes,
const geom::Envelope* env = nullptr)
{
return computeSelfNodes(*li, computeRingSelfNodes, env);
}
// Quick inline calling the function above, the above should probably
// be deprecated.
std::unique_ptr<index::SegmentIntersector> computeSelfNodes(
algorithm::LineIntersector& li,
bool computeRingSelfNodes, const geom::Envelope* env = nullptr);
std::unique_ptr<index::SegmentIntersector> computeEdgeIntersections(GeometryGraph* g,
algorithm::LineIntersector* li, bool includeProper,
const geom::Envelope* env = nullptr);
std::vector<Edge*>* getEdges();
bool hasTooFewPoints();
const geom::Coordinate& getInvalidPoint();
const algorithm::BoundaryNodeRule&
getBoundaryNodeRule() const
{
return boundaryNodeRule;
}
};
} // namespace geos.geomgraph
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
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::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::geom::LinearRing
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
geos::geom::Point
Definition Point.h:61
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geomgraph::Edge
Definition geomgraph/Edge.h:63
geos::geomgraph::GeometryGraph
A GeometryGraph is a graph that models a given Geometry.
Definition GeometryGraph.h:71
geos::geomgraph::GeometryGraph::getBoundaryPoints
geom::CoordinateSequence * getBoundaryPoints()
Returned object is owned by this GeometryGraph.
geos::geomgraph::GeometryGraph::computeSelfNodes
std::unique_ptr< index::SegmentIntersector > computeSelfNodes(algorithm::LineIntersector *li, bool computeRingSelfNodes, const geom::Envelope *env=nullptr)
Compute self-nodes, taking advantage of the Geometry type to minimize the number of intersection test...
Definition GeometryGraph.h:213
geos::geomgraph::GeometryGraph::getBoundaryNodes
void getBoundaryNodes(std::vector< Node * > &bdyNodes)
Returned object is owned by this GeometryGraph.
Definition GeometryGraph.h:180
geos::geomgraph::Node
The node component of a geometry graph.
Definition geomgraph/Node.h:59
geos::geomgraph::PlanarGraph::findEdge
Edge * findEdge(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the edge whose first two coordinates are p0 and p1.
geos::geomgraph::index::EdgeSetIntersector
An EdgeSetIntersector computes all the intersections between the edges in the set.
Definition geomgraph/index/EdgeSetIntersector.h:40
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos::geomgraph::index
Contains classes that implement indexes for performing noding on geometry graph edges.
Definition geomgraph/Edge.h:53
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38