From 8fb87f182872c2db99d55198d5eef6048f26fad4 Mon Sep 17 00:00:00 2001 From: Alvaro Huarte Date: Wed, 15 Jan 2014 08:40:43 +0100 Subject: [PATCH] #8725-R: minor changes --- python/core/qgssimplifymethod.sip | 3 +++ src/core/qgssimplifymethod.cpp | 6 ++++++ src/core/qgssimplifymethod.h | 3 +++ src/providers/postgres/qgspostgresfeatureiterator.cpp | 2 +- src/ui/qgsoptionsbase.ui | 2 +- src/ui/qgsvectorlayerpropertiesbase.ui | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/python/core/qgssimplifymethod.sip b/python/core/qgssimplifymethod.sip index 55db7bb01da..d053badbf93 100644 --- a/python/core/qgssimplifymethod.sip +++ b/python/core/qgssimplifymethod.sip @@ -29,6 +29,9 @@ class QgsSimplifyMethod /** Gets the tolerance of simplification */ double tolerance() const; + /** Returns the optimal tolerance for Douglas-Peucker simplification algorithms */ + double toleranceForDouglasPeuckerAlgorithms() const; + /** Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries */ void setForceLocalOptimization( bool localOptimization ); /** Gets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries */ diff --git a/src/core/qgssimplifymethod.cpp b/src/core/qgssimplifymethod.cpp index b3a6e89b74f..29c402d9d3f 100644 --- a/src/core/qgssimplifymethod.cpp +++ b/src/core/qgssimplifymethod.cpp @@ -53,6 +53,12 @@ void QgsSimplifyMethod::setForceLocalOptimization( bool localOptimization ) { mForceLocalOptimization = localOptimization; } + +double QgsSimplifyMethod::toleranceForDouglasPeuckerAlgorithms() const +{ + //TODO: define more precise value, now, it is experimental but conservative + return mTolerance / 5.0; +} QgsAbstractGeometrySimplifier* QgsSimplifyMethod::createGeometrySimplifier( const QgsSimplifyMethod& simplifyMethod ) { diff --git a/src/core/qgssimplifymethod.h b/src/core/qgssimplifymethod.h index 2143ffbaf19..4d844288604 100644 --- a/src/core/qgssimplifymethod.h +++ b/src/core/qgssimplifymethod.h @@ -48,6 +48,9 @@ class CORE_EXPORT QgsSimplifyMethod //! Gets the tolerance of simplification inline double tolerance() const { return mTolerance; } + //! Returns the optimal tolerance for Douglas-Peucker simplification algorithms + double toleranceForDouglasPeuckerAlgorithms() const; + //! Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries void setForceLocalOptimization( bool localOptimization ); //! Gets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index da8dac128c6..2cadc8fba93 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -309,7 +309,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause ) double tolerance = simplifyMethod.methodType() == QgsSimplifyMethod::OptimizeForRendering ? - simplifyMethod.tolerance() / 5.0f /* experimental */ + simplifyMethod.toleranceForDouglasPeuckerAlgorithms() : simplifyMethod.tolerance(); diff --git a/src/ui/qgsoptionsbase.ui b/src/ui/qgsoptionsbase.ui index c460a1038b9..c1f3fd8bdea 100644 --- a/src/ui/qgsoptionsbase.ui +++ b/src/ui/qgsoptionsbase.ui @@ -1755,7 +1755,7 @@ - Runs on provider side, otherwise it will execute once obtained the geometry from data source + Simplify on provider side if possible diff --git a/src/ui/qgsvectorlayerpropertiesbase.ui b/src/ui/qgsvectorlayerpropertiesbase.ui index c7b54e5b69b..468b6a7c682 100644 --- a/src/ui/qgsvectorlayerpropertiesbase.ui +++ b/src/ui/qgsvectorlayerpropertiesbase.ui @@ -1014,7 +1014,7 @@ - Runs on provider side, otherwise it will execute once obtained the geometry from data source + Simplify on provider side if possible