GEOS  3.9.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 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRING_H
26 #define GEOS_SIMPLIFY_TAGGEDLINESTRING_H
27 
28 #include <geos/export.h>
29 #include <vector>
30 #include <memory>
31 
32 #ifdef _MSC_VER
33 #pragma warning(push)
34 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35 #endif
36 
37 // Forward declarations
38 namespace geos {
39 namespace geom {
40 class Coordinate;
41 class CoordinateSequence;
42 class Geometry;
43 class LineString;
44 class LinearRing;
45 }
46 namespace simplify {
47 class TaggedLineSegment;
48 }
49 }
50 
51 namespace geos {
52 namespace simplify { // geos::simplify
53 
54 
58 class GEOS_DLL TaggedLineString {
59 
60 public:
61 
62  typedef std::vector<geom::Coordinate> CoordVect;
63 
64  typedef std::unique_ptr<CoordVect> CoordVectPtr;
65 
67 
68  typedef std::unique_ptr<geom::CoordinateSequence> CoordSeqPtr;
69 
70  TaggedLineString(const geom::LineString* nParentLine,
71  std::size_t minimumSize = 2);
72 
74 
75  std::size_t getMinimumSize() const;
76 
77  const geom::LineString* getParent() const;
78 
79  const CoordSeq* getParentCoordinates() const;
80 
81  CoordSeqPtr getResultCoordinates() const;
82 
83  std::size_t getResultSize() const;
84 
85  TaggedLineSegment* getSegment(std::size_t i);
86 
87  const TaggedLineSegment* getSegment(std::size_t i) const;
88 
89  std::vector<TaggedLineSegment*>& getSegments();
90 
91  const std::vector<TaggedLineSegment*>& getSegments() const;
92 
93  void addToResult(std::unique_ptr<TaggedLineSegment> seg);
94 
95  std::unique_ptr<geom::Geometry> asLineString() const;
96 
97  std::unique_ptr<geom::Geometry> asLinearRing() const;
98 
99 private:
100 
101  const geom::LineString* parentLine;
102 
103  // TaggedLineSegments owned by this object
104  std::vector<TaggedLineSegment*> segs;
105 
106  // TaggedLineSegments owned by this object
107  std::vector<TaggedLineSegment*> resultSegs;
108 
109  std::size_t minimumSize;
110 
111  void init();
112 
113  static CoordVectPtr extractCoordinates(
114  const std::vector<TaggedLineSegment*>& segs);
115 
116  // Copying is turned off
118  TaggedLineString& operator= (const TaggedLineString&);
119 
120 };
121 
122 } // namespace geos::simplify
123 } // namespace geos
124 
125 #ifdef _MSC_VER
126 #pragma warning(pop)
127 #endif
128 
129 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRING_H
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:54
Definition: LineString.h:68
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:58
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58