Search code examples
androidskmapsskobbler-maps

Route calculation failed and simulating re-routing


I am using Skobbler sample Android SDK (downloaded from here) to write navigation application , it works perfect if I run application from Android studio but when I install application using generated APK, it usually fails on route calculation and in logs all i get is:

06-04 10:09:43.435    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKMapSurfaceView----@setZoom  11.0
06-04 10:09:43.435    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKMapSurfaceView---- centerMapOnPosition [101.6156902,3.0311728]
06-04 10:09:43.435    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKRouteManager---- @clearAllRoutesFromCache
06-04 10:09:43.436    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKRouteManager---- @calculateRoute SKRouteSettings [startCoordinate=[101.6156902,3.0311728], destinationCoordinate=[101.6156,3.03496], routeMode=CAR_FASTEST, alternativeRouteModes=null, routeConnectionMode=HYBRID, downloadRouteCorridor=true, routeCorridorWidthInMeters=2000, waitForCorridorDownload=false, destinationIsPoint=true, tollRoadsAvoided=false, highWaysAvoided=false, avoidFerries=false, noOfRoutes=1, countryCodesReturned=false, extendedPointsReturned=false, viaPoints=null, useRoadSlopes=false, exposeRoute=true, filterAlternatives=false, requestAdvices=true, bicycleWalk= false, bicycleCarryAvoided= false]
06-04 10:09:43.437    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKRouteManager----@clearCurrentRoute
06-04 10:09:43.437    6285-6285/com.skobbler.sdkdemo D/SkobblerNG﹕ clear route
06-04 10:09:43.437    6285-6285/com.skobbler.sdkdemo D/SkobblerNG﹕ clear route final
06-04 10:09:43.439    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKUtils----Return calculated device type HIGH
06-04 10:09:43.440    6285-6285/com.skobbler.sdkdemo D/SKMaps﹕ SKRouteManager---- Calculate route setroute SKRouteSettings [startCoordinate=[101.6156902,3.0311728], destinationCoordinate=[101.6156,3.03496], routeMode=CAR_FASTEST, alternativeRouteModes=null, routeConnectionMode=HYBRID, downloadRouteCorridor=true, routeCorridorWidthInMeters=2000, waitForCorridorDownload=false, destinationIsPoint=true, tollRoadsAvoided=false, highWaysAvoided=false, avoidFerries=false, noOfRoutes=1, countryCodesReturned=false, extendedPointsReturned=false, viaPoints=null, useRoadSlopes=false, exposeRoute=true, filterAlternatives=false, requestAdvices=true, bicycleWalk= false, bicycleCarryAvoided= false]
06-04 10:09:43.440    6285-6285/com.skobbler.sdkdemo D/SkobblerNG﹕ Java_com_skobbler_ngx_routing_SKRouteManager_setroute
06-04 10:09:43.440    6285-6285/com.skobbler.sdkdemo D/SkobblerNG﹕ No Via points added to the route
06-04 10:09:43.442    6285-6285/com.skobbler.sdkdemo D/SkobblerNG﹕ Java_com_skobbler_ngx_routing_SKRouteManager_setroute final
06-04 10:09:43.445    6285-6344/com.skobbler.sdkdemo D/SKMaps﹕ SKRouteManager---- @onRouteCalculationFailed called  with SKRoutingErrorCode =ROUTE_CANNOT_BE_CALCULATED
06-04 10:09:43.447    6285-6344/com.skobbler.sdkdemo W/SKMaps﹕ SKRouteManager---- @onAllRoutesCompleted called

Also, is there any way to simluate the re-routing when using navigation in SKNavigationType.SIMULATION mode? I tried changing current user location explicitly inside onCurrentPositionUpdate(SKPosition currentPosition) method like this, but it isn't working:

@Override
public void onCurrentPositionUpdate(SKPosition currentPosition) {
    iteration++;

    this.currentPosition = currentPosition;
    if (mapView != null) {

        if(iteration >= 5) {
            Toast.makeText(MapActivity.this, "Changed location", Toast.LENGTH_LONG).show();
            this.currentPosition = new SKPosition();
            this.currentPosition.setCoordinate(new SKCoordinate(101.618133, 3.025863));
        }

        mapView.reportNewGPSPosition(this.currentPosition);
    }
}

Solution

  • For simulating the re-routing, you have to use the blockRoad method from SKNavigationManager. Please check the doc here: http://developer.skobbler.ro/docs/android/com/skobbler/ngx/navigation/SKNavigationManager.html#blockRoad%28double%29