Skip to content

Commit

Permalink
prefer non-deprecated crses (fixes part of #4977)
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennesky committed May 19, 2012
1 parent e3f25da commit 396aaf1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -256,7 +256,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q

QString mySql = "select srs_id,description,projection_acronym,"
"ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
"from tbl_srs where " + expression + "=" + quotedValue( value );
"from tbl_srs where " + expression + "=" + quotedValue( value ) + " order by deprecated";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(),
mySql.toUtf8().length(),
&myPreparedStatement, &myTail );
Expand Down Expand Up @@ -444,7 +444,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
* - if the above does not match perform a whole text search on proj4 string (if not null)
*/
// QgsDebugMsg( "wholetext match on name failed, trying proj4string match" );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) + " order by deprecated" );
if ( myRecord.empty() )
{
// Ticket #722 - aaronr
Expand Down Expand Up @@ -479,7 +479,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
myStart2 = myLat2RegExp.indexIn( theProj4String, myStart2 );
theProj4StringModified.replace( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
QgsDebugMsg( "trying proj4string match with swapped lat_1,lat_2" );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) + " order by deprecated" );
}
}

Expand Down Expand Up @@ -513,13 +513,13 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String

if ( !datum.isEmpty() )
{
myRecord = getRecord( sql + delim + datum );
myRecord = getRecord( sql + delim + datum + " order by deprecated" );
}

if ( myRecord.empty() )
{
// datum might have disappeared in definition - retry without it
myRecord = getRecord( sql );
myRecord = getRecord( sql + " order by deprecated" );
}
}

Expand Down Expand Up @@ -559,7 +559,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
if ( mIsValidFlag )
{
// but the proj.4 parsed string might already be in our database
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
if ( myRecord.empty() )
{
// It's not, so try to add it
Expand All @@ -569,7 +569,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
if ( mIsValidFlag )
{
// but validate that it's there afterwards
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
}
}

Expand Down Expand Up @@ -929,7 +929,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
// Set up the query to retrieve the projection information
// needed to populate the list
QString mySql = QString( "select srs_id,parameters from tbl_srs where "
"projection_acronym=%1 and ellipsoid_acronym=%2" )
"projection_acronym=%1 and ellipsoid_acronym=%2 order by deprecated" )
.arg( quotedValue( mProjectionAcronym ) )
.arg( quotedValue( mEllipsoidAcronym ) );
// Get the full path name to the sqlite3 spatial reference database.
Expand Down Expand Up @@ -1213,7 +1213,7 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int theSrsId )

QString myDatabaseFileName;
QString myProjString;
QString mySql = QString( "select parameters from tbl_srs where srs_id = %1" ).arg( theSrsId );
QString mySql = QString( "select parameters from tbl_srs where srs_id = %1 order by deprecated" ).arg( theSrsId );

QgsDebugMsg( "mySrsId = " + QString::number( theSrsId ) );
QgsDebugMsg( "USER_CRS_START_ID = " + QString::number( USER_CRS_START_ID ) );
Expand Down Expand Up @@ -1452,7 +1452,7 @@ int QgsCoordinateReferenceSystem::syncDb()

const char *tail;
sqlite3_stmt *select;
QString sql = "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL";
QString sql = "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL order by deprecated";
if ( sqlite3_prepare( database, sql.toAscii(), sql.size(), &select, &tail ) != SQLITE_OK )
{
qCritical( "Could not prepare: %s [%s]\n", sql.toAscii().constData(), sqlite3_errmsg( database ) );
Expand Down

0 comments on commit 396aaf1

Please sign in to comment.