GEOS  3.9.0dev
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 #ifndef GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
16 #define GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
17 
18 #include <geos/export.h>
19 #include <vector>
20 
21 #include <geos/geom/CoordinateSequence.h>
22 
23 #include <geos/inline.h>
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Coordinate;
29 }
30 }
31 
32 
33 namespace geos {
34 namespace geom { // geos.geom
35 
38 public:
39 
41 
43 
44  std::unique_ptr<CoordinateSequence> clone() const override;
45 
46  const Coordinate& getAt(std::size_t pos) const override;
47 
49  void getAt(std::size_t i, Coordinate& c) const override;
50 
51  size_t getSize() const override;
52 
53  // See dox in CoordinateSequence.h
54  void toVector(std::vector<Coordinate>&) const override;
55 
58 
60  CoordinateArraySequence(std::vector<Coordinate> && coords,
61  std::size_t dimension = 0);
62 
64  CoordinateArraySequence(std::vector<Coordinate>* coords,
65  std::size_t dimension = 0);
66 
68  CoordinateArraySequence(std::size_t n, std::size_t dimension = 0);
69 
70  ~CoordinateArraySequence() override = default;
71 
72  bool
73  isEmpty() const override
74  {
75  return empty();
76  }
77 
78  bool
79  empty() const
80  {
81  return vect.empty();
82  }
83 
85  void
87  {
88  vect.clear();
89  }
90 
92  void add(const Coordinate& c);
93 
100  void add(const Coordinate& c, bool allowRepeated);
101 
113  void add(std::size_t i, const Coordinate& coord, bool allowRepeated);
114 
115  void add(const CoordinateSequence* cl, bool allowRepeated, bool direction);
116 
117  void setAt(const Coordinate& c, std::size_t pos) override;
118 
119  void setPoints(const std::vector<Coordinate>& v) override;
120 
121  void setOrdinate(std::size_t index, std::size_t ordinateIndex,
122  double value) override;
123 
124  void expandEnvelope(Envelope& env) const override;
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 
132 private:
133  std::vector<Coordinate> vect;
134  mutable std::size_t dimension;
135 };
136 
139 
140 } // namespace geos.geom
141 } // namespace geos
142 
143 #endif // ndef GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
CoordinateArraySequence DefaultCoordinateSequence
This is for backward API compatibility.
Definition: CoordinateArraySequence.h:138
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
The default implementation of CoordinateSequence.
Definition: CoordinateArraySequence.h:37
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
bool isEmpty() const override
Returns true it list contains no coordinates.
Definition: CoordinateArraySequence.h:73
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
void clear()
Reset this CoordinateArraySequence to the empty state.
Definition: CoordinateArraySequence.h:86