[Marble-commits] KDE/kdeedu/marble/src/lib/routing/instructions
Dennis Nienhüser
earthwings at gentoo.org
Thu Nov 11 22:37:31 CET 2010
SVN commit 1195732 by nienhueser:
Leave out the road name when generating instructions for unknown roads. Generate instructions for entering/leaving motorways ("take the ramp/exit").
M +61 -2 RoutingInstruction.cpp
M +5 -0 RoutingInstruction.h
M +1 -1 RoutingWaypoint.cpp
--- trunk/KDE/kdeedu/marble/src/lib/routing/instructions/RoutingInstruction.cpp #1195731:1195732
@@ -19,7 +19,8 @@
{
RoutingInstruction::RoutingInstruction( const RoutingWaypoint &item ) :
- m_roadName( item.roadName() ), m_secondsLeft( item.secondsRemaining() ),
+ m_roadName( item.roadName() ), m_roadType( item.roadType() ),
+ m_secondsLeft( item.secondsRemaining() ),
m_angleToPredecessor( 0.0 ), m_roundaboutExit( 0 ),
m_predecessor( 0 ), m_successor( 0 )
{
@@ -43,6 +44,11 @@
return m_roadName;
}
+QString RoutingInstruction::roadType() const
+{
+ return m_roadType;
+}
+
int RoutingInstruction::secondsLeft() const
{
return m_secondsLeft;
@@ -218,14 +224,66 @@
QString RoutingInstruction::nextRoadInstruction() const
{
+ // Unused so far, but may come in handy after string freeze.
+ QObject::tr( "Enter the roundabout." );
+
+ if ( roadType() == "motorway_link" ) {
+ QStringList motorways = QStringList() << "motorway" << "motorway_link";
+ bool const leaving = predecessor() && motorways.contains( predecessor()->roadType() );
+ if ( leaving ) {
+ if ( roadName().isEmpty() ) {
+ return QObject::tr( "Take the exit." );
+ } else {
+ return QObject::tr( "Take the exit towards %1." ).arg( roadName() );
+ }
+ }
+ if ( roadName().isEmpty() ) {
+ return QObject::tr( "Take the ramp." );
+ } else {
+ return QObject::tr( "Take the ramp towards %1." ).arg( roadName() );
+ }
+ }
+
if ( predecessor() && predecessor()->roundaboutExitNumber() ) {
+ int exit = predecessor()->roundaboutExitNumber();
+ if ( roadName().isEmpty() ) {
+ return QObject::tr( "Take the %1. exit in the roundabout." ).arg( exit );
+ } else {
QString text = QObject::tr( "Take the %1. exit in the roundabout into %2." );
- int exit = predecessor()->roundaboutExitNumber();
return text.arg( exit ).arg( roadName() );
}
+ }
+ if ( roadName().isEmpty() ) {
switch( m_turnType ) {
case TurnAround:
+ return QObject::tr( "Turn around." );
+ case SharpLeft:
+ return QObject::tr( "Turn sharp left." );
+ case Left:
+ return QObject::tr( "Turn left." );
+ case SlightLeft:
+ return QObject::tr( "Keep slightly left." );
+ case Straight:
+ return QObject::tr( "Go straight ahead." );
+ case SlightRight:
+ return QObject::tr( "Keep slightly right." );
+ case Right:
+ return QObject::tr( "Turn right." );
+ case SharpRight:
+ return QObject::tr( "Turn sharp right." );
+ case Unknown:
+ case RoundaboutExit:
+ case RoundaboutFirstExit:
+ case RoundaboutSecondExit:
+ case RoundaboutThirdExit:
+ Q_ASSERT( false && "Internal error: Unknown/Roundabout should have been handled earlier." );
+ return QString();
+ break;
+ }
+ } else {
+ switch( m_turnType ) {
+ case TurnAround:
return QObject::tr( "Turn around onto %1." ).arg( roadName() );
case SharpLeft:
return QObject::tr( "Turn sharp left on %1." ).arg( roadName() );
@@ -250,6 +308,7 @@
return QString();
break;
}
+ }
Q_ASSERT( false && "Internal error: Switch did not handle all cases.");
return QString();
--- trunk/KDE/kdeedu/marble/src/lib/routing/instructions/RoutingInstruction.h #1195731:1195732
@@ -57,6 +57,9 @@
/** Name of the road to turn into */
QString roadName() const;
+ /** OSM type of the road to turn into */
+ QString roadType() const;
+
/** Estimated number of seconds to the route destination */
int secondsLeft() const;
@@ -128,6 +131,8 @@
QString m_roadName;
+ QString m_roadType;
+
int m_secondsLeft;
qreal m_angleToPredecessor;
--- trunk/KDE/kdeedu/marble/src/lib/routing/instructions/RoutingWaypoint.cpp #1195731:1195732
@@ -57,7 +57,7 @@
QString RoutingWaypoint::roadName() const
{
- return m_roadName.isEmpty() ? QObject::tr( "unknown road" ) : m_roadName;
+ return m_roadName;
}
} // namespace Marble
More information about the Marble-commits
mailing list