GEOS  3.9.1dev
LineString.h
Go to the documentation of this file.
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  uint8_t 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 std::unique_ptr<Point> getPointN(std::size_t n) const;
120 
125  virtual std::unique_ptr<Point> getStartPoint() const;
126 
131  virtual std::unique_ptr<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 
197  const GeometryFactory& newFactory);
198 
199  Envelope::Ptr computeEnvelopeInternal() const override;
200 
202 
203  int
204  getSortIndex() const override
205  {
206  return SORTINDEX_LINESTRING;
207  };
208 
209 private:
210 
211  void validateConstruction();
212  void normalizeClosed();
213 
214 
215 };
216 
218  bool
219  operator()(const LineString* ls1, const LineString* ls2) const
220  {
221  return ls1->compareTo(ls2) < 0;
222  }
223 };
224 
225 
226 inline std::unique_ptr<Geometry>
228 {
229  return std::unique_ptr<Geometry>(new LineString(*this));
230 }
231 
232 } // namespace geos::geom
233 } // namespace geos
234 
235 #ifdef _MSC_VER
236 #pragma warning(pop)
237 #endif
238 
239 #endif // ndef GEOS_GEOS_LINESTRING_H
CoordinateSequence::Ptr points
Definition: LineString.h:201
Geometry classes support the concept of applying a Geometry filter to the Geometry.
#define GEOS_DLL
Definition: export.h:28
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:227
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...
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...
std::unique_ptr< CoordinateSequence > Ptr
virtual int compareTo(const Geometry *geom) const
Comparator for sorting geometry.
int getSortIndex() const override
Definition: LineString.h:204
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Basic namespace for all GEOS functionalities.
The internal representation of a list of coordinates inside a Geometry.
std::unique_ptr< Envelope > Ptr
Definition: Envelope.h:64
bool operator()(const LineString *ls1, const LineString *ls2) const
Definition: LineString.h:219