| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/********************************************************************** |
|
2
|
|
|
|
|
|
|
* |
|
3
|
|
|
|
|
|
|
* GEOS - Geometry Engine Open Source |
|
4
|
|
|
|
|
|
|
* http://geos.osgeo.org |
|
5
|
|
|
|
|
|
|
* |
|
6
|
|
|
|
|
|
|
* Copyright (C) 2006 Refractions Research Inc. |
|
7
|
|
|
|
|
|
|
* |
|
8
|
|
|
|
|
|
|
* This is free software; you can redistribute and/or modify it under |
|
9
|
|
|
|
|
|
|
* the terms of the GNU Lesser General Public Licence as published |
|
10
|
|
|
|
|
|
|
* by the Free Software Foundation. |
|
11
|
|
|
|
|
|
|
* See the COPYING file for more information. |
|
12
|
|
|
|
|
|
|
* |
|
13
|
|
|
|
|
|
|
**********************************************************************/ |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#ifndef GEOS_GEOM_COORDINATESEQUENCE_H |
|
16
|
|
|
|
|
|
|
#define GEOS_GEOM_COORDINATESEQUENCE_H |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#include |
|
19
|
|
|
|
|
|
|
#include |
|
20
|
|
|
|
|
|
|
#include |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#include // for applyCoordinateFilter |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
#include // ostream |
|
26
|
|
|
|
|
|
|
#include // for unique_ptr typedef |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
// Forward declarations |
|
29
|
|
|
|
|
|
|
namespace geos { |
|
30
|
|
|
|
|
|
|
namespace geom { |
|
31
|
|
|
|
|
|
|
class Envelope; |
|
32
|
|
|
|
|
|
|
class CoordinateFilter; |
|
33
|
|
|
|
|
|
|
class Coordinate; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
namespace geos { |
|
38
|
|
|
|
|
|
|
namespace geom { // geos::geom |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
/** |
|
41
|
|
|
|
|
|
|
* \class CoordinateSequence geom.h geos.h |
|
42
|
|
|
|
|
|
|
* |
|
43
|
|
|
|
|
|
|
* \brief |
|
44
|
|
|
|
|
|
|
* The internal representation of a list of coordinates inside a Geometry. |
|
45
|
|
|
|
|
|
|
* |
|
46
|
|
|
|
|
|
|
* There are some cases in which you might want Geometries to store their |
|
47
|
|
|
|
|
|
|
* points using something other than the GEOS Coordinate class. For example, you |
|
48
|
|
|
|
|
|
|
* may want to experiment with another implementation, such as an array of Xs |
|
49
|
|
|
|
|
|
|
* and an array of Ys. or you might want to use your own coordinate class, one |
|
50
|
|
|
|
|
|
|
* that supports extra attributes like M-values. |
|
51
|
|
|
|
|
|
|
* |
|
52
|
|
|
|
|
|
|
* You can do this by implementing the CoordinateSequence and |
|
53
|
|
|
|
|
|
|
* CoordinateSequenceFactory interfaces. You would then create a |
|
54
|
|
|
|
|
|
|
* GeometryFactory parameterized by your CoordinateSequenceFactory, and use |
|
55
|
|
|
|
|
|
|
* this GeometryFactory to create new Geometries. All of these new Geometries |
|
56
|
|
|
|
|
|
|
* will use your CoordinateSequence implementation. |
|
57
|
|
|
|
|
|
|
* |
|
58
|
|
|
|
|
|
|
*/ |
|
59
|
|
|
|
|
|
|
class GEOS_DLL CoordinateSequence { |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
protected: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
CoordinateSequence() {} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
CoordinateSequence(const CoordinateSequence&) {} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
public: |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
typedef std::unique_ptr Ptr; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
virtual ~CoordinateSequence() {} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
/** \brief |
|
74
|
|
|
|
|
|
|
* Returns a deep copy of this collection. |
|
75
|
|
|
|
|
|
|
*/ |
|
76
|
|
|
|
|
|
|
virtual CoordinateSequence *clone() const=0; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
/** \brief |
|
79
|
|
|
|
|
|
|
* Returns a read-only reference to Coordinate at position i. |
|
80
|
|
|
|
|
|
|
* |
|
81
|
|
|
|
|
|
|
* Whether or not the Coordinate returned is the actual underlying |
|
82
|
|
|
|
|
|
|
* Coordinate or merely a copy depends on the implementation. |
|
83
|
|
|
|
|
|
|
*/ |
|
84
|
|
|
|
|
|
|
//virtual const Coordinate& getCoordinate(int i) const=0; |
|
85
|
|
|
|
|
|
|
virtual const Coordinate& getAt(std::size_t i) const=0; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
/// Return last Coordinate in the sequence |
|
88
|
|
|
|
|
|
|
const Coordinate& back() const { |
|
89
|
|
|
|
|
|
|
return getAt(size()-1); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
/// Return first Coordinate in the sequence |
|
93
|
|
|
|
|
|
|
const Coordinate& front() const { |
|
94
|
|
|
|
|
|
|
return getAt(0); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
const Coordinate& operator[] (std::size_t i) const { |
|
98
|
|
|
|
|
|
|
return getAt(i); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
/** \brief |
|
102
|
|
|
|
|
|
|
* Write Coordinate at position i to given Coordinate. |
|
103
|
|
|
|
|
|
|
*/ |
|
104
|
|
|
|
|
|
|
virtual void getAt(std::size_t i, Coordinate& c) const=0; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
/** \brief |
|
107
|
|
|
|
|
|
|
* Returns the number of Coordinates (actual or otherwise, as |
|
108
|
|
|
|
|
|
|
* this implementation may not store its data in Coordinate objects). |
|
109
|
|
|
|
|
|
|
*/ |
|
110
|
|
|
|
|
|
|
//virtual int size() const=0; |
|
111
|
|
|
|
|
|
|
virtual std::size_t getSize() const=0; |
|
112
|
|
|
|
|
|
|
|
|
113
|
54
|
|
|
|
|
|
size_t size() const { return getSize(); } |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
/** \brief |
|
116
|
|
|
|
|
|
|
* Returns a read-only vector with the Coordinates in this collection. |
|
117
|
|
|
|
|
|
|
* |
|
118
|
|
|
|
|
|
|
* Whether or not the Coordinates returned are the actual underlying |
|
119
|
|
|
|
|
|
|
* Coordinates or merely copies depends on the implementation. |
|
120
|
|
|
|
|
|
|
* Note that if this implementation does not store its data as an |
|
121
|
|
|
|
|
|
|
* array of Coordinates, this method will incur a performance penalty |
|
122
|
|
|
|
|
|
|
* because the array needs to be built from scratch. |
|
123
|
|
|
|
|
|
|
* |
|
124
|
|
|
|
|
|
|
* This method is a port of the toCoordinateArray() method of JTS. |
|
125
|
|
|
|
|
|
|
* It is not much used as memory management requires us to |
|
126
|
|
|
|
|
|
|
* know wheter we should or not delete the returned object |
|
127
|
|
|
|
|
|
|
* in a consistent way. Our options are: use shared_ptr |
|
128
|
|
|
|
|
|
|
* or always keep ownerhips of an eventual newly created vector. |
|
129
|
|
|
|
|
|
|
* We opted for the second, so the returned object is a const, to |
|
130
|
|
|
|
|
|
|
* also ensure that returning an internal pointer doesn't make |
|
131
|
|
|
|
|
|
|
* the object mutable. |
|
132
|
|
|
|
|
|
|
* |
|
133
|
|
|
|
|
|
|
* @deprecated use toVector(std::vector&) instead |
|
134
|
|
|
|
|
|
|
*/ |
|
135
|
|
|
|
|
|
|
virtual const std::vector* toVector() const=0; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
/// Pushes all Coordinates of this sequence onto the provided vector. |
|
138
|
|
|
|
|
|
|
// |
|
139
|
|
|
|
|
|
|
/// This method is a port of the toCoordinateArray() method of JTS. |
|
140
|
|
|
|
|
|
|
/// |
|
141
|
|
|
|
|
|
|
virtual void toVector(std::vector& coords) const=0; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
/** |
|
144
|
|
|
|
|
|
|
* \brief Add an array of coordinates |
|
145
|
|
|
|
|
|
|
* @param vc The coordinates |
|
146
|
|
|
|
|
|
|
* @param allowRepeated if set to false, repeated coordinates |
|
147
|
|
|
|
|
|
|
* are collapsed |
|
148
|
|
|
|
|
|
|
* @return true (as by general collection contract) |
|
149
|
|
|
|
|
|
|
*/ |
|
150
|
|
|
|
|
|
|
void add(const std::vector* vc, bool allowRepeated); |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
/* This is here for backward compatibility.. */ |
|
153
|
|
|
|
|
|
|
//void add(CoordinateSequence *cl,bool allowRepeated,bool direction); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
/** \brief |
|
156
|
|
|
|
|
|
|
* Add an array of coordinates |
|
157
|
|
|
|
|
|
|
* |
|
158
|
|
|
|
|
|
|
* @param cl The coordinates |
|
159
|
|
|
|
|
|
|
* |
|
160
|
|
|
|
|
|
|
* @param allowRepeated |
|
161
|
|
|
|
|
|
|
* if set to false, repeated coordinates are collapsed |
|
162
|
|
|
|
|
|
|
* |
|
163
|
|
|
|
|
|
|
* @param direction if false, the array is added in reverse order |
|
164
|
|
|
|
|
|
|
* |
|
165
|
|
|
|
|
|
|
* @return true (as by general collection contract) |
|
166
|
|
|
|
|
|
|
*/ |
|
167
|
|
|
|
|
|
|
void add(const CoordinateSequence *cl, bool allowRepeated, |
|
168
|
|
|
|
|
|
|
bool direction); |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
/** |
|
171
|
|
|
|
|
|
|
* \brief Add a coordinate |
|
172
|
|
|
|
|
|
|
* @param c The coordinate to add |
|
173
|
|
|
|
|
|
|
* @param allowRepeated if set to false, repeated coordinates |
|
174
|
|
|
|
|
|
|
* are collapsed |
|
175
|
|
|
|
|
|
|
* @return true (as by general collection contract) |
|
176
|
|
|
|
|
|
|
*/ |
|
177
|
|
|
|
|
|
|
virtual void add(const Coordinate& c, bool allowRepeated); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
/** \brief |
|
180
|
|
|
|
|
|
|
* Inserts the specified coordinate at the specified position in |
|
181
|
|
|
|
|
|
|
* this list. |
|
182
|
|
|
|
|
|
|
* |
|
183
|
|
|
|
|
|
|
* @param i the position at which to insert |
|
184
|
|
|
|
|
|
|
* @param coord the coordinate to insert |
|
185
|
|
|
|
|
|
|
* @param allowRepeated if set to false, repeated coordinates are |
|
186
|
|
|
|
|
|
|
* collapsed |
|
187
|
|
|
|
|
|
|
* |
|
188
|
|
|
|
|
|
|
* NOTE: this is a CoordinateList interface in JTS |
|
189
|
|
|
|
|
|
|
*/ |
|
190
|
|
|
|
|
|
|
virtual void add(std::size_t i, const Coordinate& coord, bool allowRepeated)=0; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
/// Returns true it list contains no coordinates. |
|
193
|
|
|
|
|
|
|
virtual bool isEmpty() const=0; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
/// Add a Coordinate to the list |
|
196
|
|
|
|
|
|
|
virtual void add(const Coordinate& c)=0; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
// Get number of coordinates |
|
199
|
|
|
|
|
|
|
//virtual int getSize() const=0; |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
/// Get a reference to Coordinate at position pos |
|
202
|
|
|
|
|
|
|
//virtual const Coordinate& getAt(std::size_t pos) const=0; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
/// Copy Coordinate c to position pos |
|
205
|
|
|
|
|
|
|
virtual void setAt(const Coordinate& c, std::size_t pos)=0; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
/// Delete Coordinate at position pos (list will shrink). |
|
208
|
|
|
|
|
|
|
virtual void deleteAt(std::size_t pos)=0; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
/// Get a string rapresentation of CoordinateSequence |
|
211
|
|
|
|
|
|
|
virtual std::string toString() const=0; |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
/// Substitute Coordinate list with a copy of the given vector |
|
214
|
|
|
|
|
|
|
virtual void setPoints(const std::vector &v)=0; |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
/// Returns true if contains any two consecutive points |
|
217
|
|
|
|
|
|
|
bool hasRepeatedPoints() const; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
/// Returns lower-left Coordinate in list |
|
220
|
|
|
|
|
|
|
const Coordinate* minCoordinate() const; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
/// \brief |
|
224
|
|
|
|
|
|
|
/// Returns a new CoordinateSequence being a copy of the input |
|
225
|
|
|
|
|
|
|
/// with any consecutive equal Coordinate removed. |
|
226
|
|
|
|
|
|
|
/// |
|
227
|
|
|
|
|
|
|
/// Equality test is 2D based |
|
228
|
|
|
|
|
|
|
/// |
|
229
|
|
|
|
|
|
|
/// Ownership of returned object goes to the caller. |
|
230
|
|
|
|
|
|
|
/// |
|
231
|
|
|
|
|
|
|
static CoordinateSequence* removeRepeatedPoints( |
|
232
|
|
|
|
|
|
|
const CoordinateSequence *cl); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
/// Remove consecutive equal Coordinates from the sequence |
|
235
|
|
|
|
|
|
|
// |
|
236
|
|
|
|
|
|
|
/// Equality test is 2D based. Returns a reference to self. |
|
237
|
|
|
|
|
|
|
/// |
|
238
|
|
|
|
|
|
|
virtual CoordinateSequence& removeRepeatedPoints()=0; |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
/** \brief |
|
241
|
|
|
|
|
|
|
* Returns true if given CoordinateSequence contains |
|
242
|
|
|
|
|
|
|
* any two consecutive Coordinate |
|
243
|
|
|
|
|
|
|
*/ |
|
244
|
|
|
|
|
|
|
static bool hasRepeatedPoints(const CoordinateSequence *cl); |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
/** \brief |
|
247
|
|
|
|
|
|
|
* Returns either the given CoordinateSequence if its length |
|
248
|
|
|
|
|
|
|
* is greater than the given amount, or an empty CoordinateSequence. |
|
249
|
|
|
|
|
|
|
*/ |
|
250
|
|
|
|
|
|
|
static CoordinateSequence* atLeastNCoordinatesOrNothing(std::size_t n, |
|
251
|
|
|
|
|
|
|
CoordinateSequence *c); |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
/** \brief |
|
254
|
|
|
|
|
|
|
* Returns lower-left Coordinate in given CoordinateSequence. |
|
255
|
|
|
|
|
|
|
* This is actually the Coordinate with lower X (and Y if needed) |
|
256
|
|
|
|
|
|
|
* ordinate. |
|
257
|
|
|
|
|
|
|
*/ |
|
258
|
|
|
|
|
|
|
static const Coordinate* minCoordinate(CoordinateSequence *cl); |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
/// Return position of a Coordinate, or -1 if not found |
|
261
|
|
|
|
|
|
|
// |
|
262
|
|
|
|
|
|
|
/// FIXME: return std::size_t, using numeric_limits::max |
|
263
|
|
|
|
|
|
|
/// as 'not found' value. |
|
264
|
|
|
|
|
|
|
/// |
|
265
|
|
|
|
|
|
|
static int indexOf(const Coordinate *coordinate, |
|
266
|
|
|
|
|
|
|
const CoordinateSequence *cl); |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
/** |
|
269
|
|
|
|
|
|
|
* \brief |
|
270
|
|
|
|
|
|
|
* Returns true if the two arrays are identical, both null, |
|
271
|
|
|
|
|
|
|
* or pointwise equal |
|
272
|
|
|
|
|
|
|
*/ |
|
273
|
|
|
|
|
|
|
static bool equals(const CoordinateSequence *cl1, |
|
274
|
|
|
|
|
|
|
const CoordinateSequence *cl2); |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
/// Scroll given CoordinateSequence so to start with given Coordinate. |
|
277
|
|
|
|
|
|
|
static void scroll(CoordinateSequence *cl, const Coordinate *firstCoordinate); |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
/** \brief |
|
280
|
|
|
|
|
|
|
* Determines which orientation of the {@link Coordinate} array |
|
281
|
|
|
|
|
|
|
* is (overall) increasing. |
|
282
|
|
|
|
|
|
|
* |
|
283
|
|
|
|
|
|
|
* In other words, determines which end of the array is "smaller" |
|
284
|
|
|
|
|
|
|
* (using the standard ordering on {@link Coordinate}). |
|
285
|
|
|
|
|
|
|
* Returns an integer indicating the increasing direction. |
|
286
|
|
|
|
|
|
|
* If the sequence is a palindrome, it is defined to be |
|
287
|
|
|
|
|
|
|
* oriented in a positive direction. |
|
288
|
|
|
|
|
|
|
* |
|
289
|
|
|
|
|
|
|
* @param pts the array of Coordinates to test |
|
290
|
|
|
|
|
|
|
* @return 1 if the array is smaller at the start |
|
291
|
|
|
|
|
|
|
* or is a palindrome, |
|
292
|
|
|
|
|
|
|
* -1 if smaller at the end |
|
293
|
|
|
|
|
|
|
* |
|
294
|
|
|
|
|
|
|
* NOTE: this method is found in CoordinateArrays class for JTS |
|
295
|
|
|
|
|
|
|
*/ |
|
296
|
|
|
|
|
|
|
static int increasingDirection(const CoordinateSequence& pts); |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
/// Reverse Coordinate order in given CoordinateSequence |
|
299
|
|
|
|
|
|
|
static void reverse(CoordinateSequence *cl); |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
/// Standard ordinate index values |
|
302
|
|
|
|
|
|
|
enum { X,Y,Z,M }; |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
/** |
|
305
|
|
|
|
|
|
|
* Returns the dimension (number of ordinates in each coordinate) |
|
306
|
|
|
|
|
|
|
* for this sequence. |
|
307
|
|
|
|
|
|
|
* |
|
308
|
|
|
|
|
|
|
* @return the dimension of the sequence. |
|
309
|
|
|
|
|
|
|
*/ |
|
310
|
|
|
|
|
|
|
virtual std::size_t getDimension() const=0; |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
/** |
|
313
|
|
|
|
|
|
|
* Returns the ordinate of a coordinate in this sequence. |
|
314
|
|
|
|
|
|
|
* Ordinate indices 0 and 1 are assumed to be X and Y. |
|
315
|
|
|
|
|
|
|
* Ordinates indices greater than 1 have user-defined semantics |
|
316
|
|
|
|
|
|
|
* (for instance, they may contain other dimensions or measure values). |
|
317
|
|
|
|
|
|
|
* |
|
318
|
|
|
|
|
|
|
* @param index the coordinate index in the sequence |
|
319
|
|
|
|
|
|
|
* @param ordinateIndex the ordinate index in the coordinate |
|
320
|
|
|
|
|
|
|
* (in range [0, dimension-1]) |
|
321
|
|
|
|
|
|
|
*/ |
|
322
|
|
|
|
|
|
|
virtual double getOrdinate(std::size_t index, std::size_t ordinateIndex) const=0; |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
/** |
|
325
|
|
|
|
|
|
|
* Returns ordinate X (0) of the specified coordinate. |
|
326
|
|
|
|
|
|
|
* |
|
327
|
|
|
|
|
|
|
* @param index |
|
328
|
|
|
|
|
|
|
* @return the value of the X ordinate in the index'th coordinate |
|
329
|
|
|
|
|
|
|
*/ |
|
330
|
|
|
|
|
|
|
virtual double getX(std::size_t index) const { return getOrdinate(index, X); } |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
/** |
|
333
|
|
|
|
|
|
|
* Returns ordinate Y (1) of the specified coordinate. |
|
334
|
|
|
|
|
|
|
* |
|
335
|
|
|
|
|
|
|
* @param index |
|
336
|
|
|
|
|
|
|
* @return the value of the Y ordinate in the index'th coordinate |
|
337
|
|
|
|
|
|
|
*/ |
|
338
|
|
|
|
|
|
|
virtual double getY(std::size_t index) const { return getOrdinate(index, Y); } |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
/** |
|
342
|
|
|
|
|
|
|
* Sets the value for a given ordinate of a coordinate in this sequence. |
|
343
|
|
|
|
|
|
|
* |
|
344
|
|
|
|
|
|
|
* @param index the coordinate index in the sequence |
|
345
|
|
|
|
|
|
|
* @param ordinateIndex the ordinate index in the coordinate |
|
346
|
|
|
|
|
|
|
* (in range [0, dimension-1]) |
|
347
|
|
|
|
|
|
|
* @param value the new ordinate value |
|
348
|
|
|
|
|
|
|
*/ |
|
349
|
|
|
|
|
|
|
virtual void setOrdinate(std::size_t index, std::size_t ordinateIndex, double value)=0; |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
/** |
|
352
|
|
|
|
|
|
|
* Expands the given Envelope to include the coordinates in the |
|
353
|
|
|
|
|
|
|
* sequence. |
|
354
|
|
|
|
|
|
|
* Allows implementing classes to optimize access to coordinate values. |
|
355
|
|
|
|
|
|
|
* |
|
356
|
|
|
|
|
|
|
* @param env the envelope to expand |
|
357
|
|
|
|
|
|
|
*/ |
|
358
|
|
|
|
|
|
|
virtual void expandEnvelope(Envelope &env) const; |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
virtual void apply_rw(const CoordinateFilter *filter)=0; //Abstract |
|
361
|
|
|
|
|
|
|
virtual void apply_ro(CoordinateFilter *filter) const=0; //Abstract |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
/** \brief |
|
364
|
|
|
|
|
|
|
* Apply a fiter to each Coordinate of this sequence. |
|
365
|
|
|
|
|
|
|
* The filter is expected to provide a .filter(Coordinate&) |
|
366
|
|
|
|
|
|
|
* method. |
|
367
|
|
|
|
|
|
|
* |
|
368
|
|
|
|
|
|
|
* TODO: accept a Functor instead, will be more flexible. |
|
369
|
|
|
|
|
|
|
* actually, define iterators on Geometry |
|
370
|
|
|
|
|
|
|
*/ |
|
371
|
|
|
|
|
|
|
template |
|
372
|
|
|
|
|
|
|
void applyCoordinateFilter(T& f) |
|
373
|
|
|
|
|
|
|
{ |
|
374
|
|
|
|
|
|
|
Coordinate c; |
|
375
|
|
|
|
|
|
|
for(std::size_t i=0, n=size(); i
|
|
376
|
|
|
|
|
|
|
{ |
|
377
|
|
|
|
|
|
|
getAt(i, c); |
|
378
|
|
|
|
|
|
|
f.filter(c); |
|
379
|
|
|
|
|
|
|
setAt(c, i); |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
}; |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
GEOS_DLL std::ostream& operator<< (std::ostream& os, const CoordinateSequence& cs); |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
GEOS_DLL bool operator== (const CoordinateSequence& s1, const CoordinateSequence& s2); |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
GEOS_DLL bool operator!= (const CoordinateSequence& s1, const CoordinateSequence& s2); |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
} // namespace geos::geom |
|
392
|
|
|
|
|
|
|
} // namespace geos |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
//#ifdef GEOS_INLINE |
|
395
|
|
|
|
|
|
|
//# include "geos/geom/CoordinateSequence.inl" |
|
396
|
|
|
|
|
|
|
//#endif |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
#endif // ndef GEOS_GEOM_COORDINATESEQUENCE_H |