GEOS 3.14.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#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#include <geos/geom/SimpleCurve.h>
29
30#include <string>
31#include <vector>
32#include <memory> // for unique_ptr
33
34
35#ifdef _MSC_VER
36#pragma warning(push)
37#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38#endif
39
40namespace geos {
41namespace geom {
42class Coordinate;
43class CoordinateSequenceFilter;
44}
45}
46
47namespace geos {
48namespace geom { // geos::geom
49
66class GEOS_DLL LineString: public SimpleCurve {
67
68public:
69
70 friend class GeometryFactory;
71
73 typedef std::vector<const LineString*> ConstVect;
74
75 ~LineString() override;
76
84 std::unique_ptr<LineString> clone() const
85 {
86 return std::unique_ptr<LineString>(cloneImpl());
87 }
88
89 std::string getGeometryType() const override;
90
92
93 double getLength() const override;
94
95 bool isCurved() const override {
96 return false;
97 }
98
105 std::unique_ptr<LineString> reverse() const { return std::unique_ptr<LineString>(reverseImpl()); }
106
107protected:
108
109 LineString(const LineString& ls);
110
114 LineString(CoordinateSequence::Ptr && pts,
115 const GeometryFactory& newFactory);
116
117 LineString* cloneImpl() const override { return new LineString(*this); }
118
119 LineString* reverseImpl() const override;
120
121 int
122 getSortIndex() const override
123 {
124 return SORTINDEX_LINESTRING;
125 };
126
127 void geometryChangedAction() override
128 {
129 envelope = computeEnvelopeInternal(true);
130 }
131
132private:
133
134 void validateConstruction();
135};
136
137struct GEOS_DLL LineStringLT {
138 bool
139 operator()(const LineString* ls1, const LineString* ls2) const
140 {
141 return ls1->compareTo(ls2) < 0;
142 }
143};
144
145} // namespace geos::geom
146} // namespace geos
147
148#ifdef _MSC_VER
149#pragma warning(pop)
150#endif
151
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Definition LineString.h:66
LineString * reverseImpl() const override
Make a geometry with coordinates in reverse order.
LineString * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition LineString.h:117
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
std::unique_ptr< LineString > reverse() const
Definition LineString.h:105
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition LineString.h:73
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.
std::string getGeometryType() const override
Return a string representation of this Geometry type.
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:84
void geometryChangedAction() override
Notifies this Geometry that its Coordinates have been changed by an external party.
Definition LineString.h:127
GeometryTypeId
Geometry types.
Definition Geometry.h:74
Basic namespace for all GEOS functionalities.
Definition geos.h:39