Skip to content

Commit d072885

Browse files
etienneskyjef-n
authored andcommitted
prefer non-deprecated crses (fixes part of #4977)
1 parent d11f0f5 commit d072885

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/core/qgscoordinatereferencesystem.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
283283

284284
QString mySql = "select srs_id,description,projection_acronym,"
285285
"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";
287287
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(),
288288
mySql.toUtf8().length(),
289289
&myPreparedStatement, &myTail );
@@ -471,7 +471,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
471471
* - if the above does not match perform a whole text search on proj4 string (if not null)
472472
*/
473473
// 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" );
475475
if ( myRecord.empty() )
476476
{
477477
// Ticket #722 - aaronr
@@ -506,7 +506,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
506506
myStart2 = myLat2RegExp.indexIn( theProj4String, myStart2 );
507507
theProj4StringModified.replace( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
508508
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" );
510510
}
511511
}
512512

@@ -540,13 +540,13 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
540540

541541
if ( !datum.isEmpty() )
542542
{
543-
myRecord = getRecord( sql + delim + datum );
543+
myRecord = getRecord( sql + delim + datum + " order by deprecated" );
544544
}
545545

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

@@ -586,7 +586,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
586586
if ( mIsValidFlag )
587587
{
588588
// 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" );
590590
if ( myRecord.empty() )
591591
{
592592
// It's not, so try to add it
@@ -596,7 +596,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString theProj4String
596596
if ( mIsValidFlag )
597597
{
598598
// 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" );
600600
}
601601
}
602602

@@ -956,7 +956,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
956956
// Set up the query to retrieve the projection information
957957
// needed to populate the list
958958
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" )
960960
.arg( quotedValue( mProjectionAcronym ) )
961961
.arg( quotedValue( mEllipsoidAcronym ) );
962962
// Get the full path name to the sqlite3 spatial reference database.
@@ -1240,7 +1240,7 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int theSrsId )
12401240

12411241
QString myDatabaseFileName;
12421242
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 );
12441244

12451245
QgsDebugMsg( "mySrsId = " + QString::number( theSrsId ) );
12461246
QgsDebugMsg( "USER_CRS_START_ID = " + QString::number( USER_CRS_START_ID ) );
@@ -1479,7 +1479,7 @@ int QgsCoordinateReferenceSystem::syncDb()
14791479

14801480
const char *tail;
14811481
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";
14831483
if ( sqlite3_prepare( database, sql.toAscii(), sql.size(), &select, &tail ) != SQLITE_OK )
14841484
{
14851485
qCritical( "Could not prepare: %s [%s]\n", sql.toAscii().constData(), sqlite3_errmsg( database ) );

0 commit comments

Comments
 (0)