Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / geom / CoordinateArraySequence.h
blob840c7cd58ec544ccd30762c423a8bbe05c42952c
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2006 Refractions Research Inc.
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.
13 **********************************************************************/
15 #ifndef GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
16 #define GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
18 #include <geos/export.h>
19 #include <vector>
21 #include <geos/geom/CoordinateSequence.h>
23 #include <geos/inline.h>
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Coordinate;
33 namespace geos {
34 namespace geom { // geos.geom
36 /// The default implementation of CoordinateSequence
37 class GEOS_DLL CoordinateArraySequence : public CoordinateSequence {
38 public:
40 CoordinateArraySequence(const CoordinateArraySequence &cl);
42 CoordinateSequence *clone() const;
44 //const Coordinate& getCoordinate(int pos) const;
45 const Coordinate& getAt(std::size_t pos) const;
47 /// Copy Coordinate at position i to Coordinate c
48 virtual void getAt(std::size_t i, Coordinate& c) const;
50 //int size() const;
51 size_t getSize() const;
53 // @deprecated
54 const std::vector<Coordinate>* toVector() const;
56 // See dox in CoordinateSequence.h
57 void toVector(std::vector<Coordinate>&) const;
59 /// Construct an empty sequence
60 CoordinateArraySequence();
62 /// Construct sequence taking ownership of given Coordinate vector
63 CoordinateArraySequence(std::vector<Coordinate> *coords,
64 std::size_t dimension = 0);
66 /// Construct sequence allocating space for n coordinates
67 CoordinateArraySequence(std::size_t n, std::size_t dimension = 0);
69 ~CoordinateArraySequence();
71 bool isEmpty() const { return empty(); }
73 bool empty() const { return vect->empty(); }
75 /// Reset this CoordinateArraySequence to the empty state
76 void clear() { vect->clear(); }
78 void add(const Coordinate& c);
80 virtual void add(const Coordinate& c, bool allowRepeated);
82 /** \brief
83 * Inserts the specified coordinate at the specified position in
84 * this list.
86 * @param i the position at which to insert
87 * @param coord the coordinate to insert
88 * @param allowRepeated if set to false, repeated coordinates are
89 * collapsed
91 * NOTE: this is a CoordinateList interface in JTS
93 virtual void add(std::size_t i, const Coordinate& coord, bool allowRepeated);
95 void setAt(const Coordinate& c, std::size_t pos);
97 void deleteAt(std::size_t pos);
99 std::string toString() const;
101 void setPoints(const std::vector<Coordinate> &v);
103 double getOrdinate(std::size_t index,
104 size_t ordinateIndex) const;
106 void setOrdinate(std::size_t index, std::size_t ordinateIndex,
107 double value);
109 void expandEnvelope(Envelope &env) const;
111 std::size_t getDimension() const;
113 void apply_rw(const CoordinateFilter *filter);
115 void apply_ro(CoordinateFilter *filter) const;
117 virtual CoordinateSequence& removeRepeatedPoints();
119 private:
120 std::vector<Coordinate> *vect;
121 mutable std::size_t dimension;
124 /// This is for backward API compatibility
125 typedef CoordinateArraySequence DefaultCoordinateSequence;
127 } // namespace geos.geom
128 } // namespace geos
130 //#ifdef GEOS_INLINE
131 //# include "geos/geom/CoordinateArraySequence.inl"
132 //#endif
134 #endif // ndef GEOS_GEOM_COORDINATEARRAYSEQUENCE_H
136 /**********************************************************************
137 * $Log$
138 * Revision 1.4 2006/06/12 10:10:39 strk
139 * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t.
141 * Revision 1.3 2006/05/03 08:58:34 strk
142 * added new non-static CoordinateSequence::removeRepeatedPoints() mutator.
144 * Revision 1.2 2006/03/24 09:52:41 strk
145 * USE_INLINE => GEOS_INLINE
147 * Revision 1.1 2006/03/09 16:46:49 strk
148 * geos::geom namespace definition, first pass at headers split
150 **********************************************************************/