Coverage Report

Created: 2024-07-27 06:14

/src/geos/include/geos/geom/CoordinateSequence.h
Line
Count
Source (jump to first uncovered line)
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2022 ISciences LLC
7
 * Copyright (C) 2006 Refractions Research Inc.
8
 *
9
 * This is free software; you can redistribute and/or modify it under
10
 * the terms of the GNU Lesser General Public Licence as published
11
 * by the Free Software Foundation.
12
 * See the COPYING file for more information.
13
 *
14
 **********************************************************************/
15
16
#pragma once
17
18
#include <geos/export.h>
19
20
#include <geos/geom/Coordinate.h> // for applyCoordinateFilter
21
#include <geos/geom/CoordinateSequenceIterator.h>
22
23
#include <cassert>
24
#include <vector>
25
#include <iostream>
26
#include <iosfwd> // ostream
27
#include <memory> // for unique_ptr typedef
28
29
// Forward declarations
30
namespace geos {
31
namespace geom {
32
class Envelope;
33
class CoordinateFilter;
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
 * A CoordinateSequence is capable of storing XY, XYZ, XYM, or XYZM Coordinates. For efficient
47
 * storage, the dimensionality of the CoordinateSequence should be specified at creation using
48
 * the constructor with `hasz` and `hasm` arguments. Currently most of the GEOS code base
49
 * stores 2D Coordinates and accesses using the Coordinate type. Sequences used by these parts
50
 * of the code must be created with constructors without `hasz` and `hasm` arguments.
51
 *
52
 * If a high-dimension Coordinate coordinate is read from a low-dimension CoordinateSequence,
53
 * the higher dimensions will be populated with incorrect values or a segfault may occur.
54
 *
55
 */
56
class GEOS_DLL CoordinateSequence {
57
58
public:
59
60
    /// Standard ordinate index values
61
    enum { X, Y, Z, M };
62
63
    using iterator = CoordinateSequenceIterator<CoordinateSequence, Coordinate>;
64
    using const_iterator = CoordinateSequenceIterator<const CoordinateSequence, const Coordinate>;
65
66
    typedef std::unique_ptr<CoordinateSequence> Ptr;
67
68
    /// \defgroup construct Constructors
69
    /// @{
70
71
    /**
72
     *  Create an CoordinateSequence capable of storing XY or XYZ coordinates.
73
     */
74
    CoordinateSequence();
75
76
    /**
77
     * Create a CoordinateSequence capable of storing XY, XYZ or XYZM coordinates.
78
     *
79
     * @param size size of the sequence to create.
80
     * @param dim 2 for 2D, 3 for XYZ, 4 for XYZM, or 0 to determine
81
     *            this based on the first coordinate in the sequence
82
     */
83
    CoordinateSequence(std::size_t size, std::size_t dim = 0);
84
85
    /**
86
     * Create a CoordinateSequence that packs coordinates of any dimension.
87
     * Code using a CoordinateSequence constructed in this way must not
88
     * attempt to access references to coordinates with dimensions that
89
     * are not actually stored in the sequence.
90
     *
91
     * @param size size of the sequence to create
92
     * @param hasz true if the stored
93
     * @param hasm
94
     * @param initialize
95
     */
96
    CoordinateSequence(std::size_t size, bool hasz, bool hasm, bool initialize = true);
97
98
    /**
99
     * Create a CoordinateSequence from a list of XYZ coordinates.
100
     * Code using the sequence may only access references to CoordinateXY
101
     * or Coordinate objects.
102
     */
103
    CoordinateSequence(const std::initializer_list<Coordinate>&);
104
105
    /**
106
     * Create a CoordinateSequence from a list of XY coordinates.
107
     * Code using the sequence may only access references to CoordinateXY objects.
108
     */
109
    CoordinateSequence(const std::initializer_list<CoordinateXY>&);
110
111
    /**
112
     * Create a CoordinateSequence from a list of XYM coordinates.
113
     * Code using the sequence may only access references to CoordinateXY
114
     * or CoordinateXYM objects.
115
     */
116
    CoordinateSequence(const std::initializer_list<CoordinateXYM>&);
117
118
    /**
119
     * Create a CoordinateSequence from a list of XYZM coordinates.
120
     */
121
    CoordinateSequence(const std::initializer_list<CoordinateXYZM>&);
122
123
    /**
124
     * Create a CoordinateSequence storing XY values only.
125
     *
126
     * @param size size of the sequence to create
127
     */
128
0
    static CoordinateSequence XY(std::size_t size)  {
129
0
        return CoordinateSequence(size, false, false);
130
0
    }
131
132
    /**
133
     * Create a CoordinateSequence storing XYZ values only.
134
     *
135
     * @param size size of the sequence to create
136
     */
137
0
    static CoordinateSequence XYZ(std::size_t size)  {
138
0
        return CoordinateSequence(size, true, false);
139
0
    }
140
141
    /**
142
     * Create a CoordinateSequence storing XYZM values only.
143
     *
144
     * @param size size of the sequence to create
145
     */
146
8.44k
    static CoordinateSequence XYZM(std::size_t size)  {
147
8.44k
        return CoordinateSequence(size, true, true);
148
8.44k
    }
149
150
    /**
151
     * Create a CoordinateSequence storing XYM values only.
152
     *
153
     * @param size size of the sequence to create
154
     */
155
0
    static CoordinateSequence XYM(std::size_t size)  {
156
0
        return CoordinateSequence(size, false, true);
157
0
    }
158
159
    /** \brief
160
     * Returns a heap-allocated deep copy of this CoordinateSequence.
161
     */
162
    std::unique_ptr<CoordinateSequence> clone() const;
163
164
    /// @}
165
    /// \defgroup prop Properties
166
    /// @{
167
168
    /**
169
     * Return the Envelope containing all points in this sequence.
170
     * The Envelope is not cached and is computed each time the
171
     * method is called.
172
     */
173
    Envelope getEnvelope() const;
174
175
    /** \brief
176
     * Returns the number of Coordinates
177
     */
178
91.2M
    std::size_t getSize() const {
179
91.2M
        return size();
180
91.2M
    }
181
182
    /** \brief
183
     * Returns the number of Coordinates
184
     */
185
    size_t size() const
186
1.98G
    {
187
1.98G
        assert(stride() == 2 || stride() == 3 || stride() == 4);
188
1.98G
        switch(stride()) {
189
0
            case 2: return m_vect.size() / 2;
190
86.9M
            case 4: return m_vect.size() / 4;
191
1.89G
            default : return m_vect.size() / 3;
192
1.98G
        }
193
1.98G
    }
194
195
    /// Returns <code>true</code> if list contains no coordinates.
196
125M
    bool isEmpty() const {
197
125M
        return m_vect.empty();
198
125M
    }
199
200
    /** \brief
201
    * Tests whether an a {@link CoordinateSequence} forms a ring,
202
    * by checking length and closure. Self-intersection is not checked.
203
    *
204
    * @return true if the coordinate form a ring.
205
    */
206
    bool isRing() const;
207
208
    /**
209
     * Returns the dimension (number of ordinates in each coordinate)
210
     * for this sequence.
211
     *
212
     * @return the dimension of the sequence.
213
     */
214
    std::size_t getDimension() const;
215
216
69.1M
    bool hasZ() const {
217
69.1M
        return m_hasdim ? m_hasz : (m_vect.empty() || !std::isnan(m_vect[2]));
218
69.1M
    }
219
220
947M
    bool hasM() const {
221
947M
        return m_hasm;
222
947M
    }
223
224
    /// Returns true if contains any two consecutive points
225
    bool hasRepeatedPoints() const;
226
227
    /// Returns true if contains any NaN/Inf coordinates
228
    bool hasRepeatedOrInvalidPoints() const;
229
230
    /// Get the backing type of this CoordinateSequence. This is not necessarily
231
    /// consistent with the dimensionality of the stored Coordinates; 2D Coordinates
232
    /// may be stored as a XYZ coordinates.
233
909M
    CoordinateType getCoordinateType() const {
234
909M
        switch(stride()) {
235
66.0M
            case 4: return CoordinateType::XYZM;
236
0
            case 2: return CoordinateType::XY;
237
843M
            default: return hasM() ? CoordinateType::XYM : CoordinateType::XYZ;
238
909M
        }
239
909M
    }
240
241
    /// @}
242
    /// \defgroup access Accessors
243
    /// @{
244
245
    /** \brief
246
     * Returns a read-only reference to Coordinate at position i.
247
     */
248
    template<typename T=Coordinate>
249
2.47G
    const T& getAt(std::size_t i) const {
250
2.47G
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
2.47G
        assert(sizeof(T) <= sizeof(double) * stride());
252
2.47G
        assert(i*stride() < m_vect.size());
253
2.47G
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
2.47G
        return *orig;
255
2.47G
    }
geos::geom::CoordinateXY const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXY>(unsigned long) const
Line
Count
Source
249
1.28G
    const T& getAt(std::size_t i) const {
250
1.28G
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
1.28G
        assert(sizeof(T) <= sizeof(double) * stride());
252
1.28G
        assert(i*stride() < m_vect.size());
253
1.28G
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
1.28G
        return *orig;
255
1.28G
    }
geos::geom::Coordinate const& geos::geom::CoordinateSequence::getAt<geos::geom::Coordinate>(unsigned long) const
Line
Count
Source
249
949M
    const T& getAt(std::size_t i) const {
250
949M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
949M
        assert(sizeof(T) <= sizeof(double) * stride());
252
949M
        assert(i*stride() < m_vect.size());
253
949M
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
949M
        return *orig;
255
949M
    }
geos::geom::CoordinateXYZM const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYZM>(unsigned long) const
Line
Count
Source
249
35.7M
    const T& getAt(std::size_t i) const {
250
35.7M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
35.7M
        assert(sizeof(T) <= sizeof(double) * stride());
252
35.7M
        assert(i*stride() < m_vect.size());
253
35.7M
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
35.7M
        return *orig;
255
35.7M
    }
Unexecuted instantiation: geos::geom::CoordinateXYM const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYM>(unsigned long) const
Unexecuted instantiation: geos::geom::CoordinateXY const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXY const>(unsigned long) const
geos::geom::Coordinate const& geos::geom::CoordinateSequence::getAt<geos::geom::Coordinate const>(unsigned long) const
Line
Count
Source
249
174M
    const T& getAt(std::size_t i) const {
250
174M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
174M
        assert(sizeof(T) <= sizeof(double) * stride());
252
174M
        assert(i*stride() < m_vect.size());
253
174M
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
174M
        return *orig;
255
174M
    }
Unexecuted instantiation: geos::geom::CoordinateXYM const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYM const>(unsigned long) const
geos::geom::CoordinateXYZM const& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYZM const>(unsigned long) const
Line
Count
Source
249
30.6M
    const T& getAt(std::size_t i) const {
250
30.6M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
251
30.6M
        assert(sizeof(T) <= sizeof(double) * stride());
252
30.6M
        assert(i*stride() < m_vect.size());
253
30.6M
        const T* orig = reinterpret_cast<const T*>(&m_vect[i*stride()]);
254
30.6M
        return *orig;
255
30.6M
    }
256
257
    /** \brief
258
     * Returns a reference to Coordinate at position i.
259
     */
260
    template<typename T=Coordinate>
261
3.22G
    T& getAt(std::size_t i) {
262
3.22G
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
263
3.22G
        assert(sizeof(T) <= sizeof(double) * stride());
264
3.22G
        assert(i*stride() < m_vect.size());
265
3.22G
        T* orig = reinterpret_cast<T*>(&m_vect[i*stride()]);
266
3.22G
        return *orig;
267
3.22G
    }
geos::geom::Coordinate& geos::geom::CoordinateSequence::getAt<geos::geom::Coordinate>(unsigned long)
Line
Count
Source
261
1.99G
    T& getAt(std::size_t i) {
262
1.99G
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
263
1.99G
        assert(sizeof(T) <= sizeof(double) * stride());
264
1.99G
        assert(i*stride() < m_vect.size());
265
1.99G
        T* orig = reinterpret_cast<T*>(&m_vect[i*stride()]);
266
1.99G
        return *orig;
267
1.99G
    }
geos::geom::CoordinateXY& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXY>(unsigned long)
Line
Count
Source
261
1.05G
    T& getAt(std::size_t i) {
262
1.05G
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
263
1.05G
        assert(sizeof(T) <= sizeof(double) * stride());
264
1.05G
        assert(i*stride() < m_vect.size());
265
1.05G
        T* orig = reinterpret_cast<T*>(&m_vect[i*stride()]);
266
1.05G
        return *orig;
267
1.05G
    }
geos::geom::CoordinateXYZM& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYZM>(unsigned long)
Line
Count
Source
261
182M
    T& getAt(std::size_t i) {
262
182M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
263
182M
        assert(sizeof(T) <= sizeof(double) * stride());
264
182M
        assert(i*stride() < m_vect.size());
265
182M
        T* orig = reinterpret_cast<T*>(&m_vect[i*stride()]);
266
182M
        return *orig;
267
182M
    }
Unexecuted instantiation: geos::geom::CoordinateXYM& geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYM>(unsigned long)
268
269
    /** \brief
270
     * Write Coordinate at position i to given Coordinate.
271
     */
272
    template<typename T>
273
117M
    void getAt(std::size_t i, T& c) const {
274
117M
        switch(getCoordinateType()) {
275
0
            case CoordinateType::XY: c = getAt<CoordinateXY>(i); break;
276
116M
            case CoordinateType::XYZ: c = getAt<Coordinate>(i); break;
277
717k
            case CoordinateType::XYZM: c = getAt<CoordinateXYZM>(i); break;
278
0
            case CoordinateType::XYM: c = getAt<CoordinateXYM>(i); break;
279
0
            default: getAt<Coordinate>(i);
280
117M
        }
281
117M
    }
void geos::geom::CoordinateSequence::getAt<geos::geom::Coordinate>(unsigned long, geos::geom::Coordinate&) const
Line
Count
Source
273
7.52M
    void getAt(std::size_t i, T& c) const {
274
7.52M
        switch(getCoordinateType()) {
275
0
            case CoordinateType::XY: c = getAt<CoordinateXY>(i); break;
276
7.50M
            case CoordinateType::XYZ: c = getAt<Coordinate>(i); break;
277
17.8k
            case CoordinateType::XYZM: c = getAt<CoordinateXYZM>(i); break;
278
0
            case CoordinateType::XYM: c = getAt<CoordinateXYM>(i); break;
279
0
            default: getAt<Coordinate>(i);
280
7.52M
        }
281
7.52M
    }
void geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYZM>(unsigned long, geos::geom::CoordinateXYZM&) const
Line
Count
Source
273
110M
    void getAt(std::size_t i, T& c) const {
274
110M
        switch(getCoordinateType()) {
275
0
            case CoordinateType::XY: c = getAt<CoordinateXY>(i); break;
276
109M
            case CoordinateType::XYZ: c = getAt<Coordinate>(i); break;
277
699k
            case CoordinateType::XYZM: c = getAt<CoordinateXYZM>(i); break;
278
0
            case CoordinateType::XYM: c = getAt<CoordinateXYM>(i); break;
279
0
            default: getAt<Coordinate>(i);
280
110M
        }
281
110M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::getAt<geos::geom::CoordinateXYM>(unsigned long, geos::geom::CoordinateXYM&) const
282
283
0
    void getAt(std::size_t i, CoordinateXY& c) const {
284
0
        c = getAt<CoordinateXY>(i);
285
0
    }
286
287
    // TODO: change to return CoordinateXY
288
    /**
289
     * Returns a read-only reference to Coordinate at i
290
     */
291
    const Coordinate& operator[](std::size_t i) const
292
0
    {
293
0
        return getAt(i);
294
0
    }
295
296
    // TODO: change to return CoordinateXY
297
    /**
298
     * Returns a reference to Coordinate at i
299
     */
300
    Coordinate&
301
    operator[](std::size_t i)
302
0
    {
303
0
        return getAt(i);
304
0
    }
305
306
    /**
307
     * Returns the ordinate of a coordinate in this sequence.
308
     * Ordinate indices 0 and 1 are assumed to be X and Y.
309
     * Ordinates indices greater than 1 have user-defined semantics
310
     * (for instance, they may contain other dimensions or measure values).
311
     *
312
     * @param index  the coordinate index in the sequence
313
     * @param ordinateIndex the ordinate index in the coordinate
314
     *                      (in range [0, dimension-1])
315
     */
316
    double getOrdinate(std::size_t index, std::size_t ordinateIndex) const;
317
318
    /**
319
     * Returns ordinate X (0) of the specified coordinate.
320
     *
321
     * @param index
322
     * @return the value of the X ordinate in the index'th coordinate
323
     */
324
    double getX(std::size_t index) const
325
0
    {
326
0
        return m_vect[index * stride()];
327
0
    }
328
329
    /**
330
     * Returns ordinate Y (1) of the specified coordinate.
331
     *
332
     * @param index
333
     * @return the value of the Y ordinate in the index'th coordinate
334
     */
335
    double getY(std::size_t index) const
336
30.1M
    {
337
30.1M
        return m_vect[index * stride() + 1];
338
30.1M
    }
339
340
    /// Return last Coordinate in the sequence
341
    template<typename T=Coordinate>
342
    const T& back() const
343
0
    {
344
0
        return getAt<T>(size() - 1);
345
0
    }
Unexecuted instantiation: geos::geom::CoordinateXY const& geos::geom::CoordinateSequence::back<geos::geom::CoordinateXY>() const
Unexecuted instantiation: geos::geom::Coordinate const& geos::geom::CoordinateSequence::back<geos::geom::Coordinate>() const
346
347
    /// Return last Coordinate in the sequence
348
    template<typename T=Coordinate>
349
    T& back()
350
132M
    {
351
132M
        return getAt<T>(size() - 1);
352
132M
    }
geos::geom::CoordinateXY& geos::geom::CoordinateSequence::back<geos::geom::CoordinateXY>()
Line
Count
Source
350
132M
    {
351
132M
        return getAt<T>(size() - 1);
352
132M
    }
Unexecuted instantiation: geos::geom::Coordinate& geos::geom::CoordinateSequence::back<geos::geom::Coordinate>()
geos::geom::CoordinateXYZM& geos::geom::CoordinateSequence::back<geos::geom::CoordinateXYZM>()
Line
Count
Source
350
45.3k
    {
351
45.3k
        return getAt<T>(size() - 1);
352
45.3k
    }
353
354
    /// Return first Coordinate in the sequence
355
    template<typename T=Coordinate>
356
    const T& front() const
357
0
    {
358
0
        return *(reinterpret_cast<const T*>(m_vect.data()));
359
0
    }
Unexecuted instantiation: geos::geom::CoordinateXY const& geos::geom::CoordinateSequence::front<geos::geom::CoordinateXY>() const
Unexecuted instantiation: geos::geom::Coordinate const& geos::geom::CoordinateSequence::front<geos::geom::Coordinate>() const
360
361
    /// Return first Coordinate in the sequence
362
    template<typename T=Coordinate>
363
    T& front()
364
91.2M
    {
365
91.2M
        return *(reinterpret_cast<T*>(m_vect.data()));
366
91.2M
    }
geos::geom::CoordinateXY& geos::geom::CoordinateSequence::front<geos::geom::CoordinateXY>()
Line
Count
Source
364
91.2M
    {
365
91.2M
        return *(reinterpret_cast<T*>(m_vect.data()));
366
91.2M
    }
Unexecuted instantiation: geos::geom::Coordinate& geos::geom::CoordinateSequence::front<geos::geom::Coordinate>()
367
368
    /// Pushes all Coordinates of this sequence into the provided vector.
369
    void toVector(std::vector<Coordinate>& coords) const;
370
371
    void toVector(std::vector<CoordinateXY>& coords) const;
372
373
374
    /// @}
375
    /// \defgroup mutate Mutators
376
    /// @{
377
378
    /// Copy Coordinate c to position pos
379
    template<typename T>
380
250M
    void setAt(const T& c, std::size_t pos) {
381
250M
        switch(getCoordinateType()) {
382
0
            case CoordinateType::XY: setAtImpl<CoordinateXY>(c, pos); break;
383
208M
            case CoordinateType::XYZ: setAtImpl<Coordinate>(c, pos); break;
384
41.7M
            case CoordinateType::XYZM: setAtImpl<CoordinateXYZM>(c, pos); break;
385
0
            case CoordinateType::XYM: setAtImpl<CoordinateXYM>(c, pos); break;
386
0
            default: setAtImpl<Coordinate>(c, pos);
387
250M
        }
388
250M
    }
void geos::geom::CoordinateSequence::setAt<geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
Line
Count
Source
380
1
    void setAt(const T& c, std::size_t pos) {
381
1
        switch(getCoordinateType()) {
382
0
            case CoordinateType::XY: setAtImpl<CoordinateXY>(c, pos); break;
383
1
            case CoordinateType::XYZ: setAtImpl<Coordinate>(c, pos); break;
384
0
            case CoordinateType::XYZM: setAtImpl<CoordinateXYZM>(c, pos); break;
385
0
            case CoordinateType::XYM: setAtImpl<CoordinateXYM>(c, pos); break;
386
0
            default: setAtImpl<Coordinate>(c, pos);
387
1
        }
388
1
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAt<geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
void geos::geom::CoordinateSequence::setAt<geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
Line
Count
Source
380
76.7M
    void setAt(const T& c, std::size_t pos) {
381
76.7M
        switch(getCoordinateType()) {
382
0
            case CoordinateType::XY: setAtImpl<CoordinateXY>(c, pos); break;
383
61.2M
            case CoordinateType::XYZ: setAtImpl<Coordinate>(c, pos); break;
384
15.4M
            case CoordinateType::XYZM: setAtImpl<CoordinateXYZM>(c, pos); break;
385
0
            case CoordinateType::XYM: setAtImpl<CoordinateXYM>(c, pos); break;
386
0
            default: setAtImpl<Coordinate>(c, pos);
387
76.7M
        }
388
76.7M
    }
void geos::geom::CoordinateSequence::setAt<geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
Line
Count
Source
380
173M
    void setAt(const T& c, std::size_t pos) {
381
173M
        switch(getCoordinateType()) {
382
0
            case CoordinateType::XY: setAtImpl<CoordinateXY>(c, pos); break;
383
147M
            case CoordinateType::XYZ: setAtImpl<Coordinate>(c, pos); break;
384
26.2M
            case CoordinateType::XYZM: setAtImpl<CoordinateXYZM>(c, pos); break;
385
0
            case CoordinateType::XYM: setAtImpl<CoordinateXYM>(c, pos); break;
386
0
            default: setAtImpl<Coordinate>(c, pos);
387
173M
        }
388
173M
    }
389
390
    /**
391
     * Sets the value for a given ordinate of a coordinate in this sequence.
392
     *
393
     * @param index  the coordinate index in the sequence
394
     * @param ordinateIndex the ordinate index in the coordinate
395
     *                      (in range [0, dimension-1])
396
     * @param value  the new ordinate value
397
     */
398
    void setOrdinate(std::size_t index, std::size_t ordinateIndex, double value);
399
400
    /// Substitute Coordinate list with a copy of the given vector
401
    void setPoints(const std::vector<Coordinate>& v);
402
403
    /// @}
404
    /// \defgroup add Adding methods
405
    /// @{
406
407
    /// Adds the specified coordinate to the end of the sequence. Dimensions
408
    /// present in the coordinate but not in the sequence will be ignored.
409
    /// If multiple coordinates are to be added, a multiple-insert method should
410
    /// be used for best performance.
411
    template<typename T=Coordinate>
412
129M
    void add(const T& c) {
413
129M
        add(c, size());
414
129M
    }
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&)
Line
Count
Source
412
1
    void add(const T& c) {
413
1
        add(c, size());
414
1
    }
void geos::geom::CoordinateSequence::add<geos::geom::Coordinate>(geos::geom::Coordinate const&)
Line
Count
Source
412
76.5M
    void add(const T& c) {
413
76.5M
        add(c, size());
414
76.5M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&)
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&)
Line
Count
Source
412
52.5M
    void add(const T& c) {
413
52.5M
        add(c, size());
414
52.5M
    }
415
416
    /// Adds the specified coordinate to the end of the sequence. Dimensions
417
    /// present in the coordinate but not in the sequence will be ignored. If
418
    /// allowRepeated is false, the coordinate will not be added if it is the
419
    /// same as the last coordinate in the sequence.
420
    /// If multiple coordinates are to be added, a multiple-insert method should
421
    /// be used for best performance.
422
    template<typename T>
423
    void add(const T& c, bool allowRepeated)
424
29.5M
    {
425
29.5M
        if(!allowRepeated && !isEmpty()) {
426
27.0M
            const CoordinateXY& last = back<CoordinateXY>();
427
27.0M
            if(last.equals2D(c)) {
428
5.40M
                return;
429
5.40M
            }
430
27.0M
        }
431
432
24.1M
        add(c);
433
24.1M
    }
void geos::geom::CoordinateSequence::add<geos::geom::Coordinate>(geos::geom::Coordinate const&, bool)
Line
Count
Source
424
27.6M
    {
425
27.6M
        if(!allowRepeated && !isEmpty()) {
426
26.8M
            const CoordinateXY& last = back<CoordinateXY>();
427
26.8M
            if(last.equals2D(c)) {
428
5.28M
                return;
429
5.28M
            }
430
26.8M
        }
431
432
22.3M
        add(c);
433
22.3M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, bool)
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, bool)
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, bool)
Line
Count
Source
424
1.98M
    {
425
1.98M
        if(!allowRepeated && !isEmpty()) {
426
274k
            const CoordinateXY& last = back<CoordinateXY>();
427
274k
            if(last.equals2D(c)) {
428
119k
                return;
429
119k
            }
430
274k
        }
431
432
1.86M
        add(c);
433
1.86M
    }
434
435
    /** \brief
436
     * Inserts the specified coordinate at the specified position in
437
     * this sequence. If multiple coordinates are to be added, a multiple-
438
     * insert method should be used for best performance.
439
     *
440
     * @param c the coordinate to insert
441
     * @param pos the position at which to insert
442
     */
443
    template<typename T>
444
    void add(const T& c, std::size_t pos)
445
129M
    {
446
129M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
447
448
        // c may be a reference inside m_vect, so we make sure it will not
449
        // grow before adding it
450
129M
        if (m_vect.size() + stride() <= m_vect.capacity()) {
451
120M
            make_space(pos, 1);
452
120M
            setAt(c, static_cast<std::size_t>(pos));
453
120M
        } else {
454
8.34M
            T tmp{c};
455
8.34M
            make_space(pos, 1);
456
8.34M
            setAt(tmp, static_cast<std::size_t>(pos));
457
8.34M
        }
458
129M
    }
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
Line
Count
Source
445
1
    {
446
1
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
447
448
        // c may be a reference inside m_vect, so we make sure it will not
449
        // grow before adding it
450
1
        if (m_vect.size() + stride() <= m_vect.capacity()) {
451
1
            make_space(pos, 1);
452
1
            setAt(c, static_cast<std::size_t>(pos));
453
1
        } else {
454
0
            T tmp{c};
455
0
            make_space(pos, 1);
456
0
            setAt(tmp, static_cast<std::size_t>(pos));
457
0
        }
458
1
    }
void geos::geom::CoordinateSequence::add<geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
Line
Count
Source
445
76.5M
    {
446
76.5M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
447
448
        // c may be a reference inside m_vect, so we make sure it will not
449
        // grow before adding it
450
76.5M
        if (m_vect.size() + stride() <= m_vect.capacity()) {
451
75.8M
            make_space(pos, 1);
452
75.8M
            setAt(c, static_cast<std::size_t>(pos));
453
75.8M
        } else {
454
634k
            T tmp{c};
455
634k
            make_space(pos, 1);
456
634k
            setAt(tmp, static_cast<std::size_t>(pos));
457
634k
        }
458
76.5M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
Line
Count
Source
445
52.5M
    {
446
52.5M
        static_assert(std::is_base_of<CoordinateXY, T>::value, "Must be a Coordinate class");
447
448
        // c may be a reference inside m_vect, so we make sure it will not
449
        // grow before adding it
450
52.5M
        if (m_vect.size() + stride() <= m_vect.capacity()) {
451
44.8M
            make_space(pos, 1);
452
44.8M
            setAt(c, static_cast<std::size_t>(pos));
453
44.8M
        } else {
454
7.70M
            T tmp{c};
455
7.70M
            make_space(pos, 1);
456
7.70M
            setAt(tmp, static_cast<std::size_t>(pos));
457
7.70M
        }
458
52.5M
    }
459
460
    /** \brief
461
     * Inserts the specified coordinate at the specified position in
462
     * this list.
463
     *
464
     * @param i the position at which to insert
465
     * @param coord the coordinate to insert
466
     * @param allowRepeated if set to false, repeated coordinates are
467
     *                      collapsed
468
     */
469
    template<typename T>
470
    void add(std::size_t i, const T& coord, bool allowRepeated)
471
    {
472
        // don't add duplicate coordinates
473
        if(! allowRepeated) {
474
            std::size_t sz = size();
475
            if(sz > 0) {
476
                if(i > 0) {
477
                    const CoordinateXY& prev = getAt<CoordinateXY>(i - 1);
478
                    if(prev.equals2D(coord)) {
479
                        return;
480
                    }
481
                }
482
                if(i < sz) {
483
                    const CoordinateXY& next = getAt<CoordinateXY>(i);
484
                    if(next.equals2D(coord)) {
485
                        return;
486
                    }
487
                }
488
            }
489
        }
490
491
        add(coord, i);
492
    }
493
494
0
    void add(double x, double y) {
495
0
        CoordinateXY c(x, y);
496
0
        add(c);
497
0
    }
498
499
    void add(const CoordinateSequence& cs);
500
501
    void add(const CoordinateSequence& cs, bool allowRepeated);
502
503
    void add(const CoordinateSequence& cl, bool allowRepeated, bool forwardDirection);
504
505
    void add(const CoordinateSequence& cs, std::size_t from, std::size_t to);
506
507
    void add(const CoordinateSequence& cs, std::size_t from, std::size_t to, bool allowRepeated);
508
509
    template<typename T, typename... Args>
510
11.6M
    void add(T begin, T end, Args... args) {
511
23.3M
        for (auto it = begin; it != end; ++it) {
512
11.6M
            add(*it, args...);
513
11.6M
        }
514
11.6M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<std::__1::__list_const_iterator<geos::geom::Coordinate, void*>>(std::__1::__list_const_iterator<geos::geom::Coordinate, void*>, std::__1::__list_const_iterator<geos::geom::Coordinate, void*>)
void geos::geom::CoordinateSequence::add<geos::geom::Coordinate const*>(geos::geom::Coordinate const*, geos::geom::Coordinate const*)
Line
Count
Source
510
11.6M
    void add(T begin, T end, Args... args) {
511
23.3M
        for (auto it = begin; it != end; ++it) {
512
11.6M
            add(*it, args...);
513
11.6M
        }
514
11.6M
    }
void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXY const*>(geos::geom::CoordinateXY const*, geos::geom::CoordinateXY const*)
Line
Count
Source
510
1
    void add(T begin, T end, Args... args) {
511
2
        for (auto it = begin; it != end; ++it) {
512
1
            add(*it, args...);
513
1
        }
514
1
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYM const*>(geos::geom::CoordinateXYM const*, geos::geom::CoordinateXYM const*)
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<geos::geom::CoordinateXYZM const*>(geos::geom::CoordinateXYZM const*, geos::geom::CoordinateXYZM const*)
Unexecuted instantiation: void geos::geom::CoordinateSequence::add<std::__1::__wrap_iter<geos::geom::Coordinate*>>(std::__1::__wrap_iter<geos::geom::Coordinate*>, std::__1::__wrap_iter<geos::geom::Coordinate*>)
515
516
    template<typename T>
517
0
    void add(std::size_t i, T from, T to) {
518
0
        auto npts = static_cast<std::size_t>(std::distance(from, to));
519
0
        make_space(i, npts);
520
521
0
        for (auto it = from; it != to; ++it) {
522
0
            setAt(*it, i);
523
0
            i++;
524
0
        }
525
0
    }
526
527
    /// @}
528
    /// \defgroup util Utilities
529
    /// @{
530
531
175
    void clear() {
532
175
        m_vect.clear();
533
175
    }
534
535
23.9M
    void reserve(std::size_t capacity) {
536
23.9M
        m_vect.reserve(capacity * stride());
537
23.9M
    }
538
539
0
    void resize(std::size_t capacity) {
540
0
        m_vect.resize(capacity * stride());
541
0
    }
542
543
    void pop_back();
544
545
    /// Get a string representation of CoordinateSequence
546
    std::string toString() const;
547
548
    /// Returns lower-left Coordinate in list
549
    const CoordinateXY* minCoordinate() const;
550
551
    /** \brief
552
     *  Returns either the given CoordinateSequence if its length
553
     *  is greater than the given amount, or an empty CoordinateSequence.
554
     */
555
    static CoordinateSequence* atLeastNCoordinatesOrNothing(std::size_t n,
556
            CoordinateSequence* c);
557
558
    /// Return position of a Coordinate
559
    //
560
    /// or numeric_limits<std::size_t>::max() if not found
561
    ///
562
    static std::size_t indexOf(const CoordinateXY* coordinate,
563
                               const CoordinateSequence* cl);
564
565
    /**
566
     * \brief
567
     * Returns true if the two arrays are identical, both null,
568
     * or pointwise equal in two dimensions
569
     */
570
    static bool equals(const CoordinateSequence* cl1,
571
                       const CoordinateSequence* cl2);
572
573
    /**
574
     * \brief
575
     * Returns true if the two sequences are identical (pointwise
576
     * equal in all dimensions, with NaN == NaN).
577
     */
578
    bool equalsIdentical(const CoordinateSequence& other) const;
579
580
    /// Scroll given CoordinateSequence so to start with given Coordinate.
581
    static void scroll(CoordinateSequence* cl, const CoordinateXY* firstCoordinate);
582
583
    /** \brief
584
     * Determines which orientation of the {@link Coordinate} array
585
     * is (overall) increasing.
586
     *
587
     * In other words, determines which end of the array is "smaller"
588
     * (using the standard ordering on {@link Coordinate}).
589
     * Returns an integer indicating the increasing direction.
590
     * If the sequence is a palindrome, it is defined to be
591
     * oriented in a positive direction.
592
     *
593
     * @param pts the array of Coordinates to test
594
     * @return <code>1</code> if the array is smaller at the start
595
     * or is a palindrome,
596
     * <code>-1</code> if smaller at the end
597
     *
598
     * NOTE: this method is found in CoordinateArrays class for JTS
599
     */
600
    static int increasingDirection(const CoordinateSequence& pts);
601
602
    /// Reverse Coordinate order in given CoordinateSequence
603
    void reverse();
604
605
    void sort();
606
607
608
    /**
609
     * Expands the given Envelope to include the coordinates in the
610
     * sequence.
611
     * @param env the envelope to expand
612
     */
613
    void expandEnvelope(Envelope& env) const;
614
615
    void closeRing(bool allowRepeated = false);
616
617
    /// @}
618
    /// \defgroup iterate Iteration
619
    /// @{
620
621
    template<typename Filter>
622
340k
    void apply_rw(const Filter* filter) {
623
340k
        switch(getCoordinateType()) {
624
0
            case CoordinateType::XY:
625
0
                for (auto& c : items<CoordinateXY>()) {
626
0
                    if (filter->isDone()) break;
627
0
                    filter->filter_rw(&c);
628
0
                }
629
0
                break;
630
323k
            case CoordinateType::XYZ:
631
468k
                for (auto& c : items<Coordinate>()) {
632
468k
                    if (filter->isDone()) break;
633
468k
                    filter->filter_rw(&c);
634
468k
                }
635
323k
                break;
636
0
            case CoordinateType::XYM:
637
0
                for (auto& c : items<CoordinateXYM>()) {
638
0
                    if (filter->isDone()) break;
639
0
                    filter->filter_rw(&c);
640
0
                }
641
0
                break;
642
16.7k
            case CoordinateType::XYZM:
643
37.9k
                for (auto& c : items<CoordinateXYZM>()) {
644
37.9k
                    if (filter->isDone()) break;
645
37.9k
                    filter->filter_rw(&c);
646
37.9k
                }
647
16.7k
                break;
648
340k
        }
649
340k
        m_hasdim = m_hasz = false; // re-check (see http://trac.osgeo.org/geos/ticket/435)
650
340k
    }
void geos::geom::CoordinateSequence::apply_rw<geos::geom::CoordinateFilter>(geos::geom::CoordinateFilter const*)
Line
Count
Source
622
340k
    void apply_rw(const Filter* filter) {
623
340k
        switch(getCoordinateType()) {
624
0
            case CoordinateType::XY:
625
0
                for (auto& c : items<CoordinateXY>()) {
626
0
                    if (filter->isDone()) break;
627
0
                    filter->filter_rw(&c);
628
0
                }
629
0
                break;
630
323k
            case CoordinateType::XYZ:
631
468k
                for (auto& c : items<Coordinate>()) {
632
468k
                    if (filter->isDone()) break;
633
468k
                    filter->filter_rw(&c);
634
468k
                }
635
323k
                break;
636
0
            case CoordinateType::XYM:
637
0
                for (auto& c : items<CoordinateXYM>()) {
638
0
                    if (filter->isDone()) break;
639
0
                    filter->filter_rw(&c);
640
0
                }
641
0
                break;
642
16.7k
            case CoordinateType::XYZM:
643
37.9k
                for (auto& c : items<CoordinateXYZM>()) {
644
37.9k
                    if (filter->isDone()) break;
645
37.9k
                    filter->filter_rw(&c);
646
37.9k
                }
647
16.7k
                break;
648
340k
        }
649
340k
        m_hasdim = m_hasz = false; // re-check (see http://trac.osgeo.org/geos/ticket/435)
650
340k
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::apply_rw<geos::noding::ScaledNoder::ReScaler>(geos::noding::ScaledNoder::ReScaler const*)
Unexecuted instantiation: void geos::geom::CoordinateSequence::apply_rw<geos::noding::ScaledNoder::Scaler>(geos::noding::ScaledNoder::Scaler const*)
651
652
    template<typename Filter>
653
76.2M
    void apply_ro(Filter* filter) const {
654
76.2M
        switch(getCoordinateType()) {
655
0
            case CoordinateType::XY:
656
0
                for (const auto& c : items<CoordinateXY>()) {
657
0
                    if (filter->isDone()) break;
658
0
                    filter->filter_ro(&c);
659
0
                }
660
0
                break;
661
73.5M
            case CoordinateType::XYZ:
662
141M
                for (const auto& c : items<Coordinate>()) {
663
141M
                    if (filter->isDone()) break;
664
141M
                    filter->filter_ro(&c);
665
141M
                }
666
73.5M
                break;
667
0
            case CoordinateType::XYM:
668
0
                for (const auto& c : items<CoordinateXYM>()) {
669
0
                    if (filter->isDone()) break;
670
0
                    filter->filter_ro(&c);
671
0
                }
672
0
                break;
673
2.71M
            case CoordinateType::XYZM:
674
5.57M
                for (const auto& c : items<CoordinateXYZM>()) {
675
5.57M
                    if (filter->isDone()) break;
676
5.57M
                    filter->filter_ro(&c);
677
5.57M
                }
678
2.71M
                break;
679
76.2M
        }
680
76.2M
    }
void geos::geom::CoordinateSequence::apply_ro<geos::geom::CoordinateFilter>(geos::geom::CoordinateFilter*) const
Line
Count
Source
653
29.3M
    void apply_ro(Filter* filter) const {
654
29.3M
        switch(getCoordinateType()) {
655
0
            case CoordinateType::XY:
656
0
                for (const auto& c : items<CoordinateXY>()) {
657
0
                    if (filter->isDone()) break;
658
0
                    filter->filter_ro(&c);
659
0
                }
660
0
                break;
661
29.2M
            case CoordinateType::XYZ:
662
29.2M
                for (const auto& c : items<Coordinate>()) {
663
29.2M
                    if (filter->isDone()) break;
664
29.2M
                    filter->filter_ro(&c);
665
29.2M
                }
666
29.2M
                break;
667
0
            case CoordinateType::XYM:
668
0
                for (const auto& c : items<CoordinateXYM>()) {
669
0
                    if (filter->isDone()) break;
670
0
                    filter->filter_ro(&c);
671
0
                }
672
0
                break;
673
50.8k
            case CoordinateType::XYZM:
674
50.8k
                for (const auto& c : items<CoordinateXYZM>()) {
675
50.7k
                    if (filter->isDone()) break;
676
50.7k
                    filter->filter_ro(&c);
677
50.7k
                }
678
50.8k
                break;
679
29.3M
        }
680
29.3M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::apply_ro<geos::operation::valid::RepeatedPointFilter>(geos::operation::valid::RepeatedPointFilter*) const
Unexecuted instantiation: void geos::geom::CoordinateSequence::apply_ro<geos::operation::valid::RepeatedInvalidPointFilter>(geos::operation::valid::RepeatedInvalidPointFilter*) const
Unexecuted instantiation: void geos::geom::CoordinateSequence::apply_ro<geos::precision::PrecisionReducerFilter>(geos::precision::PrecisionReducerFilter*) const
void geos::geom::CoordinateSequence::apply_ro<geos::index::chain::ChainBuilder>(geos::index::chain::ChainBuilder*) const
Line
Count
Source
653
46.9M
    void apply_ro(Filter* filter) const {
654
46.9M
        switch(getCoordinateType()) {
655
0
            case CoordinateType::XY:
656
0
                for (const auto& c : items<CoordinateXY>()) {
657
0
                    if (filter->isDone()) break;
658
0
                    filter->filter_ro(&c);
659
0
                }
660
0
                break;
661
44.3M
            case CoordinateType::XYZ:
662
111M
                for (const auto& c : items<Coordinate>()) {
663
111M
                    if (filter->isDone()) break;
664
111M
                    filter->filter_ro(&c);
665
111M
                }
666
44.3M
                break;
667
0
            case CoordinateType::XYM:
668
0
                for (const auto& c : items<CoordinateXYM>()) {
669
0
                    if (filter->isDone()) break;
670
0
                    filter->filter_ro(&c);
671
0
                }
672
0
                break;
673
2.66M
            case CoordinateType::XYZM:
674
5.52M
                for (const auto& c : items<CoordinateXYZM>()) {
675
5.52M
                    if (filter->isDone()) break;
676
5.52M
                    filter->filter_ro(&c);
677
5.52M
                }
678
2.66M
                break;
679
46.9M
        }
680
46.9M
    }
681
682
    template<typename F>
683
568k
    void forEach(F&& fun) const {
684
568k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
33.2M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
25.1M
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
568k
        }
690
568k
    }
Unexecuted instantiation: CoordinateSequence.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, geos::geom::CoordinateSequence const&)::$_0&>(geos::geom::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, geos::geom::CoordinateSequence const&)::$_0&) const
GeometryFactory.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::GeometryFactory::createMultiPoint(geos::geom::CoordinateSequence const&) const::$_0>(geos::geom::GeometryFactory::createMultiPoint(geos::geom::CoordinateSequence const&) const::$_0&&) const
Line
Count
Source
683
12.6k
    void forEach(F&& fun) const {
684
12.6k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
7.96M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
21.5k
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
12.6k
        }
690
12.6k
    }
void geos::geom::CoordinateSequence::forEach<geos::operation::overlayng::PointExtractingFilter::filter_ro(geos::geom::Geometry const*)::{lambda(auto:1 const&)#1}>(geos::operation::overlayng::PointExtractingFilter::filter_ro(geos::geom::Geometry const*)::{lambda(auto:1 const&)#1}&&) const
Line
Count
Source
683
446k
    void forEach(F&& fun) const {
684
446k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
441k
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
4.46k
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
446k
        }
690
446k
    }
HotPixelIndex.cpp:void geos::geom::CoordinateSequence::forEach<geos::noding::snapround::HotPixelIndex::addNodes(geos::geom::CoordinateSequence const*)::$_0>(geos::noding::snapround::HotPixelIndex::addNodes(geos::geom::CoordinateSequence const*)::$_0&&) const
Line
Count
Source
683
8.33k
    void forEach(F&& fun) const {
684
8.33k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
0
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
4.93M
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
8.33k
        }
690
8.33k
    }
SnapRoundingNoder.cpp:void geos::geom::CoordinateSequence::forEach<geos::noding::snapround::SnapRoundingNoder::round(geos::geom::CoordinateSequence const&) const::$_0>(geos::noding::snapround::SnapRoundingNoder::round(geos::geom::CoordinateSequence const&) const::$_0&&) const
Line
Count
Source
683
33.4k
    void forEach(F&& fun) const {
684
33.4k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
5.16M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
295k
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
33.4k
        }
690
33.4k
    }
SnapRoundingNoder.cpp:void geos::geom::CoordinateSequence::forEach<geos::noding::snapround::SnapRoundingNoder::addVertexNodeSnaps(geos::noding::NodedSegmentString*)::$_0>(geos::noding::snapround::SnapRoundingNoder::addVertexNodeSnaps(geos::noding::NodedSegmentString*)::$_0&&) const
Line
Count
Source
683
17.0k
    void forEach(F&& fun) const {
684
17.0k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
1.97M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
160k
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
17.0k
        }
690
17.0k
    }
OverlayMixedPoints.cpp:void geos::geom::CoordinateSequence::forEach<geos::operation::overlayng::OverlayMixedPoints::findPoints(bool, geos::geom::CoordinateSequence const*) const::$_0>(geos::operation::overlayng::OverlayMixedPoints::findPoints(bool, geos::geom::CoordinateSequence const*) const::$_0&&) const
Line
Count
Source
683
25.5k
    void forEach(F&& fun) const {
684
25.5k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
14.0M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
15.2M
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
25.5k
        }
690
25.5k
    }
OverlayMixedPoints.cpp:void geos::geom::CoordinateSequence::forEach<geos::operation::overlayng::OverlayMixedPoints::createPoints(geos::geom::CoordinateSequence const&) const::$_0>(geos::operation::overlayng::OverlayMixedPoints::createPoints(geos::geom::CoordinateSequence const&) const::$_0&&) const
Line
Count
Source
683
25.4k
    void forEach(F&& fun) const {
684
25.4k
        switch(getCoordinateType()) {
685
0
            case CoordinateType::XY:    for (const auto& c : items<CoordinateXY>())   { fun(c); } break;
686
3.69M
            case CoordinateType::XYZ:   for (const auto& c : items<Coordinate>())     { fun(c); } break;
687
0
            case CoordinateType::XYM:   for (const auto& c : items<CoordinateXYM>())  { fun(c); } break;
688
4.39M
            case CoordinateType::XYZM:  for (const auto& c : items<CoordinateXYZM>()) { fun(c); } break;
689
25.4k
        }
690
25.4k
    }
691
692
    template<typename T, typename F>
693
    void forEach(F&& fun) const
694
676k
    {
695
13.8M
        for (std::size_t i = 0; i < size(); i++) {
696
13.1M
            fun(getAt<T>(i));
697
13.1M
        }
698
676k
    }
Unexecuted instantiation: PointwisePrecisionReducerTransformer.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::Coordinate, geos::precision::PointwisePrecisionReducerTransformer::reducePointwise(geos::geom::CoordinateSequence const*)::$_0>(geos::precision::PointwisePrecisionReducerTransformer::reducePointwise(geos::geom::CoordinateSequence const*)::$_0&&) const
SnappingNoder.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::Coordinate, geos::noding::snap::SnappingNoder::snap(geos::geom::CoordinateSequence const*)::$_0>(geos::noding::snap::SnappingNoder::snap(geos::geom::CoordinateSequence const*)::$_0&&) const
Line
Count
Source
694
676k
    {
695
13.8M
        for (std::size_t i = 0; i < size(); i++) {
696
13.1M
            fun(getAt<T>(i));
697
13.1M
        }
698
676k
    }
699
700
    template<typename T, typename F>
701
    void forEach(std::size_t from, std::size_t to, F&& fun) const
702
205k
    {
703
447k
        for (std::size_t i = from; i <= to; i++) {
704
242k
            fun(getAt<T>(i));
705
242k
        }
706
205k
    }
Unexecuted instantiation: CoordinateSequence.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::CoordinateXY, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_0>(unsigned long, unsigned long, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_0&&) const
CoordinateSequence.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::Coordinate, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_1>(unsigned long, unsigned long, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_1&&) const
Line
Count
Source
702
205k
    {
703
447k
        for (std::size_t i = from; i <= to; i++) {
704
242k
            fun(getAt<T>(i));
705
242k
        }
706
205k
    }
Unexecuted instantiation: CoordinateSequence.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::CoordinateXYZM, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_2>(unsigned long, unsigned long, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_2&&) const
Unexecuted instantiation: CoordinateSequence.cpp:void geos::geom::CoordinateSequence::forEach<geos::geom::CoordinateXYM, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_3>(unsigned long, unsigned long, geos::geom::CoordinateSequence::add(geos::geom::CoordinateSequence const&, unsigned long, unsigned long)::$_3&&) const
707
708
    template<typename T>
709
    class Coordinates {
710
    public:
711
        using SequenceType = typename std::conditional<std::is_const<T>::value, const CoordinateSequence, CoordinateSequence>::type;
712
713
77.2M
        explicit Coordinates(SequenceType* seq) : m_seq(seq) {}
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY const>::Coordinates(geos::geom::CoordinateSequence const*)
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY>::Coordinates(geos::geom::CoordinateSequence*)
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate>::Coordinates(geos::geom::CoordinateSequence*)
Line
Count
Source
713
360k
        explicit Coordinates(SequenceType* seq) : m_seq(seq) {}
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM>::Coordinates(geos::geom::CoordinateSequence*)
Line
Count
Source
713
30.8k
        explicit Coordinates(SequenceType* seq) : m_seq(seq) {}
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM>::Coordinates(geos::geom::CoordinateSequence*)
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate const>::Coordinates(geos::geom::CoordinateSequence const*)
Line
Count
Source
713
74.0M
        explicit Coordinates(SequenceType* seq) : m_seq(seq) {}
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM const>::Coordinates(geos::geom::CoordinateSequence const*)
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM const>::Coordinates(geos::geom::CoordinateSequence const*)
Line
Count
Source
713
2.77M
        explicit Coordinates(SequenceType* seq) : m_seq(seq) {}
714
715
77.2M
        CoordinateSequenceIterator<SequenceType, T> begin() {
716
77.2M
            return {m_seq};
717
77.2M
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY const>::begin()
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY>::begin()
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate>::begin()
Line
Count
Source
715
342k
        CoordinateSequenceIterator<SequenceType, T> begin() {
716
342k
            return {m_seq};
717
342k
        }
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM>::begin()
Line
Count
Source
715
23.8k
        CoordinateSequenceIterator<SequenceType, T> begin() {
716
23.8k
            return {m_seq};
717
23.8k
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM>::begin()
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate const>::begin()
Line
Count
Source
715
74.0M
        CoordinateSequenceIterator<SequenceType, T> begin() {
716
74.0M
            return {m_seq};
717
74.0M
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM const>::begin()
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM const>::begin()
Line
Count
Source
715
2.77M
        CoordinateSequenceIterator<SequenceType, T> begin() {
716
2.77M
            return {m_seq};
717
2.77M
        }
718
719
77.2M
        CoordinateSequenceIterator<SequenceType, T> end() {
720
77.2M
            return {m_seq, m_seq->getSize()};
721
77.2M
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY const>::end()
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY>::end()
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate>::end()
Line
Count
Source
719
342k
        CoordinateSequenceIterator<SequenceType, T> end() {
720
342k
            return {m_seq, m_seq->getSize()};
721
342k
        }
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM>::end()
Line
Count
Source
719
23.8k
        CoordinateSequenceIterator<SequenceType, T> end() {
720
23.8k
            return {m_seq, m_seq->getSize()};
721
23.8k
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM>::end()
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate const>::end()
Line
Count
Source
719
74.0M
        CoordinateSequenceIterator<SequenceType, T> end() {
720
74.0M
            return {m_seq, m_seq->getSize()};
721
74.0M
        }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM const>::end()
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM const>::end()
Line
Count
Source
719
2.77M
        CoordinateSequenceIterator<SequenceType, T> end() {
720
2.77M
            return {m_seq, m_seq->getSize()};
721
2.77M
        }
722
723
        CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>
724
0
        begin() const {
725
0
            return CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>{m_seq};
726
0
        }
727
728
        CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>
729
0
        end() const {
730
0
            return CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>{m_seq, m_seq->getSize()};
731
0
        }
732
733
        CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>
734
0
        cbegin() const {
735
0
            return CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>{m_seq};
736
0
        }
737
738
        CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>
739
0
        cend() const {
740
0
            return CoordinateSequenceIterator<const SequenceType, typename std::add_const<T>::type>{m_seq, m_seq->getSize()};
741
0
        }
742
743
    private:
744
        SequenceType* m_seq;
745
    };
746
747
    template<typename T>
748
76.8M
    Coordinates<typename std::add_const<T>::type> items() const {
749
76.8M
        return Coordinates<typename std::add_const<T>::type>(this);
750
76.8M
    }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<std::__1::add_const<geos::geom::CoordinateXY>::type> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXY>() const
geos::geom::CoordinateSequence::Coordinates<std::__1::add_const<geos::geom::Coordinate>::type> geos::geom::CoordinateSequence::items<geos::geom::Coordinate>() const
Line
Count
Source
748
74.0M
    Coordinates<typename std::add_const<T>::type> items() const {
749
74.0M
        return Coordinates<typename std::add_const<T>::type>(this);
750
74.0M
    }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<std::__1::add_const<geos::geom::CoordinateXYM>::type> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXYM>() const
geos::geom::CoordinateSequence::Coordinates<std::__1::add_const<geos::geom::CoordinateXYZM>::type> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXYZM>() const
Line
Count
Source
748
2.77M
    Coordinates<typename std::add_const<T>::type> items() const {
749
2.77M
        return Coordinates<typename std::add_const<T>::type>(this);
750
2.77M
    }
751
752
    template<typename T>
753
391k
    Coordinates<T> items() {
754
391k
        return Coordinates<T>(this);
755
391k
    }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXY> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXY>()
geos::geom::CoordinateSequence::Coordinates<geos::geom::Coordinate> geos::geom::CoordinateSequence::items<geos::geom::Coordinate>()
Line
Count
Source
753
360k
    Coordinates<T> items() {
754
360k
        return Coordinates<T>(this);
755
360k
    }
geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYZM> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXYZM>()
Line
Count
Source
753
30.8k
    Coordinates<T> items() {
754
30.8k
        return Coordinates<T>(this);
755
30.8k
    }
Unexecuted instantiation: geos::geom::CoordinateSequence::Coordinates<geos::geom::CoordinateXYM> geos::geom::CoordinateSequence::items<geos::geom::CoordinateXYM>()
756
757
758
    /// @}
759
760
0
    double* data() {
761
0
        return m_vect.data();
762
0
    }
763
764
0
    const double* data() const {
765
0
        return m_vect.data();
766
0
    }
767
768
private:
769
    std::vector<double> m_vect; // Vector to store values
770
771
    uint8_t m_stride;           // Stride of stored values, corresponding to underlying type
772
773
    mutable bool m_hasdim;      // Has the dimension of this sequence been determined? Or was it created with no
774
                                // explicit dimensionality, and we're waiting for getDimension() to be called
775
                                // after some coordinates have been added?
776
    mutable bool m_hasz;
777
    bool m_hasm;
778
779
    void initialize();
780
781
    template<typename T1, typename T2>
782
250M
    void setAtImpl(const T2& c, std::size_t pos) {
783
250M
        auto& orig = getAt<T1>(pos);
784
250M
        orig = c;
785
250M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXY, geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
void geos::geom::CoordinateSequence::setAtImpl<geos::geom::Coordinate, geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
Line
Count
Source
782
1
    void setAtImpl(const T2& c, std::size_t pos) {
783
1
        auto& orig = getAt<T1>(pos);
784
1
        orig = c;
785
1
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYZM, geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYM, geos::geom::CoordinateXY>(geos::geom::CoordinateXY const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXY, geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::Coordinate, geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYZM, geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYM, geos::geom::CoordinateXYM>(geos::geom::CoordinateXYM const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXY, geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
void geos::geom::CoordinateSequence::setAtImpl<geos::geom::Coordinate, geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
Line
Count
Source
782
61.2M
    void setAtImpl(const T2& c, std::size_t pos) {
783
61.2M
        auto& orig = getAt<T1>(pos);
784
61.2M
        orig = c;
785
61.2M
    }
void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYZM, geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
Line
Count
Source
782
15.4M
    void setAtImpl(const T2& c, std::size_t pos) {
783
15.4M
        auto& orig = getAt<T1>(pos);
784
15.4M
        orig = c;
785
15.4M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYM, geos::geom::Coordinate>(geos::geom::Coordinate const&, unsigned long)
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXY, geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
void geos::geom::CoordinateSequence::setAtImpl<geos::geom::Coordinate, geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
Line
Count
Source
782
147M
    void setAtImpl(const T2& c, std::size_t pos) {
783
147M
        auto& orig = getAt<T1>(pos);
784
147M
        orig = c;
785
147M
    }
void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYZM, geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
Line
Count
Source
782
26.2M
    void setAtImpl(const T2& c, std::size_t pos) {
783
26.2M
        auto& orig = getAt<T1>(pos);
784
26.2M
        orig = c;
785
26.2M
    }
Unexecuted instantiation: void geos::geom::CoordinateSequence::setAtImpl<geos::geom::CoordinateXYM, geos::geom::CoordinateXYZM>(geos::geom::CoordinateXYZM const&, unsigned long)
786
787
129M
    void make_space(std::size_t pos, std::size_t n) {
788
129M
        m_vect.insert(std::next(m_vect.begin(), static_cast<std::ptrdiff_t>(pos * stride())),
789
129M
                      m_stride * n,
790
129M
                      DoubleNotANumber);
791
129M
    }
792
793
9.01G
    std::uint8_t stride() const {
794
9.01G
        return m_stride;
795
9.01G
    }
796
797
};
798
799
GEOS_DLL std::ostream& operator<< (std::ostream& os, const CoordinateSequence& cs);
800
801
GEOS_DLL bool operator== (const CoordinateSequence& s1, const CoordinateSequence& s2);
802
803
GEOS_DLL bool operator!= (const CoordinateSequence& s1, const CoordinateSequence& s2);
804
805
} // namespace geos::geom
806
} // namespace geos
807