GEOS  3.8.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<Geometry> clone() const override;
87 
88  std::unique_ptr<CoordinateSequence> getCoordinates() const override;
89 
92 
93  virtual const Coordinate& getCoordinateN(size_t n) const;
94 
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 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 
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 
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
geos::geom::LineString::reverse
std::unique_ptr< Geometry > reverse() const override
geos::geom::LineString::LineString
LineString(CoordinateSequence::Ptr &&pts, const GeometryFactory &newFactory)
Hopefully cleaner version of the above.
geos::geom::LineString::getLength
double getLength() const override
Returns the length of this Geometry.
geos::geom::LineString::getBoundary
std::unique_ptr< Geometry > getBoundary() const override
Returns a MultiPoint. Empty for closed LineString, a Point for each vertex otherwise.
geos::geom::LineString::getCoordinate
const Coordinate * getCoordinate() const override
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::geom::LineString::ConstVect
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition: LineString.h:75
geos::geom::GeometryComponentFilter
Definition: GeometryComponentFilter.h:43
geos::geom::LineString::getStartPoint
virtual std::unique_ptr< Point > getStartPoint() const
Return the start point of the LineString or NULL if this is an EMPTY LineString.
geos::geom::LineString::getBoundaryDimension
int getBoundaryDimension() const override
Returns Dimension::False for a closed LineString, 0 otherwise (LineString boundary is a MultiPoint)
geos::geom::LineString::clone
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
geos::geom::LineString::apply_ro
void apply_ro(CoordinateSequenceFilter &filter) const override
geos::geom::LineString::getCoordinateDimension
int getCoordinateDimension() const override
Returns coordinate dimension.
geos::geom::LineString::normalize
void normalize() override
Normalizes a LineString.
geos::geom::LineString::getCoordinates
std::unique_ptr< CoordinateSequence > getCoordinates() const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
geos::geom::Dimension::DimensionType
DimensionType
Definition: Dimension.h:67
geos::geom::LineString::apply_rw
void apply_rw(CoordinateSequenceFilter &filter) override
geos::geom::LineString::getCoordinatesRO
const CoordinateSequence * getCoordinatesRO() const
Returns a read-only pointer to internal CoordinateSequence.
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:84
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
geos::geom::CoordinateSequenceFilter
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
geos::geom::LineString::getDimension
Dimension::DimensionType getDimension() const override
Returns line dimension (1)
geos::geom::LineString::getGeometryTypeId
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
geos::geom::LineString::getNumPoints
std::size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
geos::geom::LineString::LineString
LineString(CoordinateSequence *pts, const GeometryFactory *newFactory)
Constructs a LineString taking ownership the given CoordinateSequence.
geos::geom::GeometryTypeId
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
geos::geom::LineString::getEndPoint
virtual std::unique_ptr< Point > getEndPoint() const
Return the end point of the LineString or NULL if this is an EMPTY LineString.
geos::geom::LineString::isEmpty
bool isEmpty() const override
Returns whether or not the set of points in this Geometry is empty.
geos::geom::CoordinateFilter
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:67
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
geos::geom::LineString::getGeometryType
std::string getGeometryType() const override
Return a string representation of this Geometry type.
geos::geom::GeometryFilter
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
geos::geom::LineString
Definition: LineString.h:68
geos::geom::LineString::equalsExact
bool equalsExact(const Geometry *other, double tolerance=0) const override
Returns true iff the two Geometrys are of the same type and their vertices corresponding by index are...