Skip to content

Commit

Permalink
Show some summary properties of selected crs in detailed crs selectio…
Browse files Browse the repository at this point in the history
…n widget

- geographic/non geographic and map units
- whether crs is dynamic or not
- ensemble details
  • Loading branch information
nyalldawson committed May 10, 2021
1 parent 9e7e0d4 commit 4b8fe67
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/gui/qgsprojectionselectiontreewidget.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgssettings.h"
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystemregistry.h"
#include "qgsdatums.h"

//qt includes
#include <QFileInfo>
Expand Down Expand Up @@ -947,17 +948,54 @@ void QgsProjectionSelectionTreeWidget::updateBoundsPreview()
.arg( rect.yMaximum(), 0, 'f', 2 );
}

QStringList properties;
if ( currentCrs.isGeographic() )
properties << tr( "Geographic (uses latitude and longitude for coordinates)" );
else
{
properties << tr( "Units: %1" ).arg( QgsUnitTypes::toString( currentCrs.mapUnits() ) );
}
properties << ( currentCrs.isDynamic() ? tr( "Dynamic (relies on a datum which is not plate-fixed)" ) : tr( "Static (relies on a datum which is plate-fixed)" ) );

try
{
const QgsDatumEnsemble ensemble = currentCrs.datumEnsemble();
if ( ensemble.isValid() )
{
QString id;
if ( !ensemble.code().isEmpty() )
id = QStringLiteral( "<i>%1</i> (%2:%3)" ).arg( ensemble.name(), ensemble.authority(), ensemble.code() );
else
id = QStringLiteral( "<i>%</i>”" ).arg( ensemble.name() );
if ( ensemble.accuracy() > 0 )
{
properties << tr( "Based on %1, which has a limited accuracy of <b>at best %2 meters</b>." ).arg( id ).arg( ensemble.accuracy() );
}
else
{
properties << tr( "Based on %1, which has a limited accuracy." ).arg( id );
}
}
}
catch ( QgsNotSupportedException & )
{

}

const QString propertiesString = QStringLiteral( "<dt><b>%1</b></dt><dd><ul><li>%2</li></ul></dd>" ).arg( tr( "Properties" ),
properties.join( QStringLiteral( "</li><li>" ) ) );

const QString extentHtml = QStringLiteral( "<dt><b>%1</b></dt><dd>%2</dd>" ).arg( tr( "Extent" ), extentString );
const QString wktString = tr( "<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr( "WKT" ), currentCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ).replace( '\n', QLatin1String( "<br>" ) ).replace( ' ', QLatin1String( "&nbsp;" ) ) );
const QString proj4String = tr( "<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr( "Proj4" ), currentCrs.toProj() );
const QString wktString = QStringLiteral( "<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr( "WKT" ), currentCrs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED, true ).replace( '\n', QLatin1String( "<br>" ) ).replace( ' ', QLatin1String( "&nbsp;" ) ) );
const QString proj4String = QStringLiteral( "<dt><b>%1</b></dt><dd><code>%2</code></dd>" ).arg( tr( "Proj4" ), currentCrs.toProj() );

#ifdef Q_OS_WIN
const int smallerPointSize = std::max( font().pointSize() - 1, 8 ); // bit less on windows, due to poor rendering of small point sizes
#else
const int smallerPointSize = std::max( font().pointSize() - 2, 6 );
#endif

teProjection->setText( QStringLiteral( "<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + wktString + proj4String + extentHtml + QStringLiteral( "</dl></div>" ) );
teProjection->setText( QStringLiteral( "<div style=\"font-size: %1pt\"><h3>%2</h3><dl>" ).arg( smallerPointSize ).arg( selectedName() ) + propertiesString + wktString + proj4String + extentHtml + QStringLiteral( "</dl></div>" ) );
}

QStringList QgsProjectionSelectionTreeWidget::authorities()
Expand Down

0 comments on commit 4b8fe67

Please sign in to comment.