LineBuilder.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.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/operation/overlayng/InputGeometry.h>
#include <geos/operation/overlayng/OverlayNG.h>
#include <geos/geom/Location.h>
#include <geos/geom/LineString.h>
#include <vector>
// Forward declarations
namespace geos {
namespace geom {
class GeometryFactory;
class LineString;
}
namespace operation {
namespace overlayng {
class OverlayEdge;
class OverlayGraph;
class OverlayLabel;
class InputGeometry;
}
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL LineBuilder {
private:
// Members
OverlayGraph* graph;
int opCode;
const geom::GeometryFactory* geometryFactory;
bool hasResultArea;
int8_t inputAreaIndex;
std::vector<std::unique_ptr<geom::LineString>> lines;
bool isAllowMixedResult = ! OverlayNG::STRICT_MODE_DEFAULT;
bool isAllowCollapseLines = ! OverlayNG::STRICT_MODE_DEFAULT;
void markResultLines();
bool isResultLine(const OverlayLabel* lbl) const;
static geom::Location effectiveLocation(const OverlayLabel* lbl, uint8_t geomIndex);
void addResultLines();
void addResultLinesMerged();
std::unique_ptr<geom::LineString> toLine(OverlayEdge* edge) const;
void addResultLinesForNodes();
void addResultLinesRings();
std::unique_ptr<geom::LineString> buildLine(OverlayEdge* node);
/*
* Finds the next edge around a node which forms
* part of a result line.
*/
static OverlayEdge* nextLineEdgeUnvisited(OverlayEdge* node) ;
static int degreeOfLines(OverlayEdge* node) ;
public:
LineBuilder(const InputGeometry* inputGeom, OverlayGraph* p_graph, bool p_hasResultArea, int p_opCode, const geom::GeometryFactory* geomFact)
: graph(p_graph)
, opCode(p_opCode)
, geometryFactory(geomFact)
, hasResultArea(p_hasResultArea)
, inputAreaIndex((int8_t)inputGeom->getAreaIndex())
, isAllowMixedResult(! OverlayNG::STRICT_MODE_DEFAULT)
, isAllowCollapseLines(! OverlayNG::STRICT_MODE_DEFAULT)
{}
LineBuilder(const LineBuilder&) = delete;
LineBuilder& operator=(const LineBuilder&) = delete;
std::vector<std::unique_ptr<geom::LineString>> getLines();
void setStrictMode(bool p_isStrictResultMode)
{
isAllowCollapseLines = ! p_isStrictResultMode;
isAllowMixedResult = ! p_isStrictResultMode;
}
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::LineString
Definition LineString.h:66
geos::operation::overlayng::InputGeometry
Definition InputGeometry.h:41
geos::operation::overlayng::OverlayEdge
Definition OverlayEdge.h:47
geos::operation::overlayng::OverlayGraph
Definition OverlayGraph.h:52
geos::operation::overlayng::OverlayLabel
Definition OverlayLabel.h:86
geos::operation::overlayng::OverlayNG::STRICT_MODE_DEFAULT
static constexpr bool STRICT_MODE_DEFAULT
Definition OverlayNG.h:173
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::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38