openModeller
Version 1.4.0
|
#include <GdalRaster.hh>
Public Member Functions | |
GdalRaster () | |
void | createRaster (const std::string &file, int categ=0) |
void | createRaster (const std::string &file, const MapFormat &format) |
~GdalRaster () | |
int | iget (int x, int y, Scalar *val) |
int | iput (int x, int y, Scalar val) |
int | get (Coord x, Coord y, Scalar *val) |
int | put (Coord x, Coord y, Scalar val) |
int | put (Coord x, Coord y) |
int | getMinMax (Scalar *min, Scalar *max) |
int | calcMinMax (int band=0) |
void | finish () |
int | deleteRaster () |
bool | hasCustomGeotransform () |
int | getExtentInStandardCs (Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax) |
Private Member Functions | |
void | open (char mode) |
void | create (int format) |
void | initBuffer () |
void | read (Scalar *buf, int first_row, int num_rows) |
void | write (Scalar *buf, int first_row, int num_rows) |
void | loadRow (int row, bool writeOperation=false) |
void | saveRow () |
GdalRaster (const GdalRaster &) | |
GdalRaster & | operator= (const GdalRaster &) |
Static Private Member Functions | |
static void | initGdal () |
Private Attributes | |
GDALDataset * | f_ds |
Scalar * | f_data |
int | f_size |
int | f_format |
int | f_currentRow |
int | f_changed |
GDALDataset * | f_warped_ds |
Manages raster files with GDAL (Geospatial Data Abstraction Library - http://www.remotesensing.org/gdal/index.html)
Definition at line 51 of file GdalRaster.hh.
GdalRaster::GdalRaster | ( | ) | [inline] |
Definition at line 56 of file GdalRaster.hh.
Destructor
Definition at line 281 of file GdalRaster.cpp.
References f_data, f_ds, Raster::f_file, and saveRow().
GdalRaster::GdalRaster | ( | const GdalRaster & | ) | [private] |
int GdalRaster::calcMinMax | ( | int | band = 0 | ) |
Find the minimum and maximum values in 'band'.
Definition at line 765 of file GdalRaster.cpp.
References Raster::f_hdr, iget(), min(), Header::minmax, Header::nband, Header::vmax, Header::vmin, Header::xdim, and Header::ydim.
Referenced by getMinMax().
void GdalRaster::create | ( | int | format | ) | [private] |
Create a new raster file based on 'hdr'.
Definition at line 442 of file GdalRaster.cpp.
References MapFormat::ByteASC, MapFormat::ByteHFA, GDAL_Format::dataType, Log::error(), f_ds, Raster::f_file, f_format, Raster::f_hdr, MapFormat::FloatingASC, MapFormat::FloatingHFA, GDAL_Format::GDalDriverName, MapFormat::GreyTiff100, Header::gt, initBuffer(), Log::instance(), Header::nband, Header::noval, Header::proj, Log::warn(), Header::xdim, and Header::ydim.
void GdalRaster::createRaster | ( | const std::string & | file, |
int | categ = 0 |
||
) | [virtual] |
Open an existing file -- read only. If 'categ' != 0 this is a categorical map (ie it can't be interpolated). Othewise this is a continuos map.
Implements Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
void GdalRaster::createRaster | ( | const std::string & | file, |
const MapFormat & | format | ||
) | [virtual] |
Create a new file for projections.
file | is the name of the output file |
format | is the output format specification. |
Implements Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
int GdalRaster::deleteRaster | ( | ) | [virtual] |
Method to delete a raster.
Implements Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
Definition at line 931 of file GdalRaster.cpp.
References f_ds, and Raster::f_file.
void GdalRaster::finish | ( | ) | [virtual] |
Event that must be called to indicate when the projection is finished.
Reimplemented from Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
Definition at line 873 of file GdalRaster.cpp.
References MapFormat::ByteASC, Log::error(), f_ds, Raster::f_file, f_format, MapFormat::FloatingASC, Log::instance(), saveRow(), and Log::warn().
int GdalRaster::get | ( | Coord | x, |
Coord | y, | ||
Scalar * | val | ||
) | [virtual] |
Fills '*val' with the map value at (x,y). Returns zero if (x,y) is out of range.
Implements Raster.
Definition at line 683 of file GdalRaster.cpp.
References Header::convertLonLat2XY(), Raster::f_hdr, iget(), Header::nband, Header::noval, Header::xdim, and Header::ydim.
int GdalRaster::getExtentInStandardCs | ( | Coord * | xmin, |
Coord * | ymin, | ||
Coord * | xmax, | ||
Coord * | ymax | ||
) | [virtual] |
Calculates the raster extent in openModeller's standard coordinate system. IMPORTANT: Call this only if hasCustomGeotransform returns true. When interacting with Map objects, use Map.getExtent instead, which encapsulates a call to this method when necessary. For some projections, such as lambert azimuth equal area, getting the raster extent through manual coordinate conversion, as was usually done in the Map.getExtent, can be problematic. This method provides a way for raster implementations to better perform the task of calculating the extent.
xmin | Pointer to minimum X value |
ymin | Pointer to minimum Y value |
xmax | Pointer to maximum X value |
ymax | Pointer to maximum Y value |
Reimplemented from Raster.
Definition at line 950 of file GdalRaster.cpp.
References f_warped_ds.
int GdalRaster::getMinMax | ( | Scalar * | min, |
Scalar * | max | ||
) | [virtual] |
Finds the minimum and maximum values in the first band.
min | Pointer to minimum value |
max | Pointer to maximum value |
Implements Raster.
Definition at line 748 of file GdalRaster.cpp.
References calcMinMax(), Raster::f_hdr, Header::vmax, and Header::vmin.
bool GdalRaster::hasCustomGeotransform | ( | ) | [inline, virtual] |
Indicates if the raster has a better way to carry out conversions from its own coordinate system to the standard system used by openModeller.
Reimplemented from Raster.
Definition at line 133 of file GdalRaster.hh.
int GdalRaster::iget | ( | int | x, |
int | y, | ||
Scalar * | val | ||
) |
Definition at line 661 of file GdalRaster.cpp.
References f_data, Raster::f_hdr, f_size, loadRow(), Header::nband, and Header::noval.
Referenced by calcMinMax(), and get().
void GdalRaster::initBuffer | ( | ) | [private] |
Definition at line 611 of file GdalRaster.cpp.
References f_changed, f_currentRow, f_data, Raster::f_hdr, f_size, Header::nband, and Header::xdim.
void GdalRaster::initGdal | ( | ) | [static, private] |
Definition at line 630 of file GdalRaster.cpp.
int GdalRaster::iput | ( | int | x, |
int | y, | ||
Scalar | val | ||
) |
void GdalRaster::loadRow | ( | int | row, |
bool | writeOperation = false |
||
) | [private] |
Definition at line 825 of file GdalRaster.cpp.
References f_changed, f_currentRow, f_data, Raster::f_hdr, f_size, Header::noval, read(), and saveRow().
Referenced by iget(), and iput().
void GdalRaster::open | ( | char | mode | ) | [private] |
Open a raster file.
Definition at line 360 of file GdalRaster.cpp.
References Header::calculateCell(), GeoTransform::compareCoordSystemStrings(), Log::error(), f_ds, Raster::f_file, Raster::f_hdr, f_warped_ds, GeoTransform::getDefaultCS(), Header::grid, Header::gt, Header::hasProj(), initBuffer(), Log::instance(), Header::minmax, Header::nband, Header::noval, Header::setProj(), Header::vmax, Header::vmin, Log::warn(), Header::xdim, Header::xmax, Header::xmin, Header::ydim, Header::ymax, and Header::ymin.
GdalRaster& GdalRaster::operator= | ( | const GdalRaster & | ) | [private] |
int GdalRaster::put | ( | Coord | x, |
Coord | y, | ||
Scalar | val | ||
) | [virtual] |
Put '*val' at the (x,y) coordinate. Returns 0 if (x,y) is out of range or the map is read only. supports only single band output files.
Implements Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
Definition at line 710 of file GdalRaster.cpp.
References Header::convertLonLat2XY(), Raster::f_hdr, Raster::f_scalefactor, Log::instance(), iput(), Log::warn(), Header::xdim, and Header::ydim.
int GdalRaster::put | ( | Coord | x, |
Coord | y | ||
) | [virtual] |
Put 'no data val' at the (x,y) coordinate. Returns 0 if (x,y) is out of range or the map is read only. supports only single band output files.
Implements Raster.
Reimplemented in RemoteRaster, and WcsProxyRaster.
Definition at line 728 of file GdalRaster.cpp.
References Header::convertLonLat2XY(), Raster::f_hdr, Log::instance(), iput(), Header::noval, Log::warn(), Header::xdim, and Header::ydim.
void GdalRaster::read | ( | Scalar * | buf, |
int | first_row, | ||
int | num_rows | ||
) | [private] |
Read 'num_rows' rows starting from 'first_row' to the memory pointed to by 'buf'. Each element read is transformed in a 'Scalar'.
Definition at line 304 of file GdalRaster.cpp.
References f_ds, Raster::f_hdr, f_size, f_type, Header::nband, and Header::noval.
Referenced by loadRow().
void GdalRaster::saveRow | ( | ) | [private] |
Definition at line 858 of file GdalRaster.cpp.
References f_changed, f_currentRow, f_data, and write().
Referenced by finish(), loadRow(), and ~GdalRaster().
void GdalRaster::write | ( | Scalar * | buf, |
int | first_row, | ||
int | num_rows | ||
) | [private] |
Write 'num_rows' rows starting from 'first_row' to the memory pointed to by 'buf'.
Definition at line 334 of file GdalRaster.cpp.
References Log::error(), f_ds, Raster::f_file, Raster::f_hdr, f_size, f_type, Log::instance(), and Header::nband.
Referenced by saveRow().
int GdalRaster::f_changed [private] |
Definition at line 187 of file GdalRaster.hh.
Referenced by initBuffer(), iput(), loadRow(), and saveRow().
int GdalRaster::f_currentRow [private] |
Definition at line 186 of file GdalRaster.hh.
Referenced by initBuffer(), loadRow(), and saveRow().
Scalar* GdalRaster::f_data [private] |
Definition at line 181 of file GdalRaster.hh.
Referenced by iget(), initBuffer(), iput(), loadRow(), saveRow(), and ~GdalRaster().
GDALDataset* GdalRaster::f_ds [private] |
Definition at line 179 of file GdalRaster.hh.
Referenced by create(), deleteRaster(), finish(), open(), read(), write(), and ~GdalRaster().
int GdalRaster::f_format [private] |
Definition at line 184 of file GdalRaster.hh.
int GdalRaster::f_size [private] |
Definition at line 182 of file GdalRaster.hh.
Referenced by iget(), initBuffer(), loadRow(), read(), and write().
GDALDataset* GdalRaster::f_warped_ds [private] |
Definition at line 195 of file GdalRaster.hh.
Referenced by getExtentInStandardCs(), and open().