GEOS  3.6.1
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 
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*
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
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
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
virtual Geometry * clone() const
Creates and returns a full copy of this LineString object (including all coordinates contained by it)...
Definition: LineString.h:219
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