PDA

View Full Version : [Android] Bug with AlternativeRoutes and SKRouteRestrictions



paulneesham
01.06.2016, 12:10
In beta 3.0 I'm trying to apply SKRouteRestrictions to alternative routes but if I set the RouteRestrictions on the alternative routes to anything other than defaults the onRouteCalculationFailed methed return INVALID_START or INVALID_DESTINATION.



private void launchAlternativeRouteCalculation() {

if (routeIds.isEmpty()) {
SKRouteSettings route = new SKRouteSettings();
routeIds.clear();
mapView.deleteAllAnnotationsAndCustomPOIs();
currentJob = null;
AutocabJob.Stage stage = DataStore.getInstance().getJobSubject().getCurrent StageData();

LatLng loc = DataStore.masToLatLng(stage.Latitude, stage.Longitude);
route.setStartCoordinate(new SKCoordinate(currentPosition.getCoordinate().getLa titude(),
currentPosition.getCoordinate().getLongitude()));
route.setDestinationCoordinate(new SKCoordinate(loc.latitude, loc.longitude));

// selecting the total number of routes, with 2 alternatives
route.setMaximumReturnedRoutes(3);
if (Configuration.navigationObjectiveShortest) {
route.setRouteMode(SKRouteSettings.SKRouteMode.CAR _SHORTEST);
} else {
route.setRouteMode(SKRouteSettings.SKRouteMode.CAR _FASTEST);
}
List<SKRouteAlternativeSettings> routeModes = new ArrayList<>();

SKRouteAlternativeSettings skRouteSecond;
if (Configuration.navigationObjectiveShortest) {
skRouteSecond = new SKRouteAlternativeSettings(SKRouteSettings.SKRoute Mode.CAR_FASTEST);
} else {
skRouteSecond = new SKRouteAlternativeSettings(SKRouteSettings.SKRoute Mode.CAR_SHORTEST);
}

SKRouteAlternativeSettings skRouteThird = new SKRouteAlternativeSettings(SKRouteSettings.SKRoute Mode.EFFICIENT);


routeModes.add(skRouteSecond);
routeModes.add(skRouteThird);

route.setAlternativeRouteModes(routeModes);
route.setRouteExposed(true);
SKRouteRestrictions restrictions = new SKRouteRestrictions();
restrictions.setFerriesAvoided(avoidFerry);
restrictions.setHighWaysAvoided(avoidHighway);
restrictions.setTollRoadsAvoided(avoidToll);
route.setRouteRestrictions(restrictions);
// problem is here if these two get anything of than default values its fails
skRouteThird.setRouteRestrictions(new SKRouteRestrictions());
skRouteSecond.setRouteRestrictions(new SKRouteRestrictions());

SKRouteManager.getInstance().calculateRoute(route) ;
} else {
selectRoute(selectedRouteIndex);
}
isRouting = true;
}

dandronic
02.06.2016, 12:40
We confirm that this is a bug.
We've fixed it and as soon as we have another stable beta version we'll notify you.

Adela_Silvia
10.06.2016, 15:14
hi paulneesham,

Please check the new beta build (https://www.dropbox.com/sh/rcr4gyzjrw16dg1/AABoLJIe2Y5kOyx9RjNg66PGa?dl=0) - this issue was included in the latest fix from 10th of June.

paulneesham
20.06.2016, 15:49
scrap that it starts now, will check tolls, motorways and ferry now

[Edit 2]: Yep restrictions seem to work fine now.

Adela_Silvia
24.06.2016, 09:52
Thanks for letting us know