GEOS 3.12.0
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
39namespace geos {
40namespace geom {
41class Coordinate;
42class CoordinateSequenceFilter;
43}
44}
45
46namespace geos {
47namespace geom { // geos::geom
48
65class GEOS_DLL LineString: public Geometry {
66
67public:
68
69 friend class GeometryFactory;
70
72 typedef std::vector<const LineString*> ConstVect;
73
74 ~LineString() override;
75
83 std::unique_ptr<LineString> clone() const
84 {
85 return std::unique_ptr<LineString>(cloneImpl());
86 }
87
88 std::unique_ptr<CoordinateSequence> getCoordinates() const override;
89
92
93 virtual const Coordinate& getCoordinateN(std::size_t n) const;
94
102 std::unique_ptr<CoordinateSequence> releaseCoordinates();
103
106
112 int getBoundaryDimension() const override;
113
115 uint8_t getCoordinateDimension() const override;
116
117 bool hasM() const override;
118
119 bool hasZ() const override;
120
126 std::unique_ptr<Geometry> getBoundary() const override;
127
128 bool isEmpty() const override;
129
130 std::size_t getNumPoints() const override;
131
132 virtual std::unique_ptr<Point> getPointN(std::size_t n) const;
133
138 virtual std::unique_ptr<Point> getStartPoint() const;
139
144 virtual std::unique_ptr<Point> getEndPoint() const;
145
146 virtual bool isClosed() const;
147
148 virtual bool isRing() const;
149
150 std::string getGeometryType() const override;
151
153
154 virtual bool isCoordinate(Coordinate& pt) const;
155
156 bool equalsExact(const Geometry* other, double tolerance = 0)
157 const override;
158
159 bool equalsIdentical(const Geometry* other) const override;
160
161 void apply_rw(const CoordinateFilter* filter) override;
162
163 void apply_ro(CoordinateFilter* filter) const override;
164
165 void apply_rw(GeometryFilter* filter) override;
166
167 void apply_ro(GeometryFilter* filter) const override;
168
169 void apply_rw(GeometryComponentFilter* filter) override;
170
171 void apply_ro(GeometryComponentFilter* filter) const override;
172
173 void apply_rw(CoordinateSequenceFilter& filter) override;
174
175 void apply_ro(CoordinateSequenceFilter& filter) const override;
176
184 void normalize() override;
185
186 //was protected
187 int compareToSameClass(const Geometry* ls) const override;
188
189 const CoordinateXY* getCoordinate() const override;
190
191 double getLength() const override;
192
199 std::unique_ptr<LineString> reverse() const { return std::unique_ptr<LineString>(reverseImpl()); }
200
201 const Envelope* getEnvelopeInternal() const override {
202 return &envelope;
203 }
204
205protected:
206
207 LineString(const LineString& ls);
208
212 LineString(CoordinateSequence::Ptr && pts,
213 const GeometryFactory& newFactory);
214
215 LineString* cloneImpl() const override { return new LineString(*this); }
216
217 LineString* reverseImpl() const override;
218
219 Envelope computeEnvelopeInternal() const;
220
221 CoordinateSequence::Ptr points;
222
223 mutable Envelope envelope;
224
225 int
226 getSortIndex() const override
227 {
228 return SORTINDEX_LINESTRING;
229 };
230
231 void geometryChangedAction() override {
232 envelope = computeEnvelopeInternal();
233 }
234
235private:
236
237 void validateConstruction();
238 void normalizeClosed();
239
240
241};
242
243struct GEOS_DLL LineStringLT {
244 bool
245 operator()(const LineString* ls1, const LineString* ls2) const
246 {
247 return ls1->compareTo(ls2) < 0;
248 }
249};
250
251} // namespace geos::geom
252} // namespace geos
253
254#ifdef _MSC_VER
255#pragma warning(pop)
256#endif
257
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:55
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:216
DimensionType
Definition Dimension.h:29
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:58
Definition GeometryComponentFilter.h:41
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:65
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:45
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:186
Definition LineString.h:65
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 * reverseImpl() const override
Make a geometry with coordinates in reverse order.
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 CoordinateXY * 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.
Dimension::DimensionType getDimension() const override
Returns line dimension (1)
LineString * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition LineString.h:215
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
std::unique_ptr< LineString > reverse() const
Definition LineString.h:199
bool equalsIdentical(const Geometry *other) const override
Returns true if the two geometries are of the same type and their vertices corresponding by index are...
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:72
void apply_rw(CoordinateSequenceFilter &filter) override
std::unique_ptr< CoordinateSequence > releaseCoordinates()
Take ownership of the CoordinateSequence managed by this geometry. After releasing the coordinates,...
LineString(CoordinateSequence::Ptr &&pts, const GeometryFactory &newFactory)
Constructs a LineString taking ownership the given CoordinateSequence.
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.
const Envelope * getEnvelopeInternal() const override
Returns the minimum and maximum x and y values in this Geometry, or a null Envelope if this Geometry ...
Definition LineString.h:201
uint8_t getCoordinateDimension() const override
Returns coordinate dimension.
std::size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
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:83
void geometryChangedAction() override
Notifies this Geometry that its Coordinates have been changed by an external party.
Definition LineString.h:231
GeometryTypeId
Geometry types.
Definition Geometry.h:73
Basic namespace for all GEOS functionalities.
Definition geos.h:39