GEOS 3.6.2
LineString.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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/platform.h> // do we need this ?
26#include <geos/geom/Geometry.h> // for inheritance
27#include <geos/geom/Lineal.h> // for inheritance
28#include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
29#include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
30#include <geos/geom/Dimension.h> // for Dimension::DimensionType
31
32#include <string>
33#include <vector>
34#include <memory> // for auto_ptr
35
36#include <geos/inline.h>
37
38#ifdef _MSC_VER
39#pragma warning(push)
40#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
41#endif
42
43namespace geos {
44 namespace geom {
45 class Coordinate;
48 }
49}
50
51namespace geos {
52namespace geom { // geos::geom
53
70class GEOS_DLL LineString: public virtual Geometry, public Lineal {
71
72public:
73
74 friend class GeometryFactory;
75
77 typedef std::vector<const LineString *> ConstVect;
78
79 virtual ~LineString();
80
88 virtual Geometry *clone() const;
89
91
94
95 virtual const Coordinate& getCoordinateN(int n) const;
96
99
105 virtual int getBoundaryDimension() const;
106
108 virtual int getCoordinateDimension() const;
109
115 virtual Geometry* getBoundary() const;
116
117 virtual bool isEmpty() const;
118
119 virtual std::size_t getNumPoints() const;
120
121 virtual Point* getPointN(std::size_t n) const;
122
127 virtual Point* getStartPoint() const;
128
133 virtual Point* getEndPoint() const;
134
135 virtual bool isClosed() const;
136
137 virtual bool isRing() const;
138
139 virtual std::string getGeometryType() const;
140
142
143 virtual bool isCoordinate(Coordinate& pt) const;
144
145 virtual bool equalsExact(const Geometry *other, double tolerance=0)
146 const;
147
148 virtual void apply_rw(const CoordinateFilter *filter);
149
150 virtual void apply_ro(CoordinateFilter *filter) const;
151
152 virtual void apply_rw(GeometryFilter *filter);
153
154 virtual void apply_ro(GeometryFilter *filter) const;
155
156 virtual void apply_rw(GeometryComponentFilter *filter);
157
158 virtual void apply_ro(GeometryComponentFilter *filter) const;
159
161
163
171 virtual void normalize();
172
173 //was protected
174 virtual int compareToSameClass(const Geometry *ls) const;
175
176 virtual const Coordinate* getCoordinate() const;
177
178 virtual double getLength() const;
179
187
188protected:
189
190 LineString(const LineString &ls);
191
195 LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
196
198 LineString(CoordinateSequence::AutoPtr pts,
199 const GeometryFactory *newFactory);
200
201 Envelope::AutoPtr computeEnvelopeInternal() const;
202
203 CoordinateSequence::AutoPtr points;
204
205private:
206
207 void validateConstruction();
208
209};
210
211struct GEOS_DLL LineStringLT {
212 bool operator()(const LineString *ls1, const LineString *ls2) const {
213 return ls1->compareTo(ls2)<0;
214 }
215};
216
217
218inline Geometry*
220 return new LineString(*this);
221}
222
223} // namespace geos::geom
224} // namespace geos
225
226#ifdef _MSC_VER
227#pragma warning(pop)
228#endif
229
230#endif // ndef GEOS_GEOS_LINESTRING_H
The default implementation of CoordinateSequence.
Definition CoordinateArraySequence.h:37
Definition CoordinateFilter.h:43
Definition CoordinateSequenceFilter.h:58
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:59
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
DimensionType
Definition Dimension.h:31
Definition GeometryComponentFilter.h:43
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:48
Geometry(const Geometry &geom)
Polygon overrides to check for actual rectangle.
Definition LineString.h:70
virtual GeometryTypeId getGeometryTypeId() const
Return an integer representation of this Geometry type.
virtual int getCoordinateDimension() const
Returns coordinate dimension.
LineString(CoordinateSequence *pts, const GeometryFactory *newFactory)
Constructs a LineString taking ownership the given CoordinateSequence.
virtual Geometry * getBoundary() const
Returns a MultiPoint. Empty for closed LineString, a Point for each vertex otherwise.
virtual int getBoundaryDimension() const
Returns Dimension::False for a closed LineString, 0 otherwise (LineString boundary is a MultiPoint).
virtual bool equalsExact(const Geometry *other, double tolerance=0) const
Returns true if the two Geometrys are exactly equal, up to a specified tolerance.
virtual double getLength() const
Returns the length of this Geometry.
void apply_rw(CoordinateSequenceFilter &filter)
virtual bool isEmpty() const
Returns whether or not the set of points in this Geometry is empty.
LineString(CoordinateSequence::AutoPtr pts, const GeometryFactory *newFactory)
Hopefully cleaner version of the above.
virtual std::string getGeometryType() const
Return a string representation of this Geometry type.
Geometry * reverse() const
virtual void normalize()
Normalizes a LineString.
virtual Point * getEndPoint() const
Return the end point of the LineString or NULL if this is an EMPTY LineString.
virtual const Coordinate * getCoordinate() const
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
std::vector< const LineString * > ConstVect
A vector of const LineString pointers.
Definition LineString.h:77
virtual Dimension::DimensionType getDimension() const
Returns line dimension (1).
const CoordinateSequence * getCoordinatesRO() const
Returns a read-only pointer to internal CoordinateSequence.
virtual CoordinateSequence * getCoordinates() const
Returns this Geometry vertices. Caller takes ownership of the returned object.
void apply_ro(CoordinateSequenceFilter &filter) const
virtual Geometry * clone() const
Creates and returns a full copy of this LineString object (including all coordinates contained by it)...
Definition LineString.h:219
virtual Point * getStartPoint() const
Return the start point of the LineString or NULL if this is an EMPTY LineString.
virtual std::size_t getNumPoints() const
Returns the count of this Geometrys vertices.
Definition Point.h:68
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
GeometryTypeId
Geometry types.
Definition Geometry.h:65
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25