17#include <geos/geom/Coordinate.h>
18#include <geos/geom/CoordinateFilter.h>
19#include <geos/geom/CoordinateSequence.h>
20#include <geos/util/IllegalArgumentException.h>
33 class FixedSizeCoordinateSequence :
public CoordinateSequence {
35 explicit FixedSizeCoordinateSequence(std::size_t dimension_in = 0) : dimension(dimension_in) {}
37 std::unique_ptr<CoordinateSequence> clone() const final
override {
38 auto seq = detail::make_unique<FixedSizeCoordinateSequence<N>>(dimension);
40 return RETURN_UNIQUE_PTR(seq);
43 const Coordinate& getAt(std::size_t i)
const final override {
47 void getAt(std::size_t i, Coordinate& c)
const final override {
51 std::size_t getSize() const final
override {
55 bool isEmpty() const final
override {
59 void setAt(
const Coordinate & c, std::size_t pos)
final override {
63 void setOrdinate(std::size_t index, std::size_t ordinateIndex,
double value)
final override
65 switch(ordinateIndex) {
66 case CoordinateSequence::X:
67 m_data[index].x = value;
69 case CoordinateSequence::Y:
70 m_data[index].y = value;
72 case CoordinateSequence::Z:
73 m_data[index].z = value;
77 ss <<
"Unknown ordinate index " << ordinateIndex;
84 std::size_t getDimension() const final
override {
93 if(std::isnan(m_data[0].z)) {
103 void toVector(std::vector<Coordinate> & out)
const final override {
104 out.insert(out.end(), m_data.begin(), m_data.end());
107 void setPoints(
const std::vector<Coordinate> & v)
final override {
108 assert(v.size() == N);
110 std::copy(v.begin(), v.end(), m_data.begin());
115 void apply_ro(CoordinateFilter* filter)
const final override {
116 std::for_each(m_data.begin(), m_data.end(),
117 [&filter](
const Coordinate & c) { filter->filter_ro(&c); });
120 void apply_rw(
const CoordinateFilter* filter)
final override {
121 std::for_each(m_data.begin(), m_data.end(),
122 [&filter](Coordinate &c) { filter->filter_rw(&c); });
127 std::array<Coordinate, N> m_data;
128 mutable std::size_t dimension;
Indicates one or more illegal arguments.
Definition: IllegalArgumentException.h:33
Basic namespace for all GEOS functionalities.
Definition: geos.h:39