[Marble-commits] KDE/kdeedu/marble/src/lib/routing
Dennis Nienhüser
earthwings at gentoo.org
Mon Oct 4 00:02:19 CEST 2010
SVN commit 1182230 by nienhueser:
Store route deviation tristate and make sure to emit it again after recalculating a route. Fixes rerouting not working when travelling fast. Stop recalculating routes when all via points were visited. Access to driving instruction icons.
M +2 -1 RoutingManager.cpp
M +33 -6 RoutingModel.cpp
M +10 -0 RoutingModel.h
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.cpp #1182229:1182230
@@ -330,12 +330,13 @@
if ( d->m_routeRequest->size() == 2 && d->m_routeRequest->visited( 0 ) && !d->m_routeRequest->visited( 1 ) ) {
d->m_routeRequest->setPosition( 0, d->m_marbleModel->positionTracking()->currentLocation() );
+ updateRoute();
} else if ( d->m_routeRequest->size() != 0 && !d->m_routeRequest->visited( d->m_routeRequest->size()-1 ) ) {
d->m_routeRequest->insert( 0, d->m_marbleModel->positionTracking()->currentLocation() );
- }
updateRoute();
}
}
+}
} // namespace Marble
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingModel.cpp #1182229:1182230
@@ -55,6 +55,13 @@
class RoutingModelPrivate
{
public:
+ enum RouteDeviation
+ {
+ Unknown,
+ OnRoute,
+ OffRoute
+ };
+
RoutingModelPrivate( RouteRequest* request );
RouteElements m_route;
@@ -69,9 +76,11 @@
int m_nextInstructionIndex;
qreal m_nextInstructionDistance;
qreal m_currentInstructionLength;
+ QPixmap m_nextInstructionPixmap;
+ QPixmap m_followingInstructionPixmap;
GeoDataCoordinates m_location;
QString m_nextDescription;
- bool m_routeLeft;
+ RouteDeviation m_deviation;
QMap<RoutingInstruction::TurnType,QPixmap> m_turnTypePixmaps;
PositionTracking* m_positionTracking;
RouteRequest* m_request;
@@ -92,7 +101,7 @@
m_nextInstructionIndex( 0 ),
m_nextInstructionDistance( 0.0 ),
m_currentInstructionLength( 0.0 ),
- m_routeLeft( false ),
+ m_deviation( Unknown ),
m_positionTracking( 0 ),
m_request( request )
{
@@ -259,6 +268,7 @@
d->importPlacemark( placemark );
}
+ d->m_deviation = RoutingModelPrivate::Unknown;
reset();
return true;
}
@@ -446,6 +456,12 @@
if( d->m_nextInstructionIndex != instructions.size() ) {
d->m_location = instructions[d->m_nextInstructionIndex].position;
d->m_nextDescription = instructions[d->m_nextInstructionIndex].description;
+ d->m_nextInstructionPixmap = d->m_turnTypePixmaps[instructions[d->m_nextInstructionIndex].turnType];
+ if ( d->m_nextInstructionIndex+1 < instructions.size() ) {
+ d->m_followingInstructionPixmap = d->m_turnTypePixmaps[instructions[d->m_nextInstructionIndex+1].turnType];
+ } else if ( d->m_request->size() > 0 ) {
+ d->m_followingInstructionPixmap = d->m_request->pixmap( d->m_request->size()-1 );
+ }
//distance between current position and next instruction point
distanceRemaining = distanceSphere( location, d->m_location ) * radius;
}
@@ -484,9 +500,10 @@
emit nextInstruction( d->m_totalTimeRemaining, d->m_totalDistanceRemaining );
bool const deviated = d->deviatedFromRoute( location, wayPoints );
- if ( deviated != d->m_routeLeft ) {
- d->m_routeLeft = deviated;
- emit deviatedFromRoute( d->m_routeLeft );
+ RoutingModelPrivate::RouteDeviation const deviation = deviated ? RoutingModelPrivate::OffRoute : RoutingModelPrivate::OnRoute;
+ if ( d->m_deviation != deviation ) {
+ d->m_deviation = deviation;
+ emit deviatedFromRoute( deviated );
}
d->updateViaPoints( location );
@@ -520,7 +537,7 @@
bool RoutingModel::deviatedFromRoute() const
{
- return d->m_routeLeft;
+ return d->m_deviation != RoutingModelPrivate::OnRoute;
}
qreal RoutingModel::nextInstructionDistance() const
@@ -533,6 +550,16 @@
return d->m_currentInstructionLength;
}
+QPixmap RoutingModel::nextInstructionPixmap() const
+{
+ return d->m_nextInstructionPixmap;
+}
+
+QPixmap RoutingModel::followingInstructionPixmap() const
+{
+ return d->m_followingInstructionPixmap;
+}
+
} // namespace Marble
#include "RoutingModel.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingModel.h #1182229:1182230
@@ -151,6 +151,16 @@
*/
qreal currentInstructionLength() const;
+ /**
+ * Returns an icon indicating the turn type for the next driving instruction
+ */
+ QPixmap nextInstructionPixmap() const;
+
+ /**
+ * Returns an icon indicating the turn type for the next but one driving instruction
+ */
+ QPixmap followingInstructionPixmap() const;
+
public Q_SLOTS:
/**
* Old data in the model is discarded, the parsed content of the provided document
More information about the Marble-commits
mailing list