From 08527175b5d81f004c53667bcd79c74210c8a586 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Tue, 21 Mar 2017 23:44:08 +0000 Subject: [PATCH] Fresh lock file --- docs/nodejs/api.md | 237 ++++++++++++++++++++------------------ package.json | 15 +-- scripts/build_api_docs.sh | 2 +- yarn.lock | 140 +++++++--------------- 4 files changed, 170 insertions(+), 224 deletions(-) diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index fd6ab418e..bbe8fcb45 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -1,30 +1,18 @@ - +# OSRM -### Table of Contents +The `OSRM` method is the main constructor for creating an OSRM instance. An OSRM instance requires a `.osrm` network, +which is prepared by the OSRM Backend C++ library. -- [OSRM](#osrm) - - - [Methods](#methods) - - [General Options](#general-options) - - [route](#route) - - [nearest](#nearest) - - [table](#table) - - [tile](#tile) - - [match](#match) - - [trip](#trip) -- [Responses](#responses) - - [Route](#route-1) - - [RouteLeg](#routeleg) - - [RouteStep](#routestep) - - [StepManeuver](#stepmaneuver) - - [Waypoint](#waypoint) +You can create such a `.osrm` file by running the OSRM binaries we ship in `node_modules/osrm/lib/binding/` and default +profiles (e.g. for setting speeds and determining road types to route on) in `node_modules/osrm/profiles/`: -## OSRM + node_modules/osrm/lib/binding/osrm-extract data.osm.pbf -p node_modules/osrm/profiles/car.lua + node_modules/osrm/lib/binding/osrm-contract data.osrm -The `OSRM` method is the main constructor for creating an OSRM instance. -An OSRM instance requires a `.osrm` dataset, which is prepared by the OSRM toolchain. -The documentation on `osrm-extract` and `osrm-contract` for more information. -Once you have a complete `network.osrm` file, you can calculate routes in javascript with this library using the methods below. -To create an OSRM instance with your network you need to construct an instance like this: +Consult the [osrm-backend](https://github.com/Project-OSRM/osrm-backend) documentation or further details. + +Once you have a complete `network.osrm` file, you can calculate networks in javascript with this library using the +methods below. To create an OSRM instance with your network you need to construct an instance like this: ```javascript var osrm = new OSRM('network.osrm'); @@ -38,44 +26,41 @@ var osrm = new OSRM('network.osrm'); | [`osrm.nearest`](#nearest) | returns the nearest street segment for a given coordinate | | [`osrm.table`](#table) | computes distance tables for given coordinates | | [`osrm.match`](#match) | matches given coordinates to the road network | -| [`osrm.trip`](#trip) | computes the shortest trip between given coordinates | +| [`osrm.trip`](#trip) | Compute the shortest trip between given coordinates | | [`osrm.tile`](#tile) | Return vector tiles containing debugging info | #### General Options -Each OSRM method (except for `OSRM.tile()`) has set of general options as well as unique options, -outlined below. +Each OSRM method (except for `OSRM.tile()`) has set of general options as well as unique options, outlined below. -| Option | Values | Description | Format | -| ----------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | -| coordinates | `array` of `coordinate` elements: `[{coordinate}, ...]` | The coordinates this request will use. | `array` with `[{lon},{lat}]` values, in decimal degrees | -| bearings | `array` of `bearing` elements: `[{bearing}, ...]` | Limits the search to segments with given bearing in degrees towards true north in clockwise direction. | `null` or `array` with `[{value},{range}]` `integer 0 .. 360,integer 0 .. 180` | -| radiuses | `array` of `radius` elements: `[{radius}, ...]` | Limits the search to given radius in meters. | `null` or `double >= 0` or `unlimited` (default) | -| hints | `array` of `hint` elements: `[{hint}, ...]` | Hint to derive position in street network. | Base64 `string` | +| Option | Values | Description | Format | +| --------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| coordinates | `array` of `coordinate` elements: `[{coordinate}, ...]` | The coordinates this request will use. | `array` with `[{lon},{lat}]` values, in decimal degrees | +| bearings | `array` of `bearing` elements: `[{bearing}, ...]` | Limits the search to segments with given bearing in degrees towards true north in clockwise direction. | `null` or `array` with `[{value},{range}]` `integer 0 .. 360,integer 0 .. 180` | +| radiuses | `array` of `radius` elements: `[{radius}, ...]` | Limits the search to given radius in meters. | `null` or `double >= 0` or `unlimited` (default) | +| hints | `array` of `hint` elements: `[{hint}, ...]` | Hint to derive position in street network. | Base64 `string` | +| generate\_hints | `true` (default) or `false` | Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. | `Boolean` | -### route +## route Returns the fastest route between two or more coordinates while visiting the waypoints in order. **Parameters** - `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the route query. - - `options.alternatives` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Search for alternative routes and return as well. - _Please note that even if an alternative route is requested, a result cannot be guaranteed._ (optional, default `false`) - - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return route steps for each route leg. (optional, default `false`) - - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) - - `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - - `options.continue_straight` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile. - `null`/`true`/`false` -- `or` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** {Array} [options.annotations=false] Return annotations for each route leg. - Can be `false`, `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. + - `options.alternatives` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Search for alternative routes and return as well. _Please note that even if an alternative route is requested, a result cannot be guaranteed._ (optional, default `false`) + - `options.steps` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route steps for each route leg. (optional, default `false`) + - `options.annotations` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)] or \[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** Return annotations for each route leg for duration, nodes, distance, weight, datasources and/or speed. Annotations can be `false` or `true` (no/full annotations) or an array of strings with `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. (optional, default `false`) + - `options.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) + - `options.overview` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) + - `options.continue_straight` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Forces the route to keep going straight at waypoints and don't do a uturn even if it would be faster. Default value depends on the profile. `null`/`true`/`false` - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** ```javascript var osrm = new OSRM("berlin-latest.osrm"); -osrm.route({coordinates: [[52.519930,13.438640], [52.513191,13.415852]]}, function(err, result) { +osrm.route({coordinates: [[13.438640,52.519930], [13.415852, 52.513191]]}, function(err, result) { if(err) throw err; console.log(result.waypoints); // array of Waypoint objects representing all waypoints in order console.log(result.routes); // array of Route objects ordered by descending recommendation rank @@ -84,7 +69,7 @@ osrm.route({coordinates: [[52.519930,13.438640], [52.513191,13.415852]]}, functi Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** An array of [Waypoint](#waypoint) objects representing all waypoints in order AND an array of [`Route`](#route) objects ordered by descending recommendation rank. -### nearest +## nearest Snaps a coordinate to the street network and returns the nearest n matches. @@ -93,7 +78,7 @@ Note: `coordinates` in the general options only supports a single `{longitude},{ **Parameters** - `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the nearest query. - - `options.number` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of nearest segments that should be returned. + - `options.number` **\[[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** Number of nearest segments that should be returned. Must be an integer greater than or equal to `1`. (optional, default `1`) - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** @@ -113,21 +98,19 @@ osrm.nearest(options, function(err, response) { Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `waypoints`. **`waypoints`**: array of [`Ẁaypoint`](#waypoint) objects sorted by distance to the input coordinate. - Each object has an additional `distance` property, which is the distance in meters to the supplied input coordinate. +Each object has an additional `distance` property, which is the distance in meters to the supplied +input coordinate. -### table +## table -Computes duration tables for the given locations. Allows for both symmetric and asymmetric -tables. +Computes duration tables for the given locations. Allows for both symmetric and asymmetric tables. **Parameters** - `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the table query. - - `options.sources` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < #coordinates`) to - use + - `options.sources` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)]** An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as source. Default is to use all. - - `options.destinations` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** An array of `index` elements (`0 <= integer < - #coordinates`) to use location with given index as destination. Default is to use all. + - `options.destinations` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)]** An array of `index` elements (`0 <= integer < #coordinates`) to use location with given index as destination. Default is to use all. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -149,25 +132,24 @@ osrm.table(options, function(err, response) { ``` Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `durations`, `sources`, and `destinations`. -**`durations`**: array of arrays that stores the matrix in row-major order. `durations[i][j]` gives the travel time from the i-th waypoint to the j-th waypoint. - Values are given in seconds. +**`durations`**: array of arrays that stores the matrix in row-major order. `durations[i][j]` +gives the travel time from the i-th waypoint to the j-th waypoint. Values are given in seconds. **`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources in order. **`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations in order. -### tile +## tile This generates [Mapbox Vector Tiles](https://mapbox.com/vector-tiles) that can be viewed with a vector-tile capable slippy-map viewer. The tiles contain road geometries and metadata that can be used to examine the routing graph. The tiles are generated directly from the data in-memory, -so are in sync with actual routing results, and let you examine which roads are actually -routable, +so are in sync with actual routing results, and let you examine which roads are actually routable, and what weights they have applied. **Parameters** - `ZXY` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** an array consisting of `x`, `y`, and `z` values representing tile coordinates like - [wiki.openstreetmap.org/wiki/Slippy_map_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames) - and are supported by vector tile viewers like [Mapbox GL JS](https://www.mapbox.com/mapbox-gl-js/api/). + [wiki.openstreetmap.org/wiki/Slippy_map_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames) + and are supported by vector tile viewers like [Mapbox GL JS]\(. - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -182,7 +164,7 @@ osrm.tile([0, 0, 0], function(err, response) { Returns **[Buffer](https://nodejs.org/api/buffer.html)** contains a Protocol Buffer encoded vector tile. -### match +## match Map matching matches given GPS points to the road network in the most plausible way. Please note the request might result multiple sub-traces. Large jumps in the timestamps @@ -193,13 +175,15 @@ if they can not be matched successfully. **Parameters** - `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the match query. - - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return route steps for each route. (optional, default `false`) - - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) - - `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - - `options.timestamps` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** Timestamp of the input location (integers, UNIX-like timestamp). - - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy (`double >= 0`, default `5m`). -- `or` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** {Array} [options.annotations=false] Return annotations for each route leg. - Can be `false`, `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. + - `options.steps` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route steps for each route. (optional, default `false`) + - `options.annotations` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)] or \[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** Return annotations for each route leg for duration, nodes, distance, weight, datasources and/or speed. Annotations can be `false` or `true` (no/full annotations) or an array of strings with `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. (optional, default `false`) + - `options.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview + and per step). Can also be `geojson`. (optional, default `polyline`) + - `options.overview` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Add overview geometry either `full`, `simplified` + according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) + - `options.timestamps` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>]** Timestamp of the input location (integers, UNIX-like timestamp). + - `options.radiuses` **\[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)]** Standard deviation of GPS precision used for map matching. + If applicable use GPS accuracy (`double >= 0`, default `5m`). - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** @@ -219,36 +203,53 @@ osrm.match(options, function(err, response) { Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `tracepoints` and `matchings`. **`tracepoints`** Array of [`Ẁaypoint`](#waypoint) objects representing all points of the trace in order. - If the trace point was ommited by map matching because it is an outlier, the entry will be null. - Each `Waypoint` object includes two additional properties, 1) `matchings_index`: Index to the - [`Route`](#route) object in matchings the sub-trace was matched to, 2) `waypoint_index`: Index of - the waypoint inside the matched route. -**`matchings`** is an array of [`Route`](#route) objects that assemble the trace. Each `Route` object has an additional `confidence` property, - which is the confidence of the matching. float value between `0` and `1`. `1` is very confident that the matching is correct. +If the trace point was ommited by map matching because it is an outlier, the entry will be null. Each +`Waypoint` object includes two additional properties, 1) `matchings_index`: Index to the +[`Route`](#route) object in matchings the sub-trace was matched to, 2) `waypoint_index`: Index of +the waypoint inside the matched route. +**`matchings`** is an array of [`Route`](#route) objects that +assemble the trace. Each `Route` object has an additional `confidence` property, which is the confidence of +the matching. float value between `0` and `1`. `1` is very confident that the matching is correct. -### trip +## trip -The trip plugin solves the Traveling Salesman Problem using a greedy heuristic -(farthest-insertion algorithm) for 10 or _ more waypoints and uses brute force for less than 10 -waypoints. The returned path does not have to be the shortest path, _ as TSP is NP-hard it is -only an approximation. -Note that all input coordinates have to be connected for the trip service to work. - -**Parameters** +The trip plugin solves the Traveling Salesman Problem using a greedy heuristic (farthest-insertion algorithm). The returned path does not have to be the fastest path, as TSP is NP-hard it is only an approximation. Note that all input coordinates have to be connected for the trip service to work. +**Parameters** - `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object literal containing parameters for the trip query. - - `options.steps` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return route steps for each route. (optional, default `false`) - - `options.geometries` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Returned route geometry format (influences overview and per step). Can also be `geojson`. (optional, default `polyline`) - - `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Add overview geometry either `full`, `simplified` (optional, default `simplified`) - - `options.roundtrip` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return route is a roundtrip. (optional, default `true`) - - `options.source` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return route starts at `any` or `first` coordinate. (optional, default `any`) - - `options.destination` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** Return route ends at `any` or `last` coordinate. (optional, default `any`) -- `or` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** {Array} [options.annotations=false] Return annotations for each route leg. Can be `false`, - `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. + - `options.roundtrip` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route is a roundtrip. (optional, default `true`) + - `options.source` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Return route starts at `any` coordinate. Can also be `first`. (optional, default `any`) + - `options.destination` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Return route ends at `any` coordinate. Can also be `last`. (optional, default `any`) + - `options.steps` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route steps for each route. (optional, default `false`) + - `options.annotations` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)] or \[[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>]** Return annotations for each route leg for duration, nodes, distance, weight, datasources and/or speed. Annotations can be `false` or `true` (no/full annotations) or an array of strings with `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`. (optional, default `false`) + - `options.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview + and per step). Can also be `geojson`. (optional, default `polyline`) + - `options.overview` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Add overview geometry either `full`, `simplified` (optional, default `simplified`) - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** +**Fixing Start and End Points** + +It is possible to explicitly set the start or end coordinate of the trip. When source is set to `first`, the first coordinate is used as start coordinate of the trip in the output. When destination is set to `last`, the last coordinate will be used as destination of the trip in the returned output. If you specify `any`, any of the coordinates can be used as the first or last coordinate in the output. + +However, if `source=any&destination=any` the returned round-trip will still start at the first input coordinate by default. + +Currently, not all combinations of `roundtrip`, `source` and `destination` are supported. +Right now, the following combinations are possible: + +| roundtrip | source | destination | supported | +| :-- | :-- | :-- | :-- | +| true | first | last | **yes** | +| true | first | any | **yes** | +| true | any | last | **yes** | +| true | any | any | **yes** | +| false | first | last | **yes** | +| false | first | any | no | +| false | any | last | no | +| false | any | any | no | + **Examples** +Roundtrip Request ```javascript var osrm = new OSRM('network.osrm'); var options = { @@ -264,57 +265,69 @@ osrm.trip(options, function(err, response) { }); ``` +Non Roundtrip Request +```javascript +var osrm = new OSRM('network.osrm'); +var options = { + coordinates: [ + [13.36761474609375, 52.51663871100423], + [13.374481201171875, 52.506191342034576] + ], + source: "first", + destination: "last", + roundtrip: false +} +osrm.trip(options, function(err, response) { + if (err) throw err; + console.log(response.waypoints); // array of Waypoint objects + console.log(response.trips); // array of Route objects +}); +``` + Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** containing `waypoints` and `trips`. -**`waypoints`**: an array of [`Waypoint`](#waypoint) objects representing all waypoints in input order. - Each Waypoint object has the following additional properties, - 1) `trips_index`: index to trips of the sub-trip the point was matched to, - and 2) `waypoint_index`: index of the point in the trip. +**`waypoints`**: an array of [`Ẁaypoint`](#waypoint) objects representing all waypoints in input order. +Each Waypoint object has the following additional properties, 1) `trips_index`: index to trips of the +sub-trip the point was matched to, and 2) `waypoint_index`: index of the point in the trip. **`trips`**: an array of [`Route`](#route) objects that assemble the trace. -## Responses +# Responses Responses -### Route +## Route Represents a route through (potentially multiple) waypoints. **Parameters** -- `exteral` **documentation** in - [`osrm-backend`](../http.md#route) +- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#route) -### RouteLeg +## RouteLeg Represents a route between two waypoints. **Parameters** -- `exteral` **documentation** in - [`osrm-backend`](../http.md#routeleg) +- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routeleg) -### RouteStep +## RouteStep -A step consists of a maneuver such as a turn or merge, followed by a distance of travel along a -single way to the subsequent step. +A step consists of a maneuver such as a turn or merge, followed by a distance of travel along a single way to the subsequent step. **Parameters** -- `exteral` **documentation** in - [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep) +- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep) -### StepManeuver +## StepManeuver **Parameters** -- `exteral` **documentation** in - [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmaneuver) +- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmanuever) -### Waypoint +## Waypoint Object used to describe waypoint on a route. **Parameters** -- `exteral` **documentation** in - [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint) +- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint) diff --git a/package.json b/package.json index 2147b3a18..58e29cd72 100644 --- a/package.json +++ b/package.json @@ -48,21 +48,12 @@ "node": ">=4.0.0" }, "devDependencies": { - "aws-sdk": "~2.0.31", - "babel-cli": "^6.24.0", - "babel-polyfill": "^6.23.0", - "babel-preset-es2015": "^6.24.0", - "babel-preset-react": "^6.23.0", - "babel-preset-stage-0": "^6.22.0", - "babelify": "^7.3.0", - "brfs": "^1.4.3", - "browserify": "^14.1.0", "docbox": "^1.0.2", "documentation": "^4.0.0-beta.18", "eslint": "^2.4.0", - "react-dom": "^15.4.2", - "tape": "^4.2.2", - "uglifyjs": "^2.4.10" + + "aws-sdk": "~2.0.31", + "tape": "^4.2.2" }, "bundleDependencies": [ "node-pre-gyp" diff --git a/scripts/build_api_docs.sh b/scripts/build_api_docs.sh index 2d14bd402..ecf3dee64 100755 --- a/scripts/build_api_docs.sh +++ b/scripts/build_api_docs.sh @@ -14,7 +14,7 @@ babel -V >/dev/null 2>&1 || { echo >&2 "Can't find babel. Add node_modules/.bin browserify --help >/dev/null 2>&1 || { echo >&2 "Can't find browserify. Add node_modules/.bin to your path, or run via \"npm run\""; exit 1; } uglifyjs -V >/dev/null 2>&1 || { echo >&2 "Can't find uglifyjs. Add node_modules/.bin to your path, or run via \"npm run\""; exit 1; } -documentation build src/nodejs/node_osrm.cpp --polyglot -f md -o docs/nodejs/api.md +#documentation build src/nodejs/node_osrm.cpp --polyglot -f md -o docs/nodejs/api.md # Clean up previous version rm -rf build/docs diff --git a/yarn.lock b/yarn.lock index 7017ff8f5..ca720c756 100644 --- a/yarn.lock +++ b/yarn.lock @@ -204,10 +204,6 @@ async@^1.4.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" -async@~0.2.6: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -244,7 +240,7 @@ aws4@^1.2.1: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-cli@^6.24.0, babel-cli@^6.4.0: +babel-cli@^6.4.0: version "6.24.0" resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.24.0.tgz#a05ffd210dca0c288a26d5319c5ac8669a265ad0" dependencies: @@ -826,7 +822,7 @@ babel-polyfill@^6.23.0, babel-polyfill@^6.3.14: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-preset-es2015@^6.24.0, babel-preset-es2015@^6.3.13, babel-preset-es2015@^6.5.0: +babel-preset-es2015@^6.3.13, babel-preset-es2015@^6.5.0: version "6.24.0" resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.0.tgz#c162d68b1932696e036cd3110dc1ccd303d2673a" dependencies: @@ -861,7 +857,7 @@ babel-preset-flow@^6.23.0: dependencies: babel-plugin-transform-flow-strip-types "^6.22.0" -babel-preset-react@^6.23.0, babel-preset-react@^6.3.13, babel-preset-react@^6.5.0: +babel-preset-react@^6.3.13, babel-preset-react@^6.5.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-preset-react/-/babel-preset-react-6.23.0.tgz#eb7cee4de98a3f94502c28565332da9819455195" dependencies: @@ -872,7 +868,7 @@ babel-preset-react@^6.23.0, babel-preset-react@^6.3.13, babel-preset-react@^6.5. babel-plugin-transform-react-jsx-source "^6.22.0" babel-preset-flow "^6.23.0" -babel-preset-stage-0@^6.22.0, babel-preset-stage-0@^6.3.13, babel-preset-stage-0@^6.5.0: +babel-preset-stage-0@^6.3.13, babel-preset-stage-0@^6.5.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-preset-stage-0/-/babel-preset-stage-0-6.22.0.tgz#707eeb5b415da769eff9c42f4547f644f9296ef9" dependencies: @@ -959,7 +955,7 @@ babel-types@^6.0.19, babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23 lodash "^4.2.0" to-fast-properties "^1.0.1" -babelify@^7.2.0, babelify@^7.3.0: +babelify@^7.2.0: version "7.3.0" resolved "https://registry.yarnpkg.com/babelify/-/babelify-7.3.0.tgz#aa56aede7067fd7bd549666ee16dc285087e88e5" dependencies: @@ -1042,7 +1038,7 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -brfs@^1.4.2, brfs@^1.4.3: +brfs@^1.4.2: version "1.4.3" resolved "https://registry.yarnpkg.com/brfs/-/brfs-1.4.3.tgz#db675d6f5e923e6df087fca5859c9090aaed3216" dependencies: @@ -1174,58 +1170,6 @@ browserify@^13.0.0: vm-browserify "~0.0.1" xtend "^4.0.0" -browserify@^14.1.0: - version "14.1.0" - resolved "https://registry.yarnpkg.com/browserify/-/browserify-14.1.0.tgz#0508cc1e7bf4c152312c2fa523e676c0b0b92311" - dependencies: - JSONStream "^1.0.3" - assert "^1.4.0" - browser-pack "^6.0.1" - browser-resolve "^1.11.0" - browserify-zlib "~0.1.2" - buffer "^5.0.2" - cached-path-relative "^1.0.0" - concat-stream "~1.5.1" - console-browserify "^1.1.0" - constants-browserify "~1.0.0" - crypto-browserify "^3.0.0" - defined "^1.0.0" - deps-sort "^2.0.0" - domain-browser "~1.1.0" - duplexer2 "~0.1.2" - events "~1.1.0" - glob "^7.1.0" - has "^1.0.0" - htmlescape "^1.1.0" - https-browserify "~0.0.0" - inherits "~2.0.1" - insert-module-globals "^7.0.0" - labeled-stream-splicer "^2.0.0" - module-deps "^4.0.8" - os-browserify "~0.1.1" - parents "^1.0.1" - path-browserify "~0.0.0" - process "~0.11.0" - punycode "^1.3.2" - querystring-es3 "~0.2.0" - read-only-stream "^2.0.0" - readable-stream "^2.0.2" - resolve "^1.1.4" - shasum "^1.0.0" - shell-quote "^1.6.1" - stream-browserify "^2.0.0" - stream-http "^2.0.0" - string_decoder "~0.10.0" - subarg "^1.0.0" - syntax-error "^1.1.1" - through2 "^2.0.0" - timers-browserify "^1.0.1" - tty-browserify "~0.0.0" - url "~0.11.0" - util "~0.10.1" - vm-browserify "~0.0.1" - xtend "^4.0.0" - browserslist@^1.0.1, browserslist@^1.5.2, browserslist@^1.7.6: version "1.7.7" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.7.7.tgz#0bd76704258be829b2398bb50e4b62d1a166b0b9" @@ -1253,13 +1197,6 @@ buffer@^4.1.0: ieee754 "^1.1.4" isarray "^1.0.0" -buffer@^5.0.2: - version "5.0.5" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.0.5.tgz#35c9393244a90aff83581063d16f0882cecc9418" - dependencies: - base64-js "^1.0.2" - ieee754 "^1.1.4" - builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -1541,13 +1478,13 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.0.0, concat-stream@^1.4.10, concat-stream@^1.4.6, concat-stream@^1.4.7, concat-stream@^1.5.0, concat-stream@^1.5.2, concat-stream@~1.5.0, concat-stream@~1.5.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" +concat-stream@^1.0.0, concat-stream@^1.4.10, concat-stream@^1.4.6, concat-stream@^1.4.7, concat-stream@^1.5.0, concat-stream@^1.5.2: + version "1.6.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: - inherits "~2.0.1" - readable-stream "~2.0.0" - typedarray "~0.0.5" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" concat-stream@~1.4.5: version "1.4.10" @@ -1557,6 +1494,14 @@ concat-stream@~1.4.5: readable-stream "~1.1.9" typedarray "~0.0.5" +concat-stream@~1.5.0, concat-stream@~1.5.1: + version "1.5.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" + dependencies: + inherits "~2.0.1" + readable-stream "~2.0.0" + typedarray "~0.0.5" + console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" @@ -3103,7 +3048,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -4299,6 +4244,10 @@ path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + path-platform@~0.11.15: version "0.11.15" resolved "https://registry.yarnpkg.com/path-platform/-/path-platform-0.11.15.tgz#e864217f74c36850f0852b78dc7bf7d4a5721bf2" @@ -4694,7 +4643,7 @@ rc@^1.1.0, rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-dom@^15.0.2, react-dom@^15.4.2: +react-dom@^15.0.2: version "15.4.2" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.4.2.tgz#015363f05b0a1fd52ae9efdd3a0060d90695208f" dependencies: @@ -4744,7 +4693,7 @@ read-pkg@^1.0.0, read-pkg@^1.1.0: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.1.0, readable-stream@^2.1.4, readable-stream@^2.1.5: +readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.1.0, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2: version "2.2.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" dependencies: @@ -5068,10 +5017,16 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" -resolve@1.1.7, resolve@^1.1.3, resolve@^1.1.4, resolve@^1.1.5, resolve@^1.1.6, resolve@~1.1.7: +resolve@1.1.7, resolve@~1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" +resolve@^1.1.3, resolve@^1.1.4, resolve@^1.1.5, resolve@^1.1.6: + version "1.3.2" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.2.tgz#1f0442c9e0cbb8136e87b9305f932f46c7f28235" + dependencies: + path-parse "^1.0.5" + restore-cursor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" @@ -5211,12 +5166,6 @@ source-map-support@^0.4.2: dependencies: source-map "^0.5.6" -source-map@0.1.34, source-map@~0.1.33: - version "0.1.34" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.34.tgz#a7cfe89aec7b1682c3b198d0acfb47d7d090566b" - dependencies: - amdefine ">=0.0.4" - source-map@0.5.6, "source-map@>= 0.1.2", source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.3: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -5227,6 +5176,12 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" +source-map@~0.1.33: + version "0.1.43" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + dependencies: + amdefine ">=0.0.4" + space-separated-tokens@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.0.tgz#9e8c60407aa527742cd9eaee2541dec639f1269b" @@ -5743,7 +5698,7 @@ type-is@~1.6.10: media-typer "0.3.0" mime-types "~2.1.13" -typedarray@~0.0.5: +typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" @@ -5763,15 +5718,6 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" -uglifyjs@^2.4.10: - version "2.4.10" - resolved "https://registry.yarnpkg.com/uglifyjs/-/uglifyjs-2.4.10.tgz#632927319fa6a3da3fc91f9773ac27bfe6c3ee92" - dependencies: - async "~0.2.6" - source-map "0.1.34" - uglify-to-browserify "~1.0.0" - yargs "~1.3.3" - uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -6223,10 +6169,6 @@ yargs@^6.0.0: y18n "^3.2.1" yargs-parser "^4.2.0" -yargs@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-1.3.3.tgz#054de8b61f22eefdb7207059eaef9d6b83fb931a" - yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"