26 #include <QTextStream> 27 #include <QDomDocument> 42 QgsProjectFileTransform::TransformItem QgsProjectFileTransform::sTransformers[] =
44 {
PFV( 0, 8, 0 ),
PFV( 0, 8, 1 ), &QgsProjectFileTransform::transformNull},
45 {
PFV( 0, 8, 1 ),
PFV( 0, 9, 0 ), &QgsProjectFileTransform::transform081to090},
46 {
PFV( 0, 9, 0 ),
PFV( 0, 9, 1 ), &QgsProjectFileTransform::transformNull},
47 {
PFV( 0, 9, 1 ),
PFV( 0, 10, 0 ), &QgsProjectFileTransform::transform091to0100},
50 {
PFV( 0, 9, 2 ),
PFV( 0, 11, 0 ), &QgsProjectFileTransform::transformNull},
51 {
PFV( 0, 10, 0 ),
PFV( 0, 11, 0 ), &QgsProjectFileTransform::transform0100to0110},
52 {
PFV( 0, 11, 0 ),
PFV( 1, 0, 0 ), &QgsProjectFileTransform::transform0110to1000},
53 {
PFV( 1, 0, 0 ),
PFV( 1, 1, 0 ), &QgsProjectFileTransform::transformNull},
54 {
PFV( 1, 0, 2 ),
PFV( 1, 1, 0 ), &QgsProjectFileTransform::transformNull},
55 {
PFV( 1, 1, 0 ),
PFV( 1, 2, 0 ), &QgsProjectFileTransform::transform1100to1200},
56 {
PFV( 1, 2, 0 ),
PFV( 1, 3, 0 ), &QgsProjectFileTransform::transformNull},
57 {
PFV( 1, 3, 0 ),
PFV( 1, 4, 0 ), &QgsProjectFileTransform::transformNull},
58 {
PFV( 1, 4, 0 ),
PFV( 1, 5, 0 ), &QgsProjectFileTransform::transform1400to1500},
59 {
PFV( 1, 5, 0 ),
PFV( 1, 6, 0 ), &QgsProjectFileTransform::transformNull},
60 {
PFV( 1, 6, 0 ),
PFV( 1, 7, 0 ), &QgsProjectFileTransform::transformNull},
61 {
PFV( 1, 7, 0 ),
PFV( 1, 8, 0 ), &QgsProjectFileTransform::transformNull},
62 {
PFV( 1, 8, 0 ),
PFV( 1, 9, 0 ), &QgsProjectFileTransform::transform1800to1900},
63 {
PFV( 1, 9, 0 ),
PFV( 2, 0, 0 ), &QgsProjectFileTransform::transformNull},
64 {
PFV( 2, 0, 0 ),
PFV( 2, 1, 0 ), &QgsProjectFileTransform::transformNull},
65 {
PFV( 2, 1, 0 ),
PFV( 2, 2, 0 ), &QgsProjectFileTransform::transformNull},
66 {
PFV( 2, 2, 0 ),
PFV( 2, 3, 0 ), &QgsProjectFileTransform::transform2200to2300},
70 {
PFV(),
PFV( 3, 0, 0 ), &QgsProjectFileTransform::transform3000},
75 Q_UNUSED( newVersion )
76 bool returnValue =
false;
80 for ( std::size_t i = 0; i <
sizeof( sTransformers ) /
sizeof( TransformItem ); i++ )
82 const TransformItem &transformer = sTransformers[i];
83 if ( transformer.to >= mCurrentVersion && ( transformer.from == mCurrentVersion || transformer.from.
isNull() ) )
86 ( this->*( transformer.transformFunc ) )();
87 mCurrentVersion = transformer.to;
97 QgsDebugMsg( QStringLiteral(
"Current project file version is %1.%2.%3" )
103 std::cout << mDom.toString( 2 ).toLatin1().constData();
111 void QgsProjectFileTransform::transform081to090()
114 if ( ! mDom.isNull() )
118 QDomElement mapCanvas;
121 QDomNode qgis = mDom.firstChildElement( QStringLiteral(
"qgis" ) );
122 if ( ! qgis.isNull() )
124 QgsDebugMsg( QStringLiteral(
"Populating new mapcanvas" ) );
127 mapCanvas = mDom.createElement( QStringLiteral(
"mapcanvas" ) );
129 qgis.appendChild( mapCanvas );
131 mapCanvas.appendChild( qgis.namedItem( QStringLiteral(
"units" ) ) );
133 mapCanvas.appendChild( qgis.namedItem( QStringLiteral(
"extent" ) ) );
137 QDomElement properties = qgis.firstChildElement( QStringLiteral(
"properties" ) );
138 QDomElement spatial = properties.firstChildElement( QStringLiteral(
"SpatialRefSys" ) );
139 QDomElement hasCrsTransformEnabled = spatial.firstChildElement( QStringLiteral(
"ProjectionsEnabled" ) );
142 QDomElement projection = mDom.createElement( QStringLiteral(
"projections" ) );
143 QgsDebugMsg( QStringLiteral(
"Projection flag: " ) + hasCrsTransformEnabled.text() );
145 projection.appendChild( mDom.createTextNode( hasCrsTransformEnabled.text() ) );
147 mapCanvas.appendChild( projection );
154 QDomNodeList mapLayers = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
155 bool doneDestination =
false;
156 for (
int i = 0; i < mapLayers.count(); i++ )
158 QDomNode mapLayer = mapLayers.item( i );
160 QDomNode coordinateTransform = mapLayer.namedItem( QStringLiteral(
"coordinatetransform" ) );
162 QDomNode sourceCrs = coordinateTransform.namedItem( QStringLiteral(
"sourcesrs" ) );
164 sourceCrs.toElement().setTagName( QStringLiteral(
"srs" ) );
166 mapLayer.appendChild( sourceCrs );
169 if ( ! doneDestination )
172 QDomNode destinationCRS = coordinateTransform.namedItem( QStringLiteral(
"destinationsrs" ) );
175 mapCanvas.appendChild( destinationCRS );
177 doneDestination =
true;
179 mapLayer.removeChild( coordinateTransform );
186 QDomNodeList legendLayerFiles = mDom.elementsByTagName( QStringLiteral(
"legendlayerfile" ) );
187 QgsDebugMsg( QStringLiteral(
"Legend layer file entries: " ) + QString::number( legendLayerFiles.count() ) );
188 for (
int i = 0; i < mapLayers.count(); i++ )
191 QDomElement mapLayer = mapLayers.item( i ).toElement();
193 QString
id = mapLayer.firstChildElement( QStringLiteral(
"id" ) ).text();
194 QgsDebugMsg( QStringLiteral(
"Handling layer %1" ).arg(
id ) );
196 for (
int j = 0; j < legendLayerFiles.count(); j++ )
198 QDomElement legendLayerFile = legendLayerFiles.item( j ).toElement();
199 if (
id == legendLayerFile.attribute( QStringLiteral(
"layerid" ) ) )
202 QgsDebugMsg( QStringLiteral(
"Found matching id" ) );
205 legendLayerFile.setAttribute( QStringLiteral(
"visible" ), mapLayer.attribute( QStringLiteral(
"visible" ) ) );
208 legendLayerFile.setAttribute( QStringLiteral(
"isInOverview" ), mapLayer.attribute( QStringLiteral(
"showInOverviewFlag" ) ) );
215 void QgsProjectFileTransform::transform091to0100()
217 if ( ! mDom.isNull() )
220 QDomNodeList rasterPropertyList = mDom.elementsByTagName( QStringLiteral(
"rasterproperties" ) );
221 QgsDebugMsg( QStringLiteral(
"Raster properties file entries: " ) + QString::number( rasterPropertyList.count() ) );
222 for (
int i = 0; i < rasterPropertyList.count(); i++ )
225 QDomNode rasterProperty = rasterPropertyList.item( i );
228 rasterProperty.namedItem( QStringLiteral(
"stdDevsToPlotDouble" ) ).toElement().setTagName( QStringLiteral(
"mStandardDeviations" ) );
230 rasterProperty.namedItem( QStringLiteral(
"invertHistogramFlag" ) ).toElement().setTagName( QStringLiteral(
"mInvertPixelsFlag" ) );
231 rasterProperty.namedItem( QStringLiteral(
"showDebugOverLayFlag" ) ).toElement().setTagName( QStringLiteral(
"mDebugOverLayFlag" ) );
233 rasterProperty.namedItem( QStringLiteral(
"redBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mRedBandName" ) );
234 rasterProperty.namedItem( QStringLiteral(
"blueBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mBlueBandName" ) );
235 rasterProperty.namedItem( QStringLiteral(
"greenBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mGreenBandName" ) );
236 rasterProperty.namedItem( QStringLiteral(
"grayBandNameQString" ) ).toElement().setTagName( QStringLiteral(
"mGrayBandName" ) );
240 QDomNodeList symbolPropertyList = mDom.elementsByTagName( QStringLiteral(
"symbol" ) );
241 for (
int i = 0; i < symbolPropertyList.count(); i++ )
244 QDomNode symbolProperty = symbolPropertyList.item( i );
246 QDomElement pointSymbol = symbolProperty.firstChildElement( QStringLiteral(
"pointsymbol" ) );
247 if ( pointSymbol.text().startsWith( QLatin1String(
"hard:" ) ) )
250 int lineWidth = symbolProperty.firstChildElement( QStringLiteral(
"outlinewidth" ) ).text().toInt();
251 int pointSize = symbolProperty.firstChildElement( QStringLiteral(
"pointsize" ) ).text().toInt();
253 if ( pointSize != 0 )
258 pointSize = pointSize + 2 + 2 * lineWidth;
259 QgsDebugMsg( QStringLiteral(
"Setting point size to %1" ).arg( pointSize ) );
260 QDomElement newPointSizeProperty = mDom.createElement( QStringLiteral(
"pointsize" ) );
261 QDomText newPointSizeTxt = mDom.createTextNode( QString::number( pointSize ) );
262 newPointSizeProperty.appendChild( newPointSizeTxt );
263 symbolProperty.replaceChild( newPointSizeProperty, pointSymbol );
271 void QgsProjectFileTransform::transform0100to0110()
273 if ( ! mDom.isNull() )
275 #ifndef QT_NO_PRINTER 277 QPrinter myPrinter( QPrinter::ScreenResolution );
278 int screenDpi = myPrinter.resolution();
279 double widthScaleFactor = 25.4 / screenDpi;
281 QDomNodeList outlineWidthList = mDom.elementsByTagName( QStringLiteral(
"outlinewidth" ) );
282 for (
int i = 0; i < outlineWidthList.size(); ++i )
285 QDomElement currentOutlineElem = outlineWidthList.at( i ).toElement();
286 double outlineWidth = currentOutlineElem.text().toDouble();
287 outlineWidth *= widthScaleFactor;
290 QDomNode outlineTextNode = currentOutlineElem.firstChild();
291 QDomText newOutlineText = mDom.createTextNode( QString::number( outlineWidth ) );
292 currentOutlineElem.replaceChild( newOutlineText, outlineTextNode );
297 QDomNodeList pointSizeList = mDom.elementsByTagName( QStringLiteral(
"pointsize" ) );
298 for (
int i = 0; i < pointSizeList.size(); ++i )
301 QDomElement currentPointSizeElem = pointSizeList.at( i ).toElement();
302 double pointSize = currentPointSizeElem.text().toDouble();
303 pointSize *= widthScaleFactor;
306 QDomNode pointSizeTextNode = currentPointSizeElem.firstChild();
307 QDomText newPointSizeText = mDom.createTextNode( QString::number( static_cast< int >( pointSize ) ) );
308 currentPointSizeElem.replaceChild( newPointSizeText, pointSizeTextNode );
314 void QgsProjectFileTransform::transform0110to1000()
316 if ( ! mDom.isNull() )
318 QDomNodeList layerList = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
319 for (
int i = 0; i < layerList.size(); ++i )
321 QDomElement layerElem = layerList.at( i ).toElement();
322 QString typeString = layerElem.attribute( QStringLiteral(
"type" ) );
323 if ( typeString != QLatin1String(
"vector" ) )
329 QDomNode dataSourceNode = layerElem.namedItem( QStringLiteral(
"datasource" ) );
330 if ( dataSourceNode.isNull() )
334 QString dataSource = dataSourceNode.toElement().text();
337 QDomNode providerNode = layerElem.namedItem( QStringLiteral(
"provider" ) );
338 if ( providerNode.isNull() )
342 QString providerKey = providerNode.toElement().text();
346 options.loadDefaultStyle =
false;
362 QDomNodeList classificationFieldList = layerElem.elementsByTagName( QStringLiteral(
"classificationfield" ) );
363 for (
int j = 0; j < classificationFieldList.size(); ++j )
365 QDomElement classificationFieldElem = classificationFieldList.
at( j ).toElement();
366 int fieldNumber = classificationFieldElem.text().toInt();
367 if ( fieldNumber >= 0 && fieldNumber < fields.
count() )
369 QDomText fieldName = mDom.createTextNode( fields.
at( fieldNumber ).
name() );
370 QDomNode nameNode = classificationFieldElem.firstChild();
371 classificationFieldElem.replaceChild( fieldName, nameNode );
379 void QgsProjectFileTransform::transform1100to1200()
385 QDomNode qgis = mDom.firstChildElement( QStringLiteral(
"qgis" ) );
389 QDomElement properties = qgis.firstChildElement( QStringLiteral(
"properties" ) );
390 if ( properties.isNull() )
393 QDomElement digitizing = properties.firstChildElement( QStringLiteral(
"Digitizing" ) );
394 if ( digitizing.isNull() )
397 QDomElement tolList = digitizing.firstChildElement( QStringLiteral(
"LayerSnappingToleranceList" ) );
398 if ( tolList.isNull() )
401 QDomElement tolUnitList = digitizing.firstChildElement( QStringLiteral(
"LayerSnappingToleranceUnitList" ) );
402 if ( !tolUnitList.isNull() )
406 for (
int i = 0; i < tolList.childNodes().count(); i++ )
407 units << QStringLiteral(
"0" );
410 value.
writeXml( QStringLiteral(
"LayerSnappingToleranceUnitList" ), digitizing, mDom );
413 void QgsProjectFileTransform::transform1400to1500()
421 QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral(
"LayerItem" ) );
422 QDomElement currentLayerItemElem;
423 QString currentLayerId;
425 for (
int i = 0; i < layerItemList.size(); ++i )
427 currentLayerItemElem = layerItemList.at( i ).toElement();
428 if ( currentLayerItemElem.isNull() )
432 currentLayerId = currentLayerItemElem.attribute( QStringLiteral(
"layerId" ) );
434 QDomNodeList vectorClassificationList = currentLayerItemElem.elementsByTagName( QStringLiteral(
"VectorClassificationItem" ) );
435 QDomElement currentClassificationElem;
436 for (
int j = 0; j < vectorClassificationList.size(); ++j )
438 currentClassificationElem = vectorClassificationList.at( j ).toElement();
439 if ( !currentClassificationElem.isNull() )
441 currentClassificationElem.setAttribute( QStringLiteral(
"layerId" ), currentLayerId );
446 QDomNodeList textItemList = currentLayerItemElem.elementsByTagName( QStringLiteral(
"TextItem" ) );
447 QDomElement currentTextItem;
449 for (
int j = 0; j < textItemList.size(); ++j )
451 currentTextItem = textItemList.at( j ).toElement();
452 if ( currentTextItem.isNull() )
457 QDomElement classificationElement;
458 if ( !vectorClassificationList.isEmpty() )
460 classificationElement = mDom.createElement( QStringLiteral(
"VectorClassificationItem" ) );
464 classificationElement = mDom.createElement( QStringLiteral(
"RasterClassificationItem" ) );
467 classificationElement.setAttribute( QStringLiteral(
"layerId" ), currentLayerId );
468 classificationElement.setAttribute( QStringLiteral(
"text" ), currentTextItem.attribute( QStringLiteral(
"text" ) ) );
469 currentLayerItemElem.replaceChild( classificationElement, currentTextItem );
474 void QgsProjectFileTransform::transform1800to1900()
484 QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral(
"rasterproperties" ) );
485 for (
int i = 0; i < layerItemList.size(); ++i )
487 QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement();
488 QDomNode layerNode = rasterPropertiesElem.parentNode();
489 QDomElement dataSourceElem = layerNode.firstChildElement( QStringLiteral(
"datasource" ) );
490 QDomElement layerNameElem = layerNode.firstChildElement( QStringLiteral(
"layername" ) );
494 rasterLayer.
readLayerXml( layerNode.toElement(), context );
500 QDomNodeList composerMapList = mDom.elementsByTagName( QStringLiteral(
"ComposerMap" ) );
501 for (
int i = 0; i < composerMapList.size(); ++i )
503 QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( QStringLiteral(
"Grid" ) );
504 for (
int j = 0; j < gridList.size(); ++j )
506 QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( QStringLiteral(
"Annotation" ) );
507 for (
int k = 0; k < annotationList.size(); ++k )
509 QDomElement annotationElem = annotationList.at( k ).toElement();
512 if ( annotationElem.hasAttribute( QStringLiteral(
"position" ) ) )
514 int pos = annotationElem.attribute( QStringLiteral(
"position" ) ).toInt();
515 annotationElem.setAttribute( QStringLiteral(
"leftPosition" ), pos );
516 annotationElem.setAttribute( QStringLiteral(
"rightPosition" ), pos );
517 annotationElem.setAttribute( QStringLiteral(
"topPosition" ), pos );
518 annotationElem.setAttribute( QStringLiteral(
"bottomPosition" ), pos );
519 annotationElem.removeAttribute( QStringLiteral(
"position" ) );
523 if ( annotationElem.hasAttribute( QStringLiteral(
"direction" ) ) )
525 int dir = annotationElem.attribute( QStringLiteral(
"direction" ) ).toInt();
528 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), 0 );
529 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), 0 );
530 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), 1 );
531 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), 1 );
535 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), 1 );
536 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), 1 );
537 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), 0 );
538 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), 0 );
542 annotationElem.setAttribute( QStringLiteral(
"leftDirection" ), dir );
543 annotationElem.setAttribute( QStringLiteral(
"rightDirection" ), dir );
544 annotationElem.setAttribute( QStringLiteral(
"topDirection" ), dir );
545 annotationElem.setAttribute( QStringLiteral(
"bottomDirection" ), dir );
547 annotationElem.removeAttribute( QStringLiteral(
"direction" ) );
554 QDomNodeList composerList = mDom.elementsByTagName( QStringLiteral(
"Composer" ) );
555 for (
int i = 0; i < composerList.size(); ++i )
557 QDomElement composerElem = composerList.at( i ).toElement();
560 QDomElement compositionElem = composerElem.firstChildElement( QStringLiteral(
"Composition" ) );
561 if ( compositionElem.isNull() )
566 QDomNodeList composerChildren = composerElem.childNodes();
568 if ( composerChildren.size() < 1 )
573 for (
int j = composerChildren.size() - 1; j >= 0; --j )
575 QDomElement childElem = composerChildren.at( j ).toElement();
576 if ( childElem.tagName() == QLatin1String(
"Composition" ) )
581 composerElem.removeChild( childElem );
582 compositionElem.appendChild( childElem );
590 QDomNodeList rendererList = mDom.elementsByTagName( QStringLiteral(
"renderer-v2" ) );
591 for (
int i = 0; i < rendererList.size(); ++i )
593 QDomNodeList layerList = rendererList.at( i ).toElement().elementsByTagName( QStringLiteral(
"layer" ) );
594 for (
int j = 0; j < layerList.size(); ++j )
596 QDomElement layerElem = layerList.at( j ).toElement();
597 if ( layerElem.attribute( QStringLiteral(
"class" ) ) == QLatin1String(
"SimpleFill" ) )
599 QDomNodeList propList = layerElem.elementsByTagName( QStringLiteral(
"prop" ) );
600 for (
int k = 0; k < propList.size(); ++k )
602 QDomElement propElem = propList.at( k ).toElement();
603 if ( propElem.attribute( QStringLiteral(
"k" ) ) == QLatin1String(
"color" ) || propElem.attribute( QStringLiteral(
"k" ) ) == QLatin1String(
"color_border" ) )
605 propElem.setAttribute( QStringLiteral(
"v" ), propElem.attribute( QStringLiteral(
"v" ) ).section(
',', 0, 2 ) +
",255" );
615 void QgsProjectFileTransform::transform2200to2300()
618 QDomNodeList composerPictureList = mDom.elementsByTagName( QStringLiteral(
"ComposerPicture" ) );
619 for (
int i = 0; i < composerPictureList.size(); ++i )
621 QDomElement picture = composerPictureList.at( i ).toElement();
622 picture.setAttribute( QStringLiteral(
"anchorPoint" ), QString::number( 4 ) );
626 void QgsProjectFileTransform::transform3000()
629 QDomElement propsElem = mDom.firstChildElement( QStringLiteral(
"qgis" ) ).toElement().firstChildElement( QStringLiteral(
"properties" ) );
630 if ( !propsElem.isNull() )
632 QDomNodeList srsNodes = propsElem.elementsByTagName( QStringLiteral(
"SpatialRefSys" ) );
634 QDomElement projElem;
635 if ( srsNodes.count() > 0 )
637 srsElem = srsNodes.at( 0 ).toElement();
638 QDomNodeList projNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectionsEnabled" ) );
639 if ( projNodes.count() == 0 )
641 projElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
642 projElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
643 QDomText projText = mDom.createTextNode( QStringLiteral(
"0" ) );
644 projElem.appendChild( projText );
645 srsElem.appendChild( projElem );
650 srsElem = mDom.createElement( QStringLiteral(
"SpatialRefSys" ) );
651 projElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
652 projElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
653 QDomText projText = mDom.createTextNode( QStringLiteral(
"0" ) );
654 projElem.appendChild( projText );
655 srsElem.appendChild( projElem );
656 propsElem.appendChild( srsElem );
662 QDomNodeList canvasNodes = mDom.elementsByTagName( QStringLiteral(
"mapcanvas" ) );
663 if ( canvasNodes.count() > 0 )
665 QDomElement canvasElem = canvasNodes.at( 0 ).toElement();
666 QDomNodeList canvasSrsNodes = canvasElem.elementsByTagName( QStringLiteral(
"spatialrefsys" ) );
667 if ( canvasSrsNodes.count() > 0 )
669 QDomElement canvasSrsElem = canvasSrsNodes.at( 0 ).toElement();
674 QDomNodeList proj4Nodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"proj4" ) );
675 if ( proj4Nodes.count() > 0 )
677 QDomElement proj4Node = proj4Nodes.at( 0 ).toElement();
678 proj = proj4Node.text();
680 QDomNodeList authidNodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"authid" ) );
681 if ( authidNodes.count() > 0 )
683 QDomElement authidNode = authidNodes.at( 0 ).toElement();
684 authid = authidNode.text();
686 QDomNodeList srsidNodes = canvasSrsElem.elementsByTagName( QStringLiteral(
"srsid" ) );
687 if ( srsidNodes.count() > 0 )
689 QDomElement srsidNode = srsidNodes.at( 0 ).toElement();
690 srsid = srsidNode.text();
694 QDomNodeList oldProjectProj4Nodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCRSProj4String" ) );
695 for (
int i = oldProjectProj4Nodes.count(); i >= 0; --i )
697 srsElem.removeChild( oldProjectProj4Nodes.at( i ) );
699 QDomNodeList oldProjectCrsNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCrs" ) );
700 for (
int i = oldProjectCrsNodes.count(); i >= 0; --i )
702 srsElem.removeChild( oldProjectCrsNodes.at( i ) );
704 QDomNodeList oldProjectCrsIdNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectCRSID" ) );
705 for (
int i = oldProjectCrsIdNodes.count(); i >= 0; --i )
707 srsElem.removeChild( oldProjectCrsIdNodes.at( i ) );
709 QDomNodeList projectionsEnabledNodes = srsElem.elementsByTagName( QStringLiteral(
"ProjectionsEnabled" ) );
710 for (
int i = projectionsEnabledNodes.count(); i >= 0; --i )
712 srsElem.removeChild( projectionsEnabledNodes.at( i ) );
715 QDomElement proj4Elem = mDom.createElement( QStringLiteral(
"ProjectCRSProj4String" ) );
716 proj4Elem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"QString" ) );
717 QDomText proj4Text = mDom.createTextNode( proj );
718 proj4Elem.appendChild( proj4Text );
719 QDomElement projectCrsElem = mDom.createElement( QStringLiteral(
"ProjectCrs" ) );
720 projectCrsElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"QString" ) );
721 QDomText projectCrsText = mDom.createTextNode( authid );
722 projectCrsElem.appendChild( projectCrsText );
723 QDomElement projectCrsIdElem = mDom.createElement( QStringLiteral(
"ProjectCRSID" ) );
724 projectCrsIdElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
725 QDomText srsidText = mDom.createTextNode( srsid );
726 projectCrsIdElem.appendChild( srsidText );
727 QDomElement projectionsEnabledElem = mDom.createElement( QStringLiteral(
"ProjectionsEnabled" ) );
728 projectionsEnabledElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"int" ) );
729 QDomText projectionsEnabledText = mDom.createTextNode( QStringLiteral(
"1" ) );
730 projectionsEnabledElem.appendChild( projectionsEnabledText );
731 srsElem.appendChild( proj4Elem );
732 srsElem.appendChild( projectCrsElem );
733 srsElem.appendChild( projectCrsIdElem );
734 srsElem.appendChild( projectionsEnabledElem );
736 QDomNodeList srsNodes = propsElem.elementsByTagName( QStringLiteral(
"SpatialRefSys" ) );
737 for (
int i = srsNodes.count(); i >= 0; --i )
739 propsElem.removeChild( srsNodes.at( i ) );
741 propsElem.appendChild( srsElem );
747 QDomNodeList mapLayers = mDom.elementsByTagName( QStringLiteral(
"maplayer" ) );
749 for (
int mapLayerIndex = 0; mapLayerIndex < mapLayers.count(); ++mapLayerIndex )
751 QDomElement layerElem = mapLayers.at( mapLayerIndex ).toElement();
754 QDomElement fieldConfigurationElement = mDom.createElement( QStringLiteral(
"fieldConfiguration" ) );
755 layerElem.appendChild( fieldConfigurationElement );
757 QDomNodeList editTypeNodes = layerElem.namedItem( QStringLiteral(
"edittypes" ) ).childNodes();
758 QDomElement constraintExpressionsElem = mDom.createElement( QStringLiteral(
"constraintExpressions" ) );
759 layerElem.appendChild( constraintExpressionsElem );
761 for (
int i = 0; i < editTypeNodes.size(); ++i )
763 QDomNode editTypeNode = editTypeNodes.at( i );
764 QDomElement editTypeElement = editTypeNode.toElement();
766 QDomElement fieldElement = mDom.createElement( QStringLiteral(
"field" ) );
767 fieldConfigurationElement.appendChild( fieldElement );
769 QString name = editTypeElement.attribute( QStringLiteral(
"name" ) );
770 fieldElement.setAttribute( QStringLiteral(
"name" ), name );
771 QDomElement constraintExpressionElem = mDom.createElement( QStringLiteral(
"constraint" ) );
772 constraintExpressionElem.setAttribute( QStringLiteral(
"field" ), name );
773 constraintExpressionsElem.appendChild( constraintExpressionElem );
775 QDomElement editWidgetElement = mDom.createElement( QStringLiteral(
"editWidget" ) );
776 fieldElement.appendChild( editWidgetElement );
778 QString ewv2Type = editTypeElement.attribute( QStringLiteral(
"widgetv2type" ) );
779 editWidgetElement.setAttribute( QStringLiteral(
"type" ), ewv2Type );
781 QDomElement ewv2CfgElem = editTypeElement.namedItem( QStringLiteral(
"widgetv2config" ) ).toElement();
783 if ( !ewv2CfgElem.isNull() )
785 QDomElement editWidgetConfigElement = mDom.createElement( QStringLiteral(
"config" ) );
786 editWidgetElement.appendChild( editWidgetConfigElement );
788 QVariantMap editWidgetConfiguration;
790 QDomNamedNodeMap configAttrs = ewv2CfgElem.attributes();
791 for (
int configIndex = 0; configIndex < configAttrs.count(); ++configIndex )
793 QDomAttr configAttr = configAttrs.item( configIndex ).toAttr();
794 if ( configAttr.name() == QStringLiteral(
"fieldEditable" ) )
796 editWidgetConfigElement.setAttribute( QStringLiteral(
"fieldEditable" ), configAttr.value() );
798 else if ( configAttr.name() == QStringLiteral(
"labelOnTop" ) )
800 editWidgetConfigElement.setAttribute( QStringLiteral(
"labelOnTop" ), configAttr.value() );
802 else if ( configAttr.name() == QStringLiteral(
"notNull" ) )
804 editWidgetConfigElement.setAttribute( QStringLiteral(
"notNull" ), configAttr.value() );
806 else if ( configAttr.name() == QStringLiteral(
"constraint" ) )
808 constraintExpressionElem.setAttribute( QStringLiteral(
"exp" ), configAttr.value() );
810 else if ( configAttr.name() == QStringLiteral(
"constraintDescription" ) )
812 constraintExpressionElem.setAttribute( QStringLiteral(
"desc" ), configAttr.value() );
816 editWidgetConfiguration.insert( configAttr.name(), configAttr.value() );
820 if ( ewv2Type == QStringLiteral(
"ValueMap" ) )
822 QDomNodeList configElements = ewv2CfgElem.childNodes();
824 for (
int configIndex = 0; configIndex < configElements.count(); ++configIndex )
826 QDomElement configElem = configElements.at( configIndex ).toElement();
827 map.insert( configElem.attribute( QStringLiteral(
"key" ) ), configElem.attribute( QStringLiteral(
"value" ) ) );
829 editWidgetConfiguration.insert( QStringLiteral(
"map" ), map );
831 else if ( ewv2Type == QStringLiteral(
"Photo" ) )
833 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
835 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewer" ), 1 );
836 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral(
"Height" ) ) );
837 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral(
"Width" ) ) );
838 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
840 else if ( ewv2Type == QStringLiteral(
"FileName" ) )
842 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
844 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
846 else if ( ewv2Type == QStringLiteral(
"WebView" ) )
848 editWidgetElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ExternalResource" ) );
850 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerHeight" ), editWidgetConfiguration.value( QStringLiteral(
"Height" ) ) );
851 editWidgetConfiguration.insert( QStringLiteral(
"DocumentViewerWidth" ), editWidgetConfiguration.value( QStringLiteral(
"Width" ) ) );
852 editWidgetConfiguration.insert( QStringLiteral(
"RelativeStorage" ), 1 );
866 QDomNode noDataNode = rasterPropertiesElem.namedItem( QStringLiteral(
"mNoDataValue" ) );
867 QDomElement noDataElement = noDataNode.toElement();
868 if ( !noDataElement.text().isEmpty() )
870 QgsDebugMsg(
"mNoDataValue = " + noDataElement.text() );
871 QDomElement noDataElem = doc.createElement( QStringLiteral(
"noData" ) );
873 QDomElement noDataRangeList = doc.createElement( QStringLiteral(
"noDataRangeList" ) );
874 noDataRangeList.setAttribute( QStringLiteral(
"bandNo" ), 1 );
876 QDomElement noDataRange = doc.createElement( QStringLiteral(
"noDataRange" ) );
877 noDataRange.setAttribute( QStringLiteral(
"min" ), noDataElement.text() );
878 noDataRange.setAttribute( QStringLiteral(
"max" ), noDataElement.text() );
879 noDataRangeList.appendChild( noDataRange );
881 noDataElem.appendChild( noDataRangeList );
883 parentNode.appendChild( noDataElem );
886 QDomElement rasterRendererElem = doc.createElement( QStringLiteral(
"rasterrenderer" ) );
890 rasterRendererElem.setAttribute( QStringLiteral(
"invertColor" ), QStringLiteral(
"0" ) );
891 QDomElement invertColorElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mInvertColor" ) );
892 if ( !invertColorElem.isNull() )
894 if ( invertColorElem.text() == QLatin1String(
"true" ) )
896 rasterRendererElem.setAttribute( QStringLiteral(
"invertColor" ), QStringLiteral(
"1" ) );
901 rasterRendererElem.setAttribute( QStringLiteral(
"opacity" ), QStringLiteral(
"1" ) );
902 QDomElement transparencyElem = parentNode.firstChildElement( QStringLiteral(
"transparencyLevelInt" ) );
903 if ( !transparencyElem.isNull() )
905 double transparency = transparencyElem.text().toInt();
906 rasterRendererElem.setAttribute( QStringLiteral(
"opacity" ), QString::number( transparency / 255.0 ) );
910 rasterRendererElem.setAttribute( QStringLiteral(
"alphaBand" ), -1 );
913 int grayBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mGrayBandName" ), rlayer );
916 QString drawingStyle = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mDrawingStyle" ) ).text();
923 if ( drawingStyle == QLatin1String(
"PalettedColor" ) )
925 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
926 QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
928 for (
int i = 0; i < colorRampEntryList.size(); ++i )
930 QDomElement colorRampEntryElem = colorRampEntryList.at( i ).toElement();
931 QString strValue = colorRampEntryElem.attribute( QStringLiteral(
"value" ) );
932 double value = strValue.toDouble();
933 if ( value < 0 || value > 10000 || !
qgsDoubleNear( value, static_cast< int >( value ) ) )
935 QgsDebugMsg( QStringLiteral(
"forcing SingleBandPseudoColor value = %1" ).arg( value ) );
936 drawingStyle = QStringLiteral(
"SingleBandPseudoColor" );
942 if ( drawingStyle == QLatin1String(
"SingleBandGray" ) )
944 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"singlebandgray" ) );
945 rasterRendererElem.setAttribute( QStringLiteral(
"grayBand" ), grayBand );
946 transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
948 else if ( drawingStyle == QLatin1String(
"SingleBandPseudoColor" ) )
950 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"singlebandpseudocolor" ) );
951 rasterRendererElem.setAttribute( QStringLiteral(
"band" ), grayBand );
952 QDomElement newRasterShaderElem = doc.createElement( QStringLiteral(
"rastershader" ) );
953 QDomElement newColorRampShaderElem = doc.createElement( QStringLiteral(
"colorrampshader" ) );
954 newRasterShaderElem.appendChild( newColorRampShaderElem );
955 rasterRendererElem.appendChild( newRasterShaderElem );
958 QString colorShadingAlgorithm = rasterPropertiesElem.firstChildElement( QStringLiteral(
"mColorShadingAlgorithm" ) ).text();
959 if ( colorShadingAlgorithm == QLatin1String(
"PseudoColorShader" ) || colorShadingAlgorithm == QLatin1String(
"FreakOutShader" ) )
961 newColorRampShaderElem.setAttribute( QStringLiteral(
"colorRampType" ), QStringLiteral(
"INTERPOLATED" ) );
967 double breakSize = ( maxValue - minValue ) / 3;
969 QStringList colorList;
970 if ( colorShadingAlgorithm == QLatin1String(
"FreakOutShader" ) )
972 colorList << QStringLiteral(
"#ff00ff" ) << QStringLiteral(
"#00ffff" ) << QStringLiteral(
"#ff0000" ) << QStringLiteral(
"#00ff00" );
976 colorList << QStringLiteral(
"#0000ff" ) << QStringLiteral(
"#00ffff" ) << QStringLiteral(
"#ffff00" ) << QStringLiteral(
"#ff0000" );
978 QStringList::const_iterator colorIt = colorList.constBegin();
979 double boundValue = minValue;
980 for ( ; colorIt != colorList.constEnd(); ++colorIt )
982 QDomElement newItemElem = doc.createElement( QStringLiteral(
"item" ) );
983 newItemElem.setAttribute( QStringLiteral(
"value" ), QString::number( boundValue ) );
984 newItemElem.setAttribute( QStringLiteral(
"label" ), QString::number( boundValue ) );
985 newItemElem.setAttribute( QStringLiteral(
"color" ), *colorIt );
986 newColorRampShaderElem.appendChild( newItemElem );
987 boundValue += breakSize;
990 else if ( colorShadingAlgorithm == QLatin1String(
"ColorRampShader" ) )
992 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
993 QString type = customColorRampElem.firstChildElement( QStringLiteral(
"colorRampType" ) ).text();
994 newColorRampShaderElem.setAttribute( QStringLiteral(
"colorRampType" ), type );
995 QDomNodeList colorNodeList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
997 QString value, label;
999 int red, green, blue;
1000 QDomElement currentItemElem;
1001 for (
int i = 0; i < colorNodeList.size(); ++i )
1003 currentItemElem = colorNodeList.at( i ).toElement();
1004 value = currentItemElem.attribute( QStringLiteral(
"value" ) );
1005 label = currentItemElem.attribute( QStringLiteral(
"label" ) );
1006 red = currentItemElem.attribute( QStringLiteral(
"red" ) ).toInt();
1007 green = currentItemElem.attribute( QStringLiteral(
"green" ) ).toInt();
1008 blue = currentItemElem.attribute( QStringLiteral(
"blue" ) ).toInt();
1009 newColor = QColor( red, green, blue );
1010 QDomElement newItemElem = doc.createElement( QStringLiteral(
"item" ) );
1011 newItemElem.setAttribute( QStringLiteral(
"value" ), value );
1012 newItemElem.setAttribute( QStringLiteral(
"label" ), label );
1013 newItemElem.setAttribute( QStringLiteral(
"color" ), newColor.name() );
1014 newColorRampShaderElem.appendChild( newItemElem );
1018 else if ( drawingStyle == QLatin1String(
"PalettedColor" ) )
1020 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"paletted" ) );
1021 rasterRendererElem.setAttribute( QStringLiteral(
"band" ), grayBand );
1022 QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( QStringLiteral(
"customColorRamp" ) );
1023 QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( QStringLiteral(
"colorRampEntry" ) );
1024 QDomElement newColorPaletteElem = doc.createElement( QStringLiteral(
"colorPalette" ) );
1030 QDomElement colorRampEntryElem;
1031 for (
int i = 0; i < colorRampEntryList.size(); ++i )
1033 colorRampEntryElem = colorRampEntryList.at( i ).toElement();
1034 QDomElement newPaletteElem = doc.createElement( QStringLiteral(
"paletteEntry" ) );
1035 value =
static_cast< int >( colorRampEntryElem.attribute( QStringLiteral(
"value" ) ).toDouble() );
1036 newPaletteElem.setAttribute( QStringLiteral(
"value" ), value );
1037 red = colorRampEntryElem.attribute( QStringLiteral(
"red" ) ).toInt();
1038 green = colorRampEntryElem.attribute( QStringLiteral(
"green" ) ).toInt();
1039 blue = colorRampEntryElem.attribute( QStringLiteral(
"blue" ) ).toInt();
1040 newPaletteElem.setAttribute( QStringLiteral(
"color" ), QColor( red, green, blue ).name() );
1041 QString label = colorRampEntryElem.attribute( QStringLiteral(
"label" ) );
1042 if ( !label.isEmpty() )
1044 newPaletteElem.setAttribute( QStringLiteral(
"label" ), label );
1046 newColorPaletteElem.appendChild( newPaletteElem );
1048 rasterRendererElem.appendChild( newColorPaletteElem );
1050 else if ( drawingStyle == QLatin1String(
"MultiBandColor" ) )
1052 rasterRendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"multibandcolor" ) );
1055 int redBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mRedBandName" ), rlayer );
1056 int greenBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mGreenBandName" ), rlayer );
1057 int blueBand = rasterBandNumber( rasterPropertiesElem, QStringLiteral(
"mBlueBandName" ), rlayer );
1058 rasterRendererElem.setAttribute( QStringLiteral(
"redBand" ), redBand );
1059 rasterRendererElem.setAttribute( QStringLiteral(
"greenBand" ), greenBand );
1060 rasterRendererElem.setAttribute( QStringLiteral(
"blueBand" ), blueBand );
1062 transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
1070 if ( !parentNode.isNull() )
1072 parentNode.replaceChild( rasterRendererElem, rasterPropertiesElem );
1076 int QgsProjectFileTransform::rasterBandNumber(
const QDomElement &rasterPropertiesElem,
const QString &bandName,
1085 QDomElement rasterBandElem = rasterPropertiesElem.firstChildElement( bandName );
1086 if ( !rasterBandElem.isNull() )
1088 QRegExp re(
"(\\d+)" );
1090 if ( re.indexIn( rasterBandElem.text() ) >= 0 )
1092 return re.cap( 1 ).toInt();
1098 void QgsProjectFileTransform::transformContrastEnhancement( QDomDocument &doc,
const QDomElement &rasterproperties, QDomElement &rendererElem )
1100 if ( rasterproperties.isNull() || rendererElem.isNull() )
1105 double minimumValue = 0;
1106 double maximumValue = 0;
1107 QDomElement contrastMinMaxElem = rasterproperties.firstChildElement( QStringLiteral(
"contrastEnhancementMinMaxValues" ) );
1108 if ( contrastMinMaxElem.isNull() )
1113 QDomElement contrastEnhancementAlgorithmElem = rasterproperties.firstChildElement( QStringLiteral(
"mContrastEnhancementAlgorithm" ) );
1114 if ( contrastEnhancementAlgorithmElem.isNull() )
1120 int algorithmEnum = 0;
1121 QString algorithmString = contrastEnhancementAlgorithmElem.text();
1122 if ( algorithmString == QLatin1String(
"StretchToMinimumMaximum" ) )
1126 else if ( algorithmString == QLatin1String(
"StretchAndClipToMinimumMaximum" ) )
1130 else if ( algorithmString == QLatin1String(
"ClipToMinimumMaximum" ) )
1134 else if ( algorithmString == QLatin1String(
"UserDefinedEnhancement" ) )
1139 QDomNodeList minMaxEntryList = contrastMinMaxElem.elementsByTagName( QStringLiteral(
"minMaxEntry" ) );
1140 QStringList enhancementNameList;
1141 if ( minMaxEntryList.size() == 1 )
1143 enhancementNameList << QStringLiteral(
"contrastEnhancement" );
1145 if ( minMaxEntryList.size() == 3 )
1147 enhancementNameList << QStringLiteral(
"redContrastEnhancement" ) << QStringLiteral(
"greenContrastEnhancement" ) << QStringLiteral(
"blueContrastEnhancement" );
1149 if ( minMaxEntryList.size() > enhancementNameList.size() )
1154 QDomElement minMaxEntryElem;
1155 for (
int i = 0; i < minMaxEntryList.size(); ++i )
1157 minMaxEntryElem = minMaxEntryList.at( i ).toElement();
1158 QDomElement minElem = minMaxEntryElem.firstChildElement( QStringLiteral(
"min" ) );
1159 if ( minElem.isNull() )
1163 minimumValue = minElem.text().toDouble();
1165 QDomElement maxElem = minMaxEntryElem.firstChildElement( QStringLiteral(
"max" ) );
1166 if ( maxElem.isNull() )
1170 maximumValue = maxElem.text().toDouble();
1172 QDomElement newContrastEnhancementElem = doc.createElement( enhancementNameList.at( i ) );
1173 QDomElement newMinValElem = doc.createElement( QStringLiteral(
"minValue" ) );
1174 QDomText minText = doc.createTextNode( QString::number( minimumValue ) );
1175 newMinValElem.appendChild( minText );
1176 newContrastEnhancementElem.appendChild( newMinValElem );
1177 QDomElement newMaxValElem = doc.createElement( QStringLiteral(
"maxValue" ) );
1178 QDomText maxText = doc.createTextNode( QString::number( maximumValue ) );
1179 newMaxValElem.appendChild( maxText );
1180 newContrastEnhancementElem.appendChild( newMaxValElem );
1182 QDomElement newAlgorithmElem = doc.createElement( QStringLiteral(
"algorithm" ) );
1183 QDomText newAlgorithmText = doc.createTextNode( QString::number( algorithmEnum ) );
1184 newAlgorithmElem.appendChild( newAlgorithmText );
1185 newContrastEnhancementElem.appendChild( newAlgorithmElem );
1187 rendererElem.appendChild( newContrastEnhancementElem );
1191 void QgsProjectFileTransform::transformRasterTransparency( QDomDocument &doc,
const QDomElement &orig, QDomElement &rendererElem )
1196 Q_UNUSED( rendererElem )
The class is used as a container of context for various read/write operations on other objects...
void setPathResolver(const QgsPathResolver &resolver)
Sets up path resolver for conversion between relative and absolute paths.
bool readLayerXml(const QDomElement &layerElement, QgsReadWriteContext &context, QgsMapLayer::ReadFlags flags=nullptr)
Sets state from DOM document.
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 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 source 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.
Contains information about the context in which a coordinate transform is executed.
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.
double minimumValue
The minimum cell value in the raster band.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
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.