21 #include "ogr_spatialref.h" 22 #include "ImgRasterGdal.h" 25 : m_gds(NULL), m_ncol(0), m_nrow(0), m_nband(0), m_dataType(GDT_Unknown)
65 OGRSpatialReference theRef;
66 theRef.SetFromUserInput(projection.c_str());
68 theRef.exportToWkt(&wktString);
69 m_projection=wktString;
71 return(
m_gds->SetProjection(wktString));
81 m_projection=projection;
83 return(
m_gds->SetProjection(projection.c_str()));
109 return((
m_gds->GetRasterBand(band+1)));
123 return(theRasterBand->GetColorTable());
133 std::string driverDescription;
135 driverDescription=
m_gds->GetDriver()->GetDescription();
136 return(driverDescription);
202 std::string gtString;
205 std::ostringstream s;
206 s <<
"[" << gt[0] <<
"," << gt[1] <<
"," << gt[2] <<
"," << gt[3] <<
"," << gt[4] <<
"," << gt[5] <<
"]";
217 if(
m_gds->GetMetadata()!=NULL)
218 return(
m_gds->GetMetadata());
230 if(
m_gds->GetMetadata()!=NULL)
231 return(
m_gds->GetMetadata());
243 char** cmetadata=
m_gds->GetMetadata();
244 while(*cmetadata!=NULL){
245 metadata.push_back(*(cmetadata));
257 if(
m_gds->GetDriver()->GetDescription()!=NULL)
258 return m_gds->GetDriver()->GetDescription();
270 if(
m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME )!=NULL)
271 return m_gds->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME );
283 if(
m_gds->GetDriver()->GetMetadataItem(
"TIFFTAG_IMAGEDESCRIPTION")!=NULL)
284 return m_gds->GetDriver()->GetMetadataItem(
"TIFFTAG_IMAGEDESCRIPTION");
296 if(
m_gds->GetMetadataItem(
"INTERLEAVE",
"IMAGE_STRUCTURE"))
297 return m_gds->GetMetadataItem(
"INTERLEAVE",
"IMAGE_STRUCTURE");
311 if(
m_gds->GetMetadataItem(
"COMPRESSION",
"IMAGE_STRUCTURE"))
312 return m_gds->GetMetadataItem(
"COMPRESSION",
"IMAGE_STRUCTURE");
392 double denom=(gt[1]-gt[2]*gt[4]/gt[5]);
395 i=(x-gt[0]-gt[2]/gt[5]*(y-gt[3]))/denom;
396 j=(y-gt[3]-gt[4]*(x-gt[0]-gt[2]/gt[5]*(y-gt[3]))/denom)/gt[5];
421 x=gt[0]+(0.5+i)*gt[1]+(0.5+j)*gt[2];
422 y=gt[3]+(0.5+i)*gt[4]+(0.5+j)*gt[5];
445 double theULX, theULY, theLRX, theLRY;
447 return((x > theULX)&&
469 double theULX, theULY, theLRX, theLRY;
471 return((ulx < theLRX)&&(lrx > theULX)&&(lry < theULY)&&(uly > theLRY));
ImgRasterGdal(void)
default constructor
bool covers(double x, double y) const
Check if a geolocation is covered by this dataset. Only the bounding box is checked, irrespective of no data values.
virtual ~ImgRasterGdal(void)
destructor
GDALDataType m_dataType
GDAL data type for this dataset.
std::string getDescription() const
Get the image description from the driver of this dataset.
int m_nband
number of bands in this dataset
bool geo2image(double x, double y, double &i, double &j) const
Convert georeferenced coordinates (x and y) to image coordinates (column and row) ...
std::string getMetadataItem() const
Get metadata item of this dataset.
CPLErr setProjectionProj4(const std::string &projection)
Set the projection for this dataset from user input (supports epsg:<number> format) ...
int nrOfCol(void) const
Get the number of columns of this dataset.
bool getBoundingBox(double &ulx, double &uly, double &lrx, double &lry) const
Get the bounding box of this dataset in georeferenced coordinates.
std::vector< double > m_noDataValues
no data values for this dataset
double m_gt[6]
geotransform information of this dataset
GDALDataset * m_gds
instance of the GDAL dataset of this dataset
std::string getDriverDescription() const
Get the GDAL driver description of this dataset.
int nrOfRow(void) const
Get the number of rows of this dataset.
bool getCenterPos(double &x, double &y) const
Get the center position of this dataset in georeferenced coordinates.
bool image2geo(double i, double j, double &x, double &y) const
Convert image coordinates (column and row) to georeferenced coordinates (x and y) ...
GDALColorTable * getColorTable(int band=0) const
Get the GDAL color table for this dataset as an instance of the GDALColorTable class.
std::string getImageDescription() const
Get the image description from the metadata of this dataset.
CPLErr setGeoTransform(double *gt)
Set the geotransform data for this dataset.
bool isGeoRef() const
Is this dataset georeferenced (pixel size in y must be negative) ?
int pushNoDataValue(double noDataValue)
Push a no data value for this dataset.
char ** getMetadata()
Get the metadata of this dataset.
void copyGeoTransform(const ImgRasterGdal &imgSrc)
Copy geotransform information from another georeferenced image.
std::string getCompression() const
Get the compression from the metadata of this dataset.
virtual void close(void)
Close the image.
std::string getProjectionRef(void) const
Get the projection reference.
std::string getProjection(void) const
Get the projection string (deprecated, use getProjectionRef instead)
GDALDataType getDataType(int band=0) const
Get the GDAL datatype for this dataset.
CPLErr setProjection(const std::string &projection)
Set the projection for this dataset in well known text (wkt) format.
GDALRasterBand * getRasterBand(int band=0) const
Get the GDAL rasterband for this dataset.
std::string getGeoTransform() const
Get the geotransform data for this dataset as a string.
int getNoDataValues(std::vector< double > &noDataValues) const
Get the no data values of this dataset as a standard template library (stl) vector.
std::string getInterleave() const
Get the band coding (interleave)