Navigation Menu

Skip to content

Commit

Permalink
Load extents from geometry_columns. Fix #7883
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 28, 2013
1 parent 6a352b7 commit d2831e3
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -574,6 +574,30 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate )
mNumberFeatures = 0;
// get features to calculate the statistics
QString statement;

QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

// Get the extents from the geometry_columns table to speed up load times.
statement = QString("SELECT min_x, min_y, max_x, max_y from geometry_columns where f_table_schema = '%1' and f_table_name = '%2'").arg( mSchemaName ).arg( mTableName );

if ( query.exec( statement ) )
{
if ( query.next() )
{
if (!query.value( 0 ).isNull() || !query.value( 1 ).isNull() ||
!query.value( 2 ).isNull() || !query.value( 3 ).isNull())
{
mExtent.setXMinimum( query.value( 0 ).toDouble() );
mExtent.setYMinimum( query.value( 1 ).toDouble() );
mExtent.setXMaximum( query.value( 2 ).toDouble() );
mExtent.setYMaximum( query.value( 3 ).toDouble() );
return;
}
}
}

// If we can't find the extents in the geometry_columns table just do what we normally do.
bool readAll = false;
if ( estimate )
{
Expand Down Expand Up @@ -603,9 +627,6 @@ void QgsMssqlProvider::UpdateStatistics( bool estimate )
statement += " where (" + mSqlWhereClause + ")";
}

QSqlQuery query = QSqlQuery( mDatabase );
query.setForwardOnly( true );

if ( !query.exec( statement ) )
{
QString msg = query.lastError().text();
Expand Down

0 comments on commit d2831e3

Please sign in to comment.