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/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<Geometry> clone() const override;
87 
88  std::unique_ptr<CoordinateSequence> getCoordinates() const override;
89 
91  const CoordinateSequence* getCoordinatesRO() const;
92 
93  virtual const Coordinate& getCoordinateN(size_t n) const;
94 
96  Dimension::DimensionType getDimension() const override;
97 
103  int getBoundaryDimension() const override;
104 
106  int getCoordinateDimension() const override;
107 
113  std::unique_ptr<Geometry> getBoundary() const override;
114 
115  bool isEmpty() const override;
116 
117  std::size_t getNumPoints() const override;
118 
119  virtual Point* getPointN(std::size_t n) const;
120 
125  virtual Point* getStartPoint() const;
126 
131  virtual Point* getEndPoint() const;
132 
133  virtual bool isClosed() const;
134 
135  virtual bool isRing() const;
136 
137  std::string getGeometryType() const override;
138 
139  GeometryTypeId getGeometryTypeId() const override;
140 
141  virtual bool isCoordinate(Coordinate& pt) const;
142 
143  bool equalsExact(const Geometry* other, double tolerance = 0)
144  const override;
145 
146  void apply_rw(const CoordinateFilter* filter) override;
147 
148  void apply_ro(CoordinateFilter* filter) const override;
149 
150  void apply_rw(GeometryFilter* filter) override;
151 
152  void apply_ro(GeometryFilter* filter) const override;
153 
154  void apply_rw(GeometryComponentFilter* filter) override;
155 
156  void apply_ro(GeometryComponentFilter* filter) const override;
157 
158  void apply_rw(CoordinateSequenceFilter& filter) override;
159 
160  void apply_ro(CoordinateSequenceFilter& filter) const override;
161 
169  void normalize() override;
170 
171  //was protected
172  int compareToSameClass(const Geometry* ls) const override;
173 
174  const Coordinate* getCoordinate() const override;
175 
176  double getLength() const override;
177 
184  std::unique_ptr<Geometry> reverse() const override;
185 
186 protected:
187 
188  LineString(const LineString& ls);
189 
193  LineString(CoordinateSequence* pts, const GeometryFactory* newFactory);
194 
196  LineString(CoordinateSequence::Ptr && pts,
197  const GeometryFactory& newFactory);
198 
199  Envelope::Ptr computeEnvelopeInternal() const override;
200 
201  CoordinateSequence::Ptr points;
202 
203  int
204  getSortIndex() const override
205  {
206  return SORTINDEX_LINESTRING;
207  };
208 
209 private:
210 
211  void validateConstruction();
212 
213 };
214 
215 struct GEOS_DLL LineStringLT {
216  bool
217  operator()(const LineString* ls1, const LineString* ls2) const
218  {
219  return ls1->compareTo(ls2) < 0;
220  }
221 };
222 
223 
224 inline std::unique_ptr<Geometry>
226 {
227  return std::unique_ptr<Geometry>(new LineString(*this));
228 }
229 
230 } // namespace geos::geom
231 } // namespace geos
232 
233 #ifdef _MSC_VER
234 #pragma warning(pop)
235 #endif
236 
237 #endif // ndef GEOS_GEOS_LINESTRING_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
std::unique_ptr< Geometry > clone() const override
Creates and returns a full copy of this LineString object (including all coordinates contained by it)...
Definition: LineString.h:225
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:66
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:65
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43