Skip to content
This repository was archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Update examples to be generic JSON payloads (#209)
Browse files Browse the repository at this point in the history
* Add image for isochrones. Update sample URI and JSON payloads

* Update examples.

* Update examples

* Updates to examples.

* Link to AWS Public Data Sets terrain page. Remove local information about data
sources (the AWS page is more accurate and timely)

* Fix some examples.

* Update Mapbox info
  • Loading branch information
dnesbitt61 authored Jan 25, 2018
1 parent 0bd52d5 commit 5dfe698
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 50 deletions.
19 changes: 9 additions & 10 deletions elevation/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ There is an option to name your elevation request. You can do this by appending

## Using the hosted Mapbox Elevation Service

The Mapbox elevation service requires an access token. In a request, you must append your own access_token to the URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens.
The Mapbox elevation service requires an access token. In a request, you must append your own access_token to the URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens. Contact Mapbox for instructions on accessing this API.

### Use a shape list for input locations

The elevation request run locally takes the form of `localhost:8002/height?json={}`, where the JSON inputs inside the `{}` are described below.

A `shape` request must include a latitude and longitude in decimal degrees, and the locations are visited in the order specified. The input coordinates can come from many input sources, such as a GPS location, a point or a click on a map, a geocoding service, and so on.

These parameters are available for `shape`.
Expand All @@ -29,10 +31,10 @@ These parameters are available for `shape`.
| `lat` | Latitude of the location in degrees. |
| `lon` | Longitude of the location in degrees. |

Here is an example of a profile request using `shape`:
Here is an example JSON payload for a profile request using `shape`:

```
**TBD**/height?json={"range":true,"shape":[{"lat":40.712431,"lon":-76.504916},{"lat":40.712275,"lon":-76.605259},{"lat":40.712122,"lon":-76.805694},{"lat":40.722431,"lon":-76.884916},{"lat":40.812275,"lon":-76.905259},{"lat":40.912122,"lon":-76.965694}]}&id=Pottsville&access_token=your-mapbox-access-token
{"range":true,"shape":[{"lat":40.712431,"lon":-76.504916},{"lat":40.712275,"lon":-76.605259},{"lat":40.712122,"lon":-76.805694},{"lat":40.722431,"lon":-76.884916},{"lat":40.812275,"lon":-76.905259},{"lat":40.912122,"lon":-76.965694}]}&id=Pottsville
```

This request provides `shape` points near Pottsville, Pennsylvania. The resulting profile response displays the input shape, as well as the `range` and `height` (as `range_height` in the response) for each point.
Expand All @@ -49,18 +51,16 @@ Without the `range`, the result looks something like this, with only a `height`:

### Use an encoded polyline for input locations

The `encoded_polyline` parameter is a string of a polyline-encoded, with **six degrees of precision**, shape and has the following parameters.

**TBD - resources and code samples for encoding/decoding polylines**
The `encoded_polyline` parameter is a string of a polyline-encoded, with **six degrees of precision**, shape and has the following parameters. Details on polyline encoding and decoding can be found [here](/decoding.md).

| Encoded polyline parameters | Description |
| :--------- | :----------- |
| `encoded_polyline` | A set of encoded latitude, longitude pairs of a line or shape.|

Here is an example `encoded_polyline` request:
Here is an example of the JSON payload for an `encoded_polyline` POST request:

```
**TBD**/height?json={"range":true,"encoded_polyline":"s{cplAfiz{pCa]xBxBx`AhC|gApBrz@{[hBsZhB_c@rFodDbRaG\\ypAfDec@l@mrBnHg|@?}TzAia@dFw^xKqWhNe^hWegBfvAcGpG{dAdy@_`CpoBqGfC_SnI{KrFgx@?ofA_Tus@c[qfAgw@s_Agc@}^}JcF{@_Dz@eFfEsArEs@pHm@pg@wDpkEx\\vjT}Djj@eUppAeKzj@eZpuE_IxaIcF~|@cBngJiMjj@_I`HwXlJuO^kKj@gJkAeaBy`AgNoHwDkAeELwD|@uDfC_i@bq@mOjUaCvDqBrEcAbGWbG|@jVd@rPkAbGsAfDqBvCaIrFsP~RoNjWajBlnD{OtZoNfXyBtE{B~HyAtEsFhL_DvDsGrF_I`HwDpGoH|T_IzLaMzKuOrFqfAbPwCl@_h@fN}OnI"}&access_token=your-mapbox-access-token
{"range":true,"encoded_polyline":"s{cplAfiz{pCa]xBxBx`AhC|gApBrz@{[hBsZhB_c@rFodDbRaG\\ypAfDec@l@mrBnHg|@?}TzAia@dFw^xKqWhNe^hWegBfvAcGpG{dAdy@_`CpoBqGfC_SnI{KrFgx@?ofA_Tus@c[qfAgw@s_Agc@}^}JcF{@_Dz@eFfEsArEs@pHm@pg@wDpkEx\\vjT}Djj@eUppAeKzj@eZpuE_IxaIcF~|@cBngJiMjj@_I`HwXlJuO^kKj@gJkAeaBy`AgNoHwDkAeELwD|@uDfC_i@bq@mOjUaCvDqBrEcAbGWbG|@jVd@rPkAbGsAfDqBvCaIrFsP~RoNjWajBlnD{OtZoNfXyBtE{B~HyAtEsFhL_DvDsGrF_I`HwDpGoH|T_IzLaMzKuOrFqfAbPwCl@_h@fN}OnI"}
```

### Get height and distance with the range parameter
Expand Down Expand Up @@ -94,9 +94,8 @@ The profile results are returned with the form of shape (shape points or encoded
| `y coordinate` | The height or elevation of the associated latitude, longitude pair. The height is returned as `null` if no height data exists for a given location. |
| `height` | An array of height for the associated latitude, longitude coordinates. |

## Data sources and known issues
## Data sources

Elevation data is obtained from the [Amazon Web Services Public Datasets](https://aws.amazon.com/public-datasets/terrain/).

**TBD The underlying data sources for the service are a mix of [SRTM](http://www2.jpl.nasa.gov/srtm/), [GMTED](http://topotools.cr.usgs.gov/gmted_viewer/), [NED](https://nationalmap.gov/elevation.html) and [ETOPO1](https://www.ngdc.noaa.gov/mgg/global/) DEMs. These sets provide global coverage at varying resolutions up to approximately 10 meters. It should be noted that both SRTM and GMTED fill oceans and other bodies of water with a value of zero to indicate mean sea level; in these areas, ETOPO1 provides bathymetry (as well as in regions which are not covered by NED, SRTM and GMTED). Many other classical DEM-related issues occur in these datasets. It is not uncommon to see large variations in elevation in areas with large buildings and other such structures. The geographic data community working with elevation data is considering how to best integrate other sources such as NRCAN and is always looking for better datasets. If you find any data issues or can suggest any slemental open datasets, please add an issue in this [GitHub repository](https://github.com/tilezen/joerd/issues).**

Binary file added images/isochrone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions isochrone/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Isochrone maps share some of the same concepts and terminology with familiar top

This is an example of isochrones showing the travel times by driving from a location in Melbourne, as depicted in Mobility Explorer.

![Isochrones for travel times by driving in Melbourne from Mobility Explorer](/images/melbourne-isochrones.png)
![Isochrones for travel times by walking in Lancaster, PA](/images/isochrone.png)

## Using the hosted Mapbox Isochrone Service

The Mapbox isochrone service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens.
The Mapbox isochrone service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens. Contact Mapbox for instructions on accessing this API.

## Inputs of the Isochrone service

A request takes the form of `servername/isochrone?json={}`, where `isochrone?` indicates an isochrone is requested and the JSON inputs inside the ``{}`` include an array of at least one location and options for the [route costing model](/turn-by-turn/api-reference/#costing-models).
An isochrone request run locally takes the form of `localhost:8002/isochrone?json={}`, where the JSON inputs inside the `{}` includes an array of at least one location and options for the [route costing model](/turn-by-turn/api-reference/#costing-models).

For example, you can use the isochrone service to find out where you can travel within a 15-minute walk from your office building. The API request for this uses `isochrone?` as the request action, `pedestrian` costing, and a single contour for a 15-minute time interval. The response is GeoJSON, which you can display on a map to visualize where you might be able to walk.

```
**TBD**/isochrone?json={"locations":[{"lat":40.744014,"lon":-73.990508}],"costing":"pedestrian","contours":[{"time":15,"color":"ff0000"}]}&id=Walk_From_Office
{"locations":[{"lat":40.744014,"lon":-73.990508}],"costing":"pedestrian","contours":[{"time":15,"color":"ff0000"}]}&id=Walk_From_Office
```

There is an option to name your isochrone request by appending `&id=`. The `id` is returned with the response so you can match it to your corresponding request.
Expand Down Expand Up @@ -85,4 +85,4 @@ Several other options are being considered as future service enhancements. These

## Data credits

The images are from Mobility Explorer, which includes data from [Transitland](https://transit.land) and [OpenStreetMap](http://www.openstreetmap.org/).
The image includes data from [OpenStreetMap](http://www.openstreetmap.org/).
6 changes: 3 additions & 3 deletions locate/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ The default logic for the OpenStreetMap tags, keys, and values used when routing

## Using the hosted Mapbox Locate Service

The Mapbox locate service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens.
The Mapbox locate service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens. Contact Mapbox for instructions on accessing this API.

## Inputs of a locate request

The path and query portion of a locate URI takes the form of `/locate?json={}`, where the JSON inputs inside the `{}` include location information, name and options for the costing model, and output options. Here is an example:
The locate request run locally takes the form of `localhost:8002/locate?json={}`, where the JSON inputs inside the `{}` include location information, name and options for the costing model, and output options. Here is the JSON payload for an example request:

```
/locate?json={"verbose":true,"locations":[{"lat":42.358528,"lon":-83.271400},{"lat":42.996613,"lon":-78.749855}],"costing":"bicycle","costing_options":{"bicycle":{"bicycle_type":"road"}},"directions_options":{"units":"miles"},"id":"12abc3afe23984fe"}&access_token=your-mapbox-access-token
{"verbose":true,"locations":[{"lat":42.358528,"lon":-83.271400},{"lat":42.996613,"lon":-78.749855}],"costing":"bicycle","costing_options":{"bicycle":{"bicycle_type":"road"}},"directions_options":{"units":"miles"},"id":"12abc3afe23984fe"}
```

This request provides detailed information about specific streets and intersections near the two input locations. Steets which do not have a surface type condusive to road bicycles will be excluded from the results. The units used for the lengths of the street sections will be displayed in miles.
Expand Down
8 changes: 4 additions & 4 deletions map-matching/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It is important to note that all service requests should be *POST* because `shap

## Using the hosted Mapbox Valhalla Map Matching Service

The Mapbox Valhalla map-matching service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens.
The Mapbox Valhalla map-matching service requires an access token. In a request, you must append your own access_token to the request URL, following access_token=. See the [Mapbox API documentation](https://www.mapbox.com/api-documentation/#access-tokens) for more on access tokens. Contact Mapbox for instructions on accessing this API.

## Trace route action

Expand Down Expand Up @@ -267,15 +267,15 @@ Follow these guidelines to improve the Map Matching results.

You can use certain parameters to tune the response.

* Use `turn_penalty_factor` to penalize turns from one road segment to next. For a pedestrian `trace_route`, you may see a back-and-forth motion along the streets of your path. Try increasing the turn penalty factor to 500 to smooth out jittering of points. Note that if GPS accuracy is already good, increasing this will have a negative affect on your results.
* Use `turn_penalty_factor` to penalize turns from one road segment to next. For a pedestrian `trace_route`, you may see a back-and-forth motion along the streets of your path. Try increasing the turn penalty factor to 500 to smooth out jittering of points. Note that if GPS accuracy is already good, increasing this will have a negative affect on your results.
* Set the `gps_accuracy` to indicate the accuracy in meters.
* Apply a `search_radius` to specify the search radius (in meters) within which to search road candidates for each measurement. The maximum search radius is 100 meters. Note that performance may decrease with a higher search radius value.

## Example Map Matching requests

### Example `trace_route` requests

The following are example requests for the `trace_routes` action. They use a base URL of **`TBD/trace_route?access_token=`, where the code is the POST body.**
The following are example JSON payloads for POST requests for the `trace_routes` action.

*`trace_route` with encoded polyline parameter*

Expand All @@ -291,7 +291,7 @@ The following are example requests for the `trace_routes` action. They use a bas

### Example `trace_attributes` requests

The following are example requests for the `trace_attributes` action. They use a base URL of **`TBD/trace_attributes?access_token=`, where the code is the POST body.**
The following are example JSON payloads for POST requests for the `trace_attributes` action.

*`trace_attributes` with shape parameter*

Expand Down
Loading

0 comments on commit 5dfe698

Please sign in to comment.