@@ -187,6 +187,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
187
187
mSimplifyMethod .setSimplifyHints ( settings.value ( " /qgis/simplifyDrawingHints" , mSimplifyMethod .simplifyHints () ).toInt () );
188
188
mSimplifyMethod .setThreshold ( settings.value ( " /qgis/simplifyDrawingTol" , mSimplifyMethod .threshold () ).toFloat () );
189
189
mSimplifyMethod .setForceLocalOptimization ( settings.value ( " /qgis/simplifyLocal" , mSimplifyMethod .forceLocalOptimization () ).toBool () );
190
+ mSimplifyMethod .setMaximumScale ( settings.value ( " /qgis/simplifyMaxScale" , mSimplifyMethod .maximumScale () ).toFloat () );
190
191
191
192
} // QgsVectorLayer ctor
192
193
@@ -701,7 +702,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
701
702
.setSubsetOfAttributes ( attributes );
702
703
703
704
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
704
- if ( simplifyDrawingCanbeApplied ( QgsVectorLayer::GeometrySimplification ) )
705
+ if ( simplifyDrawingCanbeApplied ( rendererContext, QgsVectorLayer::GeometrySimplification ) )
705
706
{
706
707
QPainter* p = rendererContext.painter ();
707
708
double dpi = ( p->device ()->logicalDpiX () + p->device ()->logicalDpiY () ) / 2 ;
@@ -1256,9 +1257,19 @@ bool QgsVectorLayer::setSubsetString( QString subset )
1256
1257
return res;
1257
1258
}
1258
1259
1259
- bool QgsVectorLayer::simplifyDrawingCanbeApplied ( int simplifyHint ) const
1260
+ bool QgsVectorLayer::simplifyDrawingCanbeApplied ( const QgsRenderContext& renderContext, int simplifyHint ) const
1260
1261
{
1261
- return mDataProvider && !mEditBuffer && ( hasGeometryType () && geometryType () != QGis::Point ) && ( mSimplifyMethod .simplifyHints () & simplifyHint ) && ( !mCurrentRendererContext || mCurrentRendererContext ->useRenderingOptimization () );
1262
+ if ( mDataProvider && !mEditBuffer && ( hasGeometryType () && geometryType () != QGis::Point ) && ( mSimplifyMethod .simplifyHints () & simplifyHint ) && renderContext.useRenderingOptimization () )
1263
+ {
1264
+ double maximumSimplificationScale = mSimplifyMethod .maximumScale ();
1265
+
1266
+ // check maximum scale at which generalisation should be carried out
1267
+ if ( maximumSimplificationScale > 1 && renderContext.rendererScale () <= maximumSimplificationScale )
1268
+ return false ;
1269
+
1270
+ return true ;
1271
+ }
1272
+ return false ;
1262
1273
}
1263
1274
1264
1275
QgsFeatureIterator QgsVectorLayer::getFeatures ( const QgsFeatureRequest& request )
@@ -1873,6 +1884,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
1873
1884
mSimplifyMethod .setSimplifyHints ( e.attribute ( " simplifyDrawingHints" , " 1" ).toInt () );
1874
1885
mSimplifyMethod .setThreshold ( e.attribute ( " simplifyDrawingTol" , " 1" ).toFloat () );
1875
1886
mSimplifyMethod .setForceLocalOptimization ( e.attribute ( " simplifyLocal" , " 1" ).toInt () );
1887
+ mSimplifyMethod .setMaximumScale ( e.attribute ( " simplifyMaxScale" , " 1" ).toFloat () );
1876
1888
1877
1889
// also restore custom properties (for labeling-ng)
1878
1890
readCustomProperties ( node, " labeling" );
@@ -2211,6 +2223,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
2211
2223
mapLayerNode.setAttribute ( " simplifyDrawingHints" , QString::number ( mSimplifyMethod .simplifyHints () ) );
2212
2224
mapLayerNode.setAttribute ( " simplifyDrawingTol" , QString::number ( mSimplifyMethod .threshold () ) );
2213
2225
mapLayerNode.setAttribute ( " simplifyLocal" , mSimplifyMethod .forceLocalOptimization () ? 1 : 0 );
2226
+ mapLayerNode.setAttribute ( " simplifyMaxScale" , QString::number ( mSimplifyMethod .maximumScale () ) );
2214
2227
2215
2228
// save customproperties (for labeling ng)
2216
2229
writeCustomProperties ( node, doc );
0 commit comments