Integrate MLD in node bindings
This commit is contained in:
committed by
Patrick Niklaus
parent
2cd4ba9a0a
commit
614398ed6c
@@ -20,7 +20,7 @@ target_link_libraries(node-osrm osrm)
|
||||
# node-osrm artifacts in ${BINDING_DIR} to depend targets on
|
||||
set(ARTIFACTS "")
|
||||
|
||||
set(OSRM_BINARIES osrm-extract osrm-contract osrm-routed osrm-datastore osrm-components)
|
||||
set(OSRM_BINARIES osrm-extract osrm-contract osrm-routed osrm-datastore osrm-components osrm-partition osrm-customize)
|
||||
foreach(binary ${OSRM_BINARIES})
|
||||
add_custom_command(OUTPUT ${BINDING_DIR}/${binary}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${binary}> ${BINDING_DIR}
|
||||
|
||||
+61
-83
@@ -48,15 +48,14 @@ NAN_MODULE_INIT(Engine::Init)
|
||||
Nan::Set(target, whoami, fn);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
*
|
||||
* 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. 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:
|
||||
* 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:
|
||||
*
|
||||
* ```javascript
|
||||
* var osrm = new OSRM('network.osrm');
|
||||
@@ -78,27 +77,18 @@ NAN_MODULE_INIT(Engine::Init)
|
||||
* 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` |
|
||||
*
|
||||
* @class OSRM
|
||||
*
|
||||
*
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::New)
|
||||
{
|
||||
if (info.IsConstructCall())
|
||||
@@ -195,6 +185,7 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
Nan::AsyncQueueWorker(new Worker{self->this_, std::move(params), service, callback});
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* Returns the fastest route between two or more coordinates while visiting the waypoints in order.
|
||||
*
|
||||
@@ -205,19 +196,14 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
* *Please note that even if an alternative route is requested, a result cannot be guaranteed.*
|
||||
* @param {Boolean} [options.steps=false] Return route steps for each route leg.
|
||||
* @param {Boolean} or {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`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview
|
||||
* and per step). Can also be `geojson`.
|
||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified`
|
||||
* according to highest zoom level it could be display on, or not at all (`false`).
|
||||
* @param {Boolean} [options.continue_straight] 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`
|
||||
* Can be `false`, `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview and per step). Can also be `geojson`.
|
||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`).
|
||||
* @param {Boolean} [options.continue_straight] 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`
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {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} An array of [Waypoint](#waypoint) objects representing all waypoints in order AND an array of [`Route`](#route) objects ordered by descending recommendation rank.
|
||||
*
|
||||
* @example
|
||||
* var osrm = new OSRM("berlin-latest.osrm");
|
||||
@@ -227,11 +213,13 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
|
||||
* console.log(result.routes); // array of Route objects ordered by descending recommendation rank
|
||||
* });
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::route) //
|
||||
{
|
||||
async(info, &argumentsToRouteParameter, &osrm::OSRM::Route, true);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* Snaps a coordinate to the street network and returns the nearest n matches.
|
||||
*
|
||||
@@ -245,11 +233,8 @@ NAN_METHOD(Engine::route) //
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {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.
|
||||
* **`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.
|
||||
*
|
||||
* @example
|
||||
* var osrm = new OSRM('network.osrm');
|
||||
@@ -262,11 +247,13 @@ NAN_METHOD(Engine::route) //
|
||||
* console.log(response.waypoints); // array of Waypoint objects
|
||||
* });
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::nearest) //
|
||||
{
|
||||
async(info, &argumentsToNearestParameter, &osrm::OSRM::Nearest, false);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* Computes duration tables for the given locations. Allows for both symmetric and asymmetric
|
||||
* tables.
|
||||
@@ -282,11 +269,10 @@ NAN_METHOD(Engine::nearest) //
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {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.
|
||||
* **`destinations`**: array of [`Ẁaypoint`](#waypoint) objects describing all destinations in order.
|
||||
*
|
||||
* @example
|
||||
* var osrm = new OSRM('network.osrm');
|
||||
@@ -303,11 +289,13 @@ NAN_METHOD(Engine::nearest) //
|
||||
* console.log(response.destinations); // array of Waypoint objects
|
||||
* });
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::table) //
|
||||
{
|
||||
async(info, &argumentsToTableParameter, &osrm::OSRM::Table, true);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* 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
|
||||
@@ -318,11 +306,9 @@ NAN_METHOD(Engine::table) //
|
||||
*
|
||||
* @name tile
|
||||
* @memberof OSRM
|
||||
* @param {Array} ZXY - 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/.
|
||||
* @param {Array} ZXY - 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/).
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {Buffer} contains a Protocol Buffer encoded vector tile.
|
||||
@@ -334,11 +320,13 @@ NAN_METHOD(Engine::table) //
|
||||
* fs.writeFileSync('./tile.vector.pbf', response); // write the buffer to a file
|
||||
* });
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::tile)
|
||||
{
|
||||
async(info, &argumentsToTileParameters, &osrm::OSRM::Tile, {/*unused*/});
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* 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
|
||||
@@ -351,31 +339,21 @@ NAN_METHOD(Engine::tile)
|
||||
* @param {Object} options - Object literal containing parameters for the match query.
|
||||
* @param {Boolean} [options.steps=false] Return route steps for each route.
|
||||
* @param {Boolean} or {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`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview
|
||||
* and per step). Can also be `geojson`.
|
||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified`
|
||||
* according to highest zoom level it could be display on, or not at all (`false`).
|
||||
* @param {Array<Number>} [options.timestamps] Timestamp of the input location (integers, UNIX-like
|
||||
* timestamp).
|
||||
* @param {Array} [options.radiuses] Standard deviation of GPS precision used for map matching.
|
||||
* If applicable use GPS accuracy (`double >= 0`, default `5m`).
|
||||
* Can be `false`, `true` or an array with strings of `duration`, `nodes`, `distance`, `weight`, `datasources`, `speed`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview and per step). Can also be `geojson`.
|
||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`).
|
||||
* @param {Array<Number>} [options.timestamps] Timestamp of the input location (integers, UNIX-like timestamp).
|
||||
* @param {Array} [options.radiuses] Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy (`double >= 0`, default `5m`).
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {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.
|
||||
* **`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.
|
||||
*
|
||||
* @example
|
||||
* var osrm = new OSRM('network.osrm');
|
||||
@@ -390,11 +368,13 @@ NAN_METHOD(Engine::tile)
|
||||
* });
|
||||
*
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::match) //
|
||||
{
|
||||
async(info, &argumentsToMatchParameter, &osrm::OSRM::Match, true);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
* 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
|
||||
@@ -406,11 +386,9 @@ NAN_METHOD(Engine::match) //
|
||||
* @memberof OSRM
|
||||
* @param {Object} options - Object literal containing parameters for the trip query.
|
||||
* @param {Boolean} [options.steps=false] Return route steps for each route.
|
||||
* @param {Boolean} or {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`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview
|
||||
* and per step). Can also be `geojson`.
|
||||
* @param {Boolean} or {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`.
|
||||
* @param {String} [options.geometries=polyline] Returned route geometry format (influences overview and per step). Can also be `geojson`.
|
||||
* @param {String} [options.overview=simplified] Add overview geometry either `full`, `simplified`
|
||||
* @param {Function} callback
|
||||
* @param {Boolean} [options.roundtrip=true] Return route is a roundtrip.
|
||||
@@ -418,11 +396,10 @@ NAN_METHOD(Engine::match) //
|
||||
* @param {String} [options.destination=any] Return route ends at `any` or `last` coordinate.
|
||||
*
|
||||
* @returns {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 [`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.
|
||||
* **`trips`**: an array of [`Route`](#route) objects that assemble the trace.
|
||||
*
|
||||
* @example
|
||||
@@ -439,6 +416,7 @@ NAN_METHOD(Engine::match) //
|
||||
* console.log(response.trips); // array of Route objects
|
||||
* });
|
||||
*/
|
||||
// clang-format on
|
||||
NAN_METHOD(Engine::trip) //
|
||||
{
|
||||
async(info, &argumentsToTripParameter, &osrm::OSRM::Trip, true);
|
||||
@@ -456,7 +434,7 @@ NAN_METHOD(Engine::trip) //
|
||||
* @memberof Responses
|
||||
*
|
||||
* @param {documentation} exteral in
|
||||
* [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#route)
|
||||
* [`osrm-backend`](../http.md#route)
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -467,7 +445,7 @@ NAN_METHOD(Engine::trip) //
|
||||
* @memberof Responses
|
||||
*
|
||||
* @param {documentation} exteral in
|
||||
* [`osrm-backend`](https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md#routeleg)
|
||||
* [`osrm-backend`](../http.md#routeleg)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user