Marble
5 #include "RoutingRunner.h"
7 #include "GeoDataExtendedData.h"
8 #include "GeoDataData.h"
9 #include "MarbleGlobal.h"
10 #include "MarbleLocale.h"
19 RoutingRunner::RoutingRunner(
QObject *parent ) :
24 const QString RoutingRunner::lengthString(qreal length)
const
26 MarbleLocale::MeasurementSystem
const measurementSystem = MarbleGlobal::getInstance()->locale()->measurementSystem();
29 QString distanceUnit = tr(
"m" );
31 switch ( measurementSystem ) {
32 case MarbleLocale::ImperialSystem:
34 distanceUnit = tr(
"mi" );
35 length *= METER2KM * KM2MI;
37 length = 10 * qRound( length * 528 );
39 distanceUnit = tr(
"ft" );
42 case MarbleLocale::MetricSystem:
43 if ( length >= 1000 ) {
45 distanceUnit = tr(
"km" );
47 }
else if ( length >= 200 ) {
48 length = 50 * qRound( length / 50 );
49 }
else if ( length >= 100 ) {
50 length = 25 * qRound( length / 25 );
52 length = 10 * qRound( length / 10 );
55 case MarbleLocale::NauticalSystem: {
56 length *= METER2KM * KM2NM;
57 distanceUnit = tr(
"nm" );
58 precision = length < 2.0 ? 2 : 1;
63 return QString(
"%1 %2" ).
arg( length, 0,
'f', precision ).
arg( distanceUnit );
66 const QString RoutingRunner::durationString(
const QTime& duration)
const
70 const QString timeString = tr(
"%1:%2 h",
"journey duration").
arg( hoursString, minutesString );
74 const QString RoutingRunner::nameString(
const QString& name, qreal length,
const QTime& duration)
const
76 const QString result =
"%1; %2 (%3)";
80 const GeoDataExtendedData RoutingRunner::routeData(qreal length,
const QTime& duration)
const
82 GeoDataExtendedData result;
83 GeoDataData lengthData;
84 lengthData.setName(QStringLiteral(
"length"));
85 lengthData.setValue( length );
86 result.addValue( lengthData );
87 GeoDataData durationData;
88 durationData.setName(QStringLiteral(
"duration"));
90 result.addValue( durationData );
96 #include "moc_RoutingRunner.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString toString(Qt::DateFormat format) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:28 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.