Skip to content

Commit 89597f3

Browse files
committed
Remove FeatureIterator simplification
1 parent 322da8b commit 89597f3

10 files changed

+4
-563
lines changed

src/core/qgsfeatureiterator.cpp

+1-36
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "qgsfeatureiterator.h"
1616
#include "qgslogger.h"
1717

18-
#include "qgsgeometrysimplifier.h"
1918
#include "qgssimplifymethod.h"
2019

2120
#include "qgsexpressionsorter.h"
@@ -27,15 +26,12 @@ QgsAbstractFeatureIterator::QgsAbstractFeatureIterator( const QgsFeatureRequest&
2726
, refs( 0 )
2827
, mFetchedCount( 0 )
2928
, mCompileStatus( NoCompilation )
30-
, mGeometrySimplifier( nullptr )
31-
, mLocalSimplification( false )
3229
, mUseCachedFeatures( false )
3330
{
3431
}
3532

3633
QgsAbstractFeatureIterator::~QgsAbstractFeatureIterator()
3734
{
38-
delete mGeometrySimplifier;
3935
}
4036

4137
bool QgsAbstractFeatureIterator::nextFeature( QgsFeature& f )
@@ -79,12 +75,6 @@ bool QgsAbstractFeatureIterator::nextFeature( QgsFeature& f )
7975
}
8076
}
8177

82-
// simplify the geometry using the simplifier configured
83-
if ( dataOk && mLocalSimplification )
84-
{
85-
if ( f.constGeometry() )
86-
simplify( f );
87-
}
8878
if ( dataOk )
8979
mFetchedCount++;
9080

@@ -138,18 +128,7 @@ void QgsAbstractFeatureIterator::deref()
138128

139129
bool QgsAbstractFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
140130
{
141-
mLocalSimplification = false;
142-
143-
delete mGeometrySimplifier;
144-
mGeometrySimplifier = nullptr;
145-
146-
// setup the simplification of geometries to fetch
147-
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && ( simplifyMethod.forceLocalOptimization() || !providerCanSimplify( simplifyMethod.methodType() ) ) )
148-
{
149-
mGeometrySimplifier = QgsSimplifyMethod::createGeometrySimplifier( simplifyMethod );
150-
mLocalSimplification = nullptr != mGeometrySimplifier;
151-
return mLocalSimplification;
152-
}
131+
Q_UNUSED( simplifyMethod );
153132
return false;
154133
}
155134

@@ -205,20 +184,6 @@ bool QgsAbstractFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodT
205184
return false;
206185
}
207186

208-
bool QgsAbstractFeatureIterator::simplify( QgsFeature& feature )
209-
{
210-
// simplify locally the geometry using the configured simplifier
211-
if ( mGeometrySimplifier )
212-
{
213-
QgsGeometry* geometry = feature.geometry();
214-
215-
QGis::GeometryType geometryType = geometry->type();
216-
if ( geometryType == QGis::Line || geometryType == QGis::Polygon )
217-
return mGeometrySimplifier->simplifyGeometry( geometry );
218-
}
219-
return false;
220-
}
221-
222187
bool QgsAbstractFeatureIterator::prepareOrderBy( const QList<QgsFeatureRequest::OrderByClause>& orderBys )
223188
{
224189
Q_UNUSED( orderBys )

src/core/qgsfeatureiterator.h

-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "qgslogger.h"
2020
#include "qgsindexedfeature.h"
2121

22-
class QgsAbstractGeometrySimplifier;
2322

2423
/** \ingroup core
2524
* Interface that can be optionaly attached to an iterator so its
@@ -145,21 +144,13 @@ class CORE_EXPORT QgsAbstractFeatureIterator
145144
virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod );
146145

147146
private:
148-
//! optional object to locally simplify geometries fetched by this feature iterator
149-
QgsAbstractGeometrySimplifier* mGeometrySimplifier;
150-
//! this iterator runs local simplification
151-
bool mLocalSimplification;
152-
153147
bool mUseCachedFeatures;
154148
QList<QgsIndexedFeature> mCachedFeatures;
155149
QList<QgsIndexedFeature>::ConstIterator mFeatureIterator;
156150

157151
//! returns whether the iterator supports simplify geometries on provider side
158152
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
159153

160-
//! simplify the specified geometry if it was configured
161-
virtual bool simplify( QgsFeature& feature );
162-
163154
/**
164155
* Should be overwritten by providers which implement an own order by strategy
165156
* If the own order by strategy is successful, return true, if not, return false

src/core/qgsvectorlayerfeatureiterator.cpp

+1-49
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ QgsVectorLayerFeatureSource::QgsVectorLayerFeatureSource( QgsVectorLayer *layer
3535
mExpressionFieldBuffer = new QgsExpressionFieldBuffer( *layer->mExpressionFieldBuffer );
3636
mCrsId = layer->crs().srsid();
3737

38-
mCanBeSimplified = layer->hasGeometryType() && layer->geometryType() != QGis::Point;
39-
4038
mHasEditBuffer = layer->editBuffer();
4139
if ( mHasEditBuffer )
4240
{
@@ -93,7 +91,6 @@ QgsFeatureIterator QgsVectorLayerFeatureSource::getFeatures( const QgsFeatureReq
9391
QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
9492
: QgsAbstractFeatureIteratorFromSource<QgsVectorLayerFeatureSource>( source, ownSource, request )
9593
, mFetchedFid( false )
96-
, mEditGeometrySimplifier( nullptr )
9794
, mInterruptionChecker( nullptr )
9895
{
9996
prepareExpressions();
@@ -191,9 +188,6 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
191188

192189
QgsVectorLayerFeatureIterator::~QgsVectorLayerFeatureIterator()
193190
{
194-
delete mEditGeometrySimplifier;
195-
mEditGeometrySimplifier = nullptr;
196-
197191
qDeleteAll( mExpressionFieldInfo );
198192

199193
close();
@@ -357,14 +351,6 @@ void QgsVectorLayerFeatureIterator::useAddedFeature( const QgsFeature& src, QgsF
357351
if ( src.constGeometry() && !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) )
358352
{
359353
f.setGeometry( new QgsGeometry( *src.constGeometry() ) );
360-
361-
// simplify the edited geometry using its simplifier configured
362-
if ( mEditGeometrySimplifier )
363-
{
364-
QgsGeometry* geometry = f.geometry();
365-
QGis::GeometryType geometryType = geometry->type();
366-
if ( geometryType == QGis::Line || geometryType == QGis::Polygon ) mEditGeometrySimplifier->simplifyGeometry( geometry );
367-
}
368354
}
369355

370356
// TODO[MD]: if subset set just some attributes
@@ -439,14 +425,6 @@ void QgsVectorLayerFeatureIterator::useChangedAttributeFeature( QgsFeatureId fid
439425
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) )
440426
{
441427
f.setGeometry( geom );
442-
443-
// simplify the edited geometry using its simplifier configured
444-
if ( mEditGeometrySimplifier )
445-
{
446-
QgsGeometry* geometry = f.geometry();
447-
QGis::GeometryType geometryType = geometry->type();
448-
if ( geometryType == QGis::Line || geometryType == QGis::Polygon ) mEditGeometrySimplifier->simplifyGeometry( geometry );
449-
}
450428
}
451429

452430
bool subsetAttrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes );
@@ -638,39 +616,13 @@ void QgsVectorLayerFeatureIterator::addVirtualAttributes( QgsFeature& f )
638616

639617
bool QgsVectorLayerFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
640618
{
641-
delete mEditGeometrySimplifier;
642-
mEditGeometrySimplifier = nullptr;
643-
644-
// setup simplification for edited geometries to fetch
645-
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && mSource->mCanBeSimplified )
646-
{
647-
mEditGeometrySimplifier = QgsSimplifyMethod::createGeometrySimplifier( simplifyMethod );
648-
return nullptr != mEditGeometrySimplifier;
649-
}
619+
Q_UNUSED( simplifyMethod );
650620
return false;
651621
}
652622

653623
bool QgsVectorLayerFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
654624
{
655625
Q_UNUSED( methodType );
656-
#if 0
657-
// TODO[MD]: after merge
658-
QgsVectorDataProvider* provider = L->dataProvider();
659-
660-
if ( provider && methodType != QgsSimplifyMethod::NoSimplification )
661-
{
662-
int capabilities = provider->capabilities();
663-
664-
if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
665-
{
666-
return ( capabilities & QgsVectorDataProvider::SimplifyGeometries );
667-
}
668-
else if ( methodType == QgsSimplifyMethod::PreserveTopology )
669-
{
670-
return ( capabilities & QgsVectorDataProvider::SimplifyGeometriesWithTopologicalValidation );
671-
}
672-
}
673-
#endif
674626
return false;
675627
}
676628

src/core/qgsvectorlayerfeatureiterator.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class QgsVectorLayerFeatureSource : public QgsAbstractFeatureSource
5555

5656
bool mHasEditBuffer;
5757

58-
bool mCanBeSimplified;
59-
6058
// A deep-copy is only performed, if the original maps change
6159
// see here https://github.com/qgis/Quantum-GIS/pull/673
6260
// for explanation
@@ -92,7 +90,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
9290

9391
//! Overrides default method as we only need to filter features in the edit buffer
9492
//! while for others filtering is left to the provider implementation.
95-
inline virtual bool nextFeatureFilterExpression( QgsFeature &f ) override { return fetchFeature( f ); }
93+
virtual bool nextFeatureFilterExpression( QgsFeature &f ) override { return fetchFeature( f ); }
9694

9795
//! Setup the simplification of geometries to fetch using the specified simplify method
9896
virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;
@@ -176,9 +174,6 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
176174
bool mHasVirtualAttributes;
177175

178176
private:
179-
//! optional object to locally simplify edited (changed or added) geometries fetched by this feature iterator
180-
QgsAbstractGeometrySimplifier* mEditGeometrySimplifier;
181-
182177
QScopedPointer<QgsExpressionContext> mExpressionContext;
183178

184179
QgsInterruptionChecker* mInterruptionChecker;

src/providers/ogr/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
SET (OGR_SRCS qgsogrprovider.cpp qgsogrdataitems.cpp qgsogrfeatureiterator.cpp qgsogrgeometrysimplifier.cpp qgsogrconnpool.cpp qgsogrexpressioncompiler.cpp)
2+
SET (OGR_SRCS qgsogrprovider.cpp qgsogrdataitems.cpp qgsogrfeatureiterator.cpp qgsogrconnpool.cpp qgsogrexpressioncompiler.cpp)
33

44
SET(OGR_MOC_HDRS qgsogrprovider.h qgsogrdataitems.h qgsogrconnpool.h)
55

src/providers/ogr/qgsogrfeatureiterator.cpp

-62
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "qgsogrfeatureiterator.h"
1616

1717
#include "qgsogrprovider.h"
18-
#include "qgsogrgeometrysimplifier.h"
1918
#include "qgsogrexpressioncompiler.h"
2019
#include "qgssqliteexpressioncompiler.h"
2120

@@ -43,7 +42,6 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
4342
, ogrLayer( nullptr )
4443
, mSubsetStringSet( false )
4544
, mFetchGeometry( false )
46-
, mGeometrySimplifier( nullptr )
4745
, mExpressionCompiled( false )
4846
{
4947
mConn = QgsOgrConnPool::instance()->acquireConnection( mSource->mProvider->dataSourceUri() );
@@ -157,46 +155,9 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource* source, bool
157155

158156
QgsOgrFeatureIterator::~QgsOgrFeatureIterator()
159157
{
160-
delete mGeometrySimplifier;
161-
mGeometrySimplifier = nullptr;
162-
163158
close();
164159
}
165160

166-
bool QgsOgrFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
167-
{
168-
delete mGeometrySimplifier;
169-
mGeometrySimplifier = nullptr;
170-
171-
// setup simplification of OGR-geometries fetched
172-
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && !simplifyMethod.forceLocalOptimization() )
173-
{
174-
QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();
175-
Q_UNUSED( methodType );
176-
177-
#if defined(GDAL_VERSION_NUM) && defined(GDAL_COMPUTE_VERSION)
178-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0)
179-
if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
180-
{
181-
int simplifyFlags = QgsMapToPixelSimplifier::SimplifyGeometry | QgsMapToPixelSimplifier::SimplifyEnvelope;
182-
mGeometrySimplifier = new QgsOgrMapToPixelSimplifier( simplifyFlags, simplifyMethod.tolerance() );
183-
return true;
184-
}
185-
#endif
186-
#endif
187-
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1900
188-
if ( methodType == QgsSimplifyMethod::PreserveTopology )
189-
{
190-
mGeometrySimplifier = new QgsOgrTopologyPreservingSimplifier( simplifyMethod.tolerance() );
191-
return true;
192-
}
193-
#endif
194-
195-
QgsDebugMsg( QString( "Simplification method type (%1) is not recognised by OgrFeatureIterator class" ).arg( methodType ) );
196-
}
197-
return QgsAbstractFeatureIterator::prepareSimplification( simplifyMethod );
198-
}
199-
200161
bool QgsOgrFeatureIterator::nextFeatureFilterExpression( QgsFeature& f )
201162
{
202163
if ( !mExpressionCompiled )
@@ -205,26 +166,6 @@ bool QgsOgrFeatureIterator::nextFeatureFilterExpression( QgsFeature& f )
205166
return fetchFeature( f );
206167
}
207168

208-
bool QgsOgrFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
209-
{
210-
#if defined(GDAL_VERSION_NUM) && defined(GDAL_COMPUTE_VERSION)
211-
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0)
212-
if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
213-
{
214-
return true;
215-
}
216-
#endif
217-
#endif
218-
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1900
219-
if ( methodType == QgsSimplifyMethod::PreserveTopology )
220-
{
221-
return true;
222-
}
223-
#endif
224-
225-
return false;
226-
}
227-
228169
bool QgsOgrFeatureIterator::fetchFeature( QgsFeature& feature )
229170
{
230171
feature.setValid( false );
@@ -337,9 +278,6 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature )
337278

338279
if ( geom )
339280
{
340-
if ( mGeometrySimplifier )
341-
mGeometrySimplifier->simplifyGeometry( geom );
342-
343281
feature.setGeometry( QgsOgrUtils::ogrGeometryToQgsGeometry( geom ) );
344282
}
345283
else

src/providers/ogr/qgsogrfeatureiterator.h

-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
class QgsOgrFeatureIterator;
2424
class QgsOgrProvider;
25-
class QgsOgrAbstractGeometrySimplifier;
2625

2726
class QgsOgrFeatureSource : public QgsAbstractFeatureSource
2827
{
@@ -66,9 +65,6 @@ class QgsOgrFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsOgr
6665
//! fetch next feature, return true on success
6766
virtual bool fetchFeature( QgsFeature& feature ) override;
6867

69-
//! Setup the simplification of geometries to fetch using the specified simplify method
70-
virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;
71-
7268
//! fetch next feature filter expression
7369
bool nextFeatureFilterExpression( QgsFeature& f ) override;
7470

@@ -88,13 +84,7 @@ class QgsOgrFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsOgr
8884
bool mFetchGeometry;
8985

9086
private:
91-
//! optional object to simplify OGR-geometries fecthed by this feature iterator
92-
QgsOgrAbstractGeometrySimplifier* mGeometrySimplifier;
93-
9487
bool mExpressionCompiled;
95-
96-
//! returns whether the iterator supports simplify geometries on provider side
97-
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const override;
9888
};
9989

10090
#endif // QGSOGRFEATUREITERATOR_H

0 commit comments

Comments
 (0)