GEOS  3.3.3
TaggedLineString.h
1 /**********************************************************************
2  * $Id: TaggedLineString.h 3275 2011-03-26 14:02:32Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: simplify/TaggedLineString.java rev. 1.2 (JTS-1.7.1)
17  *
18  **********************************************************************
19  *
20  * NOTES: This class can be optimized to work with vector<Coordinate*>
21  * rather then with CoordinateSequence. Also, LineSegment should
22  * be replaced with a class not copying Coordinates.
23  *
24  **********************************************************************/
25 
26 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRING_H
27 #define GEOS_SIMPLIFY_TAGGEDLINESTRING_H
28 
29 #include <geos/export.h>
30 #include <vector>
31 #include <memory>
32 #include <cstddef>
33 
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38 
39 // Forward declarations
40 namespace geos {
41  namespace geom {
42  class Coordinate;
43  class CoordinateSequence;
44  class Geometry;
45  class LineString;
46  class LinearRing;
47  }
48  namespace simplify {
49  class TaggedLineSegment;
50  }
51 }
52 
53 namespace geos {
54 namespace simplify { // geos::simplify
55 
56 using namespace std;
57 
63 class GEOS_DLL TaggedLineString {
64 
65 public:
66 
67  typedef std::vector<geom::Coordinate> CoordVect;
68 
69  typedef std::auto_ptr<CoordVect> CoordVectPtr;
70 
72 
73  typedef std::auto_ptr<geom::CoordinateSequence> CoordSeqPtr;
74 
75  TaggedLineString(const geom::LineString* nParentLine,
76  std::size_t minimumSize=2);
77 
79 
80  std::size_t getMinimumSize() const;
81 
82  const geom::LineString* getParent() const;
83 
84  const CoordSeq* getParentCoordinates() const;
85 
86  CoordSeqPtr getResultCoordinates() const;
87 
88  std::size_t getResultSize() const;
89 
90  TaggedLineSegment* getSegment(std::size_t i);
91 
92  const TaggedLineSegment* getSegment(std::size_t i) const;
93 
94  std::vector<TaggedLineSegment*>& getSegments();
95 
96  const std::vector<TaggedLineSegment*>& getSegments() const;
97 
98  void addToResult(std::auto_ptr<TaggedLineSegment> seg);
99 
100  std::auto_ptr<geom::Geometry> asLineString() const;
101 
102  std::auto_ptr<geom::Geometry> asLinearRing() const;
103 
104 private:
105 
106  const geom::LineString* parentLine;
107 
108  // TaggedLineSegments owned by this object
109  std::vector<TaggedLineSegment*> segs;
110 
111  // TaggedLineSegments owned by this object
112  std::vector<TaggedLineSegment*> resultSegs;
113 
114  std::size_t minimumSize;
115 
116  void init();
117 
118  static CoordVectPtr extractCoordinates(
119  const std::vector<TaggedLineSegment*>& segs);
120 
121  // Copying is turned off
123  TaggedLineString& operator= (const TaggedLineString&);
124 
125 };
126 
127 } // namespace geos::simplify
128 } // namespace geos
129 
130 #ifdef _MSC_VER
131 #pragma warning(pop)
132 #endif
133 
134 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRING_H
135 
136 /**********************************************************************
137  * $Log$
138  * Revision 1.7 2006/06/12 11:29:23 strk
139  * unsigned int => size_t
140  *
141  * Revision 1.6 2006/04/13 21:52:34 strk
142  * Many debugging lines and assertions added. Fixed bug in TaggedLineString class.
143  *
144  * Revision 1.5 2006/04/13 16:04:10 strk
145  * Made TopologyPreservingSimplifier implementation successfully build
146  *
147  * Revision 1.4 2006/04/13 09:21:45 mloskot
148  * Removed definition of copy ctor and assignment operator for TaggedLineString class.
149  * According to following rule: Declaring, but not defining, private copy operations has
150  * the effect of "turning off" copying for the class.
151  *
152  * Revision 1.3 2006/04/12 17:19:57 strk
153  * Ported TaggedLineStringSimplifier class, made LineSegment class
154  * polymorphic to fix derivation of TaggedLineSegment
155  *
156  * Revision 1.2 2006/04/12 15:20:37 strk
157  * LineSegmentIndex class
158  *
159  * Revision 1.1 2006/04/12 14:22:12 strk
160  * Initial implementation of TaggedLineSegment and TaggedLineString classes
161  *
162  **********************************************************************/