GEOS 3.3.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

LineString.h
1 /**********************************************************************
2 * $Id: LineString.h 3185 2011-02-07 15:39:27Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 * Copyright (C) 2005 2006 Refractions Research Inc.
10 *
11 * This is free software; you can redistribute and/or modify it under
12 * the terms of the GNU Lesser General Public Licence as published
13 * by the Free Software Foundation.
14 * See the COPYING file for more information.
15 *
16 **********************************************************************
17 *
18 * Last port: geom/LineString.java r320 (JTS-1.12)
19 *
20 **********************************************************************/
21
22 #ifndef GEOS_GEOS_LINESTRING_H
23 #define GEOS_GEOS_LINESTRING_H
24
25 #include <geos/export.h>
26 #include <geos/platform.h> // do we need this ?
27 #include <geos/geom/Geometry.h> // for inheritance
28 #include <geos/geom/Lineal.h> // for inheritance
29 #include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
30 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
31 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
32
33 #include <string>
34 #include <vector>
35 #include <memory> // for auto_ptr
36
37 #include <geos/inline.h>
38
39 #ifdef _MSC_VER
40 #pragma warning(push)
41 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
42 #endif
43
44 namespace geos {
45 namespace geom {
46 class Coordinate;
47 class CoordinateArraySequence;
48 class CoordinateSequenceFilter;
49 }
50 }
51
52 namespace geos {
53 namespace geom { // geos::geom
54
71 class GEOS_DLL LineString: public virtual Geometry, public Lineal {
72
73 public:
74
75 friend class GeometryFactory;
76
78 typedef std::vector<const LineString *> ConstVect;
79
80 virtual ~LineString();
81
88 virtual Geometry *clone() const;
89
90 virtual CoordinateSequence* getCoordinates() const;
91
93 const CoordinateSequence* getCoordinatesRO() const;
94
95 virtual const Coordinate& getCoordinateN(int n) const;
96
98 virtual Dimension::DimensionType getDimension() const;
99
105 virtual int getBoundaryDimension() const;
106
108 virtual int getCoordinateDimension() const;
109
115 virtual Geometry* getBoundary() const;
116
117 virtual bool isEmpty() const;
118
119 virtual std::size_t getNumPoints() const;
120
121 virtual Point* getPointN(std::size_t n) const;
122
127 virtual Point* getStartPoint() const;
128
133 virtual Point* getEndPoint() const;
134
135 virtual bool isClosed() const;
136
137 virtual bool isRing() const;
138
139 virtual std::string getGeometryType() const;
140
141 virtual GeometryTypeId getGeometryTypeId() const;
142
143 virtual bool isCoordinate(Coordinate& pt) const;
144
145 virtual bool equalsExact(const Geometry *other, double tolerance=0)
146 const;
147
148 virtual void apply_rw(const CoordinateFilter *filter);
149
150 virtual void apply_ro(CoordinateFilter *filter) const;
151
152 virtual void apply_rw(GeometryFilter *filter);
153
154 virtual void apply_ro(GeometryFilter *filter) const;
155
156 virtual void apply_rw(GeometryComponentFilter *filter);
157
158 virtual void apply_ro(GeometryComponentFilter *filter) const;
159
160 void apply_rw(CoordinateSequenceFilter& filter);
161
162 void apply_ro(CoordinateSequenceFilter& filter) const;
163
171 virtual void normalize();
172
173 //was protected
174 virtual int compareToSameClass(const Geometry *ls) const;
175
176 virtual const Coordinate* getCoordinate() const;
177
178 virtual double getLength() const;
179
186 Geometry* reverse() const;
187
188 protected:
189
190 LineString(const LineString &ls);
191
195 LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
196
198 LineString(CoordinateSequence::AutoPtr pts,
199 const GeometryFactory *newFactory);
200
201 Envelope::AutoPtr computeEnvelopeInternal() const;
202
203 CoordinateSequence::AutoPtr points;
204
205 private:
206
207 void validateConstruction();
208
209 };
210
211 struct GEOS_DLL LineStringLT {
212 bool operator()(const LineString *ls1, const LineString *ls2) const {
213 return ls1->compareTo(ls2)<0;
214 }
215 };
216
217
218 inline Geometry*
219 LineString::clone() const {
220 return new LineString(*this);
221 }
222
223 } // namespace geos::geom
224 } // namespace geos
225
226 #ifdef _MSC_VER
227 #pragma warning(pop)
228 #endif
229
230 #endif // ndef GEOS_GEOS_LINESTRING_H
231
232 /**********************************************************************
233 * $Log$
234 * Revision 1.10 2006/06/12 10:49:43 strk
235 * unsigned int => size_t
236 *
237 * Revision 1.9 2006/05/04 15:49:39 strk
238 * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
239 *
240 * Revision 1.8 2006/04/28 10:55:39 strk
241 * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
242 * which has been made friend of all Geometry derivates. getNumPoints() changed to return
243 * size_t.
244 *
245 * Revision 1.7 2006/04/11 11:16:25 strk
246 * Added LineString and LinearRing constructors by auto_ptr
247 *
248 * Revision 1.6 2006/04/10 18:15:09 strk
249 * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
250 * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
251 *
252 * Revision 1.5 2006/04/10 17:35:44 strk
253 * Changed LineString::points and Point::coordinates to be wrapped
254 * in an auto_ptr<>. This should close bugs #86 and #89
255 *
256 * Revision 1.4 2006/04/05 10:25:21 strk
257 * Fixed LineString constructor to ensure deletion of CoordinateSequence
258 * argument on exception throw
259 *
260 * Revision 1.3 2006/03/31 16:55:17 strk
261 * Added many assertions checking in LineString implementation.
262 * Changed ::getCoordinate() to return NULL on empty geom.
263 * Changed ::get{Start,End}Point() to return NULL on empty geom.
264 *
265 * Revision 1.2 2006/03/24 09:52:41 strk
266 * USE_INLINE => GEOS_INLINE
267 *
268 * Revision 1.1 2006/03/09 16:46:49 strk
269 * geos::geom namespace definition, first pass at headers split
270 *
271 **********************************************************************/