GEOS  3.8.0dev
LineString.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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/geom/Geometry.h> // for inheritance
26 #include <geos/geom/Lineal.h> // for inheritance
27 #include <geos/geom/CoordinateSequence.h> // for proper use of unique_ptr<>
28 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
29 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
30 
31 #include <string>
32 #include <vector>
33 #include <memory> // for unique_ptr
34 
35 #include <geos/inline.h>
36 
37 #ifdef _MSC_VER
38 #pragma warning(push)
39 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40 #endif
41 
42 namespace geos {
43 namespace geom {
44 class Coordinate;
45 class CoordinateArraySequence;
46 class CoordinateSequenceFilter;
47 }
48 }
49 
50 namespace geos {
51 namespace geom { // geos::geom
52 
69 class GEOS_DLL LineString: public virtual Geometry, public Lineal {
70 
71 public:
72 
73  friend class GeometryFactory;
74 
76  typedef std::vector<const LineString*> ConstVect;
77 
78  ~LineString() override;
79 
87  Geometry* clone() const override;
88 
89  CoordinateSequence* getCoordinates() const override;
90 
92  const CoordinateSequence* getCoordinatesRO() const;
93 
94  virtual const Coordinate& getCoordinateN(size_t n) const;
95 
97  Dimension::DimensionType getDimension() const override;
98 
104  int getBoundaryDimension() const override;
105 
107  int getCoordinateDimension() const override;
108 
114  Geometry* getBoundary() const override;
115 
116  bool isEmpty() const override;
117 
118  std::size_t getNumPoints() const override;
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  std::string getGeometryType() const override;
139 
140  GeometryTypeId getGeometryTypeId() const override;
141 
142  virtual bool isCoordinate(Coordinate& pt) const;
143 
144  bool equalsExact(const Geometry* other, double tolerance = 0)
145  const override;
146 
147  void apply_rw(const CoordinateFilter* filter) override;
148 
149  void apply_ro(CoordinateFilter* filter) const override;
150 
151  void apply_rw(GeometryFilter* filter) override;
152 
153  void apply_ro(GeometryFilter* filter) const override;
154 
155  void apply_rw(GeometryComponentFilter* filter) override;
156 
157  void apply_ro(GeometryComponentFilter* filter) const override;
158 
159  void apply_rw(CoordinateSequenceFilter& filter) override;
160 
161  void apply_ro(CoordinateSequenceFilter& filter) const override;
162 
170  void normalize() override;
171 
172  //was protected
173  int compareToSameClass(const Geometry* ls) const override;
174 
175  const Coordinate* getCoordinate() const override;
176 
177  double getLength() const override;
178 
185  Geometry* reverse() const override;
186 
187 protected:
188 
189  LineString(const LineString& ls);
190 
194  LineString(CoordinateSequence* pts, const GeometryFactory* newFactory);
195 
197  LineString(CoordinateSequence::Ptr pts,
198  const GeometryFactory* newFactory);
199 
200  Envelope::Ptr computeEnvelopeInternal() const override;
201 
202  CoordinateSequence::Ptr points;
203 
204  int
205  getSortIndex() const override
206  {
207  return SORTINDEX_LINESTRING;
208  };
209 
210 private:
211 
212  void validateConstruction();
213 
214 };
215 
216 struct GEOS_DLL LineStringLT {
217  bool
218  operator()(const LineString* ls1, const LineString* ls2) const
219  {
220  return ls1->compareTo(ls2) < 0;
221  }
222 };
223 
224 
225 inline Geometry*
227 {
228  return new LineString(*this);
229 }
230 
231 } // namespace geos::geom
232 } // namespace geos
233 
234 #ifdef _MSC_VER
235 #pragma warning(pop)
236 #endif
237 
238 #endif // ndef GEOS_GEOS_LINESTRING_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition: LineString.h:76
Geometry * clone() const override
Creates and returns a full copy of this LineString object (including all coordinates contained by it)...
Definition: LineString.h:226
Definition: CoordinateSequenceFilter.h:58
GeometryTypeId
Geometry types.
Definition: Geometry.h:74
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: Lineal.h:37
Definition: CoordinateFilter.h:43
Definition: LineString.h:69
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
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: Point.h:66
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43