Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
oracle provider: enable server-side simplification only with Locator …
…>=11g or Spatial
  • Loading branch information
jef-n committed Jan 30, 2016
1 parent 939fc83 commit 772dc1d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsvectordataprovider.cpp
Expand Up @@ -216,7 +216,7 @@ QString QgsVectorDataProvider::capabilitiesString() const

if ( abilities & QgsVectorDataProvider::ChangeFeatures )
{
abilitiesList += tr( "Change Geometries and Attributes at once" );
abilitiesList += tr( "Joint Geometry and Attributes updates" );
QgsDebugMsg( "Capability: change attributes and geometries at once" );
}

Expand Down
16 changes: 16 additions & 0 deletions src/providers/oracle/qgsoracleconn.cpp
Expand Up @@ -59,6 +59,7 @@ QgsOracleConn::QgsOracleConn( QgsDataSourceURI uri )
: mRef( 1 )
, mCurrentUser( QString::null )
, mHasSpatial( -1 )
, mMajorVersion( -1 )
{
QgsDebugMsg( QString( "New Oracle connection for " ) + uri.connectionInfo() );

Expand Down Expand Up @@ -773,6 +774,21 @@ QString QgsOracleConn::databaseName( QString database, QString host, QString por
return db;
}

int QgsOracleConn::majorVersion()
{
if ( mMajorVersion == -1 )
{
QSqlQuery qry( mDatabase );
if ( exec( qry, "SELECT banner FROM v$version WHERE banner LIKE 'Oracle Database%'" ) && qry.next() )
{
QRegExp vers( "([0-9]+)\\.[0-9\\.]+[0-9]" );
if ( vers.indexIn( qry.value( 0 ).toString() ) >= 0 )
mMajorVersion = vers.cap( 1 ).toInt();
}
}
return mMajorVersion;
}

bool QgsOracleConn::hasSpatial()
{
if ( mHasSpatial == -1 )
Expand Down
4 changes: 4 additions & 0 deletions src/providers/oracle/qgsoracleconn.h
Expand Up @@ -139,6 +139,7 @@ class QgsOracleConn : public QObject
QString currentUser();

bool hasSpatial();
int majorVersion();

static const int sGeomTypeSelectLimit;

Expand Down Expand Up @@ -177,6 +178,9 @@ class QgsOracleConn : public QObject
//! has spatial
int mHasSpatial;

//! major database version
int mMajorVersion;

QSqlDatabase mDatabase;
QSqlQuery mQuery;

Expand Down
2 changes: 1 addition & 1 deletion src/providers/oracle/qgsoraclefeatureiterator.cpp
Expand Up @@ -413,7 +413,7 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )

bool QgsOracleFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
{
return methodType == QgsSimplifyMethod::OptimizeForRendering;
return ( mConnection->majorVersion() > 10 || mConnection->hasSpatial() ) && methodType == QgsSimplifyMethod::OptimizeForRendering;
}

// -----------
Expand Down
8 changes: 6 additions & 2 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -747,8 +747,12 @@ bool QgsOracleProvider::hasSufficientPermsAndCapabilities()

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

// supports geometry simplification on provider side
mEnabledCapabilities |= QgsVectorDataProvider::SimplifyGeometries;
if ( mConnection->majorVersion() > 10 || mConnection->hasSpatial() )
{
// 10g doesn't support SDO_UTIL in Oracle Locator
// supports geometry simplification on provider side
mEnabledCapabilities |= QgsVectorDataProvider::SimplifyGeometries;
}

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

0 comments on commit 772dc1d

Please sign in to comment.