GEOS 3.9.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
41namespace geos {
42namespace geom {
43class Coordinate;
44class CoordinateArraySequence;
45class CoordinateSequenceFilter;
46}
47}
48
49namespace geos {
50namespace geom { // geos::geom
51
68class GEOS_DLL LineString: public Geometry {
69
70public:
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 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
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
186protected:
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
209private:
210
211 void validateConstruction();
212 void normalizeClosed();
213
214
215};
216
217struct GEOS_DLL LineStringLT {
218 bool
219 operator()(const LineString* ls1, const LineString* ls2) const
220 {
221 return ls1->compareTo(ls2) < 0;
222 }
223};
224
225
226inline 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
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition CoordinateFilter.h:43
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition CoordinateSequenceFilter.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
DimensionType
Definition Dimension.h:31
Definition GeometryComponentFilter.h:43
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:68
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:47
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:188
Definition LineString.h:68
void apply_ro(CoordinateSequenceFilter &filter) const override
virtual std::unique_ptr< Point > getStartPoint() const
Return the start point of the LineString or NULL if this is an EMPTY LineString.
std::unique_ptr< Geometry > getBoundary() const override
Returns a MultiPoint. Empty for closed LineString, a Point for each vertex otherwise.
LineString(CoordinateSequence *pts, const GeometryFactory *newFactory)
Constructs a LineString taking ownership the given CoordinateSequence.
void normalize() override
Normalizes a LineString.
std::unique_ptr< CoordinateSequence > getCoordinates() const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
const Coordinate * getCoordinate() const override
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
bool isEmpty() const override
Returns whether or not the set of points in this Geometry is empty.
std::unique_ptr< Geometry > reverse() const override
Dimension::DimensionType getDimension() const override
Returns line dimension (1)
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
virtual std::unique_ptr< Point > getEndPoint() const
Return the end point of the LineString or NULL if this is an EMPTY LineString.
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition LineString.h:75
void apply_rw(CoordinateSequenceFilter &filter) override
LineString(CoordinateSequence::Ptr &&pts, const GeometryFactory &newFactory)
Hopefully cleaner version of the above.
double getLength() const override
Returns the length of this Geometry.
int getBoundaryDimension() const override
Returns Dimension::False for a closed LineString, 0 otherwise (LineString boundary is a MultiPoint)
std::string getGeometryType() const override
Return a string representation of this Geometry type.
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...
const CoordinateSequence * getCoordinatesRO() const
Returns a read-only pointer to internal CoordinateSequence.
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
uint8_t getCoordinateDimension() const override
Returns coordinate dimension.
std::size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
GeometryTypeId
Geometry types.
Definition Geometry.h:75
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26