Skip to content

Commit

Permalink
Fix point picking precision for point parameters in processing dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Apr 26, 2019
1 parent b2aa978 commit b7772d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,10 @@ void QgsProcessingPointPanel::clear()

void QgsProcessingPointPanel::setValue( const QgsPointXY &point, const QgsCoordinateReferenceSystem &crs )
{
QString newText = QStringLiteral( "%1,%2" ).arg( point.x() ).arg( point.y() );
QString newText = QStringLiteral( "%1,%2" )
.arg( QString::number( point.x(), 'g', 18 ) )
.arg( QString::number( point.y(), 'g', 18 ) );

mCrs = crs;
if ( mCrs.isValid() )
{
Expand Down
8 changes: 6 additions & 2 deletions tests/src/gui/testprocessinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2841,19 +2841,23 @@ void TestProcessingGui::testPointPanel()
QCOMPARE( panel->value().toString(), QStringLiteral( "200,250 [EPSG:3111]" ) );
QCOMPARE( spy.count(), 2 );

panel->setValue( QgsPointXY( 123456.123456789122, 654321.987654321012 ), QgsCoordinateReferenceSystem() );
QCOMPARE( panel->value().toString(), QStringLiteral( "123456.123456789122,654321.987654321012" ) );
QCOMPARE( spy.count(), 3 );

QVERIFY( !panel->mLineEdit->showClearButton() );
panel->setAllowNull( true );
QVERIFY( panel->mLineEdit->showClearButton() );
panel->clear();
QVERIFY( !panel->value().isValid() );
QCOMPARE( spy.count(), 3 );
QCOMPARE( spy.count(), 4 );

QgsMapCanvas canvas;
canvas.setDestinationCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) );
panel->setMapCanvas( &canvas );
panel->updatePoint( QgsPointXY( 1.5, -3.5 ) );
QCOMPARE( panel->value().toString(), QStringLiteral( "1.5,-3.5 [EPSG:28356]" ) );
QCOMPARE( spy.count(), 4 );
QCOMPARE( spy.count(), 5 );

panel.reset();
}
Expand Down

0 comments on commit b7772d4

Please sign in to comment.