Skip to content

Commit

Permalink
Merge pull request #2738 from ahuarte47/OracleSimplifyProviderSide
Browse files Browse the repository at this point in the history
Feature simplification for oracle provider
  • Loading branch information
jef-n committed Jan 30, 2016
2 parents 0e4520f + 6f70953 commit 939fc83
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/providers/oracle/qgsoraclefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ bool QgsOracleFeatureIterator::nextFeatureFilterExpression( QgsFeature& f )
return fetchFeature( f );
}

bool QgsOracleFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
{
// setup simplification of geometries to fetch
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) &&
simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification &&
!simplifyMethod.forceLocalOptimization() )
{
QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();

if ( methodType == QgsSimplifyMethod::OptimizeForRendering )
{
return true;
}
else
{
QgsDebugMsg( QString( "Simplification method type (%1) is not recognised by OracleFeatureIterator" ).arg( methodType ) );
}
}
return QgsAbstractFeatureIterator::prepareSimplification( simplifyMethod );
}

bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
{
feature.setValid( false );
Expand Down Expand Up @@ -316,7 +337,20 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )

if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 && !mSource->mGeometryColumn.isNull() )
{
query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
if ( !mRequest.simplifyMethod().forceLocalOptimization() &&
mRequest.simplifyMethod().methodType() == QgsSimplifyMethod::OptimizeForRendering &&
QGis::flatType( QGis::singleType( mSource->mRequestedGeomType != QGis::WKBUnknown
? mSource->mRequestedGeomType
: mSource->mDetectedGeomType ) ) != QGis::WKBPoint )
{
query += QString( "SDO_UTIL.SIMPLIFY( %1, %2 )" )
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ) )
.arg( mRequest.simplifyMethod().tolerance() * 0.7 ); //-> We use a smaller tolerance than pre-filtering to be on the safe side
}
else
{
query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
}
delim = ",";
}

Expand Down Expand Up @@ -377,6 +411,11 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
return true;
}

bool QgsOracleFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
{
return methodType == QgsSimplifyMethod::OptimizeForRendering;
}

// -----------

QgsOracleFeatureSource::QgsOracleFeatureSource( const QgsOracleProvider* p )
Expand Down
7 changes: 7 additions & 0 deletions src/providers/oracle/qgsoraclefeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,20 @@ class QgsOracleFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
//! fetch next feature filter expression
bool nextFeatureFilterExpression( QgsFeature& f ) override;

//! Setup the simplification of geometries to fetch using the specified simplify method
virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;

bool openQuery( QString whereClause );

QgsOracleConn *mConnection;
QSqlQuery mQry;
bool mRewind;
bool mExpressionCompiled;
QgsAttributeList mAttributeList;

private:
//! returns whether the iterator supports simplify geometries on provider side
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const override;
};

#endif // QGSORACLEFEATUREITERATOR_H
3 changes: 3 additions & 0 deletions src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities()

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

// supports geometry simplification on provider side
mEnabledCapabilities |= QgsVectorDataProvider::SimplifyGeometries;

QSqlQuery qry( *mConnection );
if ( !mIsQuery )
{
Expand Down

0 comments on commit 939fc83

Please sign in to comment.