GEOS  3.12.0
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 {
58 
59 public:
60 
61  typedef std::vector<geom::Coordinate> CoordVect;
62 
63  typedef std::unique_ptr<CoordVect> CoordVectPtr;
64 
66 
67  typedef std::unique_ptr<geom::CoordinateSequence> CoordSeqPtr;
68 
69  TaggedLineString(const geom::LineString* nParentLine,
70  std::size_t minimumSize,
71  bool preserveEndpoint);
72 
74 
75  std::size_t getMinimumSize() const;
76 
77  bool getPreserveEndpoint() const;
78 
79  const geom::LineString* getParent() const;
80 
81  const CoordSeq* getParentCoordinates() const;
82 
83  CoordSeqPtr getResultCoordinates() const;
84 
85  std::size_t getResultSize() const;
86 
87  TaggedLineSegment* getSegment(std::size_t i);
88 
89  const TaggedLineSegment* getSegment(std::size_t i) const;
90 
91  std::vector<TaggedLineSegment*>& getSegments();
92 
93  const std::vector<TaggedLineSegment*>& getSegments() const;
94 
95  const std::vector<TaggedLineSegment*>& getResultSegments() const;
96 
97  void addToResult(std::unique_ptr<TaggedLineSegment> seg);
98 
99  void removeRingEndpoint();
100 
101  std::unique_ptr<geom::Geometry> asLineString() const;
102 
103  std::unique_ptr<geom::Geometry> asLinearRing() const;
104 
105 private:
106 
107  const geom::LineString* parentLine;
108 
109  // TaggedLineSegments owned by this object
110  std::vector<TaggedLineSegment*> segs;
111 
112  // TaggedLineSegments owned by this object
113  std::vector<TaggedLineSegment*> resultSegs;
114 
115  std::size_t minimumSize;
116 
117  bool preserveEndpoint;
118 
119  void init();
120 
121  static std::unique_ptr<geom::CoordinateSequence> extractCoordinates(
122  const std::vector<TaggedLineSegment*>& segs);
123 
124  // Copying is turned off
126  TaggedLineString& operator= (const TaggedLineString&);
127 
128 };
129 
130 } // namespace geos::simplify
131 } // namespace geos
132 
133 #ifdef _MSC_VER
134 #pragma warning(pop)
135 #endif
136 
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:53
Definition: LineString.h:65
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56