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