Skip to content

Commit

Permalink
Deprecate vw_srs from crs database, and use consistent translated
Browse files Browse the repository at this point in the history
strings for projection names instead of hardcoded values from
srs.db
  • Loading branch information
nyalldawson committed Jul 10, 2023
1 parent 6bd370a commit 6d8ae62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/proj/qgscoordinatereferencesystemutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ QString QgsCoordinateReferenceSystemUtils::translateProjection( const QString &p
if ( projection == QLatin1String( "lask" ) )
return QObject::tr( "Laskowski" );
if ( projection == QLatin1String( "longlat" ) )
return QObject::tr( "Long/lat(Geodetic alias)" );
return QObject::tr( "Long/lat (Geodetic Alias)" );
if ( projection == QLatin1String( "latlong" ) )
return QObject::tr( "Lat/long (Geodetic alias)" );
return QObject::tr( "Lat/long (Geodetic Alias)" );
if ( projection == QLatin1String( "lcc" ) )
return QObject::tr( "Lambert Conformal Conic" );
if ( projection == QLatin1String( "lcca" ) )
Expand Down
20 changes: 12 additions & 8 deletions src/gui/qgsprojectionselectiontreewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qgsprojoperation.h"
#include "qgsstringutils.h"
#include "qgsunittypes.h"
#include "qgscoordinatereferencesystemutils.h"

//qt includes
#include <QAction>
Expand Down Expand Up @@ -622,7 +623,7 @@ void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
// Set up the query to retrieve the projection information needed to populate the list
//note I am giving the full field names for clarity here and in case someone
//changes the underlying view TS
QString sql = QStringLiteral( "select description, srs_id, upper(auth_name||':'||auth_id), is_geo, name, parameters, deprecated from vw_srs where %1 order by name,description" )
QString sql = QStringLiteral( "select description, srs_id, upper(auth_name||':'||auth_id), is_geo, projection_acronym, deprecated from tbl_srs where %1 order by projection_acronym,description" )
.arg( sqlFilter );

rc = sqlite3_prepare( database, sql.toUtf8(), sql.toUtf8().length(), &stmt, &tail );
Expand Down Expand Up @@ -655,25 +656,28 @@ void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
{
// This is a projected srs
QTreeWidgetItem *node = nullptr;
QString srsType = QString::fromUtf8( ( char * )sqlite3_column_text( stmt, 4 ) );
if ( srsType.isEmpty() )
srsType = tr( "Other" );
const QString projectionAcronym = QString::fromUtf8( ( char * )sqlite3_column_text( stmt, 4 ) );
QString projectionName;
if ( projectionAcronym.isEmpty() )
projectionName = tr( "Other" );
else
projectionName = QgsCoordinateReferenceSystemUtils::translateProjection( projectionAcronym );

// Find the node for this type and add the projection to it
// If the node doesn't exist, create it
if ( srsType == previousSrsType )
if ( projectionName == previousSrsType )
{
node = previousSrsTypeNode;
}
else
{
// Different from last one, need to search
QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( srsType, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
QList<QTreeWidgetItem *> nodes = lstCoordinateSystems->findItems( projectionName, Qt::MatchExactly | Qt::MatchRecursive, NameColumn );
if ( nodes.isEmpty() )
{
// the node doesn't exist -- create it
// Make in an italic font to distinguish them from real projections
node = new QTreeWidgetItem( mProjList, QStringList( srsType ) );
node = new QTreeWidgetItem( mProjList, QStringList( projectionName ) );
node->setFlags( node->flags() & ~Qt::ItemIsSelectable );

QFont fontTemp = node->font( 0 );
Expand All @@ -685,7 +689,7 @@ void QgsProjectionSelectionTreeWidget::loadCrsList( QSet<QString> *crsFilter )
node = nodes.first();
}
// Update the cache.
previousSrsType = srsType;
previousSrsType = projectionName;
previousSrsTypeNode = node;
}
// add the item, setting the projection name in the first column of the list view
Expand Down

0 comments on commit 6d8ae62

Please sign in to comment.