mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Swap QgsMapLayer min/max scale API definitions
setMaximumScale() and setMinimumScale(), maximumScale() and minimumScale() had the opposite meaning to other min/max scales in the API, and were the opposite to how these settings were exposed in the GUI. This lead to very confusing API!! Their definitions have now been swapped. setMaximumScale now sets the maximum (i.e. largest scale, or most zoomed in) at which the layer will appear, and setMinimumScale now sets the minimum (i.e. smallest scale, or most zoomed out) at which the layer will appear. The same is true for the maximumScale and minimumScale getters.
This commit is contained in:
parent
0f2a49d9b5
commit
a9a7d3c3d9
@ -1515,6 +1515,9 @@ screenUpdateRequested() were removed. These members have had no effect for a num
|
|||||||
- readXml() and writeXml() expect QgsReadWriteContext reference as the last argument
|
- readXml() and writeXml() expect QgsReadWriteContext reference as the last argument
|
||||||
- the invalidTransformInput() slot was removed - calling this slot had no effect
|
- the invalidTransformInput() slot was removed - calling this slot had no effect
|
||||||
- metadata() was renamed to htmlMetadata()
|
- metadata() was renamed to htmlMetadata()
|
||||||
|
- setMaximumScale() and setMinimumScale(), maximumScale() and minimumScale() had the opposite meaning to other min/max scales in the API, and their definitions have now been swapped. setMaximumScale
|
||||||
|
now sets the maximum (i.e. largest scale, or most zoomed in) at which the layer will appear, and setMinimumScale now sets the minimum (i.e. smallest scale,
|
||||||
|
or most zoomed out) at which the layer will appear. The same is true for the maximumScale and minimumScale getters.
|
||||||
|
|
||||||
|
|
||||||
QgsMapLayerActionRegistry {#qgis_api_break_3_0_QgsMapLayerActionRegistry}
|
QgsMapLayerActionRegistry {#qgis_api_break_3_0_QgsMapLayerActionRegistry}
|
||||||
|
@ -772,9 +772,12 @@ Return pointer to layer's undo stack
|
|||||||
|
|
||||||
double minimumScale() const;
|
double minimumScale() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the minimum scale denominator at which the layer is visible.
|
Returns the minimum map scale (i.e. most "zoomed out" scale) at which the layer will be visible.
|
||||||
Scale based visibility is only used if hasScaleBasedVisibility is true.
|
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
:return: minimum scale denominator at which the layer will render
|
A scale of 0 indicates no minimum scale visibility.
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
.. seealso:: setMinimumScale()
|
.. seealso:: setMinimumScale()
|
||||||
.. seealso:: maximumScale()
|
.. seealso:: maximumScale()
|
||||||
.. seealso:: hasScaleBasedVisibility()
|
.. seealso:: hasScaleBasedVisibility()
|
||||||
@ -784,9 +787,12 @@ Return pointer to layer's undo stack
|
|||||||
|
|
||||||
double maximumScale() const;
|
double maximumScale() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the maximum scale denominator at which the layer is visible.
|
Returns the maximum map scale (i.e. most "zoomed in" scale) at which the layer will be visible.
|
||||||
Scale based visibility is only used if hasScaleBasedVisibility is true.
|
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
:return: minimum scale denominator at which the layer will render
|
A scale of 0 indicates no maximum scale visibility.
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
.. seealso:: setMaximumScale()
|
.. seealso:: setMaximumScale()
|
||||||
.. seealso:: minimumScale()
|
.. seealso:: minimumScale()
|
||||||
.. seealso:: hasScaleBasedVisibility()
|
.. seealso:: hasScaleBasedVisibility()
|
||||||
@ -889,22 +895,28 @@ Time stamp of data source in the moment when data/metadata were loaded by provid
|
|||||||
|
|
||||||
void setMinimumScale( double scale );
|
void setMinimumScale( double scale );
|
||||||
%Docstring
|
%Docstring
|
||||||
Sets the minimum scale denominator at which the layer will be visible.
|
Sets the minimum map ``scale`` (i.e. most "zoomed out" scale) at which the layer will be visible.
|
||||||
Scale based visibility is only used if setScaleBasedVisibility is set to true.
|
The ``scale`` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
\param scale minimum scale denominator at which the layer should render
|
A ``scale`` of 0 indicates no minimum scale visibility.
|
||||||
.. seealso:: minimumScale
|
.. note::
|
||||||
.. seealso:: setMaximumScale
|
|
||||||
.. seealso:: setScaleBasedVisibility
|
Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
|
.. seealso:: minimumScale()
|
||||||
|
.. seealso:: setMaximumScale()
|
||||||
|
.. seealso:: setScaleBasedVisibility()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setMaximumScale( double scale );
|
void setMaximumScale( double scale );
|
||||||
%Docstring
|
%Docstring
|
||||||
Sets the maximum scale denominator at which the layer will be visible.
|
Sets the maximum map ``scale`` (i.e. most "zoomed in" scale) at which the layer will be visible.
|
||||||
Scale based visibility is only used if setScaleBasedVisibility is set to true.
|
The ``scale`` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
\param scale maximum scale denominator at which the layer should render
|
A ``scale`` of 0 indicates no maximum scale visibility.
|
||||||
.. seealso:: maximumScale
|
.. note::
|
||||||
.. seealso:: setMinimumScale
|
|
||||||
.. seealso:: setScaleBasedVisibility
|
Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
|
.. seealso:: maximumScale()
|
||||||
|
.. seealso:: setMinimumScale()
|
||||||
|
.. seealso:: setScaleBasedVisibility()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setScaleBasedVisibility( const bool enabled );
|
void setScaleBasedVisibility( const bool enabled );
|
||||||
|
@ -8979,8 +8979,8 @@ void QgisApp::setLayerScaleVisibility()
|
|||||||
if ( layer )
|
if ( layer )
|
||||||
{
|
{
|
||||||
dlg->setScaleVisiblity( layer->hasScaleBasedVisibility() );
|
dlg->setScaleVisiblity( layer->hasScaleBasedVisibility() );
|
||||||
dlg->setMinimumScale( 1.0 / layer->maximumScale() );
|
dlg->setMinimumScale( 1.0 / layer->minimumScale() );
|
||||||
dlg->setMaximumScale( 1.0 / layer->minimumScale() );
|
dlg->setMaximumScale( 1.0 / layer->maximumScale() );
|
||||||
}
|
}
|
||||||
if ( dlg->exec() )
|
if ( dlg->exec() )
|
||||||
{
|
{
|
||||||
@ -8988,8 +8988,8 @@ void QgisApp::setLayerScaleVisibility()
|
|||||||
Q_FOREACH ( QgsMapLayer *layer, layers )
|
Q_FOREACH ( QgsMapLayer *layer, layers )
|
||||||
{
|
{
|
||||||
layer->setScaleBasedVisibility( dlg->hasScaleVisibility() );
|
layer->setScaleBasedVisibility( dlg->hasScaleVisibility() );
|
||||||
layer->setMinimumScale( 1.0 / dlg->maximumScale() );
|
layer->setMaximumScale( 1.0 / dlg->maximumScale() );
|
||||||
layer->setMaximumScale( 1.0 / dlg->minimumScale() );
|
layer->setMinimumScale( 1.0 / dlg->minimumScale() );
|
||||||
}
|
}
|
||||||
freezeCanvases( false );
|
freezeCanvases( false );
|
||||||
refreshMapCanvas();
|
refreshMapCanvas();
|
||||||
@ -9011,13 +9011,13 @@ void QgisApp::zoomToLayerScale()
|
|||||||
if ( layer && layer->hasScaleBasedVisibility() )
|
if ( layer && layer->hasScaleBasedVisibility() )
|
||||||
{
|
{
|
||||||
const double scale = mMapCanvas->scale();
|
const double scale = mMapCanvas->scale();
|
||||||
if ( scale > layer->maximumScale() )
|
if ( scale > layer->minimumScale() )
|
||||||
{
|
{
|
||||||
mMapCanvas->zoomScale( layer->maximumScale() * Qgis::SCALE_PRECISION );
|
mMapCanvas->zoomScale( layer->minimumScale() * Qgis::SCALE_PRECISION );
|
||||||
}
|
}
|
||||||
else if ( scale <= layer->minimumScale() )
|
else if ( scale <= layer->maximumScale() )
|
||||||
{
|
{
|
||||||
mMapCanvas->zoomScale( layer->minimumScale() );
|
mMapCanvas->zoomScale( layer->maximumScale() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
|
|||||||
mIncreaseMinimumSizeLabel->setEnabled( false );
|
mIncreaseMinimumSizeLabel->setEnabled( false );
|
||||||
mBarWidthSpinBox->setValue( 5 );
|
mBarWidthSpinBox->setValue( 5 );
|
||||||
mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
|
mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() );
|
||||||
mScaleRangeWidget->setScaleRange( 1.0 / layer->maximumScale(), 1.0 / layer->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
mScaleRangeWidget->setScaleRange( 1.0 / layer->minimumScale(), 1.0 / layer->maximumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
||||||
mShowAllCheckBox->setChecked( true );
|
mShowAllCheckBox->setChecked( true );
|
||||||
mCheckBoxAttributeLegend->setChecked( true );
|
mCheckBoxAttributeLegend->setChecked( true );
|
||||||
mCheckBoxSizeLegend->setChecked( false );
|
mCheckBoxSizeLegend->setChecked( false );
|
||||||
@ -266,8 +266,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer *layer, QWidget *pare
|
|||||||
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
|
mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
|
||||||
mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
|
mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
|
||||||
// caution: layer uses scale denoms, widget uses true scales
|
// caution: layer uses scale denoms, widget uses true scales
|
||||||
mScaleRangeWidget->setScaleRange( 1.0 / ( settingList.at( 0 ).maxScaleDenominator > 0 ? settingList.at( 0 ).maxScaleDenominator : layer->maximumScale() ),
|
mScaleRangeWidget->setScaleRange( 1.0 / ( settingList.at( 0 ).maxScaleDenominator > 0 ? settingList.at( 0 ).maxScaleDenominator : layer->minimumScale() ),
|
||||||
1.0 / ( settingList.at( 0 ).minScaleDenominator > 0 ? settingList.at( 0 ).minScaleDenominator : layer->minimumScale() ) );
|
1.0 / ( settingList.at( 0 ).minScaleDenominator > 0 ? settingList.at( 0 ).minScaleDenominator : layer->maximumScale() ) );
|
||||||
mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
|
mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
|
||||||
mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType );
|
mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType );
|
||||||
mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale );
|
mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale );
|
||||||
|
@ -141,7 +141,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
|
|||||||
// set up the scale based layer visibility stuff....
|
// set up the scale based layer visibility stuff....
|
||||||
mScaleRangeWidget->setMapCanvas( mMapCanvas );
|
mScaleRangeWidget->setMapCanvas( mMapCanvas );
|
||||||
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
|
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
|
||||||
mScaleRangeWidget->setScaleRange( 1.0 / lyr->maximumScale(), 1.0 / lyr->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
mScaleRangeWidget->setScaleRange( 1.0 / lyr->minimumScale(), 1.0 / lyr->maximumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
||||||
|
|
||||||
leNoDataValue->setValidator( new QDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );
|
leNoDataValue->setValidator( new QDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );
|
||||||
|
|
||||||
@ -911,8 +911,8 @@ void QgsRasterLayerProperties::apply()
|
|||||||
// set up the scale based layer visibility stuff....
|
// set up the scale based layer visibility stuff....
|
||||||
mRasterLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
|
mRasterLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
|
||||||
// caution: layer uses scale denoms, widget uses true scales
|
// caution: layer uses scale denoms, widget uses true scales
|
||||||
mRasterLayer->setMaximumScale( 1.0 / mScaleRangeWidget->minimumScale() );
|
mRasterLayer->setMinimumScale( 1.0 / mScaleRangeWidget->minimumScale() );
|
||||||
mRasterLayer->setMinimumScale( 1.0 / mScaleRangeWidget->maximumScale() );
|
mRasterLayer->setMaximumScale( 1.0 / mScaleRangeWidget->maximumScale() );
|
||||||
|
|
||||||
mRasterLayer->setAutoRefreshInterval( mRefreshLayerIntervalSpinBox->value() * 1000.0 );
|
mRasterLayer->setAutoRefreshInterval( mRefreshLayerIntervalSpinBox->value() * 1000.0 );
|
||||||
mRasterLayer->setAutoRefreshEnabled( mRefreshLayerCheckBox->isChecked() );
|
mRasterLayer->setAutoRefreshEnabled( mRefreshLayerCheckBox->isChecked() );
|
||||||
|
@ -411,7 +411,7 @@ void QgsVectorLayerProperties::syncToLayer()
|
|||||||
mDisplayExpressionWidget->setField( mLayer->displayExpression() );
|
mDisplayExpressionWidget->setField( mLayer->displayExpression() );
|
||||||
|
|
||||||
// set up the scale based layer visibility stuff....
|
// set up the scale based layer visibility stuff....
|
||||||
mScaleRangeWidget->setScaleRange( 1.0 / mLayer->maximumScale(), 1.0 / mLayer->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
mScaleRangeWidget->setScaleRange( 1.0 / mLayer->minimumScale(), 1.0 / mLayer->maximumScale() ); // caution: layer uses scale denoms, widget uses true scales
|
||||||
mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
|
mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
|
||||||
mScaleRangeWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
|
mScaleRangeWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
|
||||||
|
|
||||||
@ -510,8 +510,8 @@ void QgsVectorLayerProperties::apply()
|
|||||||
// set up the scale based layer visibility stuff....
|
// set up the scale based layer visibility stuff....
|
||||||
mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
|
mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
|
||||||
// caution: layer uses scale denoms, widget uses true scales
|
// caution: layer uses scale denoms, widget uses true scales
|
||||||
mLayer->setMaximumScale( mScaleRangeWidget->maximumScaleDenom() );
|
mLayer->setMinimumScale( mScaleRangeWidget->maximumScaleDenom() );
|
||||||
mLayer->setMinimumScale( mScaleRangeWidget->minimumScaleDenom() );
|
mLayer->setMaximumScale( mScaleRangeWidget->minimumScaleDenom() );
|
||||||
|
|
||||||
// provider-specific options
|
// provider-specific options
|
||||||
if ( mLayer->dataProvider() )
|
if ( mLayer->dataProvider() )
|
||||||
|
@ -3361,9 +3361,9 @@ static QVariant fcnGetLayerProperty( const QVariantList &values, const QgsExpres
|
|||||||
else if ( QString::compare( layerProperty, QStringLiteral( "source" ), Qt::CaseInsensitive ) == 0 )
|
else if ( QString::compare( layerProperty, QStringLiteral( "source" ), Qt::CaseInsensitive ) == 0 )
|
||||||
return layer->publicSource();
|
return layer->publicSource();
|
||||||
else if ( QString::compare( layerProperty, QStringLiteral( "min_scale" ), Qt::CaseInsensitive ) == 0 )
|
else if ( QString::compare( layerProperty, QStringLiteral( "min_scale" ), Qt::CaseInsensitive ) == 0 )
|
||||||
return layer->minimumScale();
|
|
||||||
else if ( QString::compare( layerProperty, QStringLiteral( "max_scale" ), Qt::CaseInsensitive ) == 0 )
|
|
||||||
return layer->maximumScale();
|
return layer->maximumScale();
|
||||||
|
else if ( QString::compare( layerProperty, QStringLiteral( "max_scale" ), Qt::CaseInsensitive ) == 0 )
|
||||||
|
return layer->minimumScale();
|
||||||
else if ( QString::compare( layerProperty, QStringLiteral( "crs" ), Qt::CaseInsensitive ) == 0 )
|
else if ( QString::compare( layerProperty, QStringLiteral( "crs" ), Qt::CaseInsensitive ) == 0 )
|
||||||
return layer->crs().authid();
|
return layer->crs().authid();
|
||||||
else if ( QString::compare( layerProperty, QStringLiteral( "crs_definition" ), Qt::CaseInsensitive ) == 0 )
|
else if ( QString::compare( layerProperty, QStringLiteral( "crs_definition" ), Qt::CaseInsensitive ) == 0 )
|
||||||
|
@ -106,8 +106,8 @@ void QgsMapLayer::clone( QgsMapLayer *layer ) const
|
|||||||
layer->setName( name() );
|
layer->setName( name() );
|
||||||
layer->setShortName( shortName() );
|
layer->setShortName( shortName() );
|
||||||
layer->setExtent( extent() );
|
layer->setExtent( extent() );
|
||||||
layer->setMinimumScale( minimumScale() );
|
|
||||||
layer->setMaximumScale( maximumScale() );
|
layer->setMaximumScale( maximumScale() );
|
||||||
|
layer->setMinimumScale( minimumScale() );
|
||||||
layer->setScaleBasedVisibility( hasScaleBasedVisibility() );
|
layer->setScaleBasedVisibility( hasScaleBasedVisibility() );
|
||||||
layer->setTitle( title() );
|
layer->setTitle( title() );
|
||||||
layer->setAbstract( abstract() );
|
layer->setAbstract( abstract() );
|
||||||
@ -460,8 +460,17 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, const QgsReadWr
|
|||||||
|
|
||||||
// use scale dependent visibility flag
|
// use scale dependent visibility flag
|
||||||
setScaleBasedVisibility( layerElement.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
|
setScaleBasedVisibility( layerElement.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
|
||||||
setMinimumScale( layerElement.attribute( QStringLiteral( "minimumScale" ) ).toDouble() );
|
if ( layerElement.hasAttribute( QStringLiteral( "minimumScale" ) ) )
|
||||||
setMaximumScale( layerElement.attribute( QStringLiteral( "maximumScale" ) ).toDouble() );
|
{
|
||||||
|
// older element, when scales were reversed
|
||||||
|
setMaximumScale( layerElement.attribute( QStringLiteral( "minimumScale" ) ).toDouble() );
|
||||||
|
setMinimumScale( layerElement.attribute( QStringLiteral( "maximumScale" ) ).toDouble() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setMaximumScale( layerElement.attribute( QStringLiteral( "maxScale" ) ).toDouble() );
|
||||||
|
setMinimumScale( layerElement.attribute( QStringLiteral( "minScale" ) ).toDouble() );
|
||||||
|
}
|
||||||
|
|
||||||
setAutoRefreshInterval( layerElement.attribute( QStringLiteral( "autoRefreshTime" ), 0 ).toInt() );
|
setAutoRefreshInterval( layerElement.attribute( QStringLiteral( "autoRefreshTime" ), 0 ).toInt() );
|
||||||
setAutoRefreshEnabled( layerElement.attribute( QStringLiteral( "autoRefreshEnabled" ), QStringLiteral( "0" ) ).toInt() );
|
setAutoRefreshEnabled( layerElement.attribute( QStringLiteral( "autoRefreshEnabled" ), QStringLiteral( "0" ) ).toInt() );
|
||||||
@ -564,8 +573,8 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume
|
|||||||
{
|
{
|
||||||
// use scale dependent visibility flag
|
// use scale dependent visibility flag
|
||||||
layerElement.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
|
layerElement.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
|
||||||
layerElement.setAttribute( QStringLiteral( "minimumScale" ), QString::number( minimumScale() ) );
|
layerElement.setAttribute( QStringLiteral( "maxScale" ), QString::number( maximumScale() ) );
|
||||||
layerElement.setAttribute( QStringLiteral( "maximumScale" ), QString::number( maximumScale() ) );
|
layerElement.setAttribute( QStringLiteral( "minScale" ), QString::number( minimumScale() ) );
|
||||||
|
|
||||||
if ( !mExtent.isNull() )
|
if ( !mExtent.isNull() )
|
||||||
{
|
{
|
||||||
@ -922,18 +931,18 @@ const QgsLayerMetadata &QgsMapLayer::metadata() const
|
|||||||
return mMetadata;
|
return mMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsMapLayer::setMinimumScale( double scale )
|
void QgsMapLayer::setMaximumScale( double scale )
|
||||||
{
|
{
|
||||||
mMinScale = scale;
|
mMinScale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
double QgsMapLayer::minimumScale() const
|
double QgsMapLayer::maximumScale() const
|
||||||
{
|
{
|
||||||
return mMinScale;
|
return mMinScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QgsMapLayer::setMaximumScale( double scale )
|
void QgsMapLayer::setMinimumScale( double scale )
|
||||||
{
|
{
|
||||||
mMaxScale = scale;
|
mMaxScale = scale;
|
||||||
}
|
}
|
||||||
@ -943,7 +952,7 @@ void QgsMapLayer::setScaleBasedVisibility( const bool enabled )
|
|||||||
mScaleBasedVisibility = enabled;
|
mScaleBasedVisibility = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
double QgsMapLayer::maximumScale() const
|
double QgsMapLayer::minimumScale() const
|
||||||
{
|
{
|
||||||
return mMaxScale;
|
return mMaxScale;
|
||||||
}
|
}
|
||||||
@ -1191,8 +1200,17 @@ bool QgsMapLayer::importNamedStyle( QDomDocument &myDocument, QString &myErrorMe
|
|||||||
|
|
||||||
// use scale dependent visibility flag
|
// use scale dependent visibility flag
|
||||||
setScaleBasedVisibility( myRoot.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
|
setScaleBasedVisibility( myRoot.attribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).toInt() == 1 );
|
||||||
setMinimumScale( myRoot.attribute( QStringLiteral( "minimumScale" ) ).toDouble() );
|
if ( myRoot.hasAttribute( QStringLiteral( "minimumScale" ) ) )
|
||||||
setMaximumScale( myRoot.attribute( QStringLiteral( "maximumScale" ) ).toDouble() );
|
{
|
||||||
|
//older scale element, when min/max were reversed
|
||||||
|
setMaximumScale( myRoot.attribute( QStringLiteral( "minimumScale" ) ).toDouble() );
|
||||||
|
setMinimumScale( myRoot.attribute( QStringLiteral( "maximumScale" ) ).toDouble() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setMaximumScale( myRoot.attribute( QStringLiteral( "maxScale" ) ).toDouble() );
|
||||||
|
setMinimumScale( myRoot.attribute( QStringLiteral( "minScale" ) ).toDouble() );
|
||||||
|
}
|
||||||
|
|
||||||
return readSymbology( myRoot, myErrorMessage, QgsReadWriteContext() ); // TODO: support relative paths in QML?
|
return readSymbology( myRoot, myErrorMessage, QgsReadWriteContext() ); // TODO: support relative paths in QML?
|
||||||
}
|
}
|
||||||
@ -1208,8 +1226,8 @@ void QgsMapLayer::exportNamedStyle( QDomDocument &doc, QString &errorMsg ) const
|
|||||||
myDocument.appendChild( myRootNode );
|
myDocument.appendChild( myRootNode );
|
||||||
|
|
||||||
myRootNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
|
myRootNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
|
||||||
myRootNode.setAttribute( QStringLiteral( "minimumScale" ), QString::number( minimumScale() ) );
|
myRootNode.setAttribute( QStringLiteral( "maxScale" ), QString::number( maximumScale() ) );
|
||||||
myRootNode.setAttribute( QStringLiteral( "maximumScale" ), QString::number( maximumScale() ) );
|
myRootNode.setAttribute( QStringLiteral( "mincale" ), QString::number( minimumScale() ) );
|
||||||
|
|
||||||
if ( !writeSymbology( myRootNode, myDocument, errorMsg, QgsReadWriteContext() ) ) // TODO: support relative paths in QML?
|
if ( !writeSymbology( myRootNode, myDocument, errorMsg, QgsReadWriteContext() ) ) // TODO: support relative paths in QML?
|
||||||
{
|
{
|
||||||
|
@ -689,9 +689,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
*/
|
*/
|
||||||
bool isInScaleRange( double scale ) const;
|
bool isInScaleRange( double scale ) const;
|
||||||
|
|
||||||
/** Returns the minimum scale denominator at which the layer is visible.
|
/**
|
||||||
* Scale based visibility is only used if hasScaleBasedVisibility is true.
|
* Returns the minimum map scale (i.e. most "zoomed out" scale) at which the layer will be visible.
|
||||||
* \returns minimum scale denominator at which the layer will render
|
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
|
* A scale of 0 indicates no minimum scale visibility.
|
||||||
|
* \note Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
* \see setMinimumScale()
|
* \see setMinimumScale()
|
||||||
* \see maximumScale()
|
* \see maximumScale()
|
||||||
* \see hasScaleBasedVisibility()
|
* \see hasScaleBasedVisibility()
|
||||||
@ -699,9 +701,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
*/
|
*/
|
||||||
double minimumScale() const;
|
double minimumScale() const;
|
||||||
|
|
||||||
/** Returns the maximum scale denominator at which the layer is visible.
|
/**
|
||||||
* Scale based visibility is only used if hasScaleBasedVisibility is true.
|
* Returns the maximum map scale (i.e. most "zoomed in" scale) at which the layer will be visible.
|
||||||
* \returns minimum scale denominator at which the layer will render
|
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
|
* A scale of 0 indicates no maximum scale visibility.
|
||||||
|
* \note Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
* \see setMaximumScale()
|
* \see setMaximumScale()
|
||||||
* \see minimumScale()
|
* \see minimumScale()
|
||||||
* \see hasScaleBasedVisibility()
|
* \see hasScaleBasedVisibility()
|
||||||
@ -792,21 +796,25 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Sets the minimum scale denominator at which the layer will be visible.
|
/**
|
||||||
* Scale based visibility is only used if setScaleBasedVisibility is set to true.
|
* Sets the minimum map \a scale (i.e. most "zoomed out" scale) at which the layer will be visible.
|
||||||
* \param scale minimum scale denominator at which the layer should render
|
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
* \see minimumScale
|
* A \a scale of 0 indicates no minimum scale visibility.
|
||||||
* \see setMaximumScale
|
* \note Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
* \see setScaleBasedVisibility
|
* \see minimumScale()
|
||||||
|
* \see setMaximumScale()
|
||||||
|
* \see setScaleBasedVisibility()
|
||||||
*/
|
*/
|
||||||
void setMinimumScale( double scale );
|
void setMinimumScale( double scale );
|
||||||
|
|
||||||
/** Sets the maximum scale denominator at which the layer will be visible.
|
/**
|
||||||
* Scale based visibility is only used if setScaleBasedVisibility is set to true.
|
* Sets the maximum map \a scale (i.e. most "zoomed in" scale) at which the layer will be visible.
|
||||||
* \param scale maximum scale denominator at which the layer should render
|
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||||
* \see maximumScale
|
* A \a scale of 0 indicates no maximum scale visibility.
|
||||||
* \see setMinimumScale
|
* \note Scale based visibility is only used if setScaleBasedVisibility() is set to true.
|
||||||
* \see setScaleBasedVisibility
|
* \see maximumScale()
|
||||||
|
* \see setMinimumScale()
|
||||||
|
* \see setScaleBasedVisibility()
|
||||||
*/
|
*/
|
||||||
void setMaximumScale( double scale );
|
void setMaximumScale( double scale );
|
||||||
|
|
||||||
|
@ -2209,7 +2209,7 @@ bool QgsVectorLayer::writeSld( QDomNode &node, QDomDocument &doc, QString &error
|
|||||||
QgsStringMap localProps = QgsStringMap( props );
|
QgsStringMap localProps = QgsStringMap( props );
|
||||||
if ( hasScaleBasedVisibility() )
|
if ( hasScaleBasedVisibility() )
|
||||||
{
|
{
|
||||||
QgsSymbolLayerUtils::mergeScaleDependencies( minimumScale(), maximumScale(), localProps );
|
QgsSymbolLayerUtils::mergeScaleDependencies( maximumScale(), minimumScale(), localProps );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hasGeometryType() )
|
if ( hasGeometryType() )
|
||||||
|
@ -588,11 +588,8 @@ void QgsWmsConfigParser::setLayerIdsToLegendModel( QgsLegendModel *model, const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsMapLayer *layer = nodeLayer->layer();
|
QgsMapLayer *layer = nodeLayer->layer();
|
||||||
if ( layer->hasScaleBasedVisibility() )
|
if ( !layer->isInScaleRange( scale ) )
|
||||||
{
|
{
|
||||||
if ( layer->minimumScale() > scale )
|
|
||||||
qobject_cast<QgsLayerTreeGroup *>( nodeLayer->parent() )->removeChildNode( nodeLayer );
|
|
||||||
else if ( layer->maximumScale() < scale )
|
|
||||||
qobject_cast<QgsLayerTreeGroup *>( nodeLayer->parent() )->removeChildNode( nodeLayer );
|
qobject_cast<QgsLayerTreeGroup *>( nodeLayer->parent() )->removeChildNode( nodeLayer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1324,19 +1324,19 @@ void QgsWmsProjectParser::addLayers( QDomDocument &doc,
|
|||||||
double SCALE_TO_SCALEHINT = OGC_PX_M * sqrt( 2.0 );
|
double SCALE_TO_SCALEHINT = OGC_PX_M * sqrt( 2.0 );
|
||||||
|
|
||||||
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
|
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
|
||||||
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( currentLayer->minimumScale() * SCALE_TO_SCALEHINT ) );
|
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( currentLayer->maximumScale() * SCALE_TO_SCALEHINT ) );
|
||||||
scaleHintElem.setAttribute( QStringLiteral( "max" ), QString::number( currentLayer->maximumScale() * SCALE_TO_SCALEHINT ) );
|
scaleHintElem.setAttribute( QStringLiteral( "max" ), QString::number( currentLayer->minimumScale() * SCALE_TO_SCALEHINT ) );
|
||||||
layerElem.appendChild( scaleHintElem );
|
layerElem.appendChild( scaleHintElem );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString minScaleString = QString::number( currentLayer->minimumScale() );
|
QString minScaleString = QString::number( currentLayer->maximumScale() );
|
||||||
QDomElement minScaleElem = doc.createElement( QStringLiteral( "MinScaleDenominator" ) );
|
QDomElement minScaleElem = doc.createElement( QStringLiteral( "MinScaleDenominator" ) );
|
||||||
QDomText minScaleText = doc.createTextNode( minScaleString );
|
QDomText minScaleText = doc.createTextNode( minScaleString );
|
||||||
minScaleElem.appendChild( minScaleText );
|
minScaleElem.appendChild( minScaleText );
|
||||||
layerElem.appendChild( minScaleElem );
|
layerElem.appendChild( minScaleElem );
|
||||||
|
|
||||||
QString maxScaleString = QString::number( currentLayer->maximumScale() );
|
QString maxScaleString = QString::number( currentLayer->minimumScale() );
|
||||||
QDomElement maxScaleElem = doc.createElement( QStringLiteral( "MaxScaleDenominator" ) );
|
QDomElement maxScaleElem = doc.createElement( QStringLiteral( "MaxScaleDenominator" ) );
|
||||||
QDomText maxScaleText = doc.createTextNode( maxScaleString );
|
QDomText maxScaleText = doc.createTextNode( maxScaleString );
|
||||||
maxScaleElem.appendChild( maxScaleText );
|
maxScaleElem.appendChild( maxScaleText );
|
||||||
@ -1638,8 +1638,8 @@ void QgsWmsProjectParser::addOWSLayers( QDomDocument &doc,
|
|||||||
//min/max scale denominatormScaleBasedVisibility
|
//min/max scale denominatormScaleBasedVisibility
|
||||||
if ( currentLayer->hasScaleBasedVisibility() )
|
if ( currentLayer->hasScaleBasedVisibility() )
|
||||||
{
|
{
|
||||||
QString minScaleString = QString::number( currentLayer->minimumScale() );
|
QString minScaleString = QString::number( currentLayer->maximumScale() );
|
||||||
QString maxScaleString = QString::number( currentLayer->maximumScale() );
|
QString maxScaleString = QString::number( currentLayer->minimumScale() );
|
||||||
QDomElement minScaleElem = doc.createElement( QStringLiteral( "sld:MinScaleDenominator" ) );
|
QDomElement minScaleElem = doc.createElement( QStringLiteral( "sld:MinScaleDenominator" ) );
|
||||||
QDomText minScaleText = doc.createTextNode( minScaleString );
|
QDomText minScaleText = doc.createTextNode( minScaleString );
|
||||||
minScaleElem.appendChild( minScaleText );
|
minScaleElem.appendChild( minScaleText );
|
||||||
|
@ -1002,19 +1002,19 @@ namespace QgsWms
|
|||||||
double SCALE_TO_SCALEHINT = OGC_PX_M * sqrt( 2.0 );
|
double SCALE_TO_SCALEHINT = OGC_PX_M * sqrt( 2.0 );
|
||||||
|
|
||||||
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
|
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
|
||||||
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( l->minimumScale() * SCALE_TO_SCALEHINT ) );
|
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( l->maximumScale() * SCALE_TO_SCALEHINT ) );
|
||||||
scaleHintElem.setAttribute( QStringLiteral( "max" ), QString::number( l->maximumScale() * SCALE_TO_SCALEHINT ) );
|
scaleHintElem.setAttribute( QStringLiteral( "max" ), QString::number( l->minimumScale() * SCALE_TO_SCALEHINT ) );
|
||||||
layerElem.appendChild( scaleHintElem );
|
layerElem.appendChild( scaleHintElem );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString minScaleString = QString::number( l->minimumScale() );
|
QString minScaleString = QString::number( l->maximumScale() );
|
||||||
QDomElement minScaleElem = doc.createElement( QStringLiteral( "MinScaleDenominator" ) );
|
QDomElement minScaleElem = doc.createElement( QStringLiteral( "MinScaleDenominator" ) );
|
||||||
QDomText minScaleText = doc.createTextNode( minScaleString );
|
QDomText minScaleText = doc.createTextNode( minScaleString );
|
||||||
minScaleElem.appendChild( minScaleText );
|
minScaleElem.appendChild( minScaleText );
|
||||||
layerElem.appendChild( minScaleElem );
|
layerElem.appendChild( minScaleElem );
|
||||||
|
|
||||||
QString maxScaleString = QString::number( l->maximumScale() );
|
QString maxScaleString = QString::number( l->minimumScale() );
|
||||||
QDomElement maxScaleElem = doc.createElement( QStringLiteral( "MaxScaleDenominator" ) );
|
QDomElement maxScaleElem = doc.createElement( QStringLiteral( "MaxScaleDenominator" ) );
|
||||||
QDomText maxScaleText = doc.createTextNode( maxScaleString );
|
QDomText maxScaleText = doc.createTextNode( maxScaleString );
|
||||||
maxScaleElem.appendChild( maxScaleText );
|
maxScaleElem.appendChild( maxScaleText );
|
||||||
|
@ -338,8 +338,8 @@ namespace QgsWms
|
|||||||
//min/max scale denominatorScaleBasedVisibility
|
//min/max scale denominatorScaleBasedVisibility
|
||||||
if ( l->hasScaleBasedVisibility() )
|
if ( l->hasScaleBasedVisibility() )
|
||||||
{
|
{
|
||||||
QString minScaleString = QString::number( l->minimumScale() );
|
QString minScaleString = QString::number( l->maximumScale() );
|
||||||
QString maxScaleString = QString::number( l->maximumScale() );
|
QString maxScaleString = QString::number( l->minimumScale() );
|
||||||
QDomElement minScaleElem = doc.createElement( QStringLiteral( "sld:MinScaleDenominator" ) );
|
QDomElement minScaleElem = doc.createElement( QStringLiteral( "sld:MinScaleDenominator" ) );
|
||||||
QDomText minScaleText = doc.createTextNode( minScaleString );
|
QDomText minScaleText = doc.createTextNode( minScaleString );
|
||||||
minScaleElem.appendChild( minScaleText );
|
minScaleElem.appendChild( minScaleText );
|
||||||
|
@ -1104,8 +1104,7 @@ namespace QgsWms
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//skip layer if not visible at current map scale
|
//skip layer if not visible at current map scale
|
||||||
bool useScaleConstraint = ( scaleDenominator > 0 && currentLayer->hasScaleBasedVisibility() );
|
if ( scaleDenominator > 0 && !currentLayer->isInScaleRange( scaleDenominator ) )
|
||||||
if ( useScaleConstraint && ( currentLayer->minimumScale() > scaleDenominator || currentLayer->maximumScale() < scaleDenominator ) )
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1886,9 +1885,7 @@ namespace QgsWms
|
|||||||
lName = mapLayer->shortName();
|
lName = mapLayer->shortName();
|
||||||
QgsMessageLog::logMessage( QStringLiteral( "Checking layer: %1" ).arg( lName ) );
|
QgsMessageLog::logMessage( QStringLiteral( "Checking layer: %1" ).arg( lName ) );
|
||||||
//test if layer is visible in requested scale
|
//test if layer is visible in requested scale
|
||||||
bool useScaleConstraint = ( scaleDenominator > 0 && mapLayer->hasScaleBasedVisibility() );
|
if ( scaleDenominator == 0 || mapLayer->isInScaleRange( scaleDenominator ) )
|
||||||
if ( !useScaleConstraint ||
|
|
||||||
( mapLayer->minimumScale() <= scaleDenominator && mapLayer->maximumScale() >= scaleDenominator ) )
|
|
||||||
{
|
{
|
||||||
layerKeys.push_front( mapLayer->id() );
|
layerKeys.push_front( mapLayer->id() );
|
||||||
QgsProject::instance()->addMapLayers(
|
QgsProject::instance()->addMapLayers(
|
||||||
|
@ -93,8 +93,8 @@ class TestQgsExpression: public QObject
|
|||||||
mPointsLayer->setDataUrl( QStringLiteral( "data url" ) );
|
mPointsLayer->setDataUrl( QStringLiteral( "data url" ) );
|
||||||
mPointsLayer->setAttribution( QStringLiteral( "layer attribution" ) );
|
mPointsLayer->setAttribution( QStringLiteral( "layer attribution" ) );
|
||||||
mPointsLayer->setAttributionUrl( QStringLiteral( "attribution url" ) );
|
mPointsLayer->setAttributionUrl( QStringLiteral( "attribution url" ) );
|
||||||
mPointsLayer->setMaximumScale( 500 );
|
mPointsLayer->setMinimumScale( 500 );
|
||||||
mPointsLayer->setMinimumScale( 1000 );
|
mPointsLayer->setMaximumScale( 1000 );
|
||||||
|
|
||||||
QString rasterFileName = testDataDir + "tenbytenraster.asc";
|
QString rasterFileName = testDataDir + "tenbytenraster.asc";
|
||||||
QFileInfo rasterFileInfo( rasterFileName );
|
QFileInfo rasterFileInfo( rasterFileName );
|
||||||
@ -1086,8 +1086,8 @@ class TestQgsExpression: public QObject
|
|||||||
QTest::newRow( "layer_property attribution" ) << QStringLiteral( "layer_property('%1','attribution')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->attribution() );
|
QTest::newRow( "layer_property attribution" ) << QStringLiteral( "layer_property('%1','attribution')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->attribution() );
|
||||||
QTest::newRow( "layer_property attribution_url" ) << QStringLiteral( "layer_property('%1','attribution_url')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->attributionUrl() );
|
QTest::newRow( "layer_property attribution_url" ) << QStringLiteral( "layer_property('%1','attribution_url')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->attributionUrl() );
|
||||||
QTest::newRow( "layer_property source" ) << QStringLiteral( "layer_property('%1','source')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->publicSource() );
|
QTest::newRow( "layer_property source" ) << QStringLiteral( "layer_property('%1','source')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->publicSource() );
|
||||||
QTest::newRow( "layer_property min_scale" ) << QStringLiteral( "layer_property('%1','min_scale')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->minimumScale() );
|
QTest::newRow( "layer_property min_scale" ) << QStringLiteral( "layer_property('%1','min_scale')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->maximumScale() );
|
||||||
QTest::newRow( "layer_property max_scale" ) << QStringLiteral( "layer_property('%1','max_scale')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->maximumScale() );
|
QTest::newRow( "layer_property max_scale" ) << QStringLiteral( "layer_property('%1','max_scale')" ).arg( mPointsLayer->name() ) << false << QVariant( mPointsLayer->minimumScale() );
|
||||||
QTest::newRow( "layer_property crs" ) << QStringLiteral( "layer_property('%1','crs')" ).arg( mPointsLayer->name() ) << false << QVariant( "EPSG:4326" );
|
QTest::newRow( "layer_property crs" ) << QStringLiteral( "layer_property('%1','crs')" ).arg( mPointsLayer->name() ) << false << QVariant( "EPSG:4326" );
|
||||||
QTest::newRow( "layer_property extent" ) << QStringLiteral( "geom_to_wkt(layer_property('%1','extent'))" ).arg( mPointsLayer->name() ) << false << QVariant( "Polygon ((-118.88888889 22.80020704, -83.33333333 22.80020704, -83.33333333 46.87198068, -118.88888889 46.87198068, -118.88888889 22.80020704))" );
|
QTest::newRow( "layer_property extent" ) << QStringLiteral( "geom_to_wkt(layer_property('%1','extent'))" ).arg( mPointsLayer->name() ) << false << QVariant( "Polygon ((-118.88888889 22.80020704, -83.33333333 22.80020704, -83.33333333 46.87198068, -118.88888889 46.87198068, -118.88888889 22.80020704))" );
|
||||||
QTest::newRow( "layer_property type" ) << QStringLiteral( "layer_property('%1','type')" ).arg( mPointsLayer->name() ) << false << QVariant( "Vector" );
|
QTest::newRow( "layer_property type" ) << QStringLiteral( "layer_property('%1','type')" ).arg( mPointsLayer->name() ) << false << QVariant( "Vector" );
|
||||||
|
@ -149,8 +149,8 @@ void TestQgsMapLayer::isInScaleRange()
|
|||||||
QFETCH( double, scale );
|
QFETCH( double, scale );
|
||||||
QFETCH( bool, isInScale );
|
QFETCH( bool, isInScale );
|
||||||
|
|
||||||
mpLayer->setMinimumScale( 2500.0 );
|
mpLayer->setMaximumScale( 2500.0 );
|
||||||
mpLayer->setMaximumScale( 5000.0 );
|
mpLayer->setMinimumScale( 5000.0 );
|
||||||
mpLayer->setScaleBasedVisibility( true );
|
mpLayer->setScaleBasedVisibility( true );
|
||||||
QCOMPARE( mpLayer->isInScaleRange( scale ), isInScale );
|
QCOMPARE( mpLayer->isInScaleRange( scale ), isInScale );
|
||||||
//always in scale range if scale based visibility is false
|
//always in scale range if scale based visibility is false
|
||||||
@ -160,8 +160,8 @@ void TestQgsMapLayer::isInScaleRange()
|
|||||||
|
|
||||||
void TestQgsMapLayer::isInScaleRange2()
|
void TestQgsMapLayer::isInScaleRange2()
|
||||||
{
|
{
|
||||||
mpLayer->setMinimumScale( 5000.0 );
|
mpLayer->setMaximumScale( 5000.0 );
|
||||||
mpLayer->setMaximumScale( 0.0 );
|
mpLayer->setMinimumScale( 0.0 );
|
||||||
mpLayer->setScaleBasedVisibility( true );
|
mpLayer->setScaleBasedVisibility( true );
|
||||||
QVERIFY( !mpLayer->isInScaleRange( 1000 ) );
|
QVERIFY( !mpLayer->isInScaleRange( 1000 ) );
|
||||||
QVERIFY( !mpLayer->isInScaleRange( 1 ) );
|
QVERIFY( !mpLayer->isInScaleRange( 1 ) );
|
||||||
@ -169,8 +169,8 @@ void TestQgsMapLayer::isInScaleRange2()
|
|||||||
QVERIFY( mpLayer->isInScaleRange( 5001 ) );
|
QVERIFY( mpLayer->isInScaleRange( 5001 ) );
|
||||||
QVERIFY( mpLayer->isInScaleRange( 15000 ) );
|
QVERIFY( mpLayer->isInScaleRange( 15000 ) );
|
||||||
|
|
||||||
mpLayer->setMinimumScale( 0.0 );
|
mpLayer->setMaximumScale( 0.0 );
|
||||||
mpLayer->setMaximumScale( 5000.0 );
|
mpLayer->setMinimumScale( 5000.0 );
|
||||||
mpLayer->setScaleBasedVisibility( true );
|
mpLayer->setScaleBasedVisibility( true );
|
||||||
QVERIFY( mpLayer->isInScaleRange( 1000 ) );
|
QVERIFY( mpLayer->isInScaleRange( 1000 ) );
|
||||||
QVERIFY( mpLayer->isInScaleRange( 1 ) );
|
QVERIFY( mpLayer->isInScaleRange( 1 ) );
|
||||||
|
@ -417,8 +417,8 @@ class TestQgsSymbolLayerCreateSld(unittest.TestCase):
|
|||||||
layer = QgsVectorLayer("Point", "addfeat", "memory")
|
layer = QgsVectorLayer("Point", "addfeat", "memory")
|
||||||
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "singleSymbol"))
|
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "singleSymbol"))
|
||||||
layer.loadNamedStyle(mFilePath)
|
layer.loadNamedStyle(mFilePath)
|
||||||
layer.setMinimumScale(1000)
|
layer.setMaximumScale(1000)
|
||||||
layer.setMaximumScale(500000)
|
layer.setMinimumScale(500000)
|
||||||
layer.setScaleBasedVisibility(True)
|
layer.setScaleBasedVisibility(True)
|
||||||
|
|
||||||
dom, root = self.layerToSld(layer)
|
dom, root = self.layerToSld(layer)
|
||||||
@ -442,8 +442,8 @@ class TestQgsSymbolLayerCreateSld(unittest.TestCase):
|
|||||||
layer = QgsVectorLayer("Polygon", "addfeat", "memory")
|
layer = QgsVectorLayer("Polygon", "addfeat", "memory")
|
||||||
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "categorized"))
|
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "categorized"))
|
||||||
layer.loadNamedStyle(mFilePath)
|
layer.loadNamedStyle(mFilePath)
|
||||||
layer.setMinimumScale(1000)
|
layer.setMaximumScale(1000)
|
||||||
layer.setMaximumScale(500000)
|
layer.setMinimumScale(500000)
|
||||||
layer.setScaleBasedVisibility(True)
|
layer.setScaleBasedVisibility(True)
|
||||||
|
|
||||||
dom, root = self.layerToSld(layer)
|
dom, root = self.layerToSld(layer)
|
||||||
@ -484,8 +484,8 @@ class TestQgsSymbolLayerCreateSld(unittest.TestCase):
|
|||||||
|
|
||||||
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "ruleBased"))
|
mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.qml' % (unitTestDataPath(), "ruleBased"))
|
||||||
status = layer.loadNamedStyle(mFilePath) # NOQA
|
status = layer.loadNamedStyle(mFilePath) # NOQA
|
||||||
layer.setMinimumScale(5000)
|
layer.setMaximumScale(5000)
|
||||||
layer.setMaximumScale(50000000)
|
layer.setMinimumScale(50000000)
|
||||||
layer.setScaleBasedVisibility(True)
|
layer.setScaleBasedVisibility(True)
|
||||||
|
|
||||||
dom, root = self.layerToSld(layer)
|
dom, root = self.layerToSld(layer)
|
||||||
|
@ -2176,8 +2176,8 @@ class TestQgsVectorLayer(unittest.TestCase, FeatureSourceTestCase):
|
|||||||
layer.styleManager().addStyle('style1', style1)
|
layer.styleManager().addStyle('style1', style1)
|
||||||
layer.setName('MyName')
|
layer.setName('MyName')
|
||||||
layer.setShortName('MyShortName')
|
layer.setShortName('MyShortName')
|
||||||
layer.setMinimumScale(0.5)
|
layer.setMaximumScale(0.5)
|
||||||
layer.setMaximumScale(1.5)
|
layer.setMinimumScale(1.5)
|
||||||
layer.setScaleBasedVisibility(True)
|
layer.setScaleBasedVisibility(True)
|
||||||
layer.setTitle('MyTitle')
|
layer.setTitle('MyTitle')
|
||||||
layer.setAbstract('MyAbstract')
|
layer.setAbstract('MyAbstract')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user