Repository navigation
Add mapbox isochrone #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d389b44
0fc55b0
80a507d
fcb18fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| openapi: "3.0.0" | ||
| # `parse_spec` turns `info.description` below into this service's clap | ||
| # `long_about`, so it also reaches `mapbox isochrone --help`, `--schema` and | ||
| # `generate-skills` output. Keep it to API prose only — the provenance below | ||
| # is for whoever edits this file, not for a CLI user: | ||
| # | ||
| # Hand-authored down to the parameters documented at | ||
| # docs.mapbox.com/api/navigation/isochrone. See `custom-openapi/README.md` | ||
| # for how a file like this is wired in, and `directions.yaml`'s header for | ||
| # why `profile` needs `ARG_NAME_OVERRIDES` in `src/spec.rs` — the same | ||
| # reason applies here. | ||
| info: | ||
| title: "Mapbox Isochrone API" | ||
| description: >- | ||
| How far you can get from a point in a given time or distance, for | ||
| driving (with or without live traffic), walking, or cycling — as a | ||
| GeoJSON polygon or line per contour. | ||
| version: "0.0.0" | ||
| servers: | ||
| - url: https://api.mapbox.com | ||
| description: Isochrone API | ||
| paths: | ||
| /isochrone/v1/{profile}/{coordinates}: | ||
| get: | ||
| operationId: contours | ||
| summary: Isochrone contours around one point. | ||
| description: >- | ||
| Returns one contour per value in `--contours-minutes` or | ||
| `--contours-meters` (exactly one of the two is required; not | ||
| enforced before the request goes out — the API answers 422 if both | ||
| or neither are given), as GeoJSON linestrings or, with `--polygons`, | ||
| polygons. | ||
| parameters: | ||
| - name: "profile" | ||
| in: path | ||
| required: true | ||
| # Not an `enum`: the four documented values are what's public, but | ||
| # not what's exhaustive — some customers (OEM agreements, mainly) | ||
| # have additional profiles never published to docs.mapbox.com. | ||
| # An `enum` here becomes a clap `PossibleValuesParser` that | ||
| # rejects anything else client-side, which would break this CLI | ||
| # for exactly the accounts that most need a routing profile | ||
| # named beyond `driving`/`walking`/`cycling`. Same fix as | ||
| # `directions.yaml`'s `profile`. | ||
| description: >- | ||
| The routing profile — `mapbox/driving-traffic` (accounts for | ||
| live traffic), `mapbox/driving`, `mapbox/walking`, or | ||
| `mapbox/cycling` are documented, but not necessarily | ||
| exhaustive: some accounts have additional profiles of their | ||
| own. Sent exactly as typed; the API is the authority on | ||
| whether a value is valid, not this description. | ||
| schema: | ||
| type: string | ||
| minLength: 1 | ||
| example: "mapbox/driving" | ||
| - name: "coordinates" | ||
| in: path | ||
| required: true | ||
| description: "The isochrone center, `{longitude},{latitude}`." | ||
| schema: | ||
| type: string | ||
| minLength: 1 | ||
| example: "-122.42,37.78" | ||
| - name: "access_token" | ||
| in: query | ||
| required: true | ||
| description: "Mapbox API Access Token" | ||
| schema: | ||
| type: string | ||
| minLength: 1 | ||
| # Prose rather than an `enum`: up to 4 comma-separated integers, and | ||
| # the command builder turns a spec `enum` into a clap | ||
| # `PossibleValuesParser`, which accepts one value and would refuse a | ||
| # list. Same reasoning as `directions.yaml`'s `annotations`. | ||
| - name: "contours_minutes" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Up to 4 times in minutes, 1-60, comma-separated and increasing — | ||
| one contour per value. Exactly one of this or | ||
| `--contours-meters` is required. | ||
| schema: | ||
| type: string | ||
| example: "5,10,15,20" | ||
| - name: "contours_meters" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Up to 4 distances in meters, 1-100000, comma-separated and | ||
| increasing — one contour per value. Exactly one of this or | ||
| `--contours-minutes` is required. | ||
| schema: | ||
| type: string | ||
| example: "1000,5000" | ||
| - name: "contours_colors" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| A hex color per contour (no `#`), comma-separated — must match | ||
| the contour count. | ||
| schema: | ||
| type: string | ||
| example: "ff0000,00ff00" | ||
| - name: "polygons" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Return each contour that forms a ring as a GeoJSON polygon | ||
| instead of a linestring — one that doesn't form a ring stays a | ||
| linestring either way. | ||
| schema: | ||
| type: boolean | ||
| - name: "denoise" | ||
| in: query | ||
| required: false | ||
| # Spelled "0 to 1"/"1", not "0.0-1.0"/"1.0": `first_sentence` in | ||
| # `src/main.rs` cuts a `--help` line at the first `.`, and this | ||
| # value's own bounds are the first digits that would appear no | ||
| # matter where in the sentence they sit, so a literal decimal | ||
| # point anywhere before the end truncates it — not just at the | ||
| # front, the way `directions.yaml`'s own fix assumed. `--schema` | ||
| # and `docs/commands.md` still show the fuller description below | ||
| # in full, decimals included. | ||
| description: >- | ||
| A larger value removes more of the smaller contours, 0 to 1, | ||
| defaulting to 1. A value of 1 returns only the largest contour | ||
| for each level; 0.5 drops any contour under half the largest's | ||
| area. | ||
| schema: | ||
| type: number | ||
| minimum: 0 | ||
| maximum: 1 | ||
| - name: "generalize" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Douglas-Peucker simplification tolerance in meters. A higher | ||
| value gives a coarser contour. | ||
| schema: | ||
| type: number | ||
| # Prose rather than an `enum`, for the reason given on | ||
| # `contours_minutes` above. | ||
| - name: "exclude" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Road types to route around, comma-separated. Options are | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs say all five values work only with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed against docs.mapbox.com and added: all five are scoped to mapbox/driving and mapbox/driving-traffic.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the driving/driving-traffic scoping: "all five only available for mapbox/driving and mapbox/driving-traffic." |
||
| `motorway`, `toll`, `ferry`, `unpaved`, `cash_only_tolls` — all | ||
| five only available for `mapbox/driving` and | ||
| `mapbox/driving-traffic`. | ||
| schema: | ||
| type: string | ||
| example: "motorway,toll" | ||
| - name: "depart_at" | ||
| in: query | ||
| required: false | ||
| description: >- | ||
| Departure time, ISO 8601, defaulting to now in the | ||
| coordinates' own timezone — the contours reflect traffic | ||
| conditions at this time. | ||
| schema: | ||
| type: string | ||
| responses: | ||
| "200": | ||
| description: >- | ||
| A GeoJSON `FeatureCollection`, one feature per contour, each | ||
| carrying `contour` (the minute or meter value), `metric` | ||
| (`time` or `distance`), and rendering hints (`color`, | ||
| `opacity`, and — with `--polygons` — `fill`/`fill-opacity`). | ||
| "401": | ||
| description: Unauthorized | ||
| "403": | ||
| description: Forbidden | ||
| "404": | ||
| description: Not Found — an invalid profile. | ||
| "422": | ||
| description: >- | ||
| Unprocessable Entity — invalid coordinates, an out-of-range | ||
| contour value, or neither/both of `contours_minutes` and | ||
| `contours_meters` given. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs don't say a higher value makes the contour smaller, only coarser. Please drop "smaller".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped "smaller" — confirmed the docs only say coarser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped "smaller", thanks. Now just "A higher value gives a coarser contour."