mapbox / mapbox-navigation-android

Mapbox Navigation SDK for Android
https://docs.mapbox.com/android/navigation/overview/
Other
622 stars 319 forks source link

Rerouting issues : setRoute failed to parse route: wrong geometry_index #5051

Closed Christophe668 closed 2 years ago

Christophe668 commented 2 years ago

Android API: Mapbox Navigation SDK version: 2.0.0 (GA)

Steps to trigger behavior

Looks like rerouting fails because of this :

E/nav-native: setRoute failed to parse route: wrong geometry_index
E/nav-native: setRoute failed to parse json

It's trying to reroute in a loop

Profile: Cycling

D/MbxNavigationTelemetry: onRoutesChanged. Number of routes = 1; reason = ROUTES_UPDATE_REASON_REROUTE
D/MbxNavigationTelemetry: handleReroute
W/TelemetryUtils: java.lang.SecurityException: getDataNetworkTypeForSubscriber
I/AudioManager: In isBluetoothScoOn(), calling application: bike.cowboy.app.debug
D/MbxNavigationTelemetry: populateNavigationEvent
E/❤️ (NavigationViewModel.kt:46).onOffRouteStateChanged(): offroute false
E/nav-native: setRoute failed to parse route: wrong geometry_index
E/nav-native: setRoute failed to parse json
D/MbxNavigationTelemetry: class com.mapbox.navigation.core.telemetry.events.NavigationRerouteEvent event sent
D/MbxRerouteController: Fetching route
E/❤️ (NavigationViewModel.kt:46).onOffRouteStateChanged(): offroute true
I/💚 Tracking: Event -> "event.navigation.rerouting" 
E/MbxMapboxRouteArrowView: An arrow must have at least 2 points.
E/MbxViewportDataSource: Turf lineSlice requires a LineString Geometry made up of at least 2 coordinates. The LineString passed in only contains 0.
W/MbxHybridRouter: Route request for com.mapbox.navigation.route.internal.offboard.MapboxOffboardRouter failed with:
    [RouterFailure(url=https://api.mapbox.com/directions/v5/mapbox/cycling/4.369659,50.833127;4.395989,50.837502?geometries=polyline6&overview=false&steps=true&bearings=130.4496002%2C90%3B&continue_straight=true&annotations=congestion_numeric%2Cmaxspeed%2Cspeed%2Cduration%2Cdistance%2Cclosure&language=en&roundabout_exits=true&voice_instructions=true&banner_instructions=true&voice_units=imperial&enable_refresh=true&access_token=redacted, routerOrigin=com.mapbox.navigation.base.route.RouterOrigin$Offboard@4c95086, message={"message":"annotations value must be one of duration, distance, speed, maxspeed, congestion","code":"InvalidInput"}, code=422, throwable=null)]
    Trying to fallback to com.mapbox.navigation.route.internal.onboard.MapboxOnboardRouter...
I/nav-native: Onboard router: Get route request: https://api.mapbox.com/directions/v5/mapbox/cycling/4.369659,50.833127;4.395989,50.837502?access_token=****27CA&geometries=polyline6&overview=false&steps=true&bearings=130.4496002%2C90%3B&continue_straight=true&annotations=congestion_numeric%2Cmaxspeed%2Cspeed%2Cduration%2Cdistance%2Cclosure&language=en&roundabout_exits=true&voice_instructions=true&banner_instructions=true&voice_units=imperial&enable_refresh=true
W/valhalla: No metadata found for tiles
W/valhalla: /data/valhalla/elevation/ currently has no elevation tiles
W/nav-native: Unsupported parameter: enable_refresh
D/nav-native: Requesting local router: {"format":"osrm","costing":"bicycle","costing_options":{"bicycle":{"max_hiking_difficulty":3}},"locations":[{"lat":50.833127,"lon":4.369659,"heading":130,"heading_tolerance":90,"type":"break_through"},{"lat":50.837502,"lon":4.395989,"type":"break_through"}],"access_token":"xxx","shape_format":"polyline6","generalize":-1,"steps":true,"continue_straight":true,"filters":{"attributes":["shape_attributes.congestion_numeric","shape_attributes.speed_limit","shape_attributes.speed","shape_attributes.time","shape_attributes.length","shape_attributes.closure"],"action":"include"},"language":"en","roundabout_exits":true,"units":"miles","directions_type":"instructions_visual_and_voice"}
I/valhalla: algorithm::bidirectional_a*
I/nav-native: Onboard router: Get route response: {"code":"Ok","metadata":{"map":{"tileset_version":"2021_10_15-03_00_00"}},"routes":[{"distance":2658.9,"duration":557.896,"geometry":"","legs":[{"admins":[{"iso_3166_1":"BE","iso_3166_1_alpha3":"BEL"}],"annotation":{"congestion_numeric":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"distance":[81.0,124.0,4.7,4.5,56.9,4.5,2.1,6.2,4.2,2.3,4.5,38.1,55.6,71.1,4.1,19.7,20.0,4.5,5.2,13.5,8.9,2.7,3.9,32.4,9.9,8.8,17.7,80.3,2.0,2.2,8.9,63.6,16.9,2.8,3.8,121.1,26.8,10.5,4.5,1.9,18.3,3.6,7.9,6.6,2.5,4.8,17.9,27.5,4.4,3.7,3.1,11.5,12.9,7.8,5.0,1.9,4.4,4.4,5.1,8.2,6.7,2.1,1.4,1.3,5.4,1.7,6.8,8.3,116.4,7.8,8.1,87.3,2.5,2.3,1.6,1.7,1.5,1.6,1.6,2.1,2.0,2.0,2.1,2.0,2.9,3.0,84.8,9.5,8.9,69.5,10.4,60.5,7.2,7.3,97.3,4.0,2.3,9.9,10.8,2.5,3.4,69.3,66.9,12.6,22.4,13.4,7.6,3.6,2.7,6.1,5.3,1.4,1.6,3.5,13.8,90.2,11.0,14.2,5.7,25.9,1.0,8.9,35.5,63.5,11.3,10.6,80.1,10.7,105.1,11.4,3.7,2.9,4.4,4.2,4.2,4.2,4.3,4.2,3.8,3.9,3.9,4.4,2.0,2.7,2.6,3.7,3.7,3.8,3.7,4.3,1.0,1.4,1.4,1.6,1.3,1.3,1.2,1.3,2.3,4.2,4.2,4.2,4.1,4.2,4.2,12.3,3.2,4.1,24.8,0.0],"duration":[13.246,13.133,0.498,0.73,9.319,0.73,0.341,1.012,0.838,0.462,0.89,7.612,11.121,14.219,0.828,3.221,3.271,0.729,0.85,1.571,1.772,0.573,0.832,6.868,2.367,1.763,2.9,13.147,0.328,0.357,1.039,7.384,4.354,0.718,0.922,29.075,3.859,1.515,0.653,0.27,3.657,0.725,1.666,1.397,0.535,1.006,3.797,5.816,0.883,0.749,0.629,1.148,1.294,0.783,0.993,0.372,0.876,0.874,1.029,1.632,1.337,0.423,0.29,0.267,1.07,0.344,1.354,1.664,23.286,1.56,1.616,17.453,0.492,0.453,0.317,0.334,0.308,0.324,0.312,0.739,0.735,0.725,0.75,0.721,0.614,0.625,17.963,0.95,1.771,11.371,2.677,15.546,1.855,0.853,11.295,0.469,0.269,1.154,1.258,0.402,0.556,11.332,16.065,1.815,3.229,3.206,2.291,1.08,0.818,1.817,1.06,0.282,0.312,0.692,2.25,18.031,2.205,3.004,1.137,5.179,0.204,1.783,7.095,10.391,1.307,1.235,13.115,2.14,22.252,1.207,0.394,0.575,0.436,0.418,0.422,0.422,0.426,0.423,0.81,0.828,0.823,0.938,0.404,0.535,0.521,0.883,0.883,0.901,0.876,1.033,0.21,0.27,0.276,0.323,0.255,0.266,0.24,0.251,0.464,0.684,0.68,0.685,0.679,0.687,0.686,2.008,0.637,0.981,5.949,0.0],"maxspeed":[{"speed":20,"unit":"km/h"},{"speed":20,"unit":"km/h"},{"speed":20,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":30,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":50,"unit":"km/h"},{"speed":
I/MbxOnboardRouter: Successful directions response. Metadata: {tileset_version=2021_10_15-03_00_00}
D/MbxNavigationTelemetry: onRoutesChanged. Number of routes = 1; reason = ROUTES_UPDATE_REASON_REROUTE
D/MbxNavigationTelemetry: `handleReroute`
LukasPaczos commented 2 years ago

Hey @Christophe668, unfortunately, the cycling profile does not support the congestion_numeric input which is default for other profiles. We're tracking this issue internally to unblock it on the API side but to work around this problem for now, you should use the congestion annotation instead.

For example:

RouteOptions.builder()
    .applyDefaultNavigationOptions()
    .applyLanguageAndVoiceUnitOptions(this)
    .profile(DirectionsCriteria.PROFILE_CYCLING)
    .coordinatesList(listOf(origin, destination))
    .annotationsList(
        listOf(
            DirectionsCriteria.ANNOTATION_CONGESTION,
            DirectionsCriteria.ANNOTATION_MAXSPEED,
            DirectionsCriteria.ANNOTATION_SPEED,
            DirectionsCriteria.ANNOTATION_DURATION,
            DirectionsCriteria.ANNOTATION_DISTANCE
        )
    )
    ...
    .build()

I'm going to go ahead and close here but please let us know if this didn't do the trick.