Skip to content

Commit

Permalink
technical changes application
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Oct 18, 2024
1 parent dd3c896 commit 4f1e62d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ QString InputUtils::formatNumber( const double number, int precision )
return QString::number( number, 'f', precision );
}

QString InputUtils::formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *activeProject )
QString InputUtils::formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *project )
{
if ( !activeProject )
if ( !project )
return QString();

return InputUtils::formatDistanceHelper( distanceInMeters, precision, activeProject->distanceUnits() );
return InputUtils::formatDistanceHelper( distanceInMeters, precision, project->distanceUnits() );
}

QString InputUtils::formatDistanceHelper( const double distanceInMeters, int precision, Qgis::DistanceUnit destUnit )
Expand All @@ -183,19 +183,19 @@ QString InputUtils::formatDistanceHelper( const double distanceInMeters, int pre
destUnit = Qgis::DistanceUnit::Meters;
}

double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, destUnit );
double distance = distanceInMeters * factor;
QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );
const double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::DistanceUnit::Meters, destUnit );
const double distance = distanceInMeters * factor;
const QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );

return QString( "%1 %2" ).arg( QString::number( distance, 'f', precision ), abbreviation );
}

QString InputUtils::formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *activeProject )
QString InputUtils::formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *project )
{
if ( !activeProject )
if ( !project )
return QString();

return InputUtils::formatAreaHelper( areaInSquareMeters, precision, activeProject->areaUnits() );
return InputUtils::formatAreaHelper( areaInSquareMeters, precision, project->areaUnits() );
}

QString InputUtils::formatAreaHelper( const double areaInSquareMeters, int precision, Qgis::AreaUnit destUnit )
Expand All @@ -205,9 +205,9 @@ QString InputUtils::formatAreaHelper( const double areaInSquareMeters, int preci
destUnit = Qgis::AreaUnit::SquareMeters;
}

double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::AreaUnit::SquareMeters, destUnit );
double area = areaInSquareMeters * factor;
QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );
const double factor = QgsUnitTypes::fromUnitToUnitFactor( Qgis::AreaUnit::SquareMeters, destUnit );
const double area = areaInSquareMeters * factor;
const QString abbreviation = QgsUnitTypes::toAbbreviatedString( destUnit );

return QString( "%1 %2" ).arg( QString::number( area, 'f', precision ), abbreviation );
}
Expand Down
4 changes: 2 additions & 2 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ class InputUtils: public QObject
Q_INVOKABLE QString getFileName( const QString &filePath );
Q_INVOKABLE QString formatProjectName( const QString &fullProjectName );
Q_INVOKABLE QString formatNumber( const double number, int precision = 1 );
Q_INVOKABLE QString formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *activeProject );
Q_INVOKABLE QString formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *activeProject );
Q_INVOKABLE QString formatDistanceInProjectUnit( const double distanceInMeters, int precision, QgsProject *project );
Q_INVOKABLE QString formatAreaInProjectUnit( const double areaInSquareMeters, int precision, QgsProject *project );

static QString formatDistanceHelper( const double distanceInMeters, int precision, Qgis::DistanceUnit destUnit );
static QString formatAreaHelper( const double areaInSquareMeters, int precision, Qgis::AreaUnit destUnit );
Expand Down
2 changes: 1 addition & 1 deletion app/maptools/measurementmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void MeasurementMapTool::updateMapSettings( InputMapSettings *newMapSettings )
{
connect( updatedMapSettings, &InputMapSettings::extentChanged, this, &MeasurementMapTool::updateDistance );

mDistanceArea.setEllipsoid( QStringLiteral( "WGS84" ) );
mDistanceArea.setEllipsoid( updatedMapSettings->project()->ellipsoid() );
mDistanceArea.setSourceCrs( updatedMapSettings->destinationCrs(), updatedMapSettings->transformContext() );
}
}
Expand Down

1 comment on commit 4f1e62d

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.10.686711 just submitted!

Please sign in to comment.