48 #include <QApplication>
50 #include <QDomElement>
55 #include <QFontMetrics>
62 #include <QMessageBox>
73 #define ERR(message) QGS_ERROR_MESSAGE(message,"Raster layer")
81 , QSTRING_NOT_SET(
"Not Set" )
82 , TRSTRING_NOT_SET(
tr(
"Not Set" ) )
91 QString
const & baseName,
92 bool loadDefaultStyleFlag )
94 , QSTRING_NOT_SET(
"Not Set" )
95 , TRSTRING_NOT_SET(
tr(
"Not Set" ) )
105 bool defaultLoadedFlag =
false;
106 if (
mValid && loadDefaultStyleFlag )
110 if ( !defaultLoadedFlag )
122 const QString & baseName,
123 const QString & providerKey,
124 bool loadDefaultStyleFlag )
127 , QSTRING_NOT_SET(
"Not Set" )
128 , TRSTRING_NOT_SET(
tr(
"Not Set" ) )
130 , mProviderKey( providerKey )
138 bool defaultLoadedFlag =
false;
139 if (
mValid && loadDefaultStyleFlag )
143 if ( !defaultLoadedFlag )
173 QgsDebugMsg(
"Could not resolve isValidRasterFileName in gdal provider library" );
177 bool myIsValid = pValid( theFileNameQString, retErrMsg );
192 QFileInfo fi( name );
198 t = fi.lastModified();
273 QgsDebugMsg(
"coordinateTransform set -> project extents." );
297 myProjectedViewExtent = rendererContext.
extent();
298 myProjectedLayerExtent =
extent();
301 QPainter* theQPainter = rendererContext.
painter();
310 if ( myRasterExtent.
isEmpty() )
312 QgsDebugMsg(
"draw request outside view extent." );
331 myRasterViewPort->mDrawnExtent = myRasterExtent;
334 myRasterViewPort->mSrcCRS =
crs();
343 myRasterViewPort->mSrcDatumTransform = -1;
344 myRasterViewPort->mDestDatumTransform = -1;
349 myRasterViewPort->mBottomRightPoint = theQgsMapToPixel.
transform( myRasterExtent.
xMaximum(), myRasterExtent.
yMinimum() );
357 myRasterViewPort->mTopLeftPoint.
setX( floor( myRasterViewPort->mTopLeftPoint.x() ) );
358 myRasterViewPort->mTopLeftPoint.setY( floor( myRasterViewPort->mTopLeftPoint.y() ) );
359 myRasterViewPort->mBottomRightPoint.setX( ceil( myRasterViewPort->mBottomRightPoint.x() ) );
360 myRasterViewPort->mBottomRightPoint.setY( ceil( myRasterViewPort->mBottomRightPoint.y() ) );
364 myRasterViewPort->mBottomRightPoint.y() ),
366 myRasterViewPort->mTopLeftPoint.y() )
370 myRasterViewPort->mWidth =
static_cast<int>( myRasterViewPort->mBottomRightPoint.x() - myRasterViewPort->mTopLeftPoint.x() );
371 myRasterViewPort->mHeight =
static_cast<int>( myRasterViewPort->mBottomRightPoint.y() - myRasterViewPort->mTopLeftPoint.y() );
386 QgsDebugMsgLevel( QString(
"mTopLeftPoint.x() = %1" ).arg( myRasterViewPort->mTopLeftPoint.x() ), 3 );
387 QgsDebugMsgLevel( QString(
"mBottomRightPoint.x() = %1" ).arg( myRasterViewPort->mBottomRightPoint.x() ), 3 );
388 QgsDebugMsgLevel( QString(
"mTopLeftPoint.y() = %1" ).arg( myRasterViewPort->mTopLeftPoint.y() ), 3 );
389 QgsDebugMsgLevel( QString(
"mBottomRightPoint.y() = %1" ).arg( myRasterViewPort->mBottomRightPoint.y() ), 3 );
391 QgsDebugMsgLevel( QString(
"mWidth = %1" ).arg( myRasterViewPort->mWidth ), 3 );
392 QgsDebugMsgLevel( QString(
"mHeight = %1" ).arg( myRasterViewPort->mHeight ), 3 );
401 draw( theQPainter, myRasterViewPort, &theQgsMapToPixel );
403 delete myRasterViewPort;
436 drawer.draw( theQPainter, theRasterViewPort, theQgsMapToPixel );
438 QgsDebugMsg( QString(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ) );
453 QList< QPair< QString, QColor > > symbolList;
465 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Driver" ) +
"</p>\n";
468 myMetadata +=
"</p>\n";
474 myMetadata +=
"<p class=\"glossy\">";
475 myMetadata +=
tr(
"No Data Value" );
476 myMetadata +=
"</p>\n";
485 myMetadata +=
"*" +
tr(
"NoDataValue not set" ) +
"*";
487 myMetadata +=
"</p>\n";
489 myMetadata +=
"</p>\n";
490 myMetadata +=
"<p class=\"glossy\">";
491 myMetadata +=
tr(
"Data Type" );
492 myMetadata +=
"</p>\n";
498 myMetadata +=
tr(
"Byte - Eight bit unsigned integer" );
501 myMetadata +=
tr(
"UInt16 - Sixteen bit unsigned integer " );
504 myMetadata +=
tr(
"Int16 - Sixteen bit signed integer " );
507 myMetadata +=
tr(
"UInt32 - Thirty two bit unsigned integer " );
510 myMetadata +=
tr(
"Int32 - Thirty two bit signed integer " );
513 myMetadata +=
tr(
"Float32 - Thirty two bit floating point " );
516 myMetadata +=
tr(
"Float64 - Sixty four bit floating point " );
519 myMetadata +=
tr(
"CInt16 - Complex Int16 " );
522 myMetadata +=
tr(
"CInt32 - Complex Int32 " );
525 myMetadata +=
tr(
"CFloat32 - Complex Float32 " );
528 myMetadata +=
tr(
"CFloat64 - Complex Float64 " );
531 myMetadata +=
tr(
"Could not determine raster data type." );
533 myMetadata +=
"</p>\n";
535 myMetadata +=
"<p class=\"glossy\">";
536 myMetadata +=
tr(
"Pyramid overviews" );
537 myMetadata +=
"</p>\n";
540 myMetadata +=
"<p class=\"glossy\">";
541 myMetadata +=
tr(
"Layer Spatial Reference System" );
542 myMetadata +=
"</p>\n";
545 myMetadata +=
"</p>\n";
547 myMetadata +=
"<p class=\"glossy\">";
548 myMetadata +=
tr(
"Layer Extent (layer original source projection)" );
549 myMetadata +=
"</p>\n";
552 myMetadata +=
"</p>\n";
557 myMetadata +=
"<tr><td class=\"glossy\">";
558 myMetadata +=
tr(
"Project Spatial Reference System" );
559 myMetadata +=
"</p>\n";
561 myMetadata += mCoordinateTransform->destCRS().toProj4();
562 myMetadata +=
"</p>\n";
569 for (
int myIteratorInt = 1; myIteratorInt <= myBandCountInt; ++myIteratorInt )
571 QgsDebugMsg(
"Raster properties : checking if band " + QString::number( myIteratorInt ) +
" has stats? " );
573 myMetadata +=
"<p class=\"glossy\">\n";
574 myMetadata +=
tr(
"Band" );
575 myMetadata +=
"</p>\n";
577 myMetadata +=
bandName( myIteratorInt );
578 myMetadata +=
"</p>\n";
581 myMetadata +=
tr(
"Band No" );
582 myMetadata +=
"</p>\n";
583 myMetadata +=
"<p>\n";
584 myMetadata += QString::number( myIteratorInt );
585 myMetadata +=
"</p>\n";
593 myMetadata +=
tr(
"No Stats" );
594 myMetadata +=
"</p>\n";
595 myMetadata +=
"<p>\n";
596 myMetadata +=
tr(
"No stats collected yet" );
597 myMetadata +=
"</p>\n";
606 myMetadata +=
tr(
"Min Val" );
607 myMetadata +=
"</p>\n";
608 myMetadata +=
"<p>\n";
609 myMetadata += QString::number( myRasterBandStats.
minimumValue,
'f', 10 );
610 myMetadata +=
"</p>\n";
614 myMetadata +=
tr(
"Max Val" );
615 myMetadata +=
"</p>\n";
616 myMetadata +=
"<p>\n";
617 myMetadata += QString::number( myRasterBandStats.
maximumValue,
'f', 10 );
618 myMetadata +=
"</p>\n";
622 myMetadata +=
tr(
"Range" );
623 myMetadata +=
"</p>\n";
624 myMetadata +=
"<p>\n";
625 myMetadata += QString::number( myRasterBandStats.
range,
'f', 10 );
626 myMetadata +=
"</p>\n";
630 myMetadata +=
tr(
"Mean" );
631 myMetadata +=
"</p>\n";
632 myMetadata +=
"<p>\n";
633 myMetadata += QString::number( myRasterBandStats.
mean,
'f', 10 );
634 myMetadata +=
"</p>\n";
638 myMetadata +=
tr(
"Sum of squares" );
639 myMetadata +=
"</p>\n";
640 myMetadata +=
"<p>\n";
641 myMetadata += QString::number( myRasterBandStats.
sumOfSquares,
'f', 10 );
642 myMetadata +=
"</p>\n";
646 myMetadata +=
tr(
"Standard Deviation" );
647 myMetadata +=
"</p>\n";
648 myMetadata +=
"<p>\n";
649 myMetadata += QString::number( myRasterBandStats.
stdDev,
'f', 10 );
650 myMetadata +=
"</p>\n";
654 myMetadata +=
tr(
"Sum of all cells" );
655 myMetadata +=
"</p>\n";
656 myMetadata +=
"<p>\n";
657 myMetadata += QString::number( myRasterBandStats.
sum,
'f', 10 );
658 myMetadata +=
"</p>\n";
662 myMetadata +=
tr(
"Cell Count" );
663 myMetadata +=
"</p>\n";
664 myMetadata +=
"<p>\n";
665 myMetadata += QString::number( myRasterBandStats.
elementCount );
666 myMetadata +=
"</p>\n";
690 if ( myColorRampItemList.size() > 0 )
697 QPixmap myPalettePixmap( mySize, mySize );
698 QPainter myQPainter( &myPalettePixmap );
700 QImage myQImage = QImage( mySize, mySize, QImage::Format_RGB32 );
702 myPalettePixmap.fill();
704 double myStep = (( double )myColorRampItemList.size() - 1 ) / (
double )( mySize * mySize );
705 double myValue = 0.0;
706 for (
int myRow = 0; myRow < mySize; myRow++ )
708 QRgb* myLineBuffer = ( QRgb* )myQImage.scanLine( myRow );
709 for (
int myCol = 0; myCol < mySize; myCol++ )
711 myValue = myStep * ( double )( myCol + myRow * mySize );
713 myShader.
shade( myValue, &c1, &c2, &c3, &c4 );
714 myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
718 myQPainter.drawImage( 0, 0, myQImage );
719 return myPalettePixmap;
721 QPixmap myNullPixmap;
727 QPixmap myNullPixmap;
813 if ( provider ==
"gdal" )
837 QString mySourceWkt =
crs().
toWkt();
844 QSettings myQSettings;
966 this, SLOT(
onProgress(
int,
double, QString ) )
990 QgsDebugMsg( QString(
"theAlgorithm = %1 theLimits = %2 theExtent.isEmpty() = %3" ).arg( theAlgorithm ).arg( theLimits ).arg( theExtent.
isEmpty() ) );
997 QList<QgsContrastEnhancement*> myEnhancements;
1001 if ( rendererType ==
"singlebandgray" )
1004 if ( !myGrayRenderer )
return;
1005 myBands << myGrayRenderer->
grayBand();
1007 else if ( rendererType ==
"multibandcolor" )
1010 if ( !myMultiBandRenderer )
return;
1014 foreach (
int myBand, myBands )
1022 double myMin = std::numeric_limits<double>::quiet_NaN();
1023 double myMax = std::numeric_limits<double>::quiet_NaN();
1033 double myStdDev = 1;
1035 myMin = myRasterBandStats.
mean - ( myStdDev * myRasterBandStats.
stdDev );
1036 myMax = myRasterBandStats.
mean + ( myStdDev * myRasterBandStats.
stdDev );
1040 QSettings mySettings;
1041 double myLower = mySettings.value(
"/Raster/cumulativeCutLower", QString::number(
CUMULATIVE_CUT_LOWER ) ).toDouble();
1042 double myUpper = mySettings.value(
"/Raster/cumulativeCutUpper", QString::number(
CUMULATIVE_CUT_UPPER ) ).toDouble();
1043 QgsDebugMsg( QString(
"myLower = %1 myUpper = %2" ).arg( myLower ).arg( myUpper ) );
1047 QgsDebugMsg( QString(
"myBand = %1 myMin = %2 myMax = %3" ).arg( myBand ).arg( myMin ).arg( myMax ) );
1050 myEnhancements.append( myEnhancement );
1054 myEnhancements.append( 0 );
1058 if ( rendererType ==
"singlebandgray" )
1062 else if ( rendererType ==
"multibandcolor" )
1074 QSettings mySettings;
1080 if ( dynamic_cast<QgsSingleBandGrayRenderer*>(
renderer() ) )
1082 myKey =
"singleBand";
1083 myDefault =
"StretchToMinimumMaximum";
1085 else if ( dynamic_cast<QgsMultiBandColorRenderer*>(
renderer() ) )
1089 myKey =
"multiBandSingleByte";
1090 myDefault =
"NoEnhancement";
1094 myKey =
"multiBandMultiByte";
1095 myDefault =
"StretchToMinimumMaximum";
1099 if ( myKey.isEmpty() )
1101 QgsDebugMsg(
"No default contrast enhancement for this drawing style" );
1105 QString myAlgorithmString = mySettings.value(
"/Raster/defaultContrastEnhancementAlgorithm/" + myKey, myDefault ).toString();
1106 QgsDebugMsg(
"myAlgorithmString = " + myAlgorithmString );
1115 QString myLimitsString = mySettings.value(
"/Raster/defaultContrastEnhancementLimits",
"CumulativeCut" ).toString();
1128 QgsDebugMsg(
"DrawingStyle = " + theDrawingStyleQString );
1130 if ( theDrawingStyleQString ==
"SingleBandGray" )
1134 else if ( theDrawingStyleQString ==
"SingleBandPseudoColor" )
1138 else if ( theDrawingStyleQString ==
"PalettedColor" )
1142 else if ( theDrawingStyleQString ==
"PalettedSingleBandGray" )
1146 else if ( theDrawingStyleQString ==
"PalettedSingleBandPseudoColor" )
1150 else if ( theDrawingStyleQString ==
"PalettedMultiBandColor" )
1154 else if ( theDrawingStyleQString ==
"MultiBandSingleBandGray" )
1158 else if ( theDrawingStyleQString ==
"MultiBandSingleBandPseudoColor" )
1162 else if ( theDrawingStyleQString ==
"MultiBandColor" )
1166 else if ( theDrawingStyleQString ==
"SingleBandColorDataStyle" )
1170 QgsDebugMsg(
"Setted drawingStyle to " + QString::number( drawingStyle ) );
1185 QgsDebugMsg(
"About to mDataProvider->setLayerOrder(layers)." );
1196 QgsDebugMsg(
"About to mDataProvider->setSubLayerVisibility(name, vis)." );
1205 if ( !theRenderer ) {
return; }
1232 QPixmap myQPixmap( size );
1234 myQPixmap.fill( bgColor );
1238 double myMapUnitsPerPixel;
1242 if ( myExtent.
width() / myExtent.
height() >= myQPixmap.width() / myQPixmap.height() )
1244 myMapUnitsPerPixel = myExtent.
width() / myQPixmap.width();
1245 myY = ( myQPixmap.height() - myExtent.
height() / myMapUnitsPerPixel ) / 2;
1249 myMapUnitsPerPixel = myExtent.
height() / myQPixmap.height();
1250 myX = ( myQPixmap.width() - myExtent.
width() / myMapUnitsPerPixel ) / 2;
1253 double myPixelWidth = myExtent.
width() / myMapUnitsPerPixel;
1254 double myPixelHeight = myExtent.
height() / myMapUnitsPerPixel;
1258 myRasterViewPort->
mWidth = myQPixmap.width();
1259 myRasterViewPort->
mHeight = myQPixmap.height();
1269 QPainter * myQPainter =
new QPainter( &myQPixmap );
1270 draw( myQPainter, myRasterViewPort, myMapToPixel );
1271 delete myRasterViewPort;
1272 delete myMapToPixel;
1292 Q_UNUSED( theType );
1293 Q_UNUSED( theMessage );
1294 QgsDebugMsg( QString(
"theProgress = %1" ).arg( theProgress ) );
1310 Q_UNUSED( errorMessage );
1311 QDomElement rasterRendererElem;
1317 QDomNode pipeNode = layer_node.firstChildElement(
"pipe" );
1318 if ( pipeNode.isNull() )
1320 pipeNode = layer_node;
1324 if ( !layer_node.firstChildElement(
"rasterproperties" ).isNull() )
1327 QDomNode layerNodeCopy = layer_node.cloneNode();
1328 QDomDocument doc = layerNodeCopy.ownerDocument();
1329 QDomElement rasterPropertiesElem = layerNodeCopy.firstChildElement(
"rasterproperties" );
1332 rasterRendererElem = layerNodeCopy.firstChildElement(
"rasterrenderer" );
1337 rasterRendererElem = pipeNode.firstChildElement(
"rasterrenderer" );
1340 if ( !rasterRendererElem.isNull() )
1342 QString rendererType = rasterRendererElem.attribute(
"type" );
1356 QDomElement brightnessElem = pipeNode.firstChildElement(
"brightnesscontrast" );
1357 if ( !brightnessElem.isNull() )
1359 brightnessFilter->
readXML( brightnessElem );
1367 QDomElement hueSaturationElem = pipeNode.firstChildElement(
"huesaturation" );
1368 if ( !hueSaturationElem.isNull() )
1370 hueSaturationFilter->
readXML( hueSaturationElem );
1378 QDomElement resampleElem = pipeNode.firstChildElement(
"rasterresampler" );
1379 if ( !resampleElem.isNull() )
1381 resampleFilter->
readXML( resampleElem );
1385 QDomNode blendModeNode = layer_node.namedItem(
"blendMode" );
1386 if ( !blendModeNode.isNull() )
1388 QDomElement e = blendModeNode.toElement();
1407 QDomNode pkeyNode = layer_node.namedItem(
"provider" );
1409 if ( pkeyNode.isNull() )
1415 QDomElement pkeyElt = pkeyNode.toElement();
1429 QDomNode rpNode = layer_node.namedItem(
"rasterproperties" );
1437 QgsDebugMsg(
"Old WMS URI format detected -> adding params" );
1440 QDomElement layerElement = rpNode.firstChildElement(
"wmsSublayer" );
1441 while ( !layerElement.isNull() )
1446 uri.
setParam(
"layers", layerElement.namedItem(
"name" ).toElement().text() );
1449 uri.
setParam(
"styles", layerElement.namedItem(
"style" ).toElement().text() );
1451 layerElement = layerElement.nextSiblingElement(
"wmsSublayer" );
1455 QDomNode formatNode = rpNode.namedItem(
"wmsFormat" );
1456 uri.
setParam(
"format", rpNode.namedItem(
"wmsFormat" ).toElement().text() );
1467 if ( !
mValid )
return false;
1484 QDomNode stampNode = layer_node.namedItem(
"timestamp" );
1485 if ( !stampNode.isNull() )
1487 QDateTime stamp = QDateTime::fromString( stampNode.toElement().text(), Qt::ISODate );
1489 if ( stamp < mDataProvider->dataTimestamp() )
1495 if ( !
mValid )
return false;
1501 QDomElement noDataElement = layer_node.firstChildElement(
"noData" );
1503 QDomNodeList noDataBandList = noDataElement.elementsByTagName(
"noDataList" );
1505 for (
int i = 0; i < noDataBandList.size(); ++i )
1507 QDomElement bandElement = noDataBandList.at( i ).toElement();
1509 int bandNo = bandElement.attribute(
"bandNo" ).toInt( &ok );
1510 QgsDebugMsg( QString(
"bandNo = %1" ).arg( bandNo ) );
1511 if ( ok && ( bandNo > 0 ) && ( bandNo <= mDataProvider->
bandCount() ) )
1516 QDomNodeList rangeList = bandElement.elementsByTagName(
"noDataRange" );
1518 for (
int j = 0; j < rangeList.size(); ++j )
1520 QDomElement rangeElement = rangeList.at( j ).toElement();
1521 QgsRasterRange myNoDataRange( rangeElement.attribute(
"min" ).toDouble(),
1522 rangeElement.attribute(
"max" ).toDouble() );
1523 QgsDebugMsg( QString(
"min = %1 %2" ).arg( rangeElement.attribute(
"min" ) ).arg( myNoDataRange.min() ) );
1524 myNoDataRangeList << myNoDataRange;
1541 Q_UNUSED( errorMessage );
1542 QDomElement layerElem = layer_node.toElement();
1546 QDomElement pipeElement = document.createElement(
"pipe" );
1548 for (
int i = 1; i <
mPipe.
size(); i++ )
1551 if ( !interface )
continue;
1552 interface->writeXML( document, pipeElement );
1555 layer_node.appendChild( pipeElement );
1558 QDomElement blendModeElement = document.createElement(
"blendMode" );
1560 blendModeElement.appendChild( blendModeText );
1561 layer_node.appendChild( blendModeElement );
1571 QDomDocument & document )
1575 QDomElement mapLayerNode = layer_node.toElement();
1577 if ( mapLayerNode.isNull() ||
"maplayer" != mapLayerNode.nodeName() )
1583 mapLayerNode.setAttribute(
"type",
"raster" );
1587 QDomElement provider = document.createElement(
"provider" );
1588 QDomText providerText = document.createTextNode(
mProviderKey );
1589 provider.appendChild( providerText );
1590 layer_node.appendChild( provider );
1593 QDomElement noData = document.createElement(
"noData" );
1599 QDomElement noDataRangeList = document.createElement(
"noDataList" );
1600 noDataRangeList.setAttribute(
"bandNo", bandNo );
1605 QDomElement noDataRange = document.createElement(
"noDataRange" );
1607 noDataRange.setAttribute(
"min", range.
min() );
1608 noDataRange.setAttribute(
"max", range.
max() );
1609 noDataRangeList.appendChild( noDataRange );
1612 noData.appendChild( noDataRangeList );
1615 if ( noData.hasChildNodes() )
1617 layer_node.appendChild( noData );
QgsDataProvider * classFactoryFunction_t(const QString *)
virtual int bandCount() const =0
Get number of bands.
virtual void setSubLayerVisibility(const QString &name, bool vis)
Set the visibility of the given sublayer name.
void setRenderer(QgsRasterRenderer *theRenderer)
Set raster renderer.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
virtual QStringList subLayers() const
Returns the sublayers of this layer - useful for providers that manage their own layers, such as WMS.
A rectangle specified with double values.
Base class for all map layer types.
Interface for all raster shaders.
bool isEmpty() const
test if rectangle is empty
double rasterUnitsPerPixelY()
QgsMapLayer::LayerType type() const
Get the type of the layer.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
double sum
The sum of all cells in the band.
void setCRS(const QgsCoordinateReferenceSystem &theSrcCRS, const QgsCoordinateReferenceSystem &theDestCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
set source and destination CRS
Iterator for sequentially processing raster cells.
void rendererChanged()
Signal emitted when the symbology changes, through call to setRenderer()
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
static QgsProviderRegistry * instance(QString pluginPath=QString::null)
means of accessing canonical single instance
QString lastErrorTitle()
[ data provider interface ] If an operation returns 0 (e.g.
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setEncodedUri(const QByteArray &uri)
set complete encoded uri (generic mode)
virtual QgsCoordinateReferenceSystem crs()=0
static ContrastEnhancementLimits contrastEnhancementLimitsFromString(QString theLimits)
void setDefaultContrastEnhancement()
Set default contrast enhancement.
void triggerRepaint()
Emit a signal asking for a repaint.
virtual void setUseSrcNoDataValue(int bandNo, bool use)
Set source nodata value usage.
virtual double srcNoDataValue(int bandNo) const
Value representing no data value.
QgsPoint transform(const QgsPoint &p) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
virtual void setLayerOrder(const QStringList &layers)
Reorders the previously selected sublayers of this layer from bottom to top.
void drawingProgress(int theProgress, int theTotalSteps)
Emit a signal to notify of a progress event.
double maximumValue
The maximum cell value in the raster band.
int mWidth
Width, number of columns to be rendered.
QgsRasterInterface * last() const
virtual QgsRasterRangeList userNoDataValues(int bandNo) const
Get list of user no data value ranges.
static QDateTime lastModified(const QString &name)
Return time stamp for given file name.
Raster values range container.
const QgsRectangle & extent() const
static bool isValidRasterFileName(const QString &theFileNameQString, QString &retError)
This helper checks to see whether the file name appears to be a valid raster file name...
Resample filter pipe for rasters.
Abstract base class for spatial data provider implementations.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &theList)
Set custom colormap.
void readXML(const QDomElement &filterElem)
Sets base class members from xml.
bool draw(QgsRenderContext &rendererContext)
This is called when the view on the raster layer needs to be redrawn.
static const double SAMPLE_SIZE
Default sample size (number of pixels) for estimated statistics/histogram calculation.
double scaleFactor() const
void updateProgress(int, int)
Propagate progress updates from GDAL up to the parent app.
const QgsCoordinateTransform * coordinateTransform() const
void readXML(const QDomElement &filterElem)
Sets base class members from xml.
QString mError
[ data provider interface ]The error message associated with the last error
void setBlendMode(const QPainter::CompositionMode &blendMode)
Write blend mode for layer.
QString mLayerName
Name of the layer - used for display.
void setShader(QgsRasterShader *shader)
Takes ownership of the shader.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
double rasterUnitsPerPixelX()
Returns the number of raster units per each raster pixel.
virtual int ySize() const
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
static QString identifyFormatName(QgsRaster::IdentifyFormat format)
virtual QDateTime dataTimestamp() const
Current time stamp of data source.
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
void setDrawingStyle(const QString &theDrawingStyleQString)
Overloaded version of the above function for convenience when restoring from xml. ...
void setRendererForDrawingStyle(const QgsRaster::DrawingStyle &theDrawingStyle)
Sets corresponding renderer for style.
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
void init()
Initialize default values.
virtual bool useSrcNoDataValue(int bandNo) const
Get source nodata value usage.
const QString & name() const
Get the display name of the layer.
void onProgress(int, double, QString)
receive progress signal from provider
Perform transforms between map coordinates and device coordinates.
virtual QgsRasterBandStats bandStatistics(int theBandNo, int theStats=QgsRasterBandStats::All, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0)
Get band statistics.
The drawing pipe for raster layers.
bool readXml(const QDomNode &layer_node)
Reads layer specific state from project file Dom node.
double stdDev
The standard deviation of the cell values.
virtual QStringList subLayers() const
Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsRasterRendererRegistry * instance()
void setError(const QgsError &theError)
Set error message.
double mean
The mean cell value for the band.
int height() const
Accessor that returns the height of the (unclipped) raster.
QPainter::CompositionMode blendMode() const
Read blend mode for layer.
void readXML(const QDomElement &filterElem)
Sets base class members from xml.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QgsRasterRenderer * renderer() const
virtual void setUserNoDataValue(int bandNo, QgsRasterRangeList noData)
int bandCount() const
Get the number of bands in this layer.
QgsDataProvider * provider(const QString &providerKey, const QString &dataSource)
Create an instance of the provider.
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define QgsDebugMsgLevel(str, level)
void setParam(const QString &key, const QString &value)
Set generic param (generic mode)
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QgsRasterViewPort mLastViewPort
virtual QGis::DataType srcDataType(int bandNo) const =0
Returns source data type for the band specified by number, source data type may be shorter than dataT...
virtual QgsRectangle extent()=0
Get the extent of the data source.
void statusChanged(QString theStatus)
Emit a signal with status (e.g.
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
bool readSymbology(const QDomNode &node, QString &errorMessage)
Read the symbology for the current layer from the Dom node supplied.
static const double CUMULATIVE_CUT_UPPER
Default cumulative cut upper limit.
~QgsRasterLayer()
The destructor.
ContrastEnhancementLimits
Contrast enhancement limits.
qgssize elementCount
The number of not no data cells in the band.
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
Raster renderer pipe for single band pseudocolor.
void dataChanged()
This is emitted whenever data or metadata (e.g.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
const QString bandName(int theBandNoInt)
Get the name of a band given its number.
double rasterScaleFactor() const
bool isvalidrasterfilename_t(QString const &theFileNameQString, QString &retErrMsg)
Raster renderer pipe for single band gray.
virtual QString generateBandName(int theBandNumber) const
helper function to create zero padded band names
QgsRasterResampleFilter * resampleFilter() const
Set raster resample filter.
double mapUnitsPerPixel() const
Return current map units per pixel.
static int typeSize(int dataType)
virtual void setLayerOrder(const QStringList &layers)
Reorder the list of layer names to be rendered by this provider (in order from bottom to top) ...
QgsRasterProjector * projector() const
QString lastError()
[ data provider interface ] If an operation returns 0 (e.g.
void setAlphaBand(int band)
bool mValid
Indicates if the layer is valid and can be drawn.
void setContrastEnhancement(QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm, QgsRaster::ContrastEnhancementLimits theLimits=QgsRaster::ContrastEnhancementMinMax, QgsRectangle theExtent=QgsRectangle(), int theSampleSize=SAMPLE_SIZE, bool theGenerateLookupTableFlag=true)
Set contrast enhancement algorithm.
void setDataProvider(const QString &provider)
[ data provider interface ] Set the data provider
QgsRasterDataProvider * mDataProvider
Pointer to data provider.
void setRasterShaderFunction(QgsRasterShaderFunction *)
A public method that allows the user to set their own shader function.
Base class for processing filters like renderers, reprojector, resampler etc.
A class to represent a point geometry.
void setColorRampType(QgsColorRampShader::ColorRamp_TYPE theColorRampType)
Set the color ramp type.
QPixmap previewAsPixmap(QSize size, QColor bgColor=Qt::white)
Draws a preview of the rasterlayer into a pixmap.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QPixmap paletteAsPixmap(int theBandNumber=1)
Get an 100x100 pixmap of the color palette.
bool shade(double, int *, int *, int *, int *)
Generates and new RGB value based on one input value.
static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(const QString &contrastEnhancementString)
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
virtual int colorInterpretation(int theBandNo) const
Returns data type for the band specified by number.
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
QgsPoint toMapCoordinatesF(double x, double y) const
void progressUpdate(int theValue)
Signal for notifying listeners of long running processes.
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode Added in 1.9.
void showProgress(int theValue)
[ data provider interface ] A wrapper function to emit a progress update signal
Registry for raster renderer entries.
bool writeSymbology(QDomNode &, QDomDocument &doc, QString &errorMessage) const
Write the symbology for the layer into the docment provided.
QgsPoint mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
void setContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QString metadata()
Obtain GDAL Metadata for this layer.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
QString mProviderKey
[ data provider interface ] Data provider key
Contains information about the context of a rendering operation.
virtual void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const
Get symbology items if provided by renderer.
QDateTime mLastModified
[ data provider interface ] Timestamp, the last modified time of the data source when the layer was c...
bool remove(int idx)
Remove and delete interface at given index if possible.
QList< QgsRasterRange > QgsRasterRangeList
virtual int xSize() const
Get raster size.
QString mDataSource
data source description string, varies by layer type
virtual QString loadDefaultStyle(bool &theResultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
virtual QDateTime timestamp() const
Time stamp of data source in the moment when data/metadata were loaded by provider.
virtual QString type() const
virtual QString metadata()=0
Get metadata in a format suitable for feeding directly into a subset of the GUI raster properties "Me...
virtual void reloadData()
Reloads the data from the source.
QgsRectangle intersect(const QgsRectangle *rect) const
return the intersection with the given rectangle
virtual bool isValid()=0
Returns true if this is a valid layer.
void repaintRequested()
This signal should be connected with the slot QgsMapCanvas::refresh()
int mHeight
Distance in map units from bottom edge to top edge for the part of the raster that is to be rendered...
bool update()
Update the layer if it is outdated.
Brightness/contrast filter pipe for rasters.
Class for storing a coordinate reference system (CRS)
Color and saturation filter pipe for rasters.
static const double CUMULATIVE_CUT_LOWER
Default cumulative cut lower limit.
DataType
Raster data types.
virtual QString description() const =0
return description
double range
The range is the distance between min & max.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
void closeDataProvider()
Close data provider and clear related members.
QgsHueSaturationFilter * hueSaturationFilter() const
double minimumValue
The minimum cell value in the raster band.
const QgsMapToPixel & mapToPixel() const
Renderer for multiband images with the color components.
void setLayerName(const QString &name)
Set the display name of the layer.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
void * function(const QString &providerKey, const QString &functionName)
Get pointer to provider function.
void appendError(const QgsErrorMessage &theMessage)
Add error message.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
QByteArray encodedUri() const
return complete encoded uri (generic mode)
void(*)() cast_to_fptr(void *p)
QgsRasterDataProvider * dataProvider()
Returns the data provider.
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode Added in 1.9.
virtual void setSubLayerVisibility(QString name, bool vis)
Set the visibility of the given sublayer name.
Custom exception class for Coordinate Reference System related exceptions.
QString providerType() const
[ data provider interface ] Which provider is being used for this Raster Layer?
QgsPoint mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
virtual bool srcHasNoDataValue(int bandNo) const
This class provides details of the viewable area that a raster will be rendered into.
QString mErrorCaption
[ data provider interface ] The error caption associated with the last error
double width() const
Width of the rectangle.
virtual void cumulativeCut(int theBandNo, double theLowerCount, double theUpperCount, double &theLowerValue, double &theUpperValue, const QgsRectangle &theExtent=QgsRectangle(), int theSampleSize=0)
Find values for cumulative pixel count cut.
virtual QList< QgsColorRampShader::ColorRampItem > colorTable(int bandNo) const
virtual QgsRectangle extent()
Return the extent of the layer.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
QgsRasterRenderer * renderer() const
bool set(QgsRasterInterface *theInterface)
Insert a new known interface in default place or replace interface of the same role if it already exi...
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual QgsError error() const
Get current status error.
QList< QPair< QString, QColor > > legendSymbologyItems() const
Returns a list with classification items (Text and color)
Raster renderer pipe that applies colors to a raster.
QgsRasterRendererCreateFunc rendererCreateFunction
void setDpi(int dpi)
Sets the output device resolution.
virtual QString dataSourceUri() const
Get the data source specification.
void setMaximumValue(double, bool generateTable=true)
Set the maximum value for the contrast enhancement range.
void showStatusMessage(const QString &theMessage)
bool writeXml(QDomNode &layer_node, QDomDocument &doc)
Write layer specific state to project file Dom node.
double height() const
Height of the rectangle.
QgsBrightnessContrastFilter * brightnessFilter() const
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
QString toProj4() const
Get the Proj Proj4 string representation of this srs.
virtual void reload()
Synchronises with changes in the datasource.
Base class for raster data providers.
int width() const
Accessor that returns the width of the (unclipped) raster.
double sumOfSquares
The sum of the squares.
QgsRasterLayer()
Constructor.