Skip to content
Permalink
Browse files

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 772dc1d28fcb186dad669ff1380f790795876a72
@@ -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" );
}

@@ -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() );

@@ -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 )
@@ -139,6 +139,7 @@ class QgsOracleConn : public QObject
QString currentUser();

bool hasSpatial();
int majorVersion();

static const int sGeomTypeSelectLimit;

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

//! major database version
int mMajorVersion;

QSqlDatabase mDatabase;
QSqlQuery mQuery;

@@ -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;
}

// -----------
@@ -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 )

0 comments on commit 772dc1d

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