GEOS  3.13.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 
40 namespace geos {
41 namespace geom {
42 class Coordinate;
43 class CoordinateSequenceFilter;
44 }
45 }
46 
47 namespace geos {
48 namespace geom { // geos::geom
49 
66 class GEOS_DLL LineString: public SimpleCurve {
67 
68 public:
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 
101  std::unique_ptr<LineString> reverse() const { return std::unique_ptr<LineString>(reverseImpl()); }
102 
103 protected:
104 
105  LineString(const LineString& ls);
106 
110  LineString(CoordinateSequence::Ptr && pts,
111  const GeometryFactory& newFactory);
112 
113  LineString* cloneImpl() const override { return new LineString(*this); }
114 
115  LineString* reverseImpl() const override;
116 
117  int
118  getSortIndex() const override
119  {
120  return SORTINDEX_LINESTRING;
121  };
122 
123  void geometryChangedAction() override
124  {
125  envelope = computeEnvelopeInternal(true);
126  }
127 
128 private:
129 
130  void validateConstruction();
131 };
132 
133 struct GEOS_DLL LineStringLT {
134  bool
135  operator()(const LineString* ls1, const LineString* ls2) const
136  {
137  return ls1->compareTo(ls2) < 0;
138  }
139 };
140 
141 } // namespace geos::geom
142 } // namespace geos
143 
144 #ifdef _MSC_VER
145 #pragma warning(pop)
146 #endif
147 
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:113
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
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
std::unique_ptr< LineString > reverse() const
Definition: LineString.h:101
void geometryChangedAction() override
Notifies this Geometry that its Coordinates have been changed by an external party.
Definition: LineString.h:123
GeometryTypeId
Geometry types.
Definition: Geometry.h:73
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25