GEOS  3.10.1
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/CoordinateSequence.h> // for proper use of unique_ptr<>
27 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
28 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
29 
30 #include <string>
31 #include <vector>
32 #include <memory> // for unique_ptr
33 
34 #include <geos/inline.h>
35 
36 #ifdef _MSC_VER
37 #pragma warning(push)
38 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
39 #endif
40 
41 namespace geos {
42 namespace geom {
43 class Coordinate;
44 class CoordinateArraySequence;
45 class CoordinateSequenceFilter;
46 }
47 }
48 
49 namespace geos {
50 namespace geom { // geos::geom
51 
68 class GEOS_DLL LineString: public Geometry {
69 
70 public:
71 
72  friend class GeometryFactory;
73 
75  typedef std::vector<const LineString*> ConstVect;
76 
77  ~LineString() override;
78 
86  std::unique_ptr<LineString> clone() const
87  {
88  return std::unique_ptr<LineString>(cloneImpl());
89  }
90 
91  std::unique_ptr<CoordinateSequence> getCoordinates() const override;
92 
94  const CoordinateSequence* getCoordinatesRO() const;
95 
96  virtual const Coordinate& getCoordinateN(std::size_t n) const;
97 
105  std::unique_ptr<CoordinateSequence> releaseCoordinates();
106 
108  Dimension::DimensionType getDimension() const override;
109 
115  int getBoundaryDimension() const override;
116 
118  uint8_t getCoordinateDimension() const override;
119 
125  std::unique_ptr<Geometry> getBoundary() const override;
126 
127  bool isEmpty() const override;
128 
129  std::size_t getNumPoints() const override;
130 
131  virtual std::unique_ptr<Point> getPointN(std::size_t n) const;
132 
137  virtual std::unique_ptr<Point> getStartPoint() const;
138 
143  virtual std::unique_ptr<Point> getEndPoint() const;
144 
145  virtual bool isClosed() const;
146 
147  virtual bool isRing() const;
148 
149  std::string getGeometryType() const override;
150 
151  GeometryTypeId getGeometryTypeId() const override;
152 
153  virtual bool isCoordinate(Coordinate& pt) const;
154 
155  bool equalsExact(const Geometry* other, double tolerance = 0)
156  const override;
157 
158  void apply_rw(const CoordinateFilter* filter) override;
159 
160  void apply_ro(CoordinateFilter* filter) const override;
161 
162  void apply_rw(GeometryFilter* filter) override;
163 
164  void apply_ro(GeometryFilter* filter) const override;
165 
166  void apply_rw(GeometryComponentFilter* filter) override;
167 
168  void apply_ro(GeometryComponentFilter* filter) const override;
169 
170  void apply_rw(CoordinateSequenceFilter& filter) override;
171 
172  void apply_ro(CoordinateSequenceFilter& filter) const override;
173 
181  void normalize() override;
182 
183  //was protected
184  int compareToSameClass(const Geometry* ls) const override;
185 
186  const Coordinate* getCoordinate() const override;
187 
188  double getLength() const override;
189 
196  std::unique_ptr<LineString> reverse() const { return std::unique_ptr<LineString>(reverseImpl()); }
197 
198 protected:
199 
200  LineString(const LineString& ls);
201 
205  LineString(CoordinateSequence* pts, const GeometryFactory* newFactory);
206 
208  LineString(CoordinateSequence::Ptr && pts,
209  const GeometryFactory& newFactory);
210 
211  LineString* cloneImpl() const override { return new LineString(*this); }
212 
213  LineString* reverseImpl() const override;
214 
215  Envelope::Ptr computeEnvelopeInternal() const override;
216 
217  CoordinateSequence::Ptr points;
218 
219  int
220  getSortIndex() const override
221  {
222  return SORTINDEX_LINESTRING;
223  };
224 
225 private:
226 
227  void validateConstruction();
228  void normalizeClosed();
229 
230 
231 };
232 
233 struct GEOS_DLL LineStringLT {
234  bool
235  operator()(const LineString* ls1, const LineString* ls2) const
236  {
237  return ls1->compareTo(ls2) < 0;
238  }
239 };
240 
241 } // namespace geos::geom
242 } // namespace geos
243 
244 #ifdef _MSC_VER
245 #pragma warning(pop)
246 #endif
247 
248 #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:75
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
Definition: LineString.h:68
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
std::unique_ptr< LineString > reverse() const
Definition: LineString.h:196
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
LineString * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: LineString.h:211
std::unique_ptr< LineString > clone() const
Creates and returns a full copy of this LineString object (including all coordinates contained by it)...
Definition: LineString.h:86
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43