GEOS  3.4.2
LineString.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  * Copyright (C) 2005 2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: geom/LineString.java r320 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_GEOS_LINESTRING_H
22 #define GEOS_GEOS_LINESTRING_H
23 
24 #include <geos/export.h>
25 #include <geos/platform.h> // do we need this ?
26 #include <geos/geom/Geometry.h> // for inheritance
27 #include <geos/geom/Lineal.h> // for inheritance
28 #include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
29 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
30 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
31 
32 #include <string>
33 #include <vector>
34 #include <memory> // for auto_ptr
35 
36 #include <geos/inline.h>
37 
38 #ifdef _MSC_VER
39 #pragma warning(push)
40 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
41 #endif
42 
43 namespace geos {
44  namespace geom {
45  class Coordinate;
46  class CoordinateArraySequence;
47  class CoordinateSequenceFilter;
48  }
49 }
50 
51 namespace geos {
52 namespace geom { // geos::geom
53 
70 class GEOS_DLL LineString: public virtual Geometry, public Lineal {
71 
72 public:
73 
74  friend class GeometryFactory;
75 
77  typedef std::vector<const LineString *> ConstVect;
78 
79  virtual ~LineString();
80 
87  virtual Geometry *clone() const;
88 
89  virtual CoordinateSequence* getCoordinates() const;
90 
92  const CoordinateSequence* getCoordinatesRO() const;
93 
94  virtual const Coordinate& getCoordinateN(int n) const;
95 
97  virtual Dimension::DimensionType getDimension() const;
98 
104  virtual int getBoundaryDimension() const;
105 
107  virtual int getCoordinateDimension() const;
108 
114  virtual Geometry* getBoundary() const;
115 
116  virtual bool isEmpty() const;
117 
118  virtual std::size_t getNumPoints() const;
119 
120  virtual Point* getPointN(std::size_t n) const;
121 
126  virtual Point* getStartPoint() const;
127 
132  virtual Point* getEndPoint() const;
133 
134  virtual bool isClosed() const;
135 
136  virtual bool isRing() const;
137 
138  virtual std::string getGeometryType() const;
139 
140  virtual GeometryTypeId getGeometryTypeId() const;
141 
142  virtual bool isCoordinate(Coordinate& pt) const;
143 
144  virtual bool equalsExact(const Geometry *other, double tolerance=0)
145  const;
146 
147  virtual void apply_rw(const CoordinateFilter *filter);
148 
149  virtual void apply_ro(CoordinateFilter *filter) const;
150 
151  virtual void apply_rw(GeometryFilter *filter);
152 
153  virtual void apply_ro(GeometryFilter *filter) const;
154 
155  virtual void apply_rw(GeometryComponentFilter *filter);
156 
157  virtual void apply_ro(GeometryComponentFilter *filter) const;
158 
159  void apply_rw(CoordinateSequenceFilter& filter);
160 
161  void apply_ro(CoordinateSequenceFilter& filter) const;
162 
170  virtual void normalize();
171 
172  //was protected
173  virtual int compareToSameClass(const Geometry *ls) const;
174 
175  virtual const Coordinate* getCoordinate() const;
176 
177  virtual double getLength() const;
178 
185  Geometry* reverse() const;
186 
187 protected:
188 
189  LineString(const LineString &ls);
190 
194  LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
195 
197  LineString(CoordinateSequence::AutoPtr pts,
198  const GeometryFactory *newFactory);
199 
200  Envelope::AutoPtr computeEnvelopeInternal() const;
201 
202  CoordinateSequence::AutoPtr points;
203 
204 private:
205 
206  void validateConstruction();
207 
208 };
209 
210 struct GEOS_DLL LineStringLT {
211  bool operator()(const LineString *ls1, const LineString *ls2) const {
212  return ls1->compareTo(ls2)<0;
213  }
214 };
215 
216 
217 inline Geometry*
219  return new LineString(*this);
220 }
221 
222 } // namespace geos::geom
223 } // namespace geos
224 
225 #ifdef _MSC_VER
226 #pragma warning(pop)
227 #endif
228 
229 #endif // ndef GEOS_GEOS_LINESTRING_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:48
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Definition: CoordinateSequenceFilter.h:58
GeometryTypeId
Geometry types.
Definition: Geometry.h:65
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: Lineal.h:32
Definition: CoordinateFilter.h:43
Definition: LineString.h:70
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition: LineString.h:77
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Definition: Point.h:67
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43
virtual Geometry * clone() const
Definition: LineString.h:218