Ilwis-Objects  1.0
GIS and Remote Sensing framework for data access and processing
 All Classes Functions Enumerations Pages
blockiterator.h
1 #ifndef BLOCKITERATOR_H
2 #define BLOCKITERATOR_H
3 
4 #include "ilwis.h"
5 #include "boost/geometry.hpp"
6 
7 namespace Ilwis {
8 
9 class BlockIterator;
10 class GridBlock;
11 
12 class KERNELSHARED_EXPORT CellIterator : public std::iterator<std::random_access_iterator_tag, double> {
13 public:
14  friend bool operator==(const CellIterator& iter1, const CellIterator& iter2);
15 
16  CellIterator(GridBlock *bl, bool end);
17 
18 
19  CellIterator& operator=(CellIterator& iter);
20 
21 
22  CellIterator& operator++() {
23  move(1);
24  return *this;
25  }
26  CellIterator& operator--() {
27  move(-1);
28  return *this;
29  }
30 
31  CellIterator operator++(int);
32  CellIterator operator--(int);
33 
34  double& operator*() ;
35 
36  //qint32 position() const;
37  Ilwis::Size<> blocksize() const;
38 
39 private:
40  void move(int n);
41  GridBlock *_block;
42  qint32 _positionx;
43  qint32 _positiony;
44  qint32 _positionz;
45 
46 };
47 
48 KERNELSHARED_EXPORT bool operator==(const CellIterator& iter1, const CellIterator& iter2);
49 
50 KERNELSHARED_EXPORT bool operator!=(const CellIterator& iter1, const CellIterator& iter2);
51 
52 class KERNELSHARED_EXPORT GridBlock {
53 
54  friend class BlockIterator;
55 
56 public:
57  enum Pivot{pLEFTUP, pCENTER};
58 
59  GridBlock(BlockIterator& biter);
60  double& operator()(qint32 x, qint32 y, qint32 z=0);
61  double operator()(qint32 x, qint32 y, qint32 z=0) const;
62  Size<> size() const;
63  CellIterator begin() ;
64  CellIterator end() ;
65  const BlockIterator& iterator() const;
66  bool isValid() const;
67  Pixel position() const;
68  std::vector<double> toVector(Pivot pivot = pCENTER) const;
69 private:
70  BlockIterator& _iterator;
71  std::vector<quint32> _internalBlockNumber;
72  std::vector<quint32> _offsets;
73  quint32 _blockYSize;
74  quint32 _blockXSize;
75  quint32 _bandOffset;
76  quint64 _XYSize;
77  void actualPosition(qint32 &x, qint32 &y, qint32 &z) const;
78 };
79 
80 class KERNELSHARED_EXPORT BlockIterator : public PixelIterator {
81 public:
82  friend class GridBlock;
83 
84  BlockIterator(IRasterCoverage raster, const Size<> &sz, const BoundingBox& box=BoundingBox(), const Size<> &steps=Size<>());
85 
86  GridBlock& operator*() {
87  return _block;
88  }
89  const GridBlock& operator*() const{
90  return _block;
91  }
92  BlockIterator& operator++();
93  BlockIterator& operator--();
94  BlockIterator end() const ;
95  bool operator==(const BlockIterator& iter) const;
96  bool operator!=(const BlockIterator& iter) const;
97  Size<> blockSize() const;
98  void stepsizes(const Size<>& stepsize);
99 private:
100  BlockIterator(quint64 endpos);
101  GridBlock _block;
102  Size<> _blocksize;
103  Size<> _stepsizes;
104  double _outside=rILLEGAL;
105 };
106 
107 
108 }
109 
110 #endif // BLOCKITERATOR_H