Switch to yarn
This commit is contained in:
parent
614398ed6c
commit
de98ae57b7
27
.travis.yml
27
.travis.yml
@ -7,6 +7,9 @@ git:
|
|||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
|
nodejs:
|
||||||
|
- "4"
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
||||||
@ -15,6 +18,7 @@ branches:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
|
yarn: true
|
||||||
ccache: true
|
ccache: true
|
||||||
apt: true
|
apt: true
|
||||||
directories:
|
directories:
|
||||||
@ -138,11 +142,10 @@ before_install:
|
|||||||
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||||
export JOBS=$((`sysctl -n hw.ncpu` + 1))
|
export JOBS=$((`sysctl -n hw.ncpu` + 1))
|
||||||
sudo mdutil -i off /
|
sudo mdutil -i off /
|
||||||
|
npm install -g yarn
|
||||||
fi
|
fi
|
||||||
- echo "Using ${JOBS} jobs"
|
- echo "Using ${JOBS} jobs"
|
||||||
- source ./scripts/install_node.sh 4
|
- yarn install --ignore-scripts
|
||||||
- npm install -g "npm@>=3" # Upgrade to npm >v2 to reduce size of downloaded dependencies
|
|
||||||
- npm install --ignore-scripts
|
|
||||||
# Bootstrap cmake to be able to run mason
|
# Bootstrap cmake to be able to run mason
|
||||||
- CMAKE_URL="https://mason-binaries.s3.amazonaws.com/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz"
|
- CMAKE_URL="https://mason-binaries.s3.amazonaws.com/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz"
|
||||||
- CMAKE_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}"
|
- CMAKE_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}"
|
||||||
@ -173,7 +176,16 @@ install:
|
|||||||
- export OSRM_BUILD_DIR="$(pwd)/build-osrm"
|
- export OSRM_BUILD_DIR="$(pwd)/build-osrm"
|
||||||
- mkdir ${OSRM_BUILD_DIR} && pushd ${OSRM_BUILD_DIR}
|
- mkdir ${OSRM_BUILD_DIR} && pushd ${OSRM_BUILD_DIR}
|
||||||
- export CC=${CCOMPILER} CXX=${CXXCOMPILER}
|
- export CC=${CCOMPILER} CXX=${CXXCOMPILER}
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_MASON=${ENABLE_MASON:-OFF} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} -DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} -DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} -DBUILD_TOOLS=ON -DENABLE_CCACHE=ON -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF}
|
- |
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||||
|
-DENABLE_MASON=${ENABLE_MASON:-OFF} \
|
||||||
|
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \
|
||||||
|
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} \
|
||||||
|
-DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \
|
||||||
|
-DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
|
||||||
|
-DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \
|
||||||
|
-DBUILD_TOOLS=ON \
|
||||||
|
-DENABLE_CCACHE=ON
|
||||||
- echo "travis_fold:start:MAKE"
|
- echo "travis_fold:start:MAKE"
|
||||||
- make --jobs=${JOBS}
|
- make --jobs=${JOBS}
|
||||||
- make tests --jobs=${JOBS}
|
- make tests --jobs=${JOBS}
|
||||||
@ -190,7 +202,8 @@ install:
|
|||||||
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
|
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
|
||||||
- make --jobs=${JOBS}
|
- make --jobs=${JOBS}
|
||||||
- popd
|
- popd
|
||||||
- npm run build-api-docs
|
# building docs only works with npm3+ not with yarn or npm2
|
||||||
|
#- yarn run docs
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
|
- if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
|
||||||
@ -205,7 +218,7 @@ script:
|
|||||||
- ./unit_tests/server-tests
|
- ./unit_tests/server-tests
|
||||||
- ./unit_tests/partition-tests
|
- ./unit_tests/partition-tests
|
||||||
- popd
|
- popd
|
||||||
- npm test
|
- yarn test
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- |
|
- |
|
||||||
@ -215,8 +228,6 @@ after_success:
|
|||||||
|
|
||||||
- |
|
- |
|
||||||
if [ -n "${ENABLE_NODE_BINDINGS}" ]; then
|
if [ -n "${ENABLE_NODE_BINDINGS}" ]; then
|
||||||
nvm install 4
|
|
||||||
nvm use 4
|
|
||||||
source ./scripts/travis/build.sh
|
source ./scripts/travis/build.sh
|
||||||
./scripts/travis/publish.sh
|
./scripts/travis/publish.sh
|
||||||
fi
|
fi
|
||||||
|
@ -1,30 +1,18 @@
|
|||||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
# 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)
|
You can create such a `.osrm` file by running the OSRM binaries we ship in `node_modules/osrm/lib/binding/` and default
|
||||||
- - [Methods](#methods)
|
profiles (e.g. for setting speeds and determining road types to route on) in `node_modules/osrm/profiles/`:
|
||||||
- [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)
|
|
||||||
|
|
||||||
## 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.
|
Consult the [osrm-backend](https://github.com/Project-OSRM/osrm-backend) documentation or further details.
|
||||||
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 networks in javascript with this library using the
|
||||||
Once you have a complete `network.osrm` file, you can calculate routes in javascript with this library using the methods below.
|
methods below. To create an OSRM instance with your network you need to construct an instance like this:
|
||||||
To create an OSRM instance with your network you need to construct an instance like this:
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var osrm = new OSRM('network.osrm');
|
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.nearest`](#nearest) | returns the nearest street segment for a given coordinate |
|
||||||
| [`osrm.table`](#table) | computes distance tables for given coordinates |
|
| [`osrm.table`](#table) | computes distance tables for given coordinates |
|
||||||
| [`osrm.match`](#match) | matches given coordinates to the road network |
|
| [`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 |
|
| [`osrm.tile`](#tile) | Return vector tiles containing debugging info |
|
||||||
|
|
||||||
#### General Options
|
#### General Options
|
||||||
|
|
||||||
Each OSRM method (except for `OSRM.tile()`) has set of general options as well as unique options,
|
Each OSRM method (except for `OSRM.tile()`) has set of general options as well as unique options, outlined below.
|
||||||
outlined below.
|
|
||||||
|
|
||||||
| Option | Values | Description | Format |
|
| Option | Values | Description | Format |
|
||||||
| ----------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
| --------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
||||||
| coordinates | `array` of `coordinate` elements: `[{coordinate}, ...]` | The coordinates this request will use. | `array` with `[{lon},{lat}]` values, in decimal degrees |
|
| 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` |
|
| 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) |
|
| 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` |
|
| 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.
|
Returns the fastest route between two or more coordinates while visiting the waypoints in order.
|
||||||
|
|
||||||
**Parameters**
|
**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` **[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.
|
- `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`)
|
||||||
_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.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.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.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.
|
- `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`
|
||||||
`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`.
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var osrm = new OSRM("berlin-latest.osrm");
|
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;
|
if(err) throw err;
|
||||||
console.log(result.waypoints); // array of Waypoint objects representing all waypoints in order
|
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
|
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.
|
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.
|
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**
|
**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` **[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`)
|
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)**
|
- `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`.
|
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.
|
**`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
|
Computes duration tables for the given locations. Allows for both symmetric and asymmetric tables.
|
||||||
tables.
|
|
||||||
|
|
||||||
**Parameters**
|
**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` **[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
|
- `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
|
||||||
use
|
|
||||||
location with given index as source. Default is to use all.
|
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 <
|
- `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.
|
||||||
#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)**
|
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||||
|
|
||||||
**Examples**
|
**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`.
|
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.
|
**`durations`**: array of arrays that stores the matrix in row-major order. `durations[i][j]`
|
||||||
Values are given in seconds.
|
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.
|
**`sources`**: array of [`Ẁaypoint`](#waypoint) objects describing all sources in order.
|
||||||
**`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations 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
|
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
|
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,
|
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
|
so are in sync with actual routing results, and let you examine which roads are actually routable,
|
||||||
routable,
|
|
||||||
and what weights they have applied.
|
and what weights they have applied.
|
||||||
|
|
||||||
**Parameters**
|
**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
|
- `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)
|
[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/).
|
and are supported by vector tile viewers like [Mapbox GL JS]\(<https://www.mapbox.com/mapbox-gl-js/api/>.
|
||||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||||
|
|
||||||
**Examples**
|
**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.
|
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.
|
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
|
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**
|
**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` **[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.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.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.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.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview
|
||||||
- `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).
|
and per step). Can also be `geojson`. (optional, default `polyline`)
|
||||||
- `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`).
|
- `options.overview` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Add overview geometry either `full`, `simplified`
|
||||||
- `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.
|
according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`)
|
||||||
Can be `false`, `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`.
|
- `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)**
|
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)**
|
||||||
|
|
||||||
**Examples**
|
**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`.
|
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.
|
**`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.
|
If the trace point was ommited by map matching because it is an outlier, the entry will be null. Each
|
||||||
Each `Waypoint` object includes two additional properties, 1) `matchings_index`: Index to the
|
`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
|
[`Route`](#route) object in matchings the sub-trace was matched to, 2) `waypoint_index`: Index of
|
||||||
the waypoint inside the matched route.
|
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,
|
**`matchings`** is an array of [`Route`](#route) objects that
|
||||||
which is the confidence of the matching. float value between `0` and `1`. `1` is very confident that the matching is correct.
|
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
|
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.
|
||||||
(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**
|
|
||||||
|
|
||||||
|
**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` **[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.roundtrip` **\[[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** Return route is a roundtrip. (optional, default `true`)
|
||||||
- `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.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.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.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.roundtrip` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Return route is a roundtrip. (optional, default `true`)
|
- `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.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.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.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`)
|
- `options.geometries` **\[[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** Returned route geometry format (influences overview
|
||||||
- `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`,
|
and per step). Can also be `geojson`. (optional, default `polyline`)
|
||||||
`true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`.
|
- `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)**
|
- `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**
|
**Examples**
|
||||||
|
|
||||||
|
Roundtrip Request
|
||||||
```javascript
|
```javascript
|
||||||
var osrm = new OSRM('network.osrm');
|
var osrm = new OSRM('network.osrm');
|
||||||
var options = {
|
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`.
|
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.
|
**`waypoints`**: an array of [`Ẁaypoint`](#waypoint) objects representing all waypoints in input order.
|
||||||
Each Waypoint object has the following additional properties,
|
Each Waypoint object has the following additional properties, 1) `trips_index`: index to trips of the
|
||||||
1) `trips_index`: index to trips of the sub-trip the point was matched to,
|
sub-trip the point was matched to, and 2) `waypoint_index`: index of the point in the trip.
|
||||||
and 2) `waypoint_index`: index of the point in the trip.
|
|
||||||
**`trips`**: an array of [`Route`](#route) objects that assemble the trace.
|
**`trips`**: an array of [`Route`](#route) objects that assemble the trace.
|
||||||
|
|
||||||
## Responses
|
# Responses
|
||||||
|
|
||||||
Responses
|
Responses
|
||||||
|
|
||||||
### Route
|
## Route
|
||||||
|
|
||||||
Represents a route through (potentially multiple) waypoints.
|
Represents a route through (potentially multiple) waypoints.
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `exteral` **documentation** in
|
- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#route)
|
||||||
[`osrm-backend`](../http.md#route)
|
|
||||||
|
|
||||||
### RouteLeg
|
## RouteLeg
|
||||||
|
|
||||||
Represents a route between two waypoints.
|
Represents a route between two waypoints.
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `exteral` **documentation** in
|
- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routeleg)
|
||||||
[`osrm-backend`](../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
|
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.
|
||||||
single way to the subsequent step.
|
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `exteral` **documentation** in
|
- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep)
|
||||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routestep)
|
|
||||||
|
|
||||||
### StepManeuver
|
## StepManeuver
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `exteral` **documentation** in
|
- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmanuever)
|
||||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#stepmaneuver)
|
|
||||||
|
|
||||||
### Waypoint
|
## Waypoint
|
||||||
|
|
||||||
Object used to describe waypoint on a route.
|
Object used to describe waypoint on a route.
|
||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `exteral` **documentation** in
|
- `exteral` **documentation** in [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint)
|
||||||
[`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#waypoint)
|
|
||||||
|
17
package.json
17
package.json
@ -48,19 +48,12 @@
|
|||||||
"node": ">=4.0.0"
|
"node": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aws-sdk": "~2.0.31",
|
"docbox": "^1.0.5",
|
||||||
"babel-cli": "^6.24.0",
|
"documentation": "^4.0.0-beta.18",
|
||||||
"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",
|
|
||||||
"eslint": "^2.4.0",
|
"eslint": "^2.4.0",
|
||||||
"tape": "^4.2.2",
|
|
||||||
"uglifyjs": "^2.4.10"
|
"aws-sdk": "~2.0.31",
|
||||||
|
"tape": "^4.2.2"
|
||||||
},
|
},
|
||||||
"bundleDependencies": [
|
"bundleDependencies": [
|
||||||
"node-pre-gyp"
|
"node-pre-gyp"
|
||||||
|
@ -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; }
|
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; }
|
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
|
# Clean up previous version
|
||||||
rm -rf build/docs
|
rm -rf build/docs
|
||||||
|
Loading…
Reference in New Issue
Block a user