26 #include <QTextStream> 27 #include <QDomDocument> 40 QgsProjectFileTransform::TransformItem QgsProjectFileTransform::sTransformers[] =
42 {
PFV( 0, 8, 0 ),
PFV( 0, 8, 1 ), &QgsProjectFileTransform::transformNull},
43 {
PFV( 0, 8, 1 ),
PFV( 0, 9, 0 ), &QgsProjectFileTransform::transform081to090},
44 {
PFV( 0, 9, 0 ),
PFV( 0, 9, 1 ), &QgsProjectFileTransform::transformNull},
45 {
PFV( 0, 9, 1 ),
PFV( 0, 10, 0 ), &QgsProjectFileTransform::transform091to0100},
48 {
PFV( 0, 9, 2 ),
PFV( 0, 11, 0 ), &QgsProjectFileTransform::transformNull},
49 {
PFV( 0, 10, 0 ),
PFV( 0, 11, 0 ), &QgsProjectFileTransform::transform0100to0110},
50 {
PFV( 0, 11, 0 ),
PFV( 1, 0, 0 ), &QgsProjectFileTransform::transform0110to1000},
51 {
PFV( 1, 0, 0 ),
PFV( 1, 1, 0 ), &QgsProjectFileTransform::transformNull},
52 {
PFV( 1, 0, 2 ),
PFV( 1, 1, 0 ), &QgsProjectFileTransform::transformNull},
53 {
PFV( 1, 1, 0 ),
PFV( 1, 2, 0 ), &QgsProjectFileTransform::transform1100to1200},
54 {
PFV( 1, 2, 0 ),
PFV( 1, 3, 0 ), &QgsProjectFileTransform::transformNull},
55 {
PFV( 1, 3, 0 ),
PFV( 1, 4, 0 ), &QgsProjectFileTransform::transformNull},
56 {
PFV( 1, 4, 0 ),
PFV( 1, 5, 0 ), &QgsProjectFileTransform::transform1400to1500},
57 {
PFV( 1, 5, 0 ),
PFV( 1, 6, 0 ), &QgsProjectFileTransform::transformNull},
58 {
PFV( 1, 6, 0 ),
PFV( 1, 7, 0 ), &QgsProjectFileTransform::transformNull},
59 {
PFV( 1, 7, 0 ),
PFV( 1, 8, 0 ), &QgsProjectFileTransform::transformNull},
60 {
PFV( 1, 8, 0 ),
PFV( 1, 9, 0 ), &QgsProjectFileTransform::transform1800to1900},
61 {
PFV( 1, 9, 0 ),
PFV( 2, 0, 0 ), &QgsProjectFileTransform::transformNull},
62 {
PFV( 2, 0, 0 ),
PFV( 2, 1, 0 ), &QgsProjectFileTransform::transformNull},
63 {
PFV( 2, 1, 0 ),
PFV( 2, 2, 0 ), &QgsProjectFileTransform::transformNull},
64 {
PFV( 2, 2, 0 ),
PFV( 2, 3, 0 ), &QgsProjectFileTransform::transform2200to2300},
68 {
PFV(),
PFV( 2, 99, 0 ), &QgsProjectFileTransform::transform2990},
73 Q_UNUSED( newVersion );
74 bool returnValue =
false;
78 for ( std::size_t i = 0; i <
sizeof( sTransformers ) /
sizeof( TransformItem ); i++ )
80 const TransformItem &transformer = sTransformers[i];
81 if ( transformer.from == mCurrentVersion || transformer.from.
isNull() )
84 ( this->*( transformer.transformFunc ) )();
85 mCurrentVersion = transformer.to;
95 QgsDebugMsg( QString(
"Current project file version is %1.%2.%3" )
101 std::cout << mDom.toString( 2 ).toLatin1().constData();
109 void QgsProjectFileTransform::transform081to090()
112 if ( ! mDom.isNull() )
116 QDomElement mapCanvas;
119 QDomNode qgis = mDom.firstChildElement( QStringLiteral(
"qgis" ) );
120 if ( ! qgis.isNull() )
125 mapCanvas = mDom.createElement( QStringLiteral(
"mapcanvas" ) );
127 qgis.appendChild( mapCanvas );
129 mapCanvas.appendChild( qgis.namedItem( QStringLiteral(
"units" ) ) );
131 mapCanvas.appendChild( qgis.namedItem( QStringLiteral(
"extent" ) ) );
135 QDomElement properties = qgis.firstChildElement( QStringLiteral(
"properties" ) );
136 QDomElement spatial = properties.firstChildElement( QStringLiteral(
"SpatialRefSys" ) );
137 QDomElement hasCrsTransformEnabled = spatial.firstChildElement( QStringLiteral(
"ProjectionsEnabled" ) );
140 QDomElement projection = mDom.createElement( QStringLiteral(
"projections" ) );
141 QgsDebugMsg( QString(
"Projection flag: " ) + hasCrsTransformEnabled.text() );
143 projection.appendChild( mDom.createTextNode( hasCrsTransformEnabled.text() ) );
145 mapCanvas.appendChild( projection );
152 QDomNodeList mapLayers = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
153 bool doneDestination =
false;
154 for (
int i = 0; i < mapLayers.count(); i++ )
156 QDomNode mapLayer = mapLayers.item( i );
158 QDomNode coordinateTransform = mapLayer.namedItem( QStringLiteral(
"coordinatetransform" ) );
160 QDomNode sourceCrs = coordinateTransform.namedItem( QStringLiteral(
"sourcesrs" ) );
162 sourceCrs.toElement().setTagName( QStringLiteral(
"srs" ) );
164 mapLayer.appendChild( sourceCrs );
167 if ( ! doneDestination )
170 QDomNode destinationCRS = coordinateTransform.namedItem( QStringLiteral(
"destinationsrs" ) );
173 mapCanvas.appendChild( destinationCRS );
175 doneDestination =
true;
177 mapLayer.removeChild( coordinateTransform );
184 QDomNodeList legendLayerFiles = mDom.elementsByTagName( QStringLiteral(
"legendlayerfile" ) );
185 QgsDebugMsg( QString(
"Legend layer file entries: " ) + QString::number( legendLayerFiles.count() ) );
186 for (
int i = 0; i < mapLayers.count(); i++ )
189 QDomElement mapLayer = mapLayers.item( i ).toElement();
191 QString
id = mapLayer.firstChildElement( QStringLiteral(
"id" ) ).text();
194 for (
int j = 0; j < legendLayerFiles.count(); j++ )
196 QDomElement legendLayerFile = legendLayerFiles.item( j ).toElement();
197 if (
id == legendLayerFile.attribute( QStringLiteral(
"layerid" ) ) )
203 legendLayerFile.setAttribute( QStringLiteral(
"visible" ), mapLayer.attribute( QStringLiteral(
"visible" ) ) );
206 legendLayerFile.setAttribute( QStringLiteral(
"isInOverview" ), mapLayer.attribute( QStringLiteral(
"showInOverviewFlag" ) ) );
213 void QgsProjectFileTransform::transform091to0100()
215 if ( ! mDom.isNull() )
218 QDomNodeList rasterPropertyList = mDom.elementsByTagName( QStringLiteral(
"rasterproperties" ) );
219 QgsDebugMsg( QString(
"Raster properties file entries: " ) + QString::number( rasterPropertyList.count() ) );
220 for (
int i = 0; i < rasterPropertyList.count(); i++ )
223 QDomNode rasterProperty = rasterPropertyList.item( i );
226 rasterProperty.namedItem( QStringLiteral(
"stdDevsToPlotDouble" ) ).toElement().setTagName( QStringLiteral(
"mStandardDeviations" ) );
228 rasterProperty.namedItem( QStringLiteral(
"invertHistogramFlag" ) ).toElement().setTagName( QStringLiteral(
"mInvertPixelsFlag" ) );
229 rasterProperty.namedItem( QStringLiteral(
"showDebugOverLayFlag" ) ).toElement().setTagName( QStringLiteral(
"mDebugOverLayFlag" ) );
231 rasterProperty.namedItem( QStringLiteral(
"redBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mRedBandName" ) );
232 rasterProperty.namedItem( QStringLiteral(
"blueBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mBlueBandName" ) );
233 rasterProperty.namedItem( QStringLiteral(
"greenBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mGreenBandName" ) );
234 rasterProperty.namedItem( QStringLiteral(
"grayBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mGrayBandName" ) );
238 QDomNodeList symbolPropertyList = mDom.elementsByTagName( QStringLiteral(
"symbol" ) );
239 for (
int i = 0; i < symbolPropertyList.count(); i++ )
242 QDomNode symbolProperty = symbolPropertyList.item( i );
244 QDomElement pointSymbol = symbolProperty.firstChildElement( QStringLiteral(
"pointsymbol" ) );
245 if ( pointSymbol.text().startsWith( QLatin1String(
"hard:" ) ) )
248 int lineWidth = symbolProperty.firstChildElement( QStringLiteral(
"outlinewidth" ) ).text().toInt();
249 int pointSize = symbolProperty.firstChildElement( QStringLiteral(
"pointsize" ) ).text().toInt();
251 if ( pointSize != 0 )
256 pointSize = pointSize + 2 + 2 * lineWidth;
257 QgsDebugMsg( QString(
"Setting point size to %1" ).arg( pointSize ) );
258 QDomElement newPointSizeProperty = mDom.createElement( QStringLiteral(
"pointsize" ) );
259 QDomText newPointSizeTxt = mDom.createTextNode( QString::number( pointSize ) );
260 newPointSizeProperty.appendChild( newPointSizeTxt );
261 symbolProperty.replaceChild( newPointSizeProperty, pointSymbol );
269 void QgsProjectFileTransform::transform0100to0110()
271 if ( ! mDom.isNull() )
273 #ifndef QT_NO_PRINTER 275 QPrinter myPrinter( QPrinter::ScreenResolution );
276 int screenDpi = myPrinter.resolution();
277 double widthScaleFactor = 25.4 / screenDpi;
279 QDomNodeList outlineWidthList = mDom.elementsByTagName( QStringLiteral(
"outlinewidth" ) );
280 for (
int i = 0; i < outlineWidthList.size(); ++i )
283 QDomElement currentOutlineElem = outlineWidthList.at( i ).toElement();
284 double outlineWidth = currentOutlineElem.text().toDouble();
285 outlineWidth *= widthScaleFactor;
288 QDomNode outlineTextNode = currentOutlineElem.firstChild();
289 QDomText newOutlineText = mDom.createTextNode( QString::number( outlineWidth ) );
290 currentOutlineElem.replaceChild( newOutlineText, outlineTextNode );
295 QDomNodeList pointSizeList = mDom.elementsByTagName( QStringLiteral(
"pointsize" ) );
296 for (
int i = 0; i < pointSizeList.size(); ++i )
299 QDomElement currentPointSizeElem = pointSizeList.at( i ).toElement();
300 double pointSize = currentPointSizeElem.text().toDouble();
301 pointSize *= widthScaleFactor;
304 QDomNode pointSizeTextNode = currentPointSizeElem.firstChild();
305 QDomText newPointSizeText = mDom.createTextNode( QString::number( static_cast< int >( pointSize ) ) );
306 currentPointSizeElem.replaceChild( newPointSizeText, pointSizeTextNode );
312 void QgsProjectFileTransform::transform0110to1000()
314 if ( ! mDom.isNull() )
316 QDomNodeList layerList = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
317 for (
int i = 0; i < layerList.size(); ++i )
319 QDomElement layerElem = layerList.at( i ).toElement();
320 QString typeString = layerElem.attribute( QStringLiteral(
"type" ) );
321 if ( typeString != QLatin1String(
"vector" ) )
327 QDomNode dataSourceNode = layerElem.namedItem( QStringLiteral(
"datasource" ) );
328 if ( dataSourceNode.isNull() )
332 QString dataSource = dataSourceNode.toElement().text();
335 QDomNode providerNode = layerElem.namedItem( QStringLiteral(
"provider" ) );
336 if ( providerNode.isNull() )
340 QString providerKey = providerNode.toElement().text();
360 QDomNodeList classificationFieldList = layerElem.elementsByTagName( QStringLiteral(
"classificationfield" ) );
361 for (
int j = 0; j < classificationFieldList.size(); ++j )
363 QDomElement classificationFieldElem = classificationFieldList.
at( j ).toElement();
364 int fieldNumber = classificationFieldElem.text().toInt();
365 if ( fieldNumber >= 0 && fieldNumber < fields.
count() )
367 QDomText fieldName = mDom.createTextNode( fields.
at( fieldNumber ).
name() );
368 QDomNode nameNode = classificationFieldElem.firstChild();
369 classificationFieldElem.replaceChild( fieldName, nameNode );
377 void QgsProjectFileTransform::transform1100to1200()
383 QDomNode qgis = mDom.firstChildElement( QStringLiteral(
"qgis" ) );
387 QDomElement properties = qgis.firstChildElement( QStringLiteral(
"properties" ) );
388 if ( properties.isNull() )
391 QDomElement digitizing = properties.firstChildElement( QStringLiteral(
"Digitizing" ) );
392 if ( digitizing.isNull() )
395 QDomElement tolList = digitizing.firstChildElement( QStringLiteral(
"LayerSnappingToleranceList" ) );
396 if ( tolList.isNull() )
399 QDomElement tolUnitList = digitizing.firstChildElement( QStringLiteral(
"LayerSnappingToleranceUnitList" ) );
400 if ( !tolUnitList.isNull() )
404 for (
int i = 0; i < tolList.childNodes().count(); i++ )
405 units << QStringLiteral(
"0" );
408 value.
writeXml( QStringLiteral(
"LayerSnappingToleranceUnitList" ), digitizing, mDom );
411 void QgsProjectFileTransform::transform1400to1500()
419 QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral(
"LayerItem" ) );
420 QDomElement currentLayerItemElem;
421 QString currentLayerId;
423 for (
int i = 0; i < layerItemList.size(); ++i )
425 currentLayerItemElem = layerItemList.at( i ).toElement();
426 if ( currentLayerItemElem.isNull() )
430 currentLayerId = currentLayerItemElem.attribute( QStringLiteral(
"layerId" ) );
432 QDomNodeList vectorClassificationList = currentLayerItemElem.elementsByTagName( QStringLiteral(
"VectorClassificationItem" ) );
433 QDomElement currentClassificationElem;
434 for (
int j = 0; j < vectorClassificationList.size(); ++j )
436 currentClassificationElem = vectorClassificationList.at( j ).toElement();
437 if ( !currentClassificationElem.isNull() )
439 currentClassificationElem.setAttribute( QStringLiteral(
"layerId" ), currentLayerId );
444 QDomNodeList textItemList = currentLayerItemElem.elementsByTagName( QStringLiteral(
"TextItem" ) );
445 QDomElement currentTextItem;
447 for (
int j = 0; j < textItemList.size(); ++j )
449 currentTextItem = textItemList.at( j ).toElement();
450 if ( currentTextItem.isNull() )
455 QDomElement classificationElement;
456 if ( !vectorClassificationList.isEmpty() )
458 classificationElement = mDom.createElement( QStringLiteral(
"VectorClassificationItem" ) );
462 classificationElement = mDom.createElement( QStringLiteral(
"RasterClassificationItem" ) );
465 classificationElement.setAttribute( QStringLiteral(
"layerId" ), currentLayerId );
466 classificationElement.setAttribute( QStringLiteral(
"text" ), currentTextItem.attribute( QStringLiteral(
"text" ) ) );
467 currentLayerItemElem.replaceChild( classificationElement, currentTextItem );
472 void QgsProjectFileTransform::transform1800to1900()
482 QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral(
"rasterproperties" ) );
483 for (
int i = 0; i < layerItemList.size(); ++i )
485 QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement();
486 QDomNode layerNode = rasterPropertiesElem.parentNode();
487 QDomElement dataSourceElem = layerNode.firstChildElement( QStringLiteral(
"datasource" ) );
488 QDomElement layerNameElem = layerNode.firstChildElement( QStringLiteral(
"layername" ) );
492 rasterLayer.
readLayerXml( layerNode.toElement(), context );
498 QDomNodeList composerMapList = mDom.elementsByTagName( QStringLiteral(
"ComposerMap" ) );
499 for (
int i = 0; i < composerMapList.size(); ++i )
501 QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( QStringLiteral(
"Grid" ) );
502 for (
int j = 0; j < gridList.size(); ++j )
504 QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( QStringLiteral(
"Annotation" ) );
505 for (
int k = 0; k < annotationList.size(); ++k )
507 QDomElement annotationElem = annotationList.at( k ).toElement();
510 if ( annotationElem.hasAttribute( QStringLiteral(
"position" ) ) )
512 int pos = annotationElem.attribute( QStringLiteral(
"position" ) ).toInt();
513 annotationElem.setAttribute( QStringLiteral(
"leftPosition" ), pos );
514 annotationElem.setAttribute( QStringLiteral(
"rightPosition" ), pos );
515 annotationElem.setAttribute( QStringLiteral(
"topPosition" ), pos );
516 annotationElem.setAttribute( QStringLiteral(
"bottomPosition" ), pos );
517 annotationElem.removeAttribute( QStringLiteral(
"position" ) );
521 if ( annotationElem.hasAttribute( QStringLiteral(
"direction" ) ) )
523 int dir = annotationElem.attribute( QStringLiteral(
"direction" ) ).toInt();
526 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), 0 );
527 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), 0 );
528 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), 1 );
529 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), 1 );
533 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), 1 );
534 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), 1 );
535 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), 0 );
536 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), 0 );
540 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), dir );
541 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), dir );
542 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), dir );
543 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), dir );
545 annotationElem.removeAttribute( QStringLiteral(
"direction" ) );
552 QDomNodeList composerList = mDom.elementsByTagName( QStringLiteral(
"Composer" ) );
553 for (
int i = 0; i < composerList.size(); ++i )
555 QDomElement composerElem = composerList.at( i ).toElement();
558 QDomElement compositionElem = composerElem.firstChildElement( QStringLiteral(
"Composition" ) );
559 if ( compositionElem.isNull() )
564 QDomNodeList composerChildren = composerElem.childNodes();
566 if ( composerChildren.size() < 1 )
571 for (
int j = composerChildren.size() - 1; j >= 0; --j )
573 QDomElement childElem = composerChildren.at( j ).toElement();
574 if ( childElem.tagName() == QLatin1String(
"Composition" ) )
579 composerElem.removeChild( childElem );
580 compositionElem.appendChild( childElem );
588 QDomNodeList rendererList = mDom.elementsByTagName( QStringLiteral(
"renderer-v2" ) );
589 for (
int i = 0; i < rendererList.size(); ++i )
591 QDomNodeList layerList = rendererList.at( i ).toElement().elementsByTagName( QStringLiteral(
"layer" ) );
592 for (
int j = 0; j < layerList.size(); ++j )
594 QDomElement layerElem = layerList.at( j ).toElement();
595 if ( layerElem.attribute( QStringLiteral(
"class" ) ) == QLatin1String(
"SimpleFill" ) )
597 QDomNodeList propList = layerElem.elementsByTagName( QStringLiteral(
"prop" ) );
598 for (
int k = 0; k < propList.size(); ++k )
600 QDomElement propElem = propList.at( k ).toElement();
601 if ( propElem.attribute( QStringLiteral(
"k" ) ) == QLatin1String(
"color" ) || propElem.attribute( QStringLiteral(
"k" ) ) == QLatin1String(
"color_border" ) )
603 propElem.setAttribute( QStringLiteral(
"v" ), propElem.attribute( QStringLiteral(
"v" ) ).section(
',', 0, 2 ) +
",255" );
613 void QgsProjectFileTransform::transform2200to2300()
616 QDomNodeList composerPictureList = mDom.elementsByTagName( QStringLiteral(
"ComposerPicture" ) );
617 for (
int i = 0; i < composerPictureList.size(); ++i )
619 QDomElement picture = composerPictureList.at( i ).toElement();
620 picture.setAttribute( QStringLiteral(
"anchorPoint" ), QString::number( 4 ) );
624 void QgsProjectFileTransform::transform2990()
627 QDomElement propsElem = mDom.firstChildElement( QStringLiteral(
"qgis" ) ).toElement().firstChildElement( QStringLiteral(
"properties" ) );
628 if ( !propsElem.isNull() )
630 QDomNodeList srsNodes = propsElem.elementsByTagName( QStringLiteral(
"SpatialRefSys" ) );
632 QDomElement projElem;
633 if ( srsNodes.count() > 0 )
635 srsElem = srsNodes.at( 0 ).toElement();
636 QDomNodeList projNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectionsEnabled" ) );
637 if ( projNodes.count() == 0 )
639 projElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
640 projElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
641 QDomText projText = mDom.createTextNode( QStringLiteral(
"0" ) );
642 projElem.appendChild( projText );
643 srsElem.appendChild( projElem );
648 srsElem = mDom.createElement( QStringLiteral(
"SpatialRefSys" ) );
649 projElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
650 projElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
651 QDomText projText = mDom.createTextNode( QStringLiteral(
"0" ) );
652 projElem.appendChild( projText );
653 srsElem.appendChild( projElem );
654 propsElem.appendChild( srsElem );
660 QDomNodeList canvasNodes = mDom.elementsByTagName( QStringLiteral(
"mapcanvas" ) );
661 if ( canvasNodes.count() > 0 )
663 QDomElement canvasElem = canvasNodes.at( 0 ).toElement();
664 QDomNodeList canvasSrsNodes = canvasElem.elementsByTagName( QStringLiteral(
"spatialrefsys" ) );
665 if ( canvasSrsNodes.count() > 0 )
667 QDomElement canvasSrsElem = canvasSrsNodes.at( 0 ).toElement();
672 QDomNodeList proj4Nodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"proj4" ) );
673 if ( proj4Nodes.count() > 0 )
675 QDomElement proj4Node = proj4Nodes.at( 0 ).toElement();
676 proj = proj4Node.text();
678 QDomNodeList authidNodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"authid" ) );
679 if ( authidNodes.count() > 0 )
681 QDomElement authidNode = authidNodes.at( 0 ).toElement();
682 authid = authidNode.text();
684 QDomNodeList srsidNodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"srsid" ) );
685 if ( srsidNodes.count() > 0 )
687 QDomElement srsidNode = srsidNodes.at( 0 ).toElement();
688 srsid = srsidNode.text();
692 QDomNodeList oldProjectProj4Nodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCRSProj4String" ) );
693 for (
int i = oldProjectProj4Nodes.count(); i >= 0; --i )
695 srsElem.removeChild( oldProjectProj4Nodes.at( i ) );
697 QDomNodeList oldProjectCrsNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCrs" ) );
698 for (
int i = oldProjectCrsNodes.count(); i >= 0; --i )
700 srsElem.removeChild( oldProjectCrsNodes.at( i ) );
702 QDomNodeList oldProjectCrsIdNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCRSID" ) );
703 for (
int i = oldProjectCrsIdNodes.count(); i >= 0; --i )
705 srsElem.removeChild( oldProjectCrsIdNodes.at( i ) );
707 QDomNodeList projectionsEnabledNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectionsEnabled" ) );
708 for (
int i = projectionsEnabledNodes.count(); i >= 0; --i )
710 srsElem.removeChild( projectionsEnabledNodes.at( i ) );
713 QDomElement proj4Elem = mDom.createElement( QStringLiteral(
"ProjectCRSProj4String" ) );
714 proj4Elem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"QString" ) );
715 QDomText proj4Text = mDom.createTextNode( proj );
716 proj4Elem.appendChild( proj4Text );
717 QDomElement projectCrsElem = mDom.createElement( QStringLiteral(
"ProjectCrs" ) );
718 projectCrsElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"QString" ) );
719 QDomText projectCrsText = mDom.createTextNode( authid );
720 projectCrsElem.appendChild( projectCrsText );
721 QDomElement projectCrsIdElem = mDom.createElement( QStringLiteral(
"ProjectCRSID" ) );
722 projectCrsIdElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
723 QDomText srsidText = mDom.createTextNode( srsid );
724 projectCrsIdElem.appendChild( srsidText );
725 QDomElement projectionsEnabledElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
726 projectionsEnabledElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
727 QDomText projectionsEnabledText = mDom.createTextNode( QStringLiteral(
"1" ) );
728 projectionsEnabledElem.appendChild( projectionsEnabledText );
729 srsElem.appendChild( proj4Elem );
730 srsElem.appendChild( projectCrsElem );
731 srsElem.appendChild( projectCrsIdElem );
732 srsElem.appendChild( projectionsEnabledElem );
734 QDomNodeList srsNodes = propsElem.elementsByTagName( QStringLiteral(
"SpatialRefSys" ) );
735 for (
int i = srsNodes.count(); i >= 0; --i )
737 propsElem.removeChild( srsNodes.at( i ) );
739 propsElem.appendChild( srsElem );
745 QDomNodeList mapLayers = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
747 for (
int mapLayerIndex = 0; mapLayerIndex < mapLayers.count(); ++mapLayerIndex )
749 QDomElement layerElem = mapLayers.at( mapLayerIndex ).toElement();
752 QDomElement fieldConfigurationElement = mDom.createElement( QStringLiteral(
"fieldConfiguration" ) );
753 layerElem.appendChild( fieldConfigurationElement );
755 QDomNodeList editTypeNodes = layerElem.namedItem( QStringLiteral(
"edittypes" ) ).childNodes();
756 QDomElement constraintExpressionsElem = mDom.createElement( QStringLiteral(
"constraintExpressions" ) );
757 layerElem.appendChild( constraintExpressionsElem );
759 for (
int i = 0; i < editTypeNodes.size(); ++i )
761 QDomNode editTypeNode = editTypeNodes.at( i );
762 QDomElement editTypeElement = editTypeNode.toElement();
764 QDomElement fieldElement = mDom.createElement( QStringLiteral(
"field" ) );
765 fieldConfigurationElement.appendChild( fieldElement );
767 QString name = editTypeElement.attribute( QStringLiteral(
"name" ) );
768 fieldElement.setAttribute( QStringLiteral(
"name" ), name );
769 QDomElement constraintExpressionElem = mDom.createElement( QStringLiteral(
"constraint" ) );
770 constraintExpressionElem.setAttribute( QStringLiteral(
"field" ), name );
771 constraintExpressionsElem.appendChild( constraintExpressionElem );
773 QDomElement editWidgetElement = mDom.createElement( QStringLiteral(
"editWidget" ) );
774 fieldElement.appendChild( editWidgetElement );
776 QString ewv2Type = editTypeElement.attribute( QStringLiteral(
"widgetv2type" ) );
777 editWidgetElement.setAttribute( QStringLiteral(
"type" ), ewv2Type );
779 QDomElement ewv2CfgElem = editTypeElement.namedItem( QStringLiteral(
"widgetv2config" ) ).toElement();
781 if ( !ewv2CfgElem.isNull() )
783 QDomElement editWidgetConfigElement = mDom.createElement( QStringLiteral(
"config" ) );
784 editWidgetElement.appendChild( editWidgetConfigElement );
786 QVariantMap editWidgetConfiguration;
788 QDomNamedNodeMap configAttrs = ewv2CfgElem.attributes();
789 for (
int configIndex = 0; configIndex < configAttrs.count(); ++configIndex )
791 QDomAttr configAttr = configAttrs.item( configIndex ).toAttr();
792 if ( configAttr.name() == QStringLiteral(
"fieldEditable" ) )
794 editWidgetConfigElement.setAttribute( QStringLiteral(
"fieldEditable" ), configAttr.value() );
796 else if ( configAttr.name() == QStringLiteral(
"labelOnTop" ) )
798 editWidgetConfigElement.setAttribute( QStringLiteral(
"labelOnTop" ), configAttr.value() );
800 else if ( configAttr.name() == QStringLiteral(
"notNull" ) )
802 editWidgetConfigElement.setAttribute( QStringLiteral(
"notNull" ), configAttr.value() );
804 else if ( configAttr.name() == QStringLiteral(
"constraint" ) )
806 constraintExpressionElem.setAttribute( QStringLiteral(
"exp" ), configAttr.value() );
808 else if ( configAttr.name() == QStringLiteral(
"constraintDescription" ) )
810 constraintExpressionElem.setAttribute( QStringLiteral(
"desc" ), configAttr.value() );
814 editWidgetConfiguration.insert( configAttr.name(), configAttr.value() );
818 if ( ewv2Type == QStringLiteral(
"ValueMap" ) )
820 QDomNodeList configElements = ewv2CfgElem.childNodes();
822 for (
int configIndex = 0; configIndex < configElements.count(); ++configIndex )
824 QDomElement configElem = configElements.at( configIndex ).toElement();
825 map.insert( configElem.attribute( QStringLiteral(
"key" ) ), configElem.attribute( QStringLiteral(
"value" ) ) );
827 editWidgetConfiguration.insert( QStringLiteral(
"map" ), map );
829 else if ( ewv2Type == QStringLiteral(
"Photo" ) )
831 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
833 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewer" ), 1 );
834 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral(
"Height" ) ) );
835 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral(
"Width" ) ) );
836 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
838 else if ( ewv2Type == QStringLiteral(
"FileName" ) )
840 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
842 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
844 else if ( ewv2Type == QStringLiteral(
"WebView" ) )
846 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
848 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral(
"Height" ) ) );
849 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral(
"Width" ) ) );
850 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
864 QDomNode noDataNode = rasterPropertiesElem.namedItem( QStringLiteral(
"mNoDataValue" ) );
865 QDomElement noDataElement = noDataNode.toElement();
866 if ( !noDataElement.text().isEmpty() )
868 QgsDebugMsg(
"mNoDataValue = " + noDataElement.text() );
869 QDomElement noDataElem = doc.createElement( QStringLiteral(
"noData" ) );
871 QDomElement noDataRangeList = doc.createElement( QStringLiteral(
"noDataRangeList" ) );
872 noDataRangeList.setAttribute( QStringLiteral(
"bandNo" ), 1 );
874 QDomElement noDataRange = doc.createElement( QStringLiteral(
"noDataRange" ) );
875 noDataRange.setAttribute( QStringLiteral(
"min" ), noDataElement.text() );
876 noDataRange.setAttribute( QStringLiteral(
"max" ), noDataElement.text() );
877 noDataRangeList.appendChild( noDataRange );
879 noDataElem.appendChild( noDataRangeList );
881 parentNode.appendChild( noDataElem );
884 QDomElement rasterRendererElem = doc.createElement( QStringLiteral(
"rasterrenderer" ) );
888 rasterRendererElem.setAttribute( QStringLiteral(
"invertColor" ), QStringLiteral(
"0" ) );
889 QDomElement invertColorElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mInvertColor" ) );
890 if ( !invertColorElem.isNull() )
892 if ( invertColorElem.text() == QLatin1String(
"true" ) )
894 rasterRendererElem.setAttribute( QStringLiteral(
"invertColor" ), QStringLiteral(
"1" ) );
899 rasterRendererElem.setAttribute( QStringLiteral(
"opacity" ), QStringLiteral(
"1" ) );
900 QDomElement transparencyElem = parentNode.firstChildElement( QStringLiteral(
"transparencyLevelInt" ) );
901 if ( !transparencyElem.isNull() )
903 double transparency = transparencyElem.text().toInt();
904 rasterRendererElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( transparency / 255.0 ) );
908 rasterRendererElem.setAttribute( QStringLiteral(
"alphaBand" ), -1 );
911 int grayBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mGrayBandName" ), rlayer );
914 QString drawingStyle = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mDrawingStyle" ) ).text();
921 if ( drawingStyle == QLatin1String(
"PalettedColor" ) )
923 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
924 QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
926 for (
int i = 0; i < colorRampEntryList.size(); ++i )
928 QDomElement colorRampEntryElem = colorRampEntryList.at( i ).toElement();
929 QString strValue = colorRampEntryElem.attribute( QStringLiteral(
"value" ) );
930 double value = strValue.toDouble();
931 if ( value < 0 || value > 10000 || !
qgsDoubleNear( value, static_cast< int >( value ) ) )
933 QgsDebugMsg( QString(
"forcing SingleBandPseudoColor value = %1" ).arg( value ) );
934 drawingStyle = QStringLiteral(
"SingleBandPseudoColor" );
940 if ( drawingStyle == QLatin1String(
"SingleBandGray" ) )
942 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"singlebandgray" ) );
943 rasterRendererElem.setAttribute( QStringLiteral(
"grayBand" ), grayBand );
944 transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
946 else if ( drawingStyle == QLatin1String(
"SingleBandPseudoColor" ) )
948 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"singlebandpseudocolor" ) );
949 rasterRendererElem.setAttribute( QStringLiteral(
"band" ), grayBand );
950 QDomElement newRasterShaderElem = doc.createElement( QStringLiteral(
"rastershader" ) );
951 QDomElement newColorRampShaderElem = doc.createElement( QStringLiteral(
"colorrampshader" ) );
952 newRasterShaderElem.appendChild( newColorRampShaderElem );
953 rasterRendererElem.appendChild( newRasterShaderElem );
956 QString colorShadingAlgorithm = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mColorShadingAlgorithm" ) ).text();
957 if ( colorShadingAlgorithm == QLatin1String(
"PseudoColorShader" ) || colorShadingAlgorithm == QLatin1String(
"FreakOutShader" ) )
959 newColorRampShaderElem.setAttribute( QStringLiteral(
"colorRampType" ), QStringLiteral(
"INTERPOLATED" ) );
965 double breakSize = ( maxValue - minValue ) / 3;
967 QStringList colorList;
968 if ( colorShadingAlgorithm == QLatin1String(
"FreakOutShader" ) )
970 colorList << QStringLiteral(
"#ff00ff" ) << QStringLiteral(
"#00ffff" ) << QStringLiteral(
"#ff0000" ) << QStringLiteral(
"#00ff00" );
974 colorList << QStringLiteral(
"#0000ff" ) << QStringLiteral(
"#00ffff" ) << QStringLiteral(
"#ffff00" ) << QStringLiteral(
"#ff0000" );
976 QStringList::const_iterator colorIt = colorList.constBegin();
977 double boundValue = minValue;
978 for ( ; colorIt != colorList.constEnd(); ++colorIt )
980 QDomElement newItemElem = doc.createElement( QStringLiteral(
"item" ) );
981 newItemElem.setAttribute( QStringLiteral(
"value" ), QString::number( boundValue ) );
982 newItemElem.setAttribute( QStringLiteral(
"label" ), QString::number( boundValue ) );
983 newItemElem.setAttribute( QStringLiteral(
"color" ), *colorIt );
984 newColorRampShaderElem.appendChild( newItemElem );
985 boundValue += breakSize;
988 else if ( colorShadingAlgorithm == QLatin1String(
"ColorRampShader" ) )
990 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
991 QString type = customColorRampElem.firstChildElement( QStringLiteral(
"colorRampType" ) ).text();
992 newColorRampShaderElem.setAttribute( QStringLiteral(
"colorRampType" ), type );
993 QDomNodeList colorNodeList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
995 QString value, label;
997 int red, green, blue;
998 QDomElement currentItemElem;
999 for (
int i = 0; i < colorNodeList.size(); ++i )
1001 currentItemElem = colorNodeList.at( i ).toElement();
1002 value = currentItemElem.attribute( QStringLiteral(
"value" ) );
1003 label = currentItemElem.attribute( QStringLiteral(
"label" ) );
1004 red = currentItemElem.attribute( QStringLiteral(
"red" ) ).toInt();
1005 green = currentItemElem.attribute( QStringLiteral(
"green" ) ).toInt();
1006 blue = currentItemElem.attribute( QStringLiteral(
"blue" ) ).toInt();
1007 newColor = QColor( red, green, blue );
1008 QDomElement newItemElem = doc.createElement( QStringLiteral(
"item" ) );
1009 newItemElem.setAttribute( QStringLiteral(
"value" ), value );
1010 newItemElem.setAttribute( QStringLiteral(
"label" ), label );
1011 newItemElem.setAttribute( QStringLiteral(
"color" ), newColor.name() );
1012 newColorRampShaderElem.appendChild( newItemElem );
1016 else if ( drawingStyle == QLatin1String(
"PalettedColor" ) )
1018 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"paletted" ) );
1019 rasterRendererElem.setAttribute( QStringLiteral(
"band" ), grayBand );
1020 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
1021 QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
1022 QDomElement newColorPaletteElem = doc.createElement( QStringLiteral(
"colorPalette" ) );
1028 QDomElement colorRampEntryElem;
1029 for (
int i = 0; i < colorRampEntryList.size(); ++i )
1031 colorRampEntryElem = colorRampEntryList.at( i ).toElement();
1032 QDomElement newPaletteElem = doc.createElement( QStringLiteral(
"paletteEntry" ) );
1033 value =
static_cast< int >( colorRampEntryElem.attribute( QStringLiteral(
"value" ) ).toDouble() );
1034 newPaletteElem.setAttribute( QStringLiteral(
"value" ), value );
1035 red = colorRampEntryElem.attribute( QStringLiteral(
"red" ) ).toInt();
1036 green = colorRampEntryElem.attribute( QStringLiteral(
"green" ) ).toInt();
1037 blue = colorRampEntryElem.attribute( QStringLiteral(
"blue" ) ).toInt();
1038 newPaletteElem.setAttribute( QStringLiteral(
"color" ), QColor( red, green, blue ).name() );
1039 QString label = colorRampEntryElem.attribute( QStringLiteral(
"label" ) );
1040 if ( !label.isEmpty() )
1042 newPaletteElem.setAttribute( QStringLiteral(
"label" ), label );
1044 newColorPaletteElem.appendChild( newPaletteElem );
1046 rasterRendererElem.appendChild( newColorPaletteElem );
1048 else if ( drawingStyle == QLatin1String(
"MultiBandColor" ) )
1050 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"multibandcolor" ) );
1053 int redBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mRedBandName" ), rlayer );
1054 int greenBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mGreenBandName" ), rlayer );
1055 int blueBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mBlueBandName" ), rlayer );
1056 rasterRendererElem.setAttribute( QStringLiteral(
"redBand" ), redBand );
1057 rasterRendererElem.setAttribute( QStringLiteral(
"greenBand" ), greenBand );
1058 rasterRendererElem.setAttribute( QStringLiteral(
"blueBand" ), blueBand );
1060 transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
1068 if ( !parentNode.isNull() )
1070 parentNode.replaceChild( rasterRendererElem, rasterPropertiesElem );
1074 int QgsProjectFileTransform::rasterBandNumber(
const QDomElement &rasterPropertiesElem,
const QString &bandName,
1083 QDomElement rasterBandElem = rasterPropertiesElem.firstChildElement( bandName );
1084 if ( !rasterBandElem.isNull() )
1086 QRegExp re(
"(\\d+)" );
1088 if ( re.indexIn( rasterBandElem.text() ) >= 0 )
1090 return re.cap( 1 ).toInt();
1096 void QgsProjectFileTransform::transformContrastEnhancement( QDomDocument &doc,
const QDomElement &rasterproperties, QDomElement &rendererElem )
1098 if ( rasterproperties.isNull() || rendererElem.isNull() )
1103 double minimumValue = 0;
1104 double maximumValue = 0;
1105 QDomElement contrastMinMaxElem = rasterproperties.firstChildElement( QStringLiteral(
"contrastEnhancementMinMaxValues" ) );
1106 if ( contrastMinMaxElem.isNull() )
1111 QDomElement contrastEnhancementAlgorithmElem = rasterproperties.firstChildElement( QStringLiteral(
"mContrastEnhancementAlgorithm" ) );
1112 if ( contrastEnhancementAlgorithmElem.isNull() )
1118 int algorithmEnum = 0;
1119 QString algorithmString = contrastEnhancementAlgorithmElem.text();
1120 if ( algorithmString == QLatin1String(
"StretchToMinimumMaximum" ) )
1124 else if ( algorithmString == QLatin1String(
"StretchAndClipToMinimumMaximum" ) )
1128 else if ( algorithmString == QLatin1String(
"ClipToMinimumMaximum" ) )
1132 else if ( algorithmString == QLatin1String(
"UserDefinedEnhancement" ) )
1137 QDomNodeList minMaxEntryList = contrastMinMaxElem.elementsByTagName( QStringLiteral(
"minMaxEntry" ) );
1138 QStringList enhancementNameList;
1139 if ( minMaxEntryList.size() == 1 )
1141 enhancementNameList << QStringLiteral(
"contrastEnhancement" );
1143 if ( minMaxEntryList.size() == 3 )
1145 enhancementNameList << QStringLiteral(
"redContrastEnhancement" ) << QStringLiteral(
"greenContrastEnhancement" ) << QStringLiteral(
"blueContrastEnhancement" );
1147 if ( minMaxEntryList.size() > enhancementNameList.size() )
1152 QDomElement minMaxEntryElem;
1153 for (
int i = 0; i < minMaxEntryList.size(); ++i )
1155 minMaxEntryElem = minMaxEntryList.at( i ).toElement();
1156 QDomElement minElem = minMaxEntryElem.firstChildElement( QStringLiteral(
"min" ) );
1157 if ( minElem.isNull() )
1161 minimumValue = minElem.text().toDouble();
1163 QDomElement maxElem = minMaxEntryElem.firstChildElement( QStringLiteral(
"max" ) );
1164 if ( maxElem.isNull() )
1168 maximumValue = maxElem.text().toDouble();
1170 QDomElement newContrastEnhancementElem = doc.createElement( enhancementNameList.at( i ) );
1171 QDomElement newMinValElem = doc.createElement( QStringLiteral(
"minValue" ) );
1172 QDomText minText = doc.createTextNode( QString::number( minimumValue ) );
1173 newMinValElem.appendChild( minText );
1174 newContrastEnhancementElem.appendChild( newMinValElem );
1175 QDomElement newMaxValElem = doc.createElement( QStringLiteral(
"maxValue" ) );
1176 QDomText maxText = doc.createTextNode( QString::number( maximumValue ) );
1177 newMaxValElem.appendChild( maxText );
1178 newContrastEnhancementElem.appendChild( newMaxValElem );
1180 QDomElement newAlgorithmElem = doc.createElement( QStringLiteral(
"algorithm" ) );
1181 QDomText newAlgorithmText = doc.createTextNode( QString::number( algorithmEnum ) );
1182 newAlgorithmElem.appendChild( newAlgorithmText );
1183 newContrastEnhancementElem.appendChild( newAlgorithmElem );
1185 rendererElem.appendChild( newContrastEnhancementElem );
1189 void QgsProjectFileTransform::transformRasterTransparency( QDomDocument &doc,
const QDomElement &orig, QDomElement &rendererElem )
1194 Q_UNUSED( rendererElem );
The class is used as a container of context for various read/write operations on other objects...
bool loadDefaultStyle
Sets to true if the default layer style should be loaded.
void setPathResolver(const QgsPathResolver &resolver)
Sets up path resolver for conversion between relative and absolute paths.
Setting options for loading vector layers.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double maximumValue
The maximum cell value in the raster band.
Container of fields for a vector layer.
bool readLayerXml(const QDomElement &layerElement, QgsReadWriteContext &context)
Sets state from Dom document.
bool isValid() const
Returns the status of the layer.
bool isNull() const
Returns true if this is a NULL project version.
int count() const
Returns number of items.
Project property value node, contains a QgsProjectPropertyKey's value.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
The RasterBandStats struct is a container for statistics about a single raster band.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
A class to describe the version of a project.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
bool writeXml(const QString &nodeName, QDomElement &element, QDomDocument &document) override
Writes the property hierarchy to a specified DOM element.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsVectorDataProvider * dataProvider() override
Returns the layer's data provider.
double minimumValue
The minimum cell value in the raster band.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.