@@ -283,7 +283,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
283
283
284
284
QString mySql = " select srs_id,description,projection_acronym,"
285
285
" ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
286
- " from tbl_srs where " + expression + " =" + quotedValue ( value );
286
+ " from tbl_srs where " + expression + " =" + quotedValue ( value ) + " order by deprecated " ;
287
287
myResult = sqlite3_prepare ( myDatabase, mySql.toUtf8 (),
288
288
mySql.toUtf8 ().length (),
289
289
&myPreparedStatement, &myTail );
@@ -471,7 +471,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
471
471
* - if the above does not match perform a whole text search on proj4 string (if not null)
472
472
*/
473
473
// QgsDebugMsg( "wholetext match on name failed, trying proj4string match" );
474
- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( theProj4String.trimmed () ) );
474
+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( theProj4String.trimmed () ) + " order by deprecated " );
475
475
if ( myRecord.empty () )
476
476
{
477
477
// Ticket #722 - aaronr
@@ -506,7 +506,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
506
506
myStart2 = myLat2RegExp.indexIn ( theProj4String, myStart2 );
507
507
theProj4StringModified.replace ( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
508
508
QgsDebugMsg ( " trying proj4string match with swapped lat_1,lat_2" );
509
- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( theProj4StringModified.trimmed () ) );
509
+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( theProj4StringModified.trimmed () ) + " order by deprecated " );
510
510
}
511
511
}
512
512
@@ -540,13 +540,13 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
540
540
541
541
if ( !datum.isEmpty () )
542
542
{
543
- myRecord = getRecord ( sql + delim + datum );
543
+ myRecord = getRecord ( sql + delim + datum + " order by deprecated " );
544
544
}
545
545
546
546
if ( myRecord.empty () )
547
547
{
548
548
// datum might have disappeared in definition - retry without it
549
- myRecord = getRecord ( sql );
549
+ myRecord = getRecord ( sql + " order by deprecated " );
550
550
}
551
551
}
552
552
@@ -586,7 +586,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
586
586
if ( mIsValidFlag )
587
587
{
588
588
// but the proj.4 parsed string might already be in our database
589
- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( toProj4 () ) );
589
+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( toProj4 () ) + " order by deprecated " );
590
590
if ( myRecord.empty () )
591
591
{
592
592
// It's not, so try to add it
@@ -596,7 +596,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
596
596
if ( mIsValidFlag )
597
597
{
598
598
// but validate that it's there afterwards
599
- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( toProj4 () ) );
599
+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( toProj4 () ) + " order by deprecated " );
600
600
}
601
601
}
602
602
@@ -956,7 +956,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
956
956
// Set up the query to retrieve the projection information
957
957
// needed to populate the list
958
958
QString mySql = QString ( " select srs_id,parameters from tbl_srs where "
959
- " projection_acronym=%1 and ellipsoid_acronym=%2" )
959
+ " projection_acronym=%1 and ellipsoid_acronym=%2 order by deprecated " )
960
960
.arg ( quotedValue ( mProjectionAcronym ) )
961
961
.arg ( quotedValue ( mEllipsoidAcronym ) );
962
962
// Get the full path name to the sqlite3 spatial reference database.
@@ -1240,7 +1240,7 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int theSrsId )
1240
1240
1241
1241
QString myDatabaseFileName;
1242
1242
QString myProjString;
1243
- QString mySql = QString ( " select parameters from tbl_srs where srs_id = %1" ).arg ( theSrsId );
1243
+ QString mySql = QString ( " select parameters from tbl_srs where srs_id = %1 order by deprecated " ).arg ( theSrsId );
1244
1244
1245
1245
QgsDebugMsg ( " mySrsId = " + QString::number ( theSrsId ) );
1246
1246
QgsDebugMsg ( " USER_CRS_START_ID = " + QString::number ( USER_CRS_START_ID ) );
@@ -1479,7 +1479,7 @@ int QgsCoordinateReferenceSystem::syncDb()
1479
1479
1480
1480
const char *tail;
1481
1481
sqlite3_stmt *select ;
1482
- QString sql = " select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL" ;
1482
+ 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 " ;
1483
1483
if ( sqlite3_prepare ( database, sql.toAscii (), sql.size (), &select , &tail ) != SQLITE_OK )
1484
1484
{
1485
1485
qCritical ( " Could not prepare: %s [%s]\n " , sql.toAscii ().constData (), sqlite3_errmsg ( database ) );
0 commit comments