[Marble-commits] branches/KDE/4.5/kdeedu/marble/src/lib/routing

Dennis Nienhüser earthwings at gentoo.org
Sun Sep 26 10:52:49 CEST 2010


SVN commit 1179795 by nienhueser:

Intercept the OpenRouteService "No streets within 300 m" error message and use our own, less confusing messages: A suggestion to move the point closer to a street at the first time ORS reports an error, a suggestion to check openrouteservice.org whether the country is supported at all the second time the error comes up. This is not perfect (ideally OpenRouteService could be queried for the areas it has map data for), but at least gives an indication now that OpenRouteService map data does not cover the whole world.
CCMAIL: lindsay.mathieson at gmail.com


 M  +1 -1      RoutingLayer.cpp  
 M  +11 -2     RoutingModel.cpp  


--- branches/KDE/4.5/kdeedu/marble/src/lib/routing/RoutingLayer.cpp #1179794:1179795
@@ -286,7 +286,7 @@
         } else if ( !m_routeDirty && type == RoutingModel::Error ) {
             painter->setPen( QColor( Qt::white ) );
             painter->setBrush( QBrush( QColor::fromRgb( 226, 8, 0, 200 ) ) ); // red, oxygen palette
-            painter->drawAnnotation( pos, index.data().toString(), QSize( 180, 80 ), 10, 30, 15, 15 );
+            painter->drawAnnotation( pos, index.data().toString(), QSize( 240, 100 ), 10, 30, 15, 15 );
         }
     }
 }
--- branches/KDE/4.5/kdeedu/marble/src/lib/routing/RoutingModel.cpp #1179794:1179795
@@ -48,12 +48,14 @@
 
     qreal m_totalDistance;
 
+    int m_consecutiveErrors;
+
     RoutingModelPrivate();
 
     RouteElement parseGmlPos( const QStringList &content ) const;
 };
 
-RoutingModelPrivate::RoutingModelPrivate() : m_totalDistance( 0.0 )
+RoutingModelPrivate::RoutingModelPrivate() : m_totalDistance( 0.0 ), m_consecutiveErrors( 0 )
 {
     // nothing to do
 }
@@ -143,6 +145,7 @@
 
     QDomNodeList errors = root.elementsByTagName( "xls:Error" );
     if ( errors.size() > 0 ) {
+        ++d->m_consecutiveErrors;
         for ( unsigned int i = 0; i < errors.length(); ++i ) {
             QDomNode node = errors.item( i );
             QString errorMessage = node.attributes().namedItem( "message" ).nodeValue();
@@ -151,7 +154,11 @@
                 RouteElement element;
                 GeoDataCoordinates position;
                 if ( regexp.capturedTexts().size() == 4 ) {
-                    element.description = regexp.capturedTexts().at( 1 );
+                    //element.description = regexp.capturedTexts().at( 1 );
+                    element.description = "Sorry, found no streets nearby. Try moving this point closer to a street.";
+                    if ( d->m_consecutiveErrors > 1 ) {
+                        element.description = "Sorry, still found no streets nearby. Please check http://openrouteservice.org to see whether routing in this country is supported yet.";
+                    }
                     position.setLongitude( regexp.capturedTexts().at( 2 ).toDouble(), GeoDataCoordinates::Degree );
                     position.setLatitude( regexp.capturedTexts().at( 3 ).toDouble(), GeoDataCoordinates::Degree );
                     element.position = position;
@@ -167,6 +174,8 @@
                 delete messageBox;
             }
         }
+    } else {
+        d->m_consecutiveErrors = 0;
     }
 
     QDomNodeList summary = root.elementsByTagName( "xls:RouteSummary" );


More information about the Marble-commits mailing list