Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When building on proj >= 6.2, show the full scope and remarks for coordinate operations #30501

Merged
merged 4 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgsdatumtransform.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ and ``destinationTransformId`` transforms.
bool isAvailable;
};

struct SingleOperationDetails
{
QString scope;

QString remarks;
};

struct TransformDetails
{
QString proj;
Expand All @@ -91,6 +98,8 @@ and ``destinationTransformId`` transforms.
bool isAvailable;

QList< QgsDatumTransform::GridDetails > grids;

QList< QgsDatumTransform::SingleOperationDetails > operationDetails;
};

static QList< QgsDatumTransform::TransformDetails > operations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
Expand Down
15 changes: 15 additions & 0 deletions src/core/qgsdatumtransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,21 @@ QgsDatumTransform::TransformDetails QgsDatumTransform::transformDetailsFromPj( P

details.grids.append( gridDetails );
}

#if PROJ_VERSION_MAJOR > 6 or PROJ_VERSION_MINOR >= 2
for ( int j = 0; j < proj_concatoperation_get_step_count( pjContext, op ); ++j )
{
QgsProjUtils::proj_pj_unique_ptr step( proj_concatoperation_get_step( pjContext, op, j ) );
if ( step )
{
SingleOperationDetails singleOpDetails;
singleOpDetails.remarks = QString( proj_get_remarks( step.get() ) );
singleOpDetails.scope = QString( proj_get_scope( step.get() ) );
details.operationDetails.append( singleOpDetails );
}
}
#endif

return details;
}
#endif
23 changes: 23 additions & 0 deletions src/core/qgsdatumtransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ class CORE_EXPORT QgsDatumTransform
bool isAvailable = false;
};

/**
* Contains information about a single coordinate operation.
*
* \note Only used in builds based on on Proj >= 6.2
* \since QGIS 3.10
*/
struct SingleOperationDetails
{
//! Scope of operation, from EPSG registry database
QString scope;

//! Remarks for operation, from EPSG registry database
QString remarks;
};

/**
* Contains information about a coordinate transformation operation.
*
Expand Down Expand Up @@ -174,6 +189,14 @@ class CORE_EXPORT QgsDatumTransform
* Contains a list of transform grids used by the operation.
*/
QList< QgsDatumTransform::GridDetails > grids;

/**
* Contains information about the single operation steps used in the transform operation.
*
* \note Only used in builds based on on Proj >= 6.2
* \since QGIS 3.10
*/
QList< QgsDatumTransform::SingleOperationDetails > operationDetails;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ INCLUDE_DIRECTORIES(SYSTEM
${SQLITE3_INCLUDE_DIR}
${QSCINTILLA_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
)

# disable deprecation warnings for classes re-exporting deprecated methods
Expand Down
51 changes: 50 additions & 1 deletion src/gui/qgsdatumtransformdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
#include "qgsproject.h"
#include "qgsguiutils.h"
#include "qgsgui.h"
#include "qgshelp.h"

#include <QDir>
#include <QPushButton>

#if PROJ_VERSION_MAJOR>=6
#include "qgsprojutils.h"
#include <proj.h>
#endif

bool QgsDatumTransformDialog::run( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, QWidget *parent )
Expand Down Expand Up @@ -113,6 +115,8 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QgsCoordinateReferenceSy
#if PROJ_VERSION_MAJOR>=6
// proj 6 doesn't provide deprecated operations
mHideDeprecatedCheckBox->setVisible( false );

mLabelDstDescription->hide();
#else
QgsSettings settings;
mHideDeprecatedCheckBox->setChecked( settings.value( QStringLiteral( "Windows/DatumTransformDialog/hideDeprecated" ), true ).toBool() );
Expand All @@ -137,6 +141,11 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QgsCoordinateReferenceSy
mLabelSrcDescription->clear();
mLabelDstDescription->clear();

connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ]
{
QgsHelp::openHelp( QStringLiteral( "working_with_projections/working_with_projections.html" ) );
} );

load( selectedDatumTransforms, selectedProj );
}

Expand Down Expand Up @@ -172,7 +181,47 @@ void QgsDatumTransformDialog::load( QPair<int, int> selectedDatumTransforms, con
preferredInitialRow = row;
}

const QString toolTipString = QStringLiteral( "<b>%1</b><p>%2</p>" ).arg( transform.name, transform.proj );

#if PROJ_VERSION_MAJOR > 6 or PROJ_VERSION_MINOR >= 2
QStringList opText;
for ( const QgsDatumTransform::SingleOperationDetails &singleOpDetails : transform.operationDetails )
{
QString text;
if ( !singleOpDetails.scope.isEmpty() )
{
text += QStringLiteral( "<b>%1</b>: %2" ).arg( tr( "Scope" ), singleOpDetails.scope );
}
if ( !singleOpDetails.remarks.isEmpty() )
{
if ( !text.isEmpty() )
text += QStringLiteral( "<br>" );
text += QStringLiteral( "<b>%1</b>: %2" ).arg( tr( "Remarks" ), singleOpDetails.remarks );
}

if ( !text.isEmpty() )
{
opText.append( text );
}
}

if ( opText.count() > 1 )
{
for ( int k = 0; k < opText.count(); ++k )
opText[k] = QStringLiteral( "<li>%1</li>" ).arg( opText.at( k ) );
}

const QColor disabled = palette().color( QPalette::Disabled, QPalette::Text );
const QColor active = palette().color( QPalette::Active, QPalette::Text );

const QColor codeColor( static_cast< int >( active.red() * 0.6 + disabled.red() * 0.4 ),
static_cast< int >( active.green() * 0.6 + disabled.green() * 0.4 ),
static_cast< int >( active.blue() * 0.6 + disabled.blue() * 0.4 ) );
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() ) +
QStringLiteral( "<p><code style=\"color: %1\">%2</code></p>" ).arg( codeColor.name(), transform.proj );
#else
const QString toolTipString = QStringLiteral( "<b>%1</b><p><code>%2</code></p>" ).arg( transform.name, transform.proj );
#endif
item->setToolTip( toolTipString );
if ( itemDisabled )
{
Expand Down
100 changes: 58 additions & 42 deletions src/ui/qgsdatumtransformdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,7 @@
<property name="windowTitle">
<string>Select Datum Transformations</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,3,1,0,0">
<item row="2" column="0">
<widget class="QLabel" name="mLabelSrcDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,3,1,0,0,0">
<item row="0" column="0" colspan="2">
<widget class="QStackedWidget" name="mCrsStackedWidget">
<property name="currentIndex">
Expand Down Expand Up @@ -132,15 +109,12 @@
</widget>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="mMakeDefaultCheckBox">
<property name="toolTip">
<string>If checked, the selected transformation will become the default choice in all new projects</string>
</property>
<widget class="QCheckBox" name="mHideDeprecatedCheckBox">
<property name="text">
<string>Make default</string>
<string>Hide deprecated transformations</string>
</property>
</widget>
</item>
Expand All @@ -158,9 +132,12 @@
</spacer>
</item>
<item>
<widget class="QCheckBox" name="mHideDeprecatedCheckBox">
<widget class="QCheckBox" name="mMakeDefaultCheckBox">
<property name="toolTip">
<string>If checked, the selected transformation will become the default choice in all new projects</string>
</property>
<property name="text">
<string>Hide deprecated transformations</string>
<string>Make default</string>
</property>
</widget>
</item>
Expand All @@ -176,19 +153,58 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mLabelDstDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mLabelSrcDescription">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mLabelDstDescription">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -201,8 +217,8 @@
</customwidgets>
<tabstops>
<tabstop>mDatumTransformTableWidget</tabstop>
<tabstop>mMakeDefaultCheckBox</tabstop>
<tabstop>mHideDeprecatedCheckBox</tabstop>
<tabstop>mMakeDefaultCheckBox</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down