Skip to content
Permalink
Browse files

#8725-R: FeatureIterator and other minor changes

  • Loading branch information
ahuarte47 authored and m-kuhn committed Jan 15, 2014
1 parent faebcce commit 23b6523fba7369f54171b0926e2e20ca1ec64dfa
@@ -396,10 +396,21 @@ void QgsVectorLayerProperties::syncToLayer( void )
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
mSimplifyDrawingGroupBox->setChecked( simplifyMethod.simplifyHints() != QgsVectorLayer::NoSimplification );
mSimplifyDrawingSlider->setValue(( int )( 5.0f * ( simplifyMethod.threshold() - 1 ) ) );
mSimplifyDrawingAtProvider->setChecked( !simplifyMethod.forceLocalOptimization() );
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value() > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * mSimplifyDrawingSlider->value() ) );

if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
{
mSimplifyDrawingAtProvider->setChecked( false );
mSimplifyDrawingAtProvider->setEnabled( false );
mSimplifyDrawingAtProvider->setText( QString( "%1 (%2)" ).arg( mSimplifyDrawingAtProvider->text(), tr( "Not supported" ) ) );
}
else
{
mSimplifyDrawingAtProvider->setChecked( !simplifyMethod.forceLocalOptimization() );
mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
}

// load appropriate symbology page (V1 or V2)
updateSymbologyPage();

@@ -1094,3 +1105,15 @@ void QgsVectorLayerProperties::on_mSimplifyDrawingSlider_valueChanged( int value
mSimplifyDrawingPanel->setVisible( value > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * value ) );
}

void QgsVectorLayerProperties::on_mSimplifyDrawingGroupBox_toggled( bool checked )
{
if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
{
mSimplifyDrawingAtProvider->setEnabled( false );
}
else
{
mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
}
}
@@ -120,6 +120,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
void on_mMaximumScaleSetCurrentPushButton_clicked();

void on_mSimplifyDrawingSlider_valueChanged( int value );
void on_mSimplifyDrawingGroupBox_toggled( bool checked );

signals:

@@ -25,27 +25,6 @@ QgsAbstractFeatureIterator::QgsAbstractFeatureIterator( const QgsFeatureRequest&
, refs( 0 )
, mGeometrySimplifier( NULL )
{
const QgsSimplifyMethod& simplifyMethod = request.simplifyMethod();

if ( simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && simplifyMethod.forceLocalOptimization() )
{
QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();

if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
{
int simplifyFlags = QgsMapToPixelSimplifier::SimplifyGeometry | QgsMapToPixelSimplifier::SimplifyEnvelope;
mGeometrySimplifier = new QgsMapToPixelSimplifier( simplifyFlags, simplifyMethod.tolerance() );
}
else
if ( methodType == QgsSimplifyMethod::PreserveTopology )
{
mGeometrySimplifier = new QgsTopologyPreservingSimplifier( simplifyMethod.tolerance() );
}
else
{
QgsDebugMsg( QString( "Simplification method type (%1) is not recognised" ).arg( methodType ) );
}
}
}

QgsAbstractFeatureIterator::~QgsAbstractFeatureIterator()
@@ -122,6 +101,41 @@ void QgsAbstractFeatureIterator::deref()
delete this;
}

bool QgsAbstractFeatureIterator::prepareLocalSimplification()
{
const QgsSimplifyMethod& simplifyMethod = mRequest.simplifyMethod();

if ( mGeometrySimplifier )
{
delete mGeometrySimplifier;
mGeometrySimplifier = NULL;
}

// setup the local simplification of geometries to fetch, it uses the settings of current FeatureRequest
if ( simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && simplifyMethod.forceLocalOptimization() && !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) )
{
QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();

if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
{
int simplifyFlags = QgsMapToPixelSimplifier::SimplifyGeometry | QgsMapToPixelSimplifier::SimplifyEnvelope;
mGeometrySimplifier = new QgsMapToPixelSimplifier( simplifyFlags, simplifyMethod.tolerance() );
return true;
}
else
if ( methodType == QgsSimplifyMethod::PreserveTopology )
{
mGeometrySimplifier = new QgsTopologyPreservingSimplifier( simplifyMethod.tolerance() );
return true;
}
else
{
QgsDebugMsg( QString( "Simplification method type (%1) is not recognised" ).arg( methodType ) );
}
}
return false;
}

///////

QgsFeatureIterator& QgsFeatureIterator::operator=( const QgsFeatureIterator & other )
@@ -87,6 +87,9 @@ class CORE_EXPORT QgsAbstractFeatureIterator
void deref(); //!< remove reference, delete if refs == 0
friend class QgsFeatureIterator;

//! setup if required the local simplification of geometries to fetch, it uses the settings of current FeatureRequest
virtual bool prepareLocalSimplification();

private:
//! optional object to locally simplify geometries fetched by this feature iterator
QgsAbstractGeometrySimplifier* mGeometrySimplifier;
@@ -53,7 +53,7 @@ class CORE_EXPORT QgsTopologyPreservingSimplifier : public QgsAbstractGeometrySi
QgsTopologyPreservingSimplifier( double tolerance );
virtual ~QgsTopologyPreservingSimplifier();

private:
protected:
//! Distance tolerance for the simplification
double mTolerance;

@@ -194,6 +194,12 @@ QString QgsVectorDataProvider::capabilitiesString() const
QgsDebugMsg( "Capability: Change Geometries" );
}

if ( abilities & QgsVectorDataProvider::SimplifyGeometries )
{
abilitiesList += tr( "Simplify Geometries" );
QgsDebugMsg( "Capability: Simplify Geometries before fetch the feature" );
}

return abilitiesList.join( ", " );

}
@@ -77,6 +77,9 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayer* la
mProviderIterator = L->dataProvider()->getFeatures( mProviderRequest );
}

// setup if required the local simplification of geometries to fetch
prepareLocalSimplification();

rewindEditBuffer();
}

0 comments on commit 23b6523

Please sign in to comment.
You can’t perform that action at this time.