Skip to content

Commit 6f70953

Browse files
committed
Feature simplification for oracle provider
1 parent 78d9617 commit 6f70953

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

src/providers/oracle/qgsoraclefeatureiterator.cpp

+40-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,27 @@ bool QgsOracleFeatureIterator::nextFeatureFilterExpression( QgsFeature& f )
148148
return fetchFeature( f );
149149
}
150150

151+
bool QgsOracleFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
152+
{
153+
// setup simplification of geometries to fetch
154+
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) &&
155+
simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification &&
156+
!simplifyMethod.forceLocalOptimization() )
157+
{
158+
QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();
159+
160+
if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
161+
{
162+
return true;
163+
}
164+
else
165+
{
166+
QgsDebugMsg( QString( "Simplification method type (%1) is not recognised by OracleFeatureIterator" ).arg( methodType ) );
167+
}
168+
}
169+
return QgsAbstractFeatureIterator::prepareSimplification( simplifyMethod );
170+
}
171+
151172
bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
152173
{
153174
feature.setValid( false );
@@ -316,7 +337,20 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
316337

317338
if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 && !mSource->mGeometryColumn.isNull() )
318339
{
319-
query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
340+
if ( !mRequest.simplifyMethod().forceLocalOptimization() &&
341+
mRequest.simplifyMethod().methodType() == QgsSimplifyMethod::OptimizeForRendering &&
342+
QGis::flatType( QGis::singleType( mSource->mRequestedGeomType != QGis::WKBUnknown
343+
? mSource->mRequestedGeomType
344+
: mSource->mDetectedGeomType ) ) != QGis::WKBPoint )
345+
{
346+
query += QString( "SDO_UTIL.SIMPLIFY( %1, %2 )" )
347+
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ) )
348+
.arg( mRequest.simplifyMethod().tolerance() * 0.7 ); //-> We use a smaller tolerance than pre-filtering to be on the safe side
349+
}
350+
else
351+
{
352+
query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
353+
}
320354
delim = ",";
321355
}
322356

@@ -377,6 +411,11 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
377411
return true;
378412
}
379413

414+
bool QgsOracleFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
415+
{
416+
return methodType == QgsSimplifyMethod::OptimizeForRendering;
417+
}
418+
380419
// -----------
381420

382421
QgsOracleFeatureSource::QgsOracleFeatureSource( const QgsOracleProvider* p )

src/providers/oracle/qgsoraclefeatureiterator.h

+7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,20 @@ class QgsOracleFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
7676
//! fetch next feature filter expression
7777
bool nextFeatureFilterExpression( QgsFeature& f ) override;
7878

79+
//! Setup the simplification of geometries to fetch using the specified simplify method
80+
virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;
81+
7982
bool openQuery( QString whereClause );
8083

8184
QgsOracleConn *mConnection;
8285
QSqlQuery mQry;
8386
bool mRewind;
8487
bool mExpressionCompiled;
8588
QgsAttributeList mAttributeList;
89+
90+
private:
91+
//! returns whether the iterator supports simplify geometries on provider side
92+
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const override;
8693
};
8794

8895
#endif // QGSORACLEFEATUREITERATOR_H

src/providers/oracle/qgsoracleprovider.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,9 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities()
747747

748748
mEnabledCapabilities = QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
749749

750+
// supports geometry simplification on provider side
751+
mEnabledCapabilities |= QgsVectorDataProvider::SimplifyGeometries;
752+
750753
QSqlQuery qry( *mConnection );
751754
if ( !mIsQuery )
752755
{

0 commit comments

Comments
 (0)