geomgraph/EdgeRing.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/EdgeRing.java r428 (JTS-1.12+)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geomgraph/Label.h> // for composition
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/LinearRing.h>
#include <cassert> // for testInvariant
#include <iosfwd> // for operator<<
#include <memory>
#include <vector>
#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 GeometryFactory;
class Polygon;
class Coordinate;
}
namespace geomgraph {
class DirectedEdge;
//class Label;
class Edge;
}
}
namespace geos {
namespace geomgraph { // geos.geomgraph
class GEOS_DLL EdgeRing /* non-final */ {
public:
friend std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
EdgeRing(DirectedEdge* newStart,
const geom::GeometryFactory* newGeometryFactory);
virtual ~EdgeRing() = default;
bool isIsolated();
bool isHole();
geom::LinearRing* getLinearRing();
Label& getLabel();
bool isShell();
EdgeRing* getShell();
void setShell(EdgeRing* newShell);
void addHole(EdgeRing* edgeRing);
std::unique_ptr<geom::Polygon> toPolygon(const geom::GeometryFactory* geometryFactory);
void computeRing();
virtual DirectedEdge* getNext(DirectedEdge* de) = 0;
virtual void setEdgeRing(DirectedEdge* de, EdgeRing* er) = 0;
std::vector<DirectedEdge*>& getEdges();
int getMaxNodeDegree();
void setInResult();
bool containsPoint(const geom::Coordinate& p);
void
testInvariant() const
{
// pts are never NULL
// assert(pts);
#ifndef NDEBUG
// If this is not an hole, check that
// each hole is not null and
// has 'this' as it's shell
if(! shell) {
for(const auto& hole : holes) {
assert(hole);
assert(hole->getShell() == this);
}
}
#endif // ndef NDEBUG
}
protected:
DirectedEdge* startDe; // the directed edge which starts the list of edges for this EdgeRing
const geom::GeometryFactory* geometryFactory;
void computePoints(DirectedEdge* newStart);
void mergeLabel(const Label& deLabel);
void mergeLabel(const Label& deLabel, uint8_t geomIndex);
void addPoints(Edge* edge, bool isForward, bool isFirstEdge);
std::vector<std::unique_ptr<EdgeRing>> holes;
private:
int maxNodeDegree;
std::vector<DirectedEdge*> edges;
geom::CoordinateSequence pts;
// label stores the locations of each geometry on the
// face surrounded by this ring
Label label;
std::unique_ptr<geom::LinearRing> ring; // the ring created for this EdgeRing
bool isHoleVar;
EdgeRing* shell;
void computeMaxNodeDegree();
};
std::ostream& operator<< (std::ostream& os, const EdgeRing& er);
} // namespace geos.geomgraph
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
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::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
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::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geomgraph::DirectedEdge
A directed EdgeEnd.
Definition geomgraph/DirectedEdge.h:42
geos::geomgraph::EdgeRing
Definition geomgraph/EdgeRing.h:57
geos::geomgraph::EdgeRing::toPolygon
std::unique_ptr< geom::Polygon > toPolygon(const geom::GeometryFactory *geometryFactory)
geos::geomgraph::EdgeRing::containsPoint
bool containsPoint(const geom::Coordinate &p)
geos::geomgraph::EdgeRing::holes
std::vector< std::unique_ptr< EdgeRing > > holes
a list of EdgeRings which are holes in this EdgeRing
Definition geomgraph/EdgeRing.h:167
geos::geomgraph::EdgeRing::mergeLabel
void mergeLabel(const Label &deLabel, uint8_t geomIndex)
Merge the RHS label from a DirectedEdge into the label for this EdgeRing.
geos::geomgraph::EdgeRing::getEdges
std::vector< DirectedEdge * > & getEdges()
geos::geomgraph::EdgeRing::computePoints
void computePoints(DirectedEdge *newStart)
geos::geomgraph::EdgeRing::getLinearRing
geom::LinearRing * getLinearRing()
geos::geomgraph::EdgeRing::computeRing
void computeRing()
geos::geomgraph::Edge
Definition geomgraph/Edge.h:63
geos::geomgraph::Label
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:57
geos::geom
Definition Angle.h:26
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38