GEOS  3.14.0dev
TaggedLineString.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 Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: simplify/TaggedLineString.java rev. 1.2 (JTS-1.7.1)
16  *
17  **********************************************************************
18  *
19  * NOTES: This class can be optimized to work with vector<Coordinate*>
20  * rather then with CoordinateSequence. Also, LineSegment should
21  * be replaced with a class not copying Coordinates.
22  *
23  **********************************************************************/
24 
25 #pragma once
26 
27 #include <geos/export.h>
28 #include <vector>
29 #include <memory>
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34 #endif
35 
36 // Forward declarations
37 namespace geos {
38 namespace geom {
39 class Coordinate;
40 class CoordinateSequence;
41 class Geometry;
42 class LineString;
43 class LinearRing;
44 }
45 namespace simplify {
46 class TaggedLineSegment;
47 }
48 }
49 
50 namespace geos {
51 namespace simplify { // geos::simplify
52 
53 
57 class GEOS_DLL TaggedLineString {
60 
61 public:
62 
63  typedef std::vector<Coordinate> CoordVect;
64 
65  typedef std::unique_ptr<CoordVect> CoordVectPtr;
66 
68 
69  typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
70 
71  TaggedLineString(const geom::LineString* nParentLine,
72  std::size_t minimumSize,
73  bool bIsRing);
74 
76 
77  std::size_t getMinimumSize() const;
78 
79  bool isRing() const;
80 
81  const geom::LineString* getParent() const;
82 
83  const CoordSeq* getParentCoordinates() const;
84 
85  CoordSeqPtr getResultCoordinates() const;
86 
87  const Coordinate& getCoordinate(std::size_t i) const;
88 
89  std::size_t size() const;
90 
91  const Coordinate& getComponentPoint() const;
92 
93  std::size_t getResultSize() const;
94 
95  TaggedLineSegment* getSegment(std::size_t i);
96 
97  const TaggedLineSegment* getSegment(std::size_t i) const;
98 
99  std::vector<TaggedLineSegment*>& getSegments();
100 
101  const std::vector<TaggedLineSegment*>& getSegments() const;
102 
103  const std::vector<TaggedLineSegment*>& getResultSegments() const;
104 
105  void addToResult(std::unique_ptr<TaggedLineSegment> seg);
106 
107  const TaggedLineSegment* removeRingEndpoint();
108 
109  std::unique_ptr<geom::Geometry> asLineString() const;
110 
111  std::unique_ptr<geom::Geometry> asLinearRing() const;
112 
113 private:
114 
115  const geom::LineString* parentLine;
116 
117  // TaggedLineSegments owned by this object
118  std::vector<TaggedLineSegment*> segs;
119 
120  // TaggedLineSegments owned by this object
121  std::vector<TaggedLineSegment*> resultSegs;
122 
123  std::size_t minimumSize;
124 
125  bool m_isRing;
126 
127  void init();
128 
129  static std::unique_ptr<CoordinateSequence> extractCoordinates(
130  const std::vector<TaggedLineSegment*>& segs);
131 
132  // Copying is turned off
134  TaggedLineString& operator= (const TaggedLineString&);
135 
136 };
137 
138 } // namespace geos::simplify
139 } // namespace geos
140 
141 #ifdef _MSC_VER
142 #pragma warning(pop)
143 #endif
144 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
Definition: LineString.h:66
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:53
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:57
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25