EdgeNodingBuilder.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 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.
*
**********************************************************************
*
* Last port: operation/overlayng/EdgeNodingBuilder.java 6ef89b096
*
**********************************************************************/
#pragma once
#include <geos/algorithm/LineIntersector.h>
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/Envelope.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryCollection.h>
#include <geos/geom/LinearRing.h>
#include <geos/geom/LineString.h>
#include <geos/geom/Polygon.h>
#include <geos/noding/IntersectionAdder.h>
#include <geos/noding/Noder.h>
#include <geos/noding/SegmentString.h>
#include <geos/operation/overlayng/Edge.h>
#include <geos/operation/overlayng/EdgeSourceInfo.h>
#include <geos/operation/overlayng/LineLimiter.h>
#include <geos/operation/overlayng/RingClipper.h>
#include <geos/export.h>
#include <array>
#include <memory>
#include <deque>
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL EdgeNodingBuilder {
using PrecisionModel = geos::geom::PrecisionModel;
using Envelope = geos::geom::Envelope;
using GeometryCollection = geos::geom::GeometryCollection;
using Polygon = geos::geom::Polygon;
using CoordinateSequence = geos::geom::CoordinateSequence;
using LinearRing = geos::geom::LinearRing;
using LineString = geos::geom::LineString;
using Geometry = geos::geom::Geometry;
private:
// Constants
static constexpr int MIN_LIMIT_PTS = 20;
static constexpr bool IS_NODING_VALIDATED = true;
// Members
const PrecisionModel* pm;
std::unique_ptr<std::vector<noding::SegmentString*>> inputEdges;
noding::Noder* customNoder;
std::array<bool, 2> hasEdges;
const Envelope* clipEnv;
std::unique_ptr<RingClipper> clipper;
std::unique_ptr<LineLimiter> limiter;
// For use in createFloatingPrecisionNoder()
algorithm::LineIntersector lineInt;
noding::IntersectionAdder intAdder;
std::unique_ptr<noding::Noder> internalNoder;
std::unique_ptr<noding::Noder> spareInternalNoder;
// EdgeSourceInfo*, Edge* owned by EdgeNodingBuilder, stored in deque
std::deque<EdgeSourceInfo> edgeSourceInfoQue;
std::deque<Edge> edgeQue;
bool inputHasZ;
bool inputHasM;
noding::Noder* getNoder();
static std::unique_ptr<noding::Noder> createFixedPrecisionNoder(const PrecisionModel* pm);
std::unique_ptr<noding::Noder> createFloatingPrecisionNoder(bool doValidation);
void addCollection(const GeometryCollection* gc, uint8_t geomIndex);
void addGeometryCollection(const GeometryCollection* gc, uint8_t geomIndex, int expectedDim);
void addPolygon(const Polygon* poly, uint8_t geomIndex);
void addPolygonRing(const LinearRing* ring, bool isHole, uint8_t geomIndex);
void addLine(const LineString* line, uint8_t geomIndex);
void addLine(std::unique_ptr<CoordinateSequence>& pts, uint8_t geomIndex);
void addEdge(std::unique_ptr<CoordinateSequence>& cas, const EdgeSourceInfo* info);
// Create a EdgeSourceInfo* owned by EdgeNodingBuilder
const EdgeSourceInfo* createEdgeSourceInfo(uint8_t index, int depthDelta, bool isHole);
const EdgeSourceInfo* createEdgeSourceInfo(uint8_t index);
bool isClippedCompletely(const Envelope* env) const;
bool isToBeLimited(const LineString* line) const;
std::vector<std::unique_ptr<CoordinateSequence>>& limit(const LineString* line);
std::unique_ptr<CoordinateSequence> clip(const LinearRing* line);
static std::unique_ptr<CoordinateSequence> removeRepeatedPoints(const LineString* line);
static int computeDepthDelta(const LinearRing* ring, bool isHole);
void add(const Geometry* g, uint8_t geomIndex);
std::vector<Edge*> node(std::vector<noding::SegmentString*>* segStrings);
std::vector<Edge*> createEdges(std::vector<noding::SegmentString*>* segStrings);
public:
EdgeNodingBuilder(const PrecisionModel* p_pm, noding::Noder* p_customNoder)
: pm(p_pm)
, inputEdges(new std::vector<noding::SegmentString*>)
, customNoder(p_customNoder)
, hasEdges{{false,false}}
, clipEnv(nullptr)
, intAdder(lineInt)
, inputHasZ(false)
, inputHasM(false)
{};
~EdgeNodingBuilder()
{
for (noding::SegmentString* ss: *inputEdges) {
delete ss;
}
}
void setClipEnvelope(const Envelope* clipEnv);
// returns newly allocated vector and segmentstrings
// std::vector<noding::SegmentString*>* node();
bool hasEdgesFor(uint8_t geomIndex) const;
std::vector<Edge*> build(const Geometry* geom0, const Geometry* geom1);
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
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::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::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geom::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::noding::IntersectionAdder
Computes the intersections between two line segments in SegmentString and adds them to each string.
Definition IntersectionAdder.h:54
geos::noding::Noder
Computes all intersections between segments in a set of SegmentString.
Definition Noder.h:46
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::operation::overlayng::EdgeNodingBuilder::hasEdgesFor
bool hasEdgesFor(uint8_t geomIndex) const
geos::operation::overlayng::EdgeNodingBuilder::build
std::vector< Edge * > build(const Geometry *geom0, const Geometry *geom1)
geos::operation::overlayng::EdgeNodingBuilder::EdgeNodingBuilder
EdgeNodingBuilder(const PrecisionModel *p_pm, noding::Noder *p_customNoder)
Definition EdgeNodingBuilder.h:191
geos::operation::overlayng::EdgeSourceInfo
Definition EdgeSourceInfo.h:38
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38