GEOS 3.11.1
CoordinateArraySequence.h
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#pragma once
16
17#include <geos/export.h>
18#include <vector>
19
20#include <geos/geom/CoordinateFilter.h>
21#include <geos/geom/CoordinateSequence.h>
22
23// Forward declarations
24namespace geos {
25namespace geom {
26class Coordinate;
27}
28}
29
30
31namespace geos {
32namespace geom { // geos.geom
33
36public:
37
39
41
42 std::unique_ptr<CoordinateSequence> clone() const override;
43
44 const Coordinate& getAt(std::size_t pos) const override;
45
47 void getAt(std::size_t i, Coordinate& c) const override;
48
49 std::size_t getSize() const override;
50
51 // See dox in CoordinateSequence.h
52 void toVector(std::vector<Coordinate>&) const override;
53
56
58 CoordinateArraySequence(std::vector<Coordinate> && coords,
59 std::size_t dimension = 0);
60
62 CoordinateArraySequence(std::vector<Coordinate>* coords,
63 std::size_t dimension = 0);
64
66 CoordinateArraySequence(std::size_t n, std::size_t dimension = 0);
67
68 ~CoordinateArraySequence() override = default;
69
70 bool
71 isEmpty() const override
72 {
73 return empty();
74 }
75
76 bool
77 empty() const
78 {
79 return vect.empty();
80 }
81
83 void
85 {
86 vect.clear();
87 }
88
90 void add(const Coordinate& c);
91
98 void add(const Coordinate& c, bool allowRepeated);
99
111 void add(std::size_t i, const Coordinate& coord, bool allowRepeated);
112
113 void add(const CoordinateSequence* cl, bool allowRepeated, bool direction);
114
115 void setAt(const Coordinate& c, std::size_t pos) override;
116
117 void setPoints(const std::vector<Coordinate>& v) override;
118
119 void setOrdinate(std::size_t index, std::size_t ordinateIndex,
120 double value) override;
121
122 void expandEnvelope(Envelope& env) const override;
123
124 void closeRing();
125
126 std::size_t getDimension() const override;
127
128 void apply_rw(const CoordinateFilter* filter) override;
129
130 void apply_ro(CoordinateFilter* filter) const override {
131 for(const auto& coord : vect) {
132 filter->filter_ro(&coord);
133 }
134 }
135
136private:
137 std::vector<Coordinate> vect;
138 mutable std::size_t dimension;
139};
140
143
144} // namespace geos.geom
145} // namespace geos
146
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:35
std::unique_ptr< CoordinateSequence > clone() const override
Returns a deep copy of this collection.
void toVector(std::vector< Coordinate > &) const override
const Coordinate & getAt(std::size_t pos) const override
Returns a read-only reference to Coordinate at position i.
std::size_t getSize() const override
Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data...
void expandEnvelope(Envelope &env) const override
void clear()
Reset this CoordinateArraySequence to the empty state.
Definition: CoordinateArraySequence.h:84
CoordinateArraySequence(std::vector< Coordinate > *coords, std::size_t dimension=0)
Construct sequence taking ownership of given Coordinate vector.
CoordinateArraySequence(std::size_t n, std::size_t dimension=0)
Construct sequence allocating space for n coordinates.
void setAt(const Coordinate &c, std::size_t pos) override
Copy Coordinate c to position pos.
CoordinateArraySequence()
Construct an empty sequence.
void add(std::size_t i, const Coordinate &coord, bool allowRepeated)
Inserts the specified coordinate at the specified position in this list.
void setPoints(const std::vector< Coordinate > &v) override
Substitute Coordinate list with a copy of the given vector.
void getAt(std::size_t i, Coordinate &c) const override
Copy Coordinate at position i to Coordinate c.
std::size_t getDimension() const override
void setOrdinate(std::size_t index, std::size_t ordinateIndex, double value) override
void add(const Coordinate &c)
Add a Coordinate to the list.
void add(const Coordinate &c, bool allowRepeated)
Add a coordinate.
CoordinateArraySequence(std::vector< Coordinate > &&coords, std::size_t dimension=0)
Construct sequence moving from given Coordinate vector.
bool isEmpty() const override
Returns true it list contains no coordinates.
Definition: CoordinateArraySequence.h:71
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:41
virtual void filter_ro(const Coordinate *)
Performs an operation with coord.
Definition: CoordinateFilter.h:63
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
CoordinateArraySequence DefaultCoordinateSequence
This is for backward API compatibility.
Definition: CoordinateArraySequence.h:142
Basic namespace for all GEOS functionalities.
Definition: geos.h:39