@@ -106,8 +106,8 @@ void QgsMapLayer::clone( QgsMapLayer *layer ) const
106106 layer->setName ( name () );
107107 layer->setShortName ( shortName () );
108108 layer->setExtent ( extent () );
109- layer->setMinimumScale ( minimumScale () );
110109 layer->setMaximumScale ( maximumScale () );
110+ layer->setMinimumScale ( minimumScale () );
111111 layer->setScaleBasedVisibility ( hasScaleBasedVisibility () );
112112 layer->setTitle ( title () );
113113 layer->setAbstract ( abstract () );
@@ -460,8 +460,17 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, const QgsReadWr
460460
461461 // use scale dependent visibility flag
462462 setScaleBasedVisibility ( layerElement.attribute ( QStringLiteral ( " hasScaleBasedVisibilityFlag" ) ).toInt () == 1 );
463- setMinimumScale ( layerElement.attribute ( QStringLiteral ( " minimumScale" ) ).toDouble () );
464- setMaximumScale ( layerElement.attribute ( QStringLiteral ( " maximumScale" ) ).toDouble () );
463+ if ( layerElement.hasAttribute ( QStringLiteral ( " minimumScale" ) ) )
464+ {
465+ // older element, when scales were reversed
466+ setMaximumScale ( layerElement.attribute ( QStringLiteral ( " minimumScale" ) ).toDouble () );
467+ setMinimumScale ( layerElement.attribute ( QStringLiteral ( " maximumScale" ) ).toDouble () );
468+ }
469+ else
470+ {
471+ setMaximumScale ( layerElement.attribute ( QStringLiteral ( " maxScale" ) ).toDouble () );
472+ setMinimumScale ( layerElement.attribute ( QStringLiteral ( " minScale" ) ).toDouble () );
473+ }
465474
466475 setAutoRefreshInterval ( layerElement.attribute ( QStringLiteral ( " autoRefreshTime" ), 0 ).toInt () );
467476 setAutoRefreshEnabled ( layerElement.attribute ( QStringLiteral ( " autoRefreshEnabled" ), QStringLiteral ( " 0" ) ).toInt () );
@@ -564,8 +573,8 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume
564573{
565574 // use scale dependent visibility flag
566575 layerElement.setAttribute ( QStringLiteral ( " hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility () ? 1 : 0 );
567- layerElement.setAttribute ( QStringLiteral ( " minimumScale " ), QString::number ( minimumScale () ) );
568- layerElement.setAttribute ( QStringLiteral ( " maximumScale " ), QString::number ( maximumScale () ) );
576+ layerElement.setAttribute ( QStringLiteral ( " maxScale " ), QString::number ( maximumScale () ) );
577+ layerElement.setAttribute ( QStringLiteral ( " minScale " ), QString::number ( minimumScale () ) );
569578
570579 if ( !mExtent .isNull () )
571580 {
@@ -922,18 +931,18 @@ const QgsLayerMetadata &QgsMapLayer::metadata() const
922931 return mMetadata ;
923932}
924933
925- void QgsMapLayer::setMinimumScale ( double scale )
934+ void QgsMapLayer::setMaximumScale ( double scale )
926935{
927936 mMinScale = scale;
928937}
929938
930- double QgsMapLayer::minimumScale () const
939+ double QgsMapLayer::maximumScale () const
931940{
932941 return mMinScale ;
933942}
934943
935944
936- void QgsMapLayer::setMaximumScale ( double scale )
945+ void QgsMapLayer::setMinimumScale ( double scale )
937946{
938947 mMaxScale = scale;
939948}
@@ -943,7 +952,7 @@ void QgsMapLayer::setScaleBasedVisibility( const bool enabled )
943952 mScaleBasedVisibility = enabled;
944953}
945954
946- double QgsMapLayer::maximumScale () const
955+ double QgsMapLayer::minimumScale () const
947956{
948957 return mMaxScale ;
949958}
@@ -1191,8 +1200,17 @@ bool QgsMapLayer::importNamedStyle( QDomDocument &myDocument, QString &myErrorMe
11911200
11921201 // use scale dependent visibility flag
11931202 setScaleBasedVisibility ( myRoot.attribute ( QStringLiteral ( " hasScaleBasedVisibilityFlag" ) ).toInt () == 1 );
1194- setMinimumScale ( myRoot.attribute ( QStringLiteral ( " minimumScale" ) ).toDouble () );
1195- setMaximumScale ( myRoot.attribute ( QStringLiteral ( " maximumScale" ) ).toDouble () );
1203+ if ( myRoot.hasAttribute ( QStringLiteral ( " minimumScale" ) ) )
1204+ {
1205+ // older scale element, when min/max were reversed
1206+ setMaximumScale ( myRoot.attribute ( QStringLiteral ( " minimumScale" ) ).toDouble () );
1207+ setMinimumScale ( myRoot.attribute ( QStringLiteral ( " maximumScale" ) ).toDouble () );
1208+ }
1209+ else
1210+ {
1211+ setMaximumScale ( myRoot.attribute ( QStringLiteral ( " maxScale" ) ).toDouble () );
1212+ setMinimumScale ( myRoot.attribute ( QStringLiteral ( " minScale" ) ).toDouble () );
1213+ }
11961214
11971215 return readSymbology ( myRoot, myErrorMessage, QgsReadWriteContext () ); // TODO: support relative paths in QML?
11981216}
@@ -1208,8 +1226,8 @@ void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg ) const
12081226 myDocument.appendChild ( myRootNode );
12091227
12101228 myRootNode.setAttribute ( QStringLiteral ( " hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility () ? 1 : 0 );
1211- myRootNode.setAttribute ( QStringLiteral ( " minimumScale " ), QString::number ( minimumScale () ) );
1212- myRootNode.setAttribute ( QStringLiteral ( " maximumScale " ), QString::number ( maximumScale () ) );
1229+ myRootNode.setAttribute ( QStringLiteral ( " maxScale " ), QString::number ( maximumScale () ) );
1230+ myRootNode.setAttribute ( QStringLiteral ( " mincale " ), QString::number ( minimumScale () ) );
12131231
12141232 if ( !writeSymbology ( myRootNode, myDocument, errorMsg, QgsReadWriteContext () ) ) // TODO: support relative paths in QML?
12151233 {
0 commit comments