1
/***************************************************************************
2
qgsrasterlayer.h - description
4
begin : Fri Jun 28 2002
5
copyright : (C) 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
6
email : tim@linfiniti.com
7
***************************************************************************/
9
* Peter J. Ersts - contirbuted to the refactoring and maintenance of this class
10
* B. Morley - added functions to convert this class to a data provider interface
11
* Frank Warmerdam - contributed bug fixes and migrated class to use all GDAL_C_API calls
13
/***************************************************************************
15
* This program is free software; you can redistribute it and/or modify *
16
* it under the terms of the GNU General Public License as published by *
17
* the Free Software Foundation; either version 2 of the License, or *
18
* (at your option) any later version. *
20
***************************************************************************/
22
#ifndef QGSRASTERLAYER_H
23
#define QGSRASTERLAYER_H
37
#include "qgsmaplayer.h"
38
#include "qgsrasterviewport.h"
39
#include "qgscontrastenhancement.h"
40
#include "qgsrastertransparency.h"
41
#include "qgsrastershader.h"
42
#include "qgscolorrampshader.h"
43
#include "qgsrastershaderfunction.h"
44
#include "qgsrasterdataprovider.h"
46
#define CPL_SUPRESS_CPLUSPLUS
49
* A call back function for showing progress of gdal operations.
51
int CPL_STDCALL progressCallback( double dfComplete,
52
const char *pszMessage,
53
void * pProgressArg );
56
// Forward declarations
60
class QgsRasterBandStats;
61
class QgsRasterPyramid;
62
class QgsRasterLayerProperties;
69
* This class provides qgis with the ability to render raster datasets
72
* The qgsrasterlayer class makes use of gdal for data io, and thus supports
73
* any gdal supported format. The constructor attempts to infer what type of
74
* file (LayerType) is being opened - not in terms of the file format (tif, ascii grid etc.)
75
* but rather in terms of whether the image is a GRAYSCALE, PaletteD or Multiband,
77
* Within the three allowable raster layer types, there are 8 permutations of
78
* how a layer can actually be rendered. These are defined in the DrawingStyle enum
81
* SingleBandGray -> a GRAYSCALE layer drawn as a range of gray colors (0-255)
82
* SingleBandPseudoColor -> a GRAYSCALE layer drawn using a pseudocolor algorithm
83
* PalettedSingleBandGray -> a PaletteD layer drawn in gray scale (using only one of the color components)
84
* PalettedSingleBandPseudoColor -> a PaletteD layer having only one of its color components rendered as psuedo color
85
* PalettedMultiBandColor -> a PaletteD image where the bands contains 24bit color info and 8 bits is pulled out per color
86
* MultiBandSingleGandGray -> a layer containing 2 or more bands, but using only one band to produce a grayscale image
87
* MultiBandSingleBandPseudoColor -> a layer containing 2 or more bands, but using only one band to produce a pseudocolor image
88
* MultiBandColor -> a layer containing 2 or more bands, mapped to the three RGBcolors. In the case of a multiband with only two bands, one band will have to be mapped to more than one color
90
* Each of the above mentioned drawing styles is implemented in its own draw* function.
91
* Some of the drawing styles listed above require statistics about the layer such
92
* as the min / max / mean / stddev etc. statistics for a band can be gathered using the
93
* bandStatistics function. Note that statistics gathering is a slow process and
94
* every effort should be made to call this function as few times as possible. For this
95
* reason, qgsraster has a vector class member to store stats for each band. The
96
* constructor initialises this vector on startup, but only populates the band name and
99
* Note that where bands are of gdal 'undefined' type, their values may exceed the
100
* renderable range of 0-255. Because of this a linear scaling histogram enhanceContrast is
101
* applied to undefined layers to normalise the data into the 0-255 range.
103
* A qgsrasterlayer band can be referred to either by name or by number (base=1). It
104
* should be noted that band names as stored in datafiles may not be unique, and
105
* so the rasterlayer class appends the band number in brackets behind each band name.
107
* Sample usage of the QgsRasterLayer class:
110
* QString myFileNameQString = "/path/to/file";
111
* QFileInfo myFileInfo(myFileNameQString);
112
* QString myBaseNameQString = myFileInfo.baseName();
113
* QgsRasterLayer *myRasterLayer = new QgsRasterLayer(myFileNameQString, myBaseNameQString);
117
* In order to automate redrawing of a raster layer, you should like it to a map canvas like this :
120
* QObject::connect( myRasterLayer, SIGNAL(repaintRequested()), mapCanvas, SLOT(refresh()) );
123
* A raster layer can also export its legend as a pixmap:
126
* QPixmap myQPixmap = myRasterLayer->legendPixmap();
129
* Once a layer has been created you can find out what type of layer it is (GrayOrUndefined, Palette or Multiband):
132
* if (rasterLayer->rasterType()==QgsRasterLayer::Multiband)
136
* else if (rasterLayer->rasterType()==QgsRasterLayer::Palette)
140
* else // QgsRasterLayer::GrayOrUndefined
146
* You can combine layer type detection with the setDrawingStyle method to override the default drawing style assigned
147
* when a layer is loaded:
150
* if (rasterLayer->rasterType()==QgsRasterLayer::Multiband)
152
* myRasterLayer->setDrawingStyle(QgsRasterLayer::MultiBandSingleBandPseudoColor);
154
* else if (rasterLayer->rasterType()==QgsRasterLayer::Palette)
156
* myRasterLayer->setDrawingStyle(QgsRasterLayer::PalettedSingleBandPseudoColor);
158
* else // QgsRasterLayer::GrayOrUndefined
160
* myRasterLayer->setDrawingStyle(QgsRasterLayer::SingleBandPseudoColor);
164
* Raster layers can also have an arbitrary level of transparency defined, and have their
165
* color palettes inverted using the setTransparency and setInvertHistogram methods.
167
* Pseudocolor images can have their output adjusted to a given number of standard
168
* deviations using the setStandardDeviations method.
170
* The final area of functionality you may be interested in is band mapping. Band mapping
171
* allows you to choose arbitrary band -> color mappings and is applicable only to Palette
172
* and Multiband rasters, There are four mappings that can be made: red, green, blue and gray.
173
* Mappings are non-exclusive. That is a given band can be assigned to no, some or all
174
* color mappings. The constructor sets sensible defaults for band mappings but these can be
175
* overridden at run time using the setRedBandName, setGreenBandName, setBlueBandName and setGrayBandName
179
class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
183
/** \brief This is the constructor for the RasterLayer class.
185
* The main tasks carried out by the constructor are:
187
* -Load the rasters default style (.qml) file if it exists
189
* -Populate the RasterStatsVector with initial values for each band.
191
* -Calculate the layer extents
193
* -Determine whether the layer is gray, paletted or multiband.
195
* -Assign sensible defaults for the red, green, blue and gray bands.
199
QgsRasterLayer( const QString & path = QString::null,
200
const QString & baseName = QString::null,
201
bool loadDefaultStyleFlag = true );
203
/** \brief [ data provider interface ] Constructor in provider mode */
204
QgsRasterLayer( int dummy,
205
const QString & baseName = QString(),
206
const QString & path = QString(),
207
const QString & providerLib = QString(),
208
const QStringList & layers = QStringList(),
209
const QStringList & styles = QStringList(),
210
const QString & format = QString(),
211
const QString & crs = QString() );
214
/** \brief The destructor */
219
// Enums, structs and typedefs
221
/** \brief This enumerator describes the types of shading that can be used */
222
enum ColorShadingAlgorithm
231
/** \brief This enumerator describes the different kinds of drawing we can do */
234
UndefinedDrawingStyle,
235
SingleBandGray, // a single band image drawn as a range of gray colors
236
SingleBandPseudoColor, // a single band image drawn using a pseudocolor algorithm
237
PalettedColor, //a "Palette" image drawn using color table
238
PalettedSingleBandGray, // a "Palette" layer drawn in gray scale
239
PalettedSingleBandPseudoColor, // a "Palette" layerdrawn using a pseudocolor algorithm
240
PalettedMultiBandColor, // currently not supported
241
MultiBandSingleGandGray, // a layer containing 2 or more bands, but a single band drawn as a range of gray colors
242
MultiBandSingleBandPseudoColor, //a layer containing 2 or more bands, but a single band drawn using a pseudocolor algorithm
243
MultiBandColor //a layer containing 2 or more bands, mapped to RGB color space.
244
//In the case of a multiband with only two bands, one band will be mapped to more than one color.
247
/** \brief This enumerator describes the type of raster layer */
255
/** \brief A list containing on ContrastEnhancement object per raster band in this raster layer */
256
typedef QList<QgsContrastEnhancement> ContrastEnhancementList;
258
/** \brief A list containing one RasterPyramid struct per raster band in this raster layer.
259
* POTENTIAL pyramid layer. This works by dividing the height
260
* and width of the raster by an incrementing number. As soon as the result
261
* of the division is <=256 we stop allowing RasterPyramid structs
262
* to be added to the list. Each time a RasterPyramid is created
263
* we will check to see if a pyramid matching these dimensions already exists
264
* in the raster layer, and if so mark the exists flag as true */
265
typedef QList<QgsRasterPyramid> RasterPyramidList;
267
/** \brief A list containing one RasterBandStats struct per raster band in this raster layer.
268
* Note that while every RasterBandStats element will have the name and number of its associated
269
* band populated, any additional stats are calculated on a need to know basis.*/
270
typedef QList<QgsRasterBandStats> RasterStatsList;
279
static void buildSupportedRasterFileFilter( QString & fileFilters );
281
/** This helper checks to see whether the file name appears to be a valid
282
* raster file name. If the file name looks like it could be valid,
283
* but some sort of error occurs in processing the file, the error is
284
* returned in retError.
286
static bool isValidRasterFileName( const QString & theFileNameQString, QString &retError );
288
static bool isValidRasterFileName( const QString & theFileNameQString );
290
/** Return time stamp for given file name */
291
static QDateTime lastModified( const QString & name );
293
/** \brief ensures that GDAL drivers are registered, but only once */
294
static void registerGdalDrivers();
300
// Non Static inline methods
303
/** \brief Accessor for blue band name mapping */
304
QString blueBandName() const { return mBlueBandName; }
306
/** \brief Accessor for color shader algorithm */
307
QgsRasterLayer::ColorShadingAlgorithm colorShadingAlgorithm() const { return mColorShadingAlgorithm; }
309
/** \brief Accessor for contrast enhancement algorithm */
310
QgsContrastEnhancement::ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
312
/** \brief Returns contrast enhancement algorithm as a string */
313
QString contrastEnhancementAlgorithmAsString() const;
315
/** \brief Accessor for drawing style */
316
DrawingStyle drawingStyle() { return mDrawingStyle; }
318
/** \brief Accessor for gray band name mapping */
319
QString grayBandName() const { return mGrayBandName; }
321
/** \brief Accessor for green band name mapping */
322
QString greenBandName() const { return mGreenBandName; }
324
/** \brief Accessor for mHasPyramids (READ ONLY) */
325
bool hasPyramids() { return mHasPyramids; }
327
/** \brief Accessor for mUserDefinedGrayMinimumMaximum */
328
bool hasUserDefinedGrayMinimumMaximum() const { return mUserDefinedGrayMinimumMaximum; }
330
/** \brief Accessor for mUserDefinedRGBMinimumMaximum */
331
bool hasUserDefinedRGBMinimumMaximum() const { return mUserDefinedRGBMinimumMaximum; }
333
/** \brief Accessor that returns the height of the (unclipped) raster */
334
int height() { return mHeight; }
336
/** \brief Accessor to find out whether the histogram should be inverted */
337
bool invertHistogram() const { return mInvertColor; }
339
/** \brief Is the NoDataValue Valid */
340
bool isNoDataValueValid() const { return mValidNoDataValue; }
342
/** \brief Accessor for mGrayMinimumMaximumEstimated */
343
bool isGrayMinimumMaximumEstimated() const { return mGrayMinimumMaximumEstimated; }
345
/** \brief Accessor for mRGBMinimumMaximumEstimated */
346
bool isRGBMinimumMaximumEstimated() const { return mRGBMinimumMaximumEstimated; }
348
/** \brief Accessor that returns the NO_DATA entry for this raster */
349
double noDataValue( bool* isValid = 0 ) { if ( isValid ) { *isValid = mValidNoDataValue;} return mNoDataValue; }
351
/** \brief Returns a pointer to the transparency object */
352
QgsRasterTransparency* rasterTransparency() { return &mRasterTransparency; }
354
/** \brief Accessor for raster shader */
355
QgsRasterShader* rasterShader() { return mRasterShader; }
357
/** \brief Accessor for raster layer type (which is a read only property) */
358
LayerType rasterType() { return mRasterType; }
360
/** \brief Accessor for red band name (allows alternate mappings e.g. map blue as red color) */
361
QString redBandName() const { return mRedBandName; }
363
/** [ data provider interface ] Set the data provider */
364
void setDataProvider( const QString & provider,
365
const QStringList & layers,
366
const QStringList & styles,
367
const QString & format,
368
const QString & crs );
370
/** \brief Mutator for drawing style */
371
void setDrawingStyle( const DrawingStyle & theDrawingStyle ) { mDrawingStyle = theDrawingStyle; }
373
/** \brief Mutator for mGrayMinimumMaximumEstimated */
374
void setGrayMinimumMaximumEstimated( bool theBool ) { mGrayMinimumMaximumEstimated = theBool; }
376
/** \brief Mutator to alter the state of the invert histogram flag */
377
void setInvertHistogram( bool theFlag ) { mInvertColor = theFlag; }
379
/** \brief Mutator for mRGBMinimumMaximumEstimated */
380
void setRGBMinimumMaximumEstimated( bool theBool ) { mRGBMinimumMaximumEstimated = theBool; }
382
/** \brief Mutator to alter the number of standard deviations that should be plotted */
383
void setStandardDeviations( double theStandardDeviations ) { mStandardDeviations = theStandardDeviations; }
385
/** \brief Mutator for mUserDefinedGrayMinimumMaximum */
386
void setUserDefinedGrayMinimumMaximum( bool theBool ) { mUserDefinedGrayMinimumMaximum = theBool; }
388
/** \brief Mutator for mUserDefinedRGBMinimumMaximum */
389
void setUserDefinedRGBMinimumMaximum( bool theBool ) { mUserDefinedRGBMinimumMaximum = theBool; }
391
/** \brief Accessor to find out how many standard deviations are being plotted */
392
double standardDeviations() const { return mStandardDeviations; }
394
/** \brief Accessor for transparent band name mapping */
395
QString transparentBandName() const { return mTransparencyBandName; }
397
/** \brief [ data provider interface ] Does this layer use a provider for setting/retrieving data? */
400
/** \brief Accessor that returns the width of the (unclipped) raster */
401
int width() { return mWidth; }
408
// Non Static methods
410
/** \brief Get the number of bands in this layer */
411
unsigned int bandCount();
413
/** \brief Get the name of a band given its number */
414
const QString bandName( int theBandNoInt );
416
/** \brief Get the number of a band given its name. The name is the rewritten name set
417
* up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal!
418
* If no matching band is found zero will be returned! */
419
int bandNumber( const QString & theBandName );
421
/** \brief Get RasterBandStats for a band given its number (read only) */
422
const QgsRasterBandStats bandStatistics( int );
424
/** \brief Get RasterBandStats for a band given its name (read only) */
425
const QgsRasterBandStats bandStatistics( const QString & );
427
/** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
428
* POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
429
* ACTUALLY exists you need to look at the existsFlag member in each struct stored in the
432
RasterPyramidList buildPyramidList();
434
/** \brief Accessor for color shader algorithm */
435
QString colorShadingAlgorithmAsString() const;
437
/** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
438
void computeMinimumMaximumEstimates( int theBand, double* theMinMax );
440
/** \brief Wrapper for GDALComputeRasterMinMax with the estimate option */
441
void computeMinimumMaximumEstimates( QString theBand, double* theMinMax );
443
/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent */
444
void computeMinimumMaximumFromLastExtent( int theBand, double* theMinMax );
446
/** \brief Compute the actual minimum maximum pixel values based on the current (last) display extent */
447
void computeMinimumMaximumFromLastExtent( QString theBand, double* theMinMax );
449
/** \brief Get a pointer to the contrast enhancement for the selected band */
450
QgsContrastEnhancement* contrastEnhancement( unsigned int theBand );
452
/**Copies the symbology settings from another layer. Returns true in case of success*/
453
bool copySymbologySettings( const QgsMapLayer& theOther );
455
/** \brief Get a pointer to the color table */
456
QList<QgsColorRampShader::ColorRampItem>* colorTable( int theBandNoInt );
458
/** Returns the data provider */
459
QgsRasterDataProvider* dataProvider();
461
/** Returns the data provider in a const-correct manner */
462
const QgsRasterDataProvider* dataProvider() const;
464
/** \brief This is called when the view on the raster layer needs to be redrawn */
465
bool draw( QgsRenderContext& rendererContext );
467
/** \brief This is an overloaded version of the draw() function that is called by both draw() and thumbnailAsPixmap */
468
void draw( QPainter * theQPainter,
469
QgsRasterViewPort * myRasterViewPort,
470
const QgsMapToPixel* theQgsMapToPixel = 0 );
472
/** \brief Returns a string representation of drawing style
474
* Implemented mainly for serialisation / deserialisation of settings to xml.
475
* NOTE: May be deprecated in the future!. DrawingStyle drawingStyle() instead.
477
QString drawingStyleAsString() const;
479
/** \brief Checks if symbology is the same as another layers */
480
bool hasCompatibleSymbology( const QgsMapLayer& theOther ) const;
482
/** \brief Check whether a given band number has stats associated with it */
483
bool hasStatistics( int theBandNoInt );
485
/** \brief Identify raster value(s) found on the point position */
486
bool identify( const QgsPoint & point, QMap<QString, QString>& results );
488
/** \brief Identify arbitrary details from the WMS server found on the point position */
489
QString identifyAsText( const QgsPoint & point );
491
/** \brief Currently returns always false */
492
bool isEditable() const;
494
/** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */
497
/** \brief [ data provider interface ] If an operation returns 0 (e.g. draw()), this function returns the text of the error associated with the failure */
498
QString lastErrorTitle();
500
/** \brief Get a legend image for this layer */
501
QPixmap legendAsPixmap();
503
/** \brief Overloaded version of above function that can print layer name onto legend */
504
QPixmap legendAsPixmap( bool );
506
/** \brief Use this method when you want an annotated legend suitable for print output etc */
507
QPixmap legendAsPixmap( int theLabelCount );
509
/** \brief Accessor for maximum value user for contrast enhancement */
510
double maximumValue( unsigned int theBand );
512
/** \brief Accessor for maximum value user for contrast enhancement */
513
double maximumValue( QString theBand );
515
/** \brief Obtain GDAL Metadata for this layer */
518
/** \brief Accessor for minimum value user for contrast enhancement */
519
double minimumValue( unsigned int theBand );
521
/** \brief Accessor for minimum value user for contrast enhancement */
522
double minimumValue( QString theBand );
524
/** \brief Get an 100x100 pixmap of the color palette. If the layer has no palette a white pixmap will be returned */
525
QPixmap paletteAsPixmap( int theBand = 1 );
527
/** \brief [ data provider interface ] Which provider is being used for this Raster Layer? */
528
QString providerKey();
530
/** \brief Returns the number of raster units per each raster pixel. In a world file, this is normally the first row (without the sign) */
531
double rasterUnitsPerPixel();
533
/** \brief Read color table from GDAL raster band */
534
bool readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList );
536
/** \brief Simple reset function that set the noDataValue back to the value stored in the first raster band */
537
void resetNoDataValue();
539
/** \brief Mutator for blue band name mapping */
540
void setBlueBandName( const QString & theBandName );
542
/** \brief Mutator for color shader algorithm */
543
void setColorShadingAlgorithm( QgsRasterLayer::ColorShadingAlgorithm theShaderAlgorithm );
545
/** \brief Mutator for color shader algorithm */
546
void setColorShadingAlgorithm( QString theShaderAlgorithm );
548
/** \brief Mutator for contrast enhancement algorithm */
549
void setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm,
550
bool theGenerateLookupTableFlag = true );
552
/** \brief Mutator for contrast enhancement algorithm */
553
void setContrastEnhancementAlgorithm( QString theAlgorithm, bool theGenerateLookupTableFlag = true );
555
/** \brief Mutator for contrast enhancement function */
556
void setContrastEnhancementFunction( QgsContrastEnhancementFunction* theFunction );
558
/** \brief Overloaded version of the above function for convenience when restoring from xml */
559
void setDrawingStyle( const QString & theDrawingStyleQString );
561
/** \brief Mutator for gray band name mapping */
562
void setGrayBandName( const QString & theBandName );
564
/** \brief Mutator for green band name mapping */
565
void setGreenBandName( const QString & theBandName );
567
/** \brief Mutator for setting the maximum value for contrast enhancement */
568
void setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
570
/** \brief Mutator for setting the maximum value for contrast enhancement */
571
void setMaximumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
573
/** \brief Mutator for setting the minimum value for contrast enhancement */
574
void setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag = true );
576
/** \brief Mutator for setting the minimum value for contrast enhancement */
577
void setMinimumValue( QString theBand, double theValue, bool theGenerateLookupTableFlag = true );
579
/** \brief Mutator that allows the NO_DATA entry for this raster to be overridden */
580
void setNoDataValue( double theNoData );
582
/** \brief Set the raster shader function to a user defined function */
583
void setRasterShaderFunction( QgsRasterShaderFunction* theFunction );
585
/** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color) */
586
void setRedBandName( const QString & theBandName );
588
/** \brief Mutator for transparent band name mapping */
589
void setTransparentBandName( const QString & theBandName );
591
/** \brief [ data provider interface ] A wrapper function to emit a progress update signal */
592
void showProgress( int theValue );
594
/** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
595
QStringList subLayers() const;
597
/** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
598
void thumbnailAsPixmap( QPixmap * theQPixmap );
600
/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
601
void triggerRepaint();
611
* Reorders the *previously selected* sublayers of this layer from bottom to top
613
* (Useful for providers that manage their own layers, such as WMS)
616
virtual void setLayerOrder( const QStringList & layers );
619
* Set the visibility of the given sublayer name
621
virtual void setSubLayerVisibility( const QString & name, bool vis );
628
/** \brief Create GDAL pyramid overviews */
629
QString buildPyramids( const RasterPyramidList &,
630
const QString & theResamplingMethod = "NEAREST",
631
bool theTryInternalFlag = false );
633
/** \brief Populate the histogram vector for a given band */
634
void populateHistogram( int theBandNoInt,
635
int theBinCountInt = 256,
636
bool theIgnoreOutOfRangeFlag = true,
637
bool theThoroughBandScanFlag = false );
639
void showStatusMessage( const QString & theMessage );
641
/** \brief Propagate progress updates from GDAL up to the parent app */
642
void updateProgress( int, int );
649
/** \brief Signal for notifying listeners of long running processes */
650
void progressUpdate( int theValue );
657
/** \brief Read the symbology for the current layer from the Dom node supplied */
658
bool readSymbology( const QDomNode& node, QString& errorMessage );
660
/** \brief Reads layer specific state from project file Dom node */
661
bool readXml( QDomNode & layer_node );
663
/** \brief Write the symbology for the layer into the docment provided */
664
bool writeSymbology( QDomNode&, QDomDocument& doc, QString& errorMessage ) const;
666
/** \brief Write layer specific state to project file Dom node */
667
bool writeXml( QDomNode & layer_node, QDomDocument & doc );
678
/** \brief Drawing routine for multiband image */
679
void drawMultiBandColor( QPainter * theQPainter,
680
QgsRasterViewPort * theRasterViewPort,
681
const QgsMapToPixel* theQgsMapToPixel );
683
/** \brief Drawing routine for multiband image, rendered as a single band image in grayscale */
684
void drawMultiBandSingleBandGray( QPainter * theQPainter,
685
QgsRasterViewPort * theRasterViewPort,
686
const QgsMapToPixel* theQgsMapToPixel,
689
/** \brief Drawing routine for multiband image, rendered as a single band image in pseudocolor */
690
void drawMultiBandSingleBandPseudoColor( QPainter * theQPainter,
691
QgsRasterViewPort * theRasterViewPort,
692
const QgsMapToPixel* theQgsMapToPixel,
695
/** \brief Drawing routine for single band with a color map */
696
void drawPalettedSingleBandColor( QPainter * theQPainter,
697
QgsRasterViewPort * theRasterViewPort,
698
const QgsMapToPixel* theQgsMapToPixel,
701
/** \brief Drawing routine for paletted image, rendered as a single band image in grayscale */
702
void drawPalettedSingleBandGray( QPainter * theQPainter,
703
QgsRasterViewPort * theRasterViewPort,
704
const QgsMapToPixel* theQgsMapToPixel,
707
/** \brief Drawing routine for paletted image, rendered as a single band image in pseudocolor */
708
void drawPalettedSingleBandPseudoColor( QPainter * theQPainter,
709
QgsRasterViewPort * theRasterViewPort,
710
const QgsMapToPixel* theQgsMapToPixel,
713
/** \brief Drawing routine for paletted multiband image */
714
void drawPalettedMultiBandColor( QPainter * theQPainter,
715
QgsRasterViewPort * theRasterViewPort,
716
const QgsMapToPixel* theQgsMapToPixel,
719
/** \brief Drawing routine for single band grayscale image */
720
void drawSingleBandGray( QPainter * theQPainter,
721
QgsRasterViewPort * theRasterViewPort,
722
const QgsMapToPixel* theQgsMapToPixel,
725
/** \brief Drawing routine for single band grayscale image, rendered in pseudocolor */
726
void drawSingleBandPseudoColor( QPainter * theQPainter,
727
QgsRasterViewPort * theRasterViewPort,
728
const QgsMapToPixel* theQgsMapToPixel,
731
/** \brief Close data set and release related data */
734
/** \brief helper function to create zero padded band names */
735
QString generateBandName( int );
737
/** \brief Find out whether a given band exists. */
738
bool hasBand( const QString & theBandName );
740
/** \brief Places the rendered image onto the canvas */
741
void paintImageToCanvas( QPainter* theQPainter, QgsRasterViewPort * theRasterViewPort,
742
const QgsMapToPixel* theQgsMapToPixel, QImage* theImage );
744
/** \brief Query GDAL to find out the Wkt projection string for this layer.*/
745
QString projectionWkt();
747
/** \brief Allocate memory and load data to that allocated memory */
748
void* readData( GDALRasterBandH gdalBand, QgsRasterViewPort *viewPort );
750
/** \brief Load the given raster file */
751
bool readFile( const QString & fileName );
753
/** \brief Read a raster value given position from memory block created by readData() */
754
inline double readValue( void *data, GDALDataType type, int index );
756
/** \brief Update the layer if it is outdated */
759
/** \brief Verify and transform band name for internal consistency. Return 'Not Set' on any type of failure */
760
QString validateBandName( const QString & theBandName );
766
// Private member vars
768
/** \brief Constant defining flag for XML and a constant that signals property not used */
769
const QString QSTRING_NOT_SET;
770
const QString TRSTRING_NOT_SET;
772
/** \brief The number of bands in the dataset */
775
/** \brief The band to be associated with the color blue - usually 3 */
776
QString mBlueBandName;
778
/** \brief The raster shading algorithm being used */
779
ColorShadingAlgorithm mColorShadingAlgorithm;
781
/** \brief The contrast enhancement algorithm being used */
782
QgsContrastEnhancement::ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
784
/** \brief List containing the contrast enhancements for each band */
785
ContrastEnhancementList mContrastEnhancementList;
787
/** \brief Number of stddev to plot (0) to ignore. Not applicable to all layer types */
788
double mStandardDeviations;
790
/** [ data provider interface ] Pointer to data provider derived from the abstract base class QgsDataProvider */
791
QgsRasterDataProvider* mDataProvider;
793
DrawingStyle mDrawingStyle;
795
/** [ data provider interface ] Flag indicating whether the layer is in editing mode or not*/
798
/** [ data provider interface ]The error message associated with the last error */
801
/** [ data provider interface ] The error caption associated with the last error */
802
QString mErrorCaption;
804
/** \brief Pointer to the gdaldataset */
805
GDALDatasetH mGdalBaseDataset;
807
/** \brief Pointer to the gdaldataset (possibly warped vrt) */
808
GDALDatasetH mGdalDataset;
810
/** \brief Values for mapping pixel to world coordinates. Contents of this array are the same as the GDAL adfGeoTransform */
811
double mGeoTransform[6];
813
/** \brief The band to be associated with the grayscale only output - usually 1 */
814
QString mGrayBandName;
816
/** \brief Flag to indicate of the min max values are actual or estimates/user defined */
817
bool mGrayMinimumMaximumEstimated;
819
/** \brief The band to be associated with the color green - usually 2 */
820
QString mGreenBandName;
822
/** \brief Whether this raster has overviews / pyramids or not */
825
/** \brief Raster width */
828
/** \brief Raster height */
831
/** \brief Flag indicating whether the color of pixels should be inverted or not */
834
/** [ data provider interface ] Timestamp, the last modified time of the data source when the layer was created */
835
QDateTime mLastModified;
837
QgsRasterViewPort mLastViewPort;
839
/** [ data provider interface ] pointer for loading the provider library */
842
/** [ data provider interface ] Flag indicating whether the layer has been modified since the last commit*/
845
/** \brief Cell value representing no data. e.g. -9999 */
848
/** [ data provider interface ] Data provider key */
849
QString mProviderKey;
851
/** \brief This list holds a series of RasterPyramid structs which store information for each potential pyramid level */
852
RasterPyramidList mPyramidList;
854
/** \brief The raster shader for the layer */
855
QgsRasterShader* mRasterShader;
857
/** \brief A collection of stats - one for each band in the layer */
858
RasterStatsList mRasterStatsList;
860
/** \brief The transparency container */
861
QgsRasterTransparency mRasterTransparency;
863
LayerType mRasterType;
865
/** \brief The band to be associated with the color red - usually 1 */
866
QString mRedBandName;
868
/** \brief Flag to indicate of the min max values are actual or estimates/user defined */
869
bool mRGBMinimumMaximumEstimated;
871
/** \brief The band to be associated with transparency */
872
QString mTransparencyBandName;
874
/** \brief Flag to indicate if the user entered custom min max values */
875
bool mUserDefinedGrayMinimumMaximum;
877
/** \brief Flag to indicate if the user entered custom min max values */
878
bool mUserDefinedRGBMinimumMaximum;
880
/** \brief Flag indicating if the nodatavalue is valid*/
881
bool mValidNoDataValue;