crs_deprecated.patch

patch to get non-deprecated crs entry first from queries to srs databases - Etienne Tourigny, 2012-03-30 12:51 PM

Download (5.36 KB)

View differences:

src/core/qgscoordinatereferencesystem.cpp
252 252
    is_geo integer NOT NULL);
253 253
  */
254 254

  
255
  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 );
255
  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 ) + " order by deprecated";
256 256
  myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
257 257
  // XXX Need to free memory from the error msg if one is set
258 258
  if ( myResult == SQLITE_OK && sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
......
435 435
   * - if the above does not match perform a whole text search on proj4 string (if not null)
436 436
   */
437 437
  // QgsDebugMsg( "wholetext match on name failed, trying proj4string match" );
438
  myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) );
438
  myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4String.trimmed() ) + " order by deprecated" );
439 439
  if ( myRecord.empty() )
440 440
  {
441 441
    // Ticket #722 - aaronr
......
470 470
      myStart2 = myLat2RegExp.indexIn( theProj4String, myStart2 );
471 471
      theProj4StringModified.replace( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
472 472
      QgsDebugMsg( "trying proj4string match with swapped lat_1,lat_2" );
473
      myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) );
473
      myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( theProj4StringModified.trimmed() ) + " order by deprecated" );
474 474
    }
475 475
  }
476 476

  
......
503 503

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

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

  
......
549 549
    if ( mIsValidFlag )
550 550
    {
551 551
      // but the proj.4 parsed string might already be in our database
552
      myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
552
      myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
553 553
      if ( myRecord.empty() )
554 554
      {
555 555
        // It's not, so try to add it
......
559 559
        if ( mIsValidFlag )
560 560
        {
561 561
          // but validate that it's there afterwards
562
          myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) );
562
          myRecord = getRecord( "select * from tbl_srs where parameters=" + quotedValue( toProj4() ) + " order by deprecated" );
563 563
        }
564 564
      }
565 565

  
......
913 913
  int           myResult;
914 914

  
915 915
  // Set up the query to retrieve the projection information needed to populate the list
916
  QString mySql = QString( "select srs_id,parameters from tbl_srs where projection_acronym=%1 and ellipsoid_acronym=%2" )
916
  QString mySql = QString( "select srs_id,parameters from tbl_srs where projection_acronym=%1 and ellipsoid_acronym=%2 order by deprecated" )
917 917
                  .arg( quotedValue( mProjectionAcronym ) )
918 918
                  .arg( quotedValue( mEllipsoidAcronym ) );
919 919
  // Get the full path name to the sqlite3 spatial reference database.
......
1186 1186

  
1187 1187
  QString myDatabaseFileName;
1188 1188
  QString myProjString;
1189
  QString mySql = "select parameters from tbl_srs where srs_id = ";
1190
  mySql += QString::number( theSrsId );
1189
  QString mySql = QString( "select parameters from tbl_srs where srs_id = %1 order by deprecated" ).arg( theSrsId );
1191 1190

  
1192 1191
  QgsDebugMsg( "mySrsId = " + QString::number( theSrsId ) );
1193 1192
  QgsDebugMsg( "USER_CRS_START_ID = " + QString::number( USER_CRS_START_ID ) );
......
1417 1416

  
1418 1417
  const char *tail;
1419 1418
  sqlite3_stmt *select;
1420
  QString sql = "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name IS NOT NULL AND auth_id IS NOT NULL";
1419
  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";
1421 1420
  if ( sqlite3_prepare( database, sql.toAscii(), sql.size(), &select, &tail ) != SQLITE_OK )
1422 1421
  {
1423 1422
    qCritical( "Could not prepare: %s [%s]\n", sql.toAscii().constData(), sqlite3_errmsg( database ) );