CoverageRingEdges.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2023 Paul Ramsey <pramsey@cleverelephant.ca>
* Copyright (c) 2023 Martin Davis.
*
* 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/geom/Coordinate.h>
#include <geos/geom/LineSegment.h>
#include <geos/coverage/CoverageEdge.h> // to materialize CoverageEdge
#include <set>
#include <map>
// Forward declarations
namespace geos {
namespace geom {
class CoordinateSequence;
class Geometry;
class LinearRing;
class MultiPolygon;
class Polygon;
}
namespace coverage {
class CoverageEdge;
}
}
namespace geos { // geos
namespace coverage { // geos.coverage
class GEOS_DLL CoverageRingEdges {
using Coordinate = geos::geom::Coordinate;
using CoordinateSequence = geos::geom::CoordinateSequence;
using Geometry = geos::geom::Geometry;
using LinearRing = geos::geom::LinearRing;
using LineSegment = geos::geom::LineSegment;
using MultiPolygon = geos::geom::MultiPolygon;
using Polygon = geos::geom::Polygon;
private:
// Members
const std::vector<const Geometry*>& m_coverage;
std::map<const LinearRing*, std::vector<CoverageEdge*>> m_ringEdgesMap;
std::vector<CoverageEdge*> m_edges;
std::vector<std::unique_ptr<CoverageEdge>> m_edgeStore;
/* Turn off copy constructors for MSVC */
CoverageRingEdges(const CoverageRingEdges&) = delete;
CoverageRingEdges& operator=(const CoverageRingEdges&) = delete;
public:
CoverageRingEdges(const std::vector<const Geometry*>& coverage)
: m_coverage(coverage)
{
build();
};
std::vector<CoverageEdge*>& getEdges()
{
return m_edges;
};
std::vector<CoverageEdge*> selectEdges(
std::size_t ringCount) const;
std::vector<std::unique_ptr<Geometry>> buildCoverage() const;
private:
void build();
void addRingEdges(
const LinearRing* ring,
Coordinate::UnorderedSet& nodes,
LineSegment::UnorderedSet& boundarySegs,
std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
void addBoundaryInnerNodes(
const LinearRing* ring,
LineSegment::UnorderedSet& boundarySegs,
Coordinate::UnorderedSet& nodes);
std::vector<CoverageEdge*> extractRingEdges(
const LinearRing* ring,
std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap,
Coordinate::UnorderedSet& nodes);
CoverageEdge* createEdge(
const CoordinateSequence& ring,
std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
CoverageEdge* createEdge(
const CoordinateSequence& ring,
std::size_t start, std::size_t end,
std::map<LineSegment, CoverageEdge*>& uniqueEdgeMap);
std::size_t findNextNodeIndex(
const CoordinateSequence& ring,
std::size_t start,
Coordinate::UnorderedSet& nodes) const;
static std::size_t next(
std::size_t index,
const CoordinateSequence& ring);
Coordinate::UnorderedSet findMultiRingNodes(
const std::vector<const Geometry*>& coverage);
Coordinate::UnorderedSet findBoundaryNodes(
LineSegment::UnorderedSet& lineSegments);
std::unique_ptr<Geometry> buildPolygonal(
const Geometry* geom) const;
std::unique_ptr<Geometry> buildMultiPolygon(
const MultiPolygon* geom) const;
std::unique_ptr<Polygon> buildPolygon(
const Polygon* polygon) const;
std::unique_ptr<LinearRing> buildRing(
const LinearRing* ring) const;
bool isEdgeDirForward(
const std::vector<CoverageEdge*>& ringEdges,
std::size_t index,
const Coordinate& prevPt) const;
};
} // namespace geos.coverage
} // namespace geos
geos::coverage::CoverageEdge
Definition CoverageEdge.h:46
geos::coverage::CoverageRingEdges::buildCoverage
std::vector< std::unique_ptr< Geometry > > buildCoverage() const
geos::coverage::CoverageRingEdges::selectEdges
std::vector< CoverageEdge * > selectEdges(std::size_t ringCount) const
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::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineSegment
Definition LineSegment.h:61
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::MultiPolygon
Definition MultiPolygon.h:58
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geom
Definition Angle.h:26
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38