mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Show authority:code identifiers on transform selection dialog
Many scopes/remark cross reference these, so by showing them in the table of available operations we give users more clues how to pick the correct one.
This commit is contained in:
parent
f74bd3454d
commit
dd9dfb0d08
@ -89,6 +89,10 @@ and ``destinationTransformId`` transforms.
|
||||
QString remarks;
|
||||
|
||||
QString areaOfUse;
|
||||
|
||||
QString authority;
|
||||
|
||||
QString code;
|
||||
};
|
||||
|
||||
struct TransformDetails
|
||||
@ -97,6 +101,10 @@ and ``destinationTransformId`` transforms.
|
||||
QString name;
|
||||
double accuracy;
|
||||
|
||||
QString authority;
|
||||
|
||||
QString code;
|
||||
|
||||
QString scope;
|
||||
|
||||
QString remarks;
|
||||
|
@ -323,6 +323,9 @@ QgsDatumTransform::TransformDetails QgsDatumTransform::transformDetailsFromPj( P
|
||||
details.accuracy = proj_coordoperation_get_accuracy( pjContext, op );
|
||||
details.isAvailable = proj_coordoperation_is_instantiable( pjContext, op );
|
||||
|
||||
details.authority = QString( proj_get_id_auth_name( op, 0 ) );
|
||||
details.code = QString( proj_get_id_code( op, 0 ) );
|
||||
|
||||
const char *areaOfUseName = nullptr;
|
||||
if ( proj_get_area_of_use( pjContext, op, nullptr, nullptr, nullptr, nullptr, &areaOfUseName ) )
|
||||
{
|
||||
@ -365,6 +368,8 @@ QgsDatumTransform::TransformDetails QgsDatumTransform::transformDetailsFromPj( P
|
||||
SingleOperationDetails singleOpDetails;
|
||||
singleOpDetails.remarks = QString( proj_get_remarks( step.get() ) );
|
||||
singleOpDetails.scope = QString( proj_get_scope( step.get() ) );
|
||||
singleOpDetails.authority = QString( proj_get_id_auth_name( step.get(), 0 ) );
|
||||
singleOpDetails.code = QString( proj_get_id_code( step.get(), 0 ) );
|
||||
|
||||
const char *areaOfUseName = nullptr;
|
||||
if ( proj_get_area_of_use( pjContext, step.get(), nullptr, nullptr, nullptr, nullptr, &areaOfUseName ) )
|
||||
|
@ -163,6 +163,12 @@ class CORE_EXPORT QgsDatumTransform
|
||||
|
||||
//! Area of use, from EPSG registry database
|
||||
QString areaOfUse;
|
||||
|
||||
//! Authority name, e.g. EPSG.
|
||||
QString authority;
|
||||
|
||||
//! Authority code, e.g. "8447" (for EPSG:8447).
|
||||
QString code;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -180,6 +186,22 @@ class CORE_EXPORT QgsDatumTransform
|
||||
//! Transformation accuracy (in meters)
|
||||
double accuracy = 0;
|
||||
|
||||
/**
|
||||
* Authority name, e.g. EPSG.
|
||||
*
|
||||
* This is only available for single step coordinate operations. For multi-step operations, check
|
||||
* \a operationDetails instead.
|
||||
*/
|
||||
QString authority;
|
||||
|
||||
/**
|
||||
* Identification code, e.g. "8447" (For EPSG:8447).
|
||||
*
|
||||
* This is only available for single step coordinate operations. For multi-step operations, check
|
||||
* \a operationDetails instead.
|
||||
*/
|
||||
QString code;
|
||||
|
||||
/**
|
||||
* Scope of operation, from EPSG registry database.
|
||||
*
|
||||
|
@ -172,7 +172,10 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
|
||||
item->setData( AvailableRole, transform.isAvailable );
|
||||
item->setFlags( item->flags() & ~Qt::ItemIsEditable );
|
||||
|
||||
item->setText( transform.name );
|
||||
QString name = transform.name;
|
||||
if ( !transform.authority.isEmpty() && !transform.code.isEmpty() )
|
||||
name += QStringLiteral( " — %1:%2" ).arg( transform.authority, transform.code );
|
||||
item->setText( name );
|
||||
|
||||
if ( row == 0 ) // highlight first (preferred) operation
|
||||
{
|
||||
@ -231,6 +234,7 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
|
||||
}
|
||||
|
||||
QStringList areasOfUse;
|
||||
QStringList authorityCodes;
|
||||
|
||||
#if PROJ_VERSION_MAJOR > 6 or PROJ_VERSION_MINOR >= 2
|
||||
QStringList opText;
|
||||
@ -252,6 +256,12 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
|
||||
if ( !areasOfUse.contains( singleOpDetails.areaOfUse ) )
|
||||
areasOfUse << singleOpDetails.areaOfUse;
|
||||
}
|
||||
if ( !singleOpDetails.authority.isEmpty() && !singleOpDetails.code.isEmpty() )
|
||||
{
|
||||
const QString identifier = QStringLiteral( "%1:%2" ).arg( singleOpDetails.authority, singleOpDetails.code );
|
||||
if ( !authorityCodes.contains( identifier ) )
|
||||
authorityCodes << identifier;
|
||||
}
|
||||
|
||||
if ( !text.isEmpty() )
|
||||
{
|
||||
@ -285,6 +295,10 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
|
||||
if ( !transform.areaOfUse.isEmpty() && !areasOfUse.contains( transform.areaOfUse ) )
|
||||
areasOfUse << transform.areaOfUse;
|
||||
|
||||
const QString id = QStringLiteral( "%1:%2" ).arg( transform.authority, transform.code );
|
||||
if ( !transform.authority.isEmpty() && !transform.code.isEmpty() && !authorityCodes.contains( id ) )
|
||||
authorityCodes << id;
|
||||
|
||||
#if PROJ_VERSION_MAJOR > 6 or PROJ_VERSION_MINOR >= 2
|
||||
const QColor disabled = palette().color( QPalette::Disabled, QPalette::Text );
|
||||
const QColor active = palette().color( QPalette::Active, QPalette::Text );
|
||||
@ -295,11 +309,13 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
|
||||
const QString toolTipString = QStringLiteral( "<b>%1</b>" ).arg( transform.name )
|
||||
+ ( !opText.empty() ? ( opText.count() == 1 ? QStringLiteral( "<p>%1</p>" ).arg( opText.at( 0 ) ) : QStringLiteral( "<ul>%1</ul>" ).arg( opText.join( QString() ) ) ) : QString() )
|
||||
+ ( !areasOfUse.empty() ? QStringLiteral( "<p><b>%1</b>: %2</p>" ).arg( tr( "Area of use" ), areasOfUse.join( QStringLiteral( ", " ) ) ) : QString() )
|
||||
+ ( !authorityCodes.empty() ? QStringLiteral( "<p><b>%1</b>: %2</p>" ).arg( tr( "Identifiers" ), authorityCodes.join( QStringLiteral( ", " ) ) ) : QString() )
|
||||
+ ( !missingMessage.isEmpty() ? QStringLiteral( "<p><b style=\"color: red\">%1</b></p>" ).arg( missingMessage ) : QString() )
|
||||
+ QStringLiteral( "<p><code style=\"color: %1\">%2</code></p>" ).arg( codeColor.name(), transform.proj );
|
||||
#else
|
||||
const QString toolTipString = QStringLiteral( "<b>%1</b>%2%3<p><code>%4</code></p>" ).arg( transform.name,
|
||||
const QString toolTipString = QStringLiteral( "<b>%1</b>%2%3%4<p><code>%5</code></p>" ).arg( transform.name,
|
||||
( !transform.areaOfUse.isEmpty() ? QStringLiteral( "<p><b>%1</b>: %2</p>" ).arg( tr( "Area of use" ), transform.areaOfUse ) : QString() ),
|
||||
( !id.isEmpty() ? QStringLiteral( "<p><b>%1</b>: %2</p>" ).arg( tr( "Identifier" ), id ) : QString() ),
|
||||
( !missingMessage.isEmpty() ? QStringLiteral( "<p><b style=\"color: red\">%1</b></p>" ).arg( missingMessage ) : QString() ),
|
||||
transform.proj );
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user