Agroeye  1.0
Raster.h
Go to the documentation of this file.
1 #ifndef RASTER_H
2 #define RASTER_H
3 
4 #include <memory>
5 #include <string>
6 #include <unordered_map>
7 
8 #include <gdal_priv.h>
9 #include <ogr_spatialref.h>
10 
11 #include "GeneralErrors.h"
12 #include "RasterErrors.h"
13 #include "RasterData.h"
14 #include "RasterBand.h"
15 #include "RasterDataGroup.h"
16 #include "Callback.h"
17 
18 namespace agroeye {
19 namespace handlers {
20 
24 
32 class Raster {
33 public:
34  Raster(const Raster& other);
35  Raster(Raster&& other);
36  Raster& operator=(const Raster& other);
37  Raster& operator=(Raster&& other);
38  virtual ~Raster();
46  Raster(const char* path);
47 
55  Raster(const char* path, agroeye::general::CallbackFunction func);
56 
65  static Raster copy(const Raster& other, const char* path);
66 
75  static Raster emptyCopy(const Raster& other, const char* path);
76 
77  size_t getBandsCount() const;
78  size_t getWidth() const;
79  size_t getHeight() const;
89  RasterDataGroup read(size_t x, size_t y, size_t width, size_t height);
90 
97  RasterBand getBand(const size_t bandNo);
98  std::string getPath() const {return datasetPath;};
99  std::string getProj4() const;
100  std::unique_ptr<double[]> getGeoTransform() const;
102 private:
103  void openDataset(const char* path, bool readOnly = true);
104  void openBands();
105  std::shared_ptr<GDALDataset> gdalDataset;
106 
108  std::string datasetPath;
109  std::unordered_map<size_t, RasterBand> bandsList;
110 
111  Raster(const Raster& other, const char* path, bool empty);
112 
113 };
114 
115 
116 
117 } // namspace handlers
118 } // namespace agroeye
119 
120 
121 #endif
122 
static Raster emptyCopy(const Raster &other, const char *path)
Copies and empties raster.
Definition: Raster.cpp:108
size_t getWidth() const
Definition: Raster.cpp:139
Class encapsulating Raster file object.
Definition: Raster.h:32
CallbackTypes
Type of callback that can be called function.
Definition: Callback.h:17
size_t getHeight() const
Definition: Raster.cpp:146
Raster(const Raster &other)
Definition: Raster.cpp:7
Encapsulation of read data from a couple of bands from one RasterDataGroup Also provides convinient b...
Definition: RasterDataGroup.h:18
size_t getBandsCount() const
Definition: Raster.cpp:135
Definition: ContainerMath.h:11
virtual ~Raster()
Definition: Raster.cpp:39
RasterBand getBand(const size_t bandNo)
Gets the band of raster.
Definition: Raster.cpp:153
Raster & operator=(const Raster &other)
Definition: Raster.cpp:21
std::function< void(double, ListCallbackTypes, std::string)> CallbackFunction
Definition: Callback.h:25
std::unique_ptr< double[]> getGeoTransform() const
Definition: Raster.cpp:180
Definition: RasterBand.h:20
std::string getPath() const
Definition: Raster.h:98
std::string getProj4() const
Definition: Raster.cpp:160
RasterDataGroup read(size_t x, size_t y, size_t width, size_t height)
Reads pixels data from all bands inside raster.
Definition: Raster.cpp:127
void silenceCallback(double progress, ListCallbackTypes listTypes, std::string message)
Silencing callback.
Definition: Callback.cpp:17
static Raster copy(const Raster &other, const char *path)
Copies the raster.
Definition: Raster.cpp:104