RouteOptions.alleyPriority, walkwayPriority, speed should be optional #553
Labels
backwards incompatible
changes that break backwards compatibility of public API
op-ex
Refactoring, Tech Debt or any other operational excellence work.
Milestone
RouteOptions.alleyPriority
,walkwayPriority
, andspeed
should be optional, andRouteOptions.urlQueryItems
should add the corresponding URL query items if and only if these properties are non-nil.Problem
RouteOptions only adds the
alley_bias
parameter to the request URL if the profile is eithermapbox/driving
ormapbox/walking
, but not for other profiles such asmapbox/driving-traffic
that also support this parameter.mapbox-directions-swift/Sources/MapboxDirections/RouteOptions.swift
Lines 191 to 193 in 2d9edce
Background
These options are limited to Valhalla-powered profiles and are unsupported in OSRM-based profiles, such as
mapbox/cycling
and formerlymapbox/driving-traffic
. OSRM-based endpoints return an HTTP 422 error upon encountering a parameter that’s supported by Valhalla but not OSRM.Originally, in #370, this library had to conditionalize the
alley_bias
parameter on themapbox/walking
profile because it’s supported by Valhalla but not OSRM. #416 later extended the parameter to themapbox/driving
profile once it migrated to Valhalla. We could conditionalize other parameters on the presence or absence of an explicit value, butRouteOptions.alleyPriority
had to be non-optional because optional primitive types don’t bridge to Objective-C. Fortunately, #382 dropped Objective-C support; since then, we generally use optional types to represent incremental additions to the Directions and Map Matching APIs, even for primitive types.Solution
RouteOptions.alleyPriority
should become optional, because this library still supports at least one profile (mapbox/cycling
) that doesn’t supportalley_bias
.RouteOptions.urlQueryItems
can thus conditionalize the addition ofalley_bias
on whetherRouteOptions.alleyPriority
is non-nil.The
walkway_bias
andwalking_speed
parameters added in #370 are in the same situation, soRouteOptions.walkwayPriority
andspeed
should get the same treatment. It would be pretty unlikely for a driving profile to support options specific to walkways, butDirectionsProfileIdentifier
is an extensible enumeration and there could always be a walking-related profile other thanmapbox/walking
./cc @mapbox/navigation-ios @danpat @OttyLab
The text was updated successfully, but these errors were encountered: