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