GEOS  3.13.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 
52 
53 namespace geos {
54 namespace simplify { // geos::simplify
55 
56 
60 class GEOS_DLL TaggedLineString {
61 
62 public:
63 
64  typedef std::vector<Coordinate> CoordVect;
65 
66  typedef std::unique_ptr<CoordVect> CoordVectPtr;
67 
69 
70  typedef std::unique_ptr<CoordinateSequence> CoordSeqPtr;
71 
72  TaggedLineString(const geom::LineString* nParentLine,
73  std::size_t minimumSize,
74  bool bIsRing);
75 
77 
78  std::size_t getMinimumSize() const;
79 
80  bool isRing() const;
81 
82  const geom::LineString* getParent() const;
83 
84  const CoordSeq* getParentCoordinates() const;
85 
86  CoordSeqPtr getResultCoordinates() const;
87 
88  const Coordinate& getCoordinate(std::size_t i) const;
89 
90  std::size_t size() const;
91 
92  const Coordinate& getComponentPoint() const;
93 
94  std::size_t getResultSize() const;
95 
96  TaggedLineSegment* getSegment(std::size_t i);
97 
98  const TaggedLineSegment* getSegment(std::size_t i) const;
99 
100  std::vector<TaggedLineSegment*>& getSegments();
101 
102  const std::vector<TaggedLineSegment*>& getSegments() const;
103 
104  const std::vector<TaggedLineSegment*>& getResultSegments() const;
105 
106  void addToResult(std::unique_ptr<TaggedLineSegment> seg);
107 
108  void removeRingEndpoint();
109 
110  std::unique_ptr<geom::Geometry> asLineString() const;
111 
112  std::unique_ptr<geom::Geometry> asLinearRing() const;
113 
114 private:
115 
116  const geom::LineString* parentLine;
117 
118  // TaggedLineSegments owned by this object
119  std::vector<TaggedLineSegment*> segs;
120 
121  // TaggedLineSegments owned by this object
122  std::vector<TaggedLineSegment*> resultSegs;
123 
124  std::size_t minimumSize;
125 
126  bool m_isRing;
127 
128  void init();
129 
130  static std::unique_ptr<CoordinateSequence> extractCoordinates(
131  const std::vector<TaggedLineSegment*>& segs);
132 
133  // Copying is turned off
135  TaggedLineString& operator= (const TaggedLineString&);
136 
137 };
138 
139 } // namespace geos::simplify
140 } // namespace geos
141 
142 #ifdef _MSC_VER
143 #pragma warning(pop)
144 #endif
145 
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:216
Definition: LineString.h:65
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:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25