ToolMap
Loading...
Searching...
No Matches
tmGISDataRaster Class Reference
Inheritance diagram for tmGISDataRaster:
tmGISData tmGISDataRasterEGRID tmGISDataRasterJPEG tmGISDataRasterTIFF tmGISDataRasterWeb

Public Member Functions

virtual bool Open (const wxString &filename, bool bReadWrite=TRUE)
 Generic open code.
 
void UseExisting (const wxString &filename, GDALDatasetH hdst)
 
virtual tmRealRect GetMinimalBoundingRectangle ()
 
virtual TM_GIS_SPATIAL_TYPES GetSpatialType ()
 
virtual bool SetSpatialFilter (tmRealRect filter, int type)
 Define the area of interest.
 
virtual bool IsImageInsideVisibleArea ()
 Should we load image data.
 
virtual CPLErr GetImageData (unsigned char **imgbuf, unsigned int *imglen, unsigned char **maskbuf, unsigned int *masklen, wxSize imgSize)
 Extract image data.
 
bool GetImageTranslucency (wxSize imgSize, int translucencypercent, unsigned char **alphachn)
 Return the buffer corresponding to an alpha channel with specified translucency.
 
virtual tmRealRect GetImageClipedCoordinates ()
 
virtual int GetBandCount ()
 Getting number of band.
 
virtual int GetPyramidsInfo (wxArrayString *pyramids=nullptr)
 Get info about pyramids.
 
virtual wxString GetMetaDataAsHtml ()
 Get Metadata information well formated.
 
wxString GetBandMetaData ()
 Getting number of band formatted as html.
 
wxString GetUnitMetaData ()
 Get Informations about Unit formatted for html.
 
wxString GetPyramidsMetadata ()
 Getting pyramids info as html string.
 
wxString GetImagePxSizeMetadata ()
 Get Pixels width and height.
 
virtual bool CreateSpatialIndex (GDALProgressFunc progress, void *pfProgressData)
 
virtual int IsRaster ()
 
- Public Member Functions inherited from tmGISData
 tmGISData ()
 Constructor.
 
 ~tmGISData ()
 Destructor.
 
int GetDataType ()
 
void SetCoordConvert (tmCoordConvert *coordconvert)
 
tmCoordConvertGetCoordConvert ()
 
virtual bool Close ()
 
wxString GetShortFileName ()
 
wxString GetFullFileName ()
 
virtual wxString GetDataSizeAsHtml (int iPrecision=2)
 
virtual wxArrayLong * SearchData (const tmRealRect &rect, int type)
 
virtual wxArrayLong * GetAllData ()
 
virtual bool GetSnapCoord (const wxRealPoint &clickpt, double buffersize, wxArrayRealPoints &snapppts, int snaptype)
 
virtual bool IsPointSnapped (const wxRealPoint &point, int snaptype, long excludeoid=wxNOT_FOUND)
 

Static Public Member Functions

static void InitGISDriversRaster ()
 
static wxString GetAllRasterGISFormatsWildcards ()
 
static tmGISDataRasterCreateGISRasterBasedOnType (const int &gis_format_index)
 
static tmGISDataRasterCreateGISRasterBasedOnExt (const wxString &extension)
 
- Static Public Member Functions inherited from tmGISData
static void InitGISDrivers (bool bRaster=TRUE, bool bVector=TRUE)
 Init the GDAL / OGR driver.
 
static wxString GetAllSupportedGISFormatsWildcards ()
 Return all supported formats.
 
static wxArrayString GetAllSupportedGISFormatsExtensions ()
 Returning all extensions in an array string.
 
static tmGISDataCreateGISBasedOnType (const int &gis_format_index)
 Create an object of the specified format.
 
static tmGISDataCreateGISBasedOnExt (const wxString &extension)
 
static tmGISDataLoadLayer (tmLayerProperties *layerprop)
 Call this function for loading a layer.
 
static void EnableLogging (bool enable=true)
 
static bool IsLoggingEnabled ()
 

Protected Member Functions

wxSize GetImagePxDim ()
 Get Image dimensions in Pixels.
 
bool GetImagePxSize (double &pxsizeX, double &pxsizeY, const tmRealRect &imgrealcoord=tmRealRect(0, 0, 0, 0))
 Return width and height of pixels in real units.
 
wxRect ConvertClipedImage (const tmRealRect &origin, const tmRealRect &clipped)
 Convert clipped Real size to image pixels size.
 
void * ReadImageData (GDALRasterBand *gdalBand, const wxRect &imgfilter, const wxSize &imgSize, int &buffsize)
 Reading image data based on GDAL type.
 
double ReadGDALValueToDouble (void *data, GDALDataType type, int index)
 Getting double value from data returned by GDAL.
 
bool GetStatMinMaxNoDataValue (double &dmin, double &dmax, double &dnodata)
 Returning min - max - nodata stat.
 
- Protected Member Functions inherited from tmGISData
wxString GetMinimalBoundingRectangleAsHtml (int iprecision=2)
 Get Minimal bounding rectangle as html.
 

Protected Attributes

GDALDataset * m_DataSet
 
GDALRasterBand * m_RasterBand
 
wxString m_FileType
 
wxRect m_PxImgFilter
 
tmRealRect m_RasterExtent
 
tmRealRect m_ClippedCoord
 
wxArrayString m_RotationName
 
wxArrayShort m_RotationStatus
 
- Protected Attributes inherited from tmGISData
int m_ClassType
 

Member Function Documentation

◆ ConvertClipedImage()

wxRect tmGISDataRaster::ConvertClipedImage ( const tmRealRect origin,
const tmRealRect clipped 
)
protected

Convert clipped Real size to image pixels size.

Parameters
originNon clipped coordinates (Real)
clippedClipped coordinates (Real)
Returns
Clipped coordinates (Pixels), may be used for loading part of image
Author
Lucien Schreiber (c) CREALP 2008
Date
25 September 2008

◆ CreateSpatialIndex()

bool tmGISDataRaster::CreateSpatialIndex ( GDALProgressFunc  progress,
void *  pfProgressData 
)
virtual

Reimplemented from tmGISData.

◆ GetBandCount()

int tmGISDataRaster::GetBandCount ( )
virtual

Getting number of band.

Returns
The number of band or -1 if an error occur
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

◆ GetBandMetaData()

wxString tmGISDataRaster::GetBandMetaData ( )

Getting number of band formatted as html.

Returns
An html compliant string indicating the number of bands
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

◆ GetImageData()

CPLErr tmGISDataRaster::GetImageData ( unsigned char **  imgbuf,
unsigned int *  imglen,
unsigned char **  maskbuf,
unsigned int *  masklen,
wxSize  imgSize 
)
virtual

Extract image data.

Extract the image data from the GDALDataset and pack it into a single array of RGB triples. Use the ColorTable to determine the RGB values. We extract the data from the GDALDataset rather than create our own driver because the data needs to be translated from 4 byte pixel information into 3 byte RGB information. This could be done as the data is written to the data set or afterwards, as it is done here. Any minor savings from our own driver are outweighed by the high development/maintenance costs.

Warning
You must call tmGISDataRaster::SetSpatialFilter() before this function for initialization to take place.
Note
Comes from THUBAN (http://thuban.intevation.org/) and modified for ToolMap2. Extracted from version 1.2.0
Parameters
imgbuf???
imglen???
maskbuf???
masklen???
imgSize???
Returns
CE_None if data was read succesfully
Author
Thuban Team & modfied by Lucien Schreiber
Date
24 September 2008

◆ GetImagePxDim()

wxSize tmGISDataRaster::GetImagePxDim ( )
protected

Get Image dimensions in Pixels.

Returns
The image dimensions in pixels or -1,-1 if image wasen't open
Author
Lucien Schreiber (c) CREALP 2008
Date
24 September 2008

◆ GetImagePxSize()

bool tmGISDataRaster::GetImagePxSize ( double &  pxsizeX,
double &  pxsizeY,
const tmRealRect imgrealcoord = tmRealRect(0, 0, 0, 0) 
)
protected

Return width and height of pixels in real units.

Divide the width and height of image by the width and height of image in pixels

Parameters
pxsizeXvalue of one pixels width in real units
pxsizeYvalue of one pixels height in real units
imgrealcoordIf specified, image coordinates aren't calculated again. But if empty, function will calculate image coordinate.
Returns
True if values are valid
Author
Lucien Schreiber (c) CREALP 2008
Date
25 September 2008

◆ GetImagePxSizeMetadata()

wxString tmGISDataRaster::GetImagePxSizeMetadata ( )

Get Pixels width and height.

Returns
html compliant string containing width and height of the raster in pixels
Author
Lucien Schreiber (c) CREALP 2008
Date
24 October 2008

◆ GetImageTranslucency()

bool tmGISDataRaster::GetImageTranslucency ( wxSize  imgSize,
int  translucencypercent,
unsigned char **  alphachn 
)

Return the buffer corresponding to an alpha channel with specified translucency.

This function is made for use with wxImage::SetAlpha()

Parameters
imgSizethe size of the raster
translucencypercentpercent of translucency desired
alphachna buffer containing the raster's alpha chanel
Returns
true if success, false otherwise
Author
Lucien Schreiber (c) CREALP 2009
Date
04 September 2009

◆ GetMetaDataAsHtml()

wxString tmGISDataRaster::GetMetaDataAsHtml ( )
virtual

Get Metadata information well formated.

Returns
An html string to be displayed in the properties dialog
Author
Lucien Schreiber (c) CREALP 2008
Date
22 October 2008

Reimplemented from tmGISData.

◆ GetMinimalBoundingRectangle()

tmRealRect tmGISDataRaster::GetMinimalBoundingRectangle ( )
virtual

Reimplemented from tmGISData.

◆ GetPyramidsInfo()

int tmGISDataRaster::GetPyramidsInfo ( wxArrayString *  pyramids = nullptr)
virtual

Get info about pyramids.

Pyramids are small image subsets usefull for displaying raster faster

Parameters
pyramidsString containing all pyramids informations if pyramids isn't nullptr.
Returns
Number of pyramids in the raster
Author
Lucien Schreiber (c) CREALP 2008
Date
24 October 2008

◆ GetPyramidsMetadata()

wxString tmGISDataRaster::GetPyramidsMetadata ( )

Getting pyramids info as html string.

Pyramids are small image subsets usefull for displaying raster faster

Returns
html compliant string containing pyramids info
Author
Lucien Schreiber (c) CREALP 2008
Date
24 October 2008

◆ GetSpatialType()

virtual TM_GIS_SPATIAL_TYPES tmGISDataRaster::GetSpatialType ( )
inlinevirtual

Reimplemented from tmGISData.

◆ GetStatMinMaxNoDataValue()

bool tmGISDataRaster::GetStatMinMaxNoDataValue ( double &  dmin,
double &  dmax,
double &  dnodata 
)
protected

Returning min - max - nodata stat.

This function return the following statistics :

  • Minimum band values (altitudes in case of DTM)
  • Maximum band values
  • Nodata values. If a value wasen't computed, 0 is returned.
    Parameters
    dminwill contain the minimum value
    dmaxwill contain the maximum value
    dnodatawill contain the value used for nodata
    Returns
    true if at least one value was computed succesfully
    Author
    Lucien Schreiber (c) CREALP 2008
    Date
    03 October 2008

◆ GetUnitMetaData()

wxString tmGISDataRaster::GetUnitMetaData ( )

Get Informations about Unit formatted for html.

Returns
An html compliant string containing the unit used for the raster
Author
Lucien Schreiber (c) CREALP 2008
Date
23 October 2008

◆ IsImageInsideVisibleArea()

bool tmGISDataRaster::IsImageInsideVisibleArea ( )
virtual

Should we load image data.

This function works only if tmGISDataRaster::SetSpatialFilter was called before. This function return true if m_PxImgFilter contain valid coordinates

Returns
true if the image is visible (inside drawing area), false otherwise. If false is returned, no need to call the drawing process
Author
Lucien Schreiber (c) CREALP 2008
Date
25 September 2008

◆ IsRaster()

virtual int tmGISDataRaster::IsRaster ( )
inlinevirtual

Reimplemented from tmGISData.

◆ Open()

bool tmGISDataRaster::Open ( const wxString &  filename,
bool  bReadWrite = TRUE 
)
virtual

Generic open code.

Mainly init member values used by all GIS class

Parameters
filenamepath and name of the GIS data to open
bReadWriteShould we open the dataset for r/w operations ?
Returns
Allways TRUE
Author
Lucien Schreiber (c) CREALP 2008
Date
14 July 2008

Reimplemented from tmGISData.

◆ ReadGDALValueToDouble()

double tmGISDataRaster::ReadGDALValueToDouble ( void *  data,
GDALDataType  type,
int  index 
)
protected

Getting double value from data returned by GDAL.

This function allows to deals with image with different data type such as those described in GDALDataType (see gdal doc)

Note
inspired by QGIS code
Parameters
dataPointer to data returned by tmGISDataRaster::ReadImageData
typetype of data as returned by gdalBand->GetRasterDataType()
indexindex of the pixel
Returns
Pixel value at position index
Author
Lucien Schreiber (c) CREALP 2008
Date
03 October 2008

◆ ReadImageData()

void * tmGISDataRaster::ReadImageData ( GDALRasterBand *  gdalBand,
const wxRect &  imgfilter,
const wxSize &  imgSize,
int &  buffsize 
)
protected

Reading image data based on GDAL type.

This function is used actually for DTM but may be extended for all raster.

Note
inspired by QGIS code
Parameters
gdalBandPointer to a valid GDAL band
imgfilterPosition and width of the image in real px. For reading all image pass 0,0, width, height
imgSizeSize of the bitmap we will use for displaying data
buffsize
Returns
pointer to data of type GDALDataType, data must be freed with CPLFree
Author
Lucien Schreiber (c) CREALP 2008
Date
03 October 2008

◆ SetSpatialFilter()

bool tmGISDataRaster::SetSpatialFilter ( tmRealRect  filter,
int  type 
)
virtual

Define the area of interest.

This function define the area we are interessed in. Reading may be done after with GetRasterData function.

Note
Real coordinates passed here are converted into raster coordinates
Parameters
filterFilter real coordinates
typeone of value defined in TOC_GENERIC_NAME such as :
  • TOC_NAME_TIFF
  • TOC_NAME_EGRID
Returns
bool true if all works, false otherwise
Author
Lucien Schreiber (c) CREALP 2008
Date
24 September 2008

Reimplemented in tmGISDataRasterWeb.


The documentation for this class was generated from the following files: