Overhauled the command line tool’s configuration option. Instead of the --config option that takes a JSON configuration file path, the tool now takes a single positional argument that can either be a JSON configuration file path or a Directions API or Map Matching API request URL. When you pass in a request URL, the URL is round-tripped through a DirectionsOptions object back to a URL, exercising the entire typical code path (and then some).
But if you do decide to pass in a JSON configuration file instead of a URL, the command line tool now respects the MAPBOX_HOST environment variable alongside the MAPBOX_ACCESS_TOKEN environment variable. An access token is scoped to a single API endpoint, so this configuration option makes it possible to run the tool against a proxy or staging server for testing purposes.
RouteOptions(url:) now returns nil if given a Mapbox Map Matching API request URL, and MatchOptions(url:) returns nil if given a Mapbox Directions API request URL. Previously, you could mix and match URLs to convert between RouteOptions and MatchOptions. Now, you’ll need to use JSONEncoder and JSONDecoder as well:
guard let url = URL(string: "https://api.mapbox.com/directions/v5/mapbox/driving-traffic/…"),
let routeOptions = RouteOptions(url: url),
let encodedOptions = try? JSONEncoder().encode(self) else { return }
try JSONDecoder().decode(MatchOptions.self, from: encodedOptions)
564 would unblock a more convenient conversion workflow.
Some tangential changes along the way:
When the MAPBOX_ACCESS_TOKEN environment variable is unset, the tool exits with an error code instead of crashing.
When a JSON configuration file path is passed into the tool, any tilde is expanded during validation, fixing an issue where an otherwise valid file path got rejected.
Removed mentions of the --waypoints and --url options from the command line tool’s documentation that probably came from #580.
Fixes #692 and fixes #724. Supersedes #580. Depends on #727.
Overhauled the command line tool’s configuration option. Instead of the
--config
option that takes a JSON configuration file path, the tool now takes a single positional argument that can either be a JSON configuration file path or a Directions API or Map Matching API request URL. When you pass in a request URL, the URL is round-tripped through a DirectionsOptions object back to a URL, exercising the entire typical code path (and then some).But if you do decide to pass in a JSON configuration file instead of a URL, the command line tool now respects the
MAPBOX_HOST
environment variable alongside theMAPBOX_ACCESS_TOKEN
environment variable. An access token is scoped to a single API endpoint, so this configuration option makes it possible to run the tool against a proxy or staging server for testing purposes.RouteOptions(url:)
now returnsnil
if given a Mapbox Map Matching API request URL, andMatchOptions(url:)
returnsnil
if given a Mapbox Directions API request URL. Previously, you could mix and match URLs to convert between RouteOptions and MatchOptions. Now, you’ll need to use JSONEncoder and JSONDecoder as well:564 would unblock a more convenient conversion workflow.
Some tangential changes along the way:
MAPBOX_ACCESS_TOKEN
environment variable is unset, the tool exits with an error code instead of crashing.--waypoints
and--url
options from the command line tool’s documentation that probably came from #580.Fixes #692 and fixes #724. Supersedes #580. Depends on #727.
/cc @mapbox/navigation-ios @purew