@@ -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,6 +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.
705
+ mCurrentRendererContext = &rendererContext;
704
706
if ( simplifyDrawingCanbeApplied ( QgsVectorLayer::GeometrySimplification ) )
705
707
{
706
708
QPainter* p = rendererContext.painter ();
@@ -747,6 +749,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
747
749
else
748
750
drawRendererV2 ( fit, rendererContext, labeling );
749
751
752
+ mCurrentRendererContext = NULL ;
750
753
return true ;
751
754
}
752
755
@@ -1258,7 +1261,17 @@ bool QgsVectorLayer::setSubsetString( QString subset )
1258
1261
1259
1262
bool QgsVectorLayer::simplifyDrawingCanbeApplied ( int simplifyHint ) const
1260
1263
{
1261
- return mDataProvider && !mEditBuffer && ( hasGeometryType () && geometryType () != QGis::Point ) && ( mSimplifyMethod .simplifyHints () & simplifyHint ) && ( !mCurrentRendererContext || mCurrentRendererContext ->useRenderingOptimization () );
1264
+ if ( mDataProvider && !mEditBuffer && ( hasGeometryType () && geometryType () != QGis::Point ) && ( mSimplifyMethod .simplifyHints () & simplifyHint ) && ( !mCurrentRendererContext || mCurrentRendererContext ->useRenderingOptimization () ) )
1265
+ {
1266
+ double maximumSimplificationScale = mSimplifyMethod .maximumScale ();
1267
+
1268
+ // check maximum scale at which generalisation should be carried out
1269
+ if ( mCurrentRendererContext && maximumSimplificationScale > 1 && mCurrentRendererContext ->rendererScale () <= maximumSimplificationScale )
1270
+ return false ;
1271
+
1272
+ return true ;
1273
+ }
1274
+ return false ;
1262
1275
}
1263
1276
1264
1277
QgsFeatureIterator QgsVectorLayer::getFeatures ( const QgsFeatureRequest& request )
@@ -1873,6 +1886,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
1873
1886
mSimplifyMethod .setSimplifyHints ( e.attribute ( " simplifyDrawingHints" , " 1" ).toInt () );
1874
1887
mSimplifyMethod .setThreshold ( e.attribute ( " simplifyDrawingTol" , " 1" ).toFloat () );
1875
1888
mSimplifyMethod .setForceLocalOptimization ( e.attribute ( " simplifyLocal" , " 1" ).toInt () );
1889
+ mSimplifyMethod .setMaximumScale ( e.attribute ( " simplifyMaxScale" , " 1" ).toFloat () );
1876
1890
1877
1891
// also restore custom properties (for labeling-ng)
1878
1892
readCustomProperties ( node, " labeling" );
@@ -2211,6 +2225,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
2211
2225
mapLayerNode.setAttribute ( " simplifyDrawingHints" , QString::number ( mSimplifyMethod .simplifyHints () ) );
2212
2226
mapLayerNode.setAttribute ( " simplifyDrawingTol" , QString::number ( mSimplifyMethod .threshold () ) );
2213
2227
mapLayerNode.setAttribute ( " simplifyLocal" , mSimplifyMethod .forceLocalOptimization () ? 1 : 0 );
2228
+ mapLayerNode.setAttribute ( " simplifyMaxScale" , QString::number ( mSimplifyMethod .maximumScale () ) );
2214
2229
2215
2230
// save customproperties (for labeling ng)
2216
2231
writeCustomProperties ( node, doc );
0 commit comments