00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GEOS_GEOM_COORDINATELIST_H
00022 #define GEOS_GEOM_COORDINATELIST_H
00023
00024 #include <geos/export.h>
00025 #include <geos/geom/Coordinate.h>
00026
00027 #include <list>
00028 #include <ostream>
00029 #include <memory>
00030
00031 #ifdef _MSC_VER
00032 #pragma warning(push)
00033 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00034 #endif
00035
00036
00037 namespace geos {
00038 namespace geom {
00039
00040 }
00041 }
00042
00043
00044 namespace geos {
00045 namespace geom {
00046
00056 class GEOS_DLL CoordinateList {
00057
00058 public:
00059
00060 typedef std::list<Coordinate>::iterator iterator;
00061 typedef std::list<Coordinate>::const_iterator const_iterator;
00062 typedef std::list<Coordinate>::size_type size_type;
00063
00064 friend std::ostream& operator<< (std::ostream& os,
00065 const CoordinateList& cl);
00066
00076 CoordinateList(const std::vector<Coordinate>& v)
00077 :
00078 coords(v.begin(), v.end())
00079 {
00080 }
00081
00082 CoordinateList()
00083 :
00084 coords()
00085 {
00086 }
00087
00088 size_type size() const
00089 {
00090 return coords.size();
00091 }
00092
00093 bool empty() const
00094 {
00095 return coords.empty();
00096 }
00097
00098 iterator begin()
00099 {
00100 return coords.begin();
00101 }
00102
00103 iterator end()
00104 {
00105 return coords.end();
00106 }
00107
00108 const_iterator begin() const
00109 {
00110 return coords.begin();
00111 }
00112
00113 const_iterator end() const
00114 {
00115 return coords.end();
00116 }
00117
00131 iterator insert(iterator pos, const Coordinate& c, bool allowRepeated)
00132 {
00133 if ( !allowRepeated && pos != coords.begin() ) {
00134 iterator prev = pos; --prev;
00135 if ( c.equals2D(*prev) ) return prev;
00136 }
00137 return coords.insert(pos, c);
00138 }
00139
00140 iterator insert(iterator pos, const Coordinate& c)
00141 {
00142 return coords.insert(pos, c);
00143 }
00144
00145 iterator erase(iterator pos)
00146 {
00147 return coords.erase(pos);
00148 }
00149
00150 iterator erase(iterator first, iterator last)
00151 {
00152 return coords.erase(first, last);
00153 }
00154
00155 std::auto_ptr<Coordinate::Vect> toCoordinateArray() const
00156 {
00157 std::auto_ptr<Coordinate::Vect> ret(new Coordinate::Vect);
00158 ret->assign(coords.begin(), coords.end());
00159 return ret;
00160 }
00161
00162 private:
00163
00164 std::list<Coordinate> coords;
00165 };
00166
00167 inline
00168 std::ostream& operator<< (std::ostream& os, const CoordinateList& cl)
00169 {
00170 os << "(";
00171 for (CoordinateList::const_iterator
00172 it=cl.begin(), end=cl.end();
00173 it != end;
00174 ++it)
00175 {
00176 const Coordinate& c = *it;
00177 if ( it != cl.begin() ) os << ", ";
00178 os << c;
00179 }
00180 os << ")";
00181
00182 return os;
00183 }
00184
00185 }
00186 }
00187
00188 #ifdef _MSC_VER
00189 #pragma warning(pop)
00190 #endif
00191
00192 #endif // ndef GEOS_GEOM_COORDINATELIST_H
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203