GEOS 3.14.0dev
LineMerger.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2006 Refractions Research Inc.
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: operation/linemerge/LineMerger.java r378 (JTS-1.12)
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/export.h>
22#include <geos/geom/LineString.h>
23#include <geos/operation/linemerge/LineMergeGraph.h> // for composition
24
25#include <memory>
26#include <vector>
27
28#ifdef _MSC_VER
29#pragma warning(push)
30#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31#endif
32
33// Forward declarations
34namespace geos {
35namespace geom {
36class GeometryFactory;
37class Geometry;
38}
39namespace planargraph {
40class Node;
41}
42namespace operation {
43namespace linemerge {
44class EdgeString;
45class LineMergeDirectedEdge;
46}
47}
48}
49
50
51namespace geos {
52namespace operation { // geos::operation
53namespace linemerge { // geos::operation::linemerge
54
75class GEOS_DLL LineMerger {
76
77private:
78
79 LineMergeGraph graph;
80
81 bool isDirected;
82
83 std::vector<std::unique_ptr<geom::LineString>> mergedLineStrings;
84
85 std::vector<EdgeString*> edgeStrings;
86
87 const geom::GeometryFactory* factory;
88
89 void merge();
90
91 void buildEdgeStringsForObviousStartNodes();
92
93 void buildEdgeStringsForIsolatedLoops();
94
95 void buildEdgeStringsForUnprocessedNodes();
96
97 void buildEdgeStringsForNonDegree2Nodes();
98
99 void buildEdgeStringsStartingAt(planargraph::Node* node);
100
101 EdgeString* buildEdgeStringStartingWith(LineMergeDirectedEdge* start);
102
103public:
104 LineMerger(bool directed = false);
105 ~LineMerger();
106
115 void add(std::vector<const geom::Geometry*>* geometries);
116
125 void add(const geom::Geometry* geometry);
126
133 std::vector<std::unique_ptr<geom::LineString>> getMergedLineStrings();
134
135 void add(const geom::LineString* lineString);
136
137 // Declare type as noncopyable
138 LineMerger(const LineMerger& other) = delete;
139 LineMerger& operator=(const LineMerger& rhs) = delete;
140};
141
142} // namespace geos::operation::linemerge
143} // namespace geos::operation
144} // namespace geos
145
146#ifdef _MSC_VER
147#pragma warning(pop)
148#endif
149
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition LineString.h:66
A sequence of LineMergeDirectedEdge forming one of the lines that will be output by the line-merging ...
Definition EdgeString.h:55
A DirectedEdge of a LineMergeGraph.
Definition LineMergeDirectedEdge.h:46
A planar graph of edges that is analyzed to sew the edges together.
Definition LineMergeGraph.h:58
Sews together a set of fully noded LineStrings.
Definition LineMerger.h:75
void add(std::vector< const geom::Geometry * > *geometries)
Adds a collection of Geometries to be processed. May be called multiple times.
std::vector< std::unique_ptr< geom::LineString > > getMergedLineStrings()
Returns the LineStrings built by the merging process.
void add(const geom::Geometry *geometry)
Adds a Geometry to be processed. May be called multiple times.
A node in a PlanarGraph is a location where 0 or more Edge meet.
Definition planargraph/Node.h:44
Basic namespace for all GEOS functionalities.
Definition geos.h:39