openModeller  Version 1.5.0
GdalRaster.hh
Go to the documentation of this file.
1 
30 #ifndef _GDAL_RASTERHH_
31 #define _GDAL_RASTERHH_
32 
33 #include <openmodeller/om_defs.hh>
36 
37 #include <string>
38 #include <vector>
39 
40 class GDALDataset;
41 class MapFormat;
42 
43 /****************************************************************/
44 /************************** Raster Gdal *************************/
45 
51 class dllexp GdalRaster : public Raster
52 {
53 public:
54 
55  // Empty constructor
56  GdalRaster(): f_data(0), f_size(0), f_format(-1), f_currentRow(-1), f_changed(0), f_warped_ds(0) {};
57 
63  void createRaster( const std::string& file, int categ = 0 );
64 
65  #ifdef MPI_FOUND
66 
71  void createRaster( const std::string& output_file_source, const std::string& file, const MapFormat& format );
72  #else
73 
78  void createRaster( const std::string& file, const MapFormat& format );
79  #endif
80 
84  ~GdalRaster();
85 
86  int iget( int x, int y, Scalar *val );
87  int iput( int x, int y, Scalar val );
88 
93  int get( Coord x, Coord y, Scalar *val );
94 
100  int put( Coord x, Coord y, Scalar val );
101 
107  int put( Coord x, Coord y );
108 
114  int getMinMax( Scalar *min, Scalar *max );
115 
117  int calcMinMax( int band=0 );
118 
122  void finish();
123 
127  int deleteRaster();
128 
133  bool hasCustomGeotransform() { return (f_warped_ds == 0) ? false: true; }
134 
148  int getExtentInStandardCs( Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax );
149 
150 private:
151 
153  void open( char mode );
154 
156  void create( int format );
157 
158  void initBuffer();
159 
160  static void initGdal();
161 
167  void read ( Scalar *buf, int first_row, int num_rows );
168 
173  void write( Scalar *buf, int first_row, int num_rows );
174 
175  void loadRow( int row, bool writeOperation=false );
176 
177  void saveRow(); // Save the current row.
178 
179  GDALDataset *f_ds;
180 
181  Scalar *f_data; // One line data for all bands.
182  int f_size; // Size of one line.
183 
184  int f_format; // File format used to create the raster (MapFormat::getFormat())
185 
188 
189  // Disable copying.
190  GdalRaster( const GdalRaster& );
191  GdalRaster& operator=( const GdalRaster& );
192 
193  // Warped data set converting to standard openModeller coordinate system.
194  // Only used when the raster cs is different from openModeller's default.
195  GDALDataset *f_warped_ds;
196 };
197 
198 #endif
199 
virtual void finish()
Definition: Raster.hh:154
GDALDataset * f_warped_ds
Definition: GdalRaster.hh:195
double Scalar
Type of map values.
Definition: om_defs.hh:39
virtual int put(Coord px, Coord py, Scalar val)=0
A common interface to rasters.
Definition: Raster.hh:44
virtual int getMinMax(Scalar *min, Scalar *max)=0
GDALDataset * f_ds
Definition: GdalRaster.hh:179
Scalar * f_data
Definition: GdalRaster.hh:181
int f_currentRow
Definition: GdalRaster.hh:186
double Coord
Type of map coordinates.
Definition: om_defs.hh:38
bool hasCustomGeotransform()
Definition: GdalRaster.hh:133
virtual int deleteRaster()=0
virtual int getExtentInStandardCs(Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax)
Definition: Raster.hh:180
int min(int v1, int v2)
Definition: rules_base.cpp:56
virtual void createRaster(const std::string &source, int categ=0)=0