Compare commits

...

15 Commits

Author SHA1 Message Date
Patrick Niklaus e568b600f0 Tag a new latest version for publishing 2017-04-03 12:50:45 +00:00
Patrick Niklaus 273fd689ce Always check local variables 2017-03-30 20:12:07 +00:00
Patrick Niklaus 0363d64722 Update releasing docs 2017-03-30 20:12:07 +00:00
Patrick Niklaus d200507424 Fix travis.yml 2017-03-30 20:12:07 +00:00
Patrick Niklaus fc84f605af Switch from commit message publishing to tag-based publishing 2017-03-30 20:12:07 +00:00
Patrick Niklaus 927dea37bb Fix publishing node binaries 2017-03-30 20:12:07 +00:00
Patrick Niklaus de98ae57b7 Switch to yarn 2017-03-30 20:12:07 +00:00
Patrick Niklaus 614398ed6c Integrate MLD in node bindings 2017-03-30 20:12:07 +00:00
Michael Krasnyk 2cd4ba9a0a move split_edges to global properties 2017-03-30 11:20:13 +02:00
Michael Krasnyk 57d3f71bf9 added change log entry and documentation 2017-03-30 11:20:13 +02:00
Michael Krasnyk 8f8df969a2 use signed slope to distinguish uphills and downhills 2017-03-30 11:20:13 +02:00
Michael Krasnyk e39dc3c464 adjust rasterbot test to check split_edges flag 2017-03-30 11:20:13 +02:00
Michael Krasnyk dbc6535221 add split_edge flag in extracted ways 2017-03-30 11:20:13 +02:00
Michael Krasnyk e262cac3e8 Flip source and target coordinates for segments in only backward direction 2017-03-29 22:05:37 +00:00
Michael Krasnyk 4ab3165ae3 Fix unnecessary duplication of backward segments for non-split edges
for edges with the split flag false and in_backward_direction true
if in_forward_direction is also true backward segments can be incorrectly duplicated
2017-03-29 22:05:37 +00:00
26 changed files with 6698 additions and 321 deletions
+25 -9
View File
@@ -7,14 +7,20 @@ git:
sudo: required
dist: trusty
nodejs:
- "4"
notifications:
email: false
branches:
only:
- master
# enable building tags
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
cache:
yarn: true
ccache: true
apt: true
directories:
@@ -22,6 +28,8 @@ cache:
env:
global:
- secure: "hk+32aXXF5t1ApaM2Wjqooz3dx1si907L87WRMkO47WlpJmUUU/Ye+MJk9sViH8MdhOcceocVAmdYl5/WFWOIbDWNlBya9QvXDZyIu2KIre/0QyOCTZbrsif8paBXKIO5O/R4OTvIZ8rvWZsadBdmAT9GSbDhih6FzqXAEgeIYQ="
- secure: "VE+cFkseFwW4jK6XwkP0yW3h4DixPJ8+Eb3yKcchGZ5iIJxlZ/8i1vKHYxadgPRwSYwPSB14tF70xj2OmiT2keGzZUfphmPXinBaLEhYk+Bde+GZZkoSl5ND109I/LcyNr0nG9dDgtV6pkvFchgchpyP9JnVOOS0+crEZlAz0RE="
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- CASHER_TIME_OUT=599 # one second less than 10m to avoid 10m timeout error: https://github.com/Project-OSRM/osrm-backend/issues/2742
@@ -138,11 +146,12 @@ before_install:
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
export JOBS=$((`sysctl -n hw.ncpu` + 1))
sudo mdutil -i off /
npm install -g yarn
fi
- export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
- export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off")
- echo "Using ${JOBS} jobs"
- source ./scripts/install_node.sh 4
- npm install -g "npm@>=3" # Upgrade to npm >v2 to reduce size of downloaded dependencies
- npm install --ignore-scripts
- yarn install --ignore-scripts
# 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_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}"
@@ -173,7 +182,16 @@ install:
- export OSRM_BUILD_DIR="$(pwd)/build-osrm"
- mkdir ${OSRM_BUILD_DIR} && pushd ${OSRM_BUILD_DIR}
- 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"
- make --jobs=${JOBS}
- make tests --jobs=${JOBS}
@@ -190,7 +208,8 @@ install:
- cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
- make --jobs=${JOBS}
- popd
- npm run build-api-docs
# building docs only works with npm3+ not with yarn or npm2
#- yarn run docs
script:
- if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
@@ -205,7 +224,7 @@ script:
- ./unit_tests/server-tests
- ./unit_tests/partition-tests
- popd
- npm test
- yarn test
after_success:
- |
@@ -215,8 +234,5 @@ after_success:
- |
if [ -n "${ENABLE_NODE_BINDINGS}" ]; then
nvm install 4
nvm use 4
source ./scripts/travis/build.sh
./scripts/travis/publish.sh
fi
+2
View File
@@ -10,6 +10,8 @@
- .osrm.datasource_index file was removed. Data is now part of .osrm.geometries.
- .osrm.edge_lookup was removed. The option `--generate-edge-lookup` does nothing now.
- `osrm-contract` does not depend on the `.osrm.fileIndex` file anymore
- Profiles
- Added `force_split_edges` flag to global properties. True value guarantees that segment_function will be called for all segments, but also could double memory consumption
# 5.6.3
- Changes from 5.6.0
+75
View File
@@ -0,0 +1,75 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "user for publishing to s3://mapbox-node-binary/osrm",
"Resources": {
"User": {
"Type": "AWS::IAM::User",
"Properties": {
"Policies": [
{
"PolicyName": "list",
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::mapbox-node-binary",
"Condition": {
"StringLike": {
"s3:prefix": [
"osrm/*"
]
}
}
}
]
}
},
{
"PolicyName": "publish",
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::mapbox-node-binary/osrm/*"
}
]
}
}
]
}
},
"AccessKey": {
"Type": "AWS::IAM::AccessKey",
"Properties": {
"UserName": {
"Ref": "User"
}
}
}
},
"Outputs": {
"AccessKeyId": {
"Value": {
"Ref": "AccessKey"
}
},
"SecretAccessKey": {
"Value": {
"Fn::GetAtt": [
"AccessKey",
"SecretAccessKey"
]
}
}
}
}
+59
View File
@@ -0,0 +1,59 @@
var cf = require('@mapbox/cloudfriend');
var package_json = require('../package.json')
module.exports = {
AWSTemplateFormatVersion: '2010-09-09',
Description: 'user for publishing to s3://mapbox-node-binary/' + package_json.name,
Resources: {
User: {
Type: 'AWS::IAM::User',
Properties: {
Policies: [
{
PolicyName: 'list',
PolicyDocument: {
Statement: [
{
Action: ['s3:ListBucket'],
Effect: 'Allow',
Resource: 'arn:aws:s3:::mapbox-node-binary',
Condition : {
StringLike : {
"s3:prefix": [ package_json.name + "/*"]
}
}
}
]
}
},
{
PolicyName: 'publish',
PolicyDocument: {
Statement: [
{
Action: ['s3:DeleteObject', 's3:GetObject', 's3:GetObjectAcl', 's3:PutObject', 's3:PutObjectAcl'],
Effect: 'Allow',
Resource: 'arn:aws:s3:::mapbox-node-binary/' + package_json.name + '/*'
}
]
}
}
]
}
},
AccessKey: {
Type: 'AWS::IAM::AccessKey',
Properties: {
UserName: cf.ref('User')
}
}
},
Outputs: {
AccessKeyId: {
Value: cf.ref('AccessKey')
},
SecretAccessKey: {
Value: cf.getAtt('AccessKey', 'SecretAccessKey')
}
}
};
+1
View File
@@ -36,6 +36,7 @@ use_turn_restrictions | Boolean | Are turn instructions followed?
continue_straight_at_waypoint | Boolean | Must the route continue straight on at a via point, or are U-turns allowed?
max_speed_for_map_matching | Float | Maximum vehicle speed to be assumed in matching (in m/s)
max_turn_weight | Float | Maximum turn penalty weight
force_split_edges | Boolean | True value forces a split of forward and backward edges of extracted ways and guarantees that segment_function will be called for all segments
## way_function
+13 -9
View File
@@ -32,21 +32,25 @@ We may introduce forward-compatible changes: query parameters and response prope
- The `master` branch is for the bleeding edge development
- We create and maintain release branches `x.y` to control the release flow
- We create the release branch once we tagged the final version `x.y.0` version, RCs go on master
- We create the release branch once we create release branches once we want to release the first RC
- RCs go in the release branch, commits needs to be cherry-picked from master
- No minor or major version will be released without a code-equal release candidates
- For quality assurance, release candidates will be run on the demo server for 24 hours before releaseing the version proper
- For quality assurance, release candidates need to be staged beforing tagging a final release
- Patch versions may be released without a release candidate
- We may backport fixes to older versions and release them as patch versions
## Releasing a version
1. Check out the appropriate release branch `x.y`
2. Make sure all tests are passing (e.g. Travis CI gives you a :thumbs_up:)
3. Make sure `CHANGELOG.md` is up to date.
4. Make sure the OSRM version in `CMakeLists.txt` is up to date
5. Use an annotated tag to mark the release: `git tag vx.y.z -a` Body of the tag description should be the changelog entries.
6. Use `npm run build-api-docs` to generate the API documentation. Copy `build/docs/*` to `https://github.com/Project-OSRM/project-osrm.github.com` in the `docs/vN.N.N/api` directory
6. Push tags and commits: `git push; git push --tags`
8. Proceede with the `node-osrm` release as [outlined in the repository](https://github.com/Project-OSRM/node-osrm/blob/master/docs/releasing.md).
2. Make sure `CHANGELOG.md` is up to date.
3. Make sure the OSRM version in `CMakeLists.txt` is up to date
4. Make sure the `package.json` is up to date.
5. Make sure all tests are passing (e.g. Travis CI gives you a :thumbs_up:)
6. Use an annotated tag to mark the release: `git tag vx.y.z -a` Body of the tag description should be the changelog entries.
7. Use `npm run build-api-docs` to generate the API documentation. Copy `build/docs/*` to `https://github.com/Project-OSRM/project-osrm.github.com` in the `docs/vN.N.N/api` directory
8. Push tags and commits: `git push; git push --tags`
9. If not a release-candidate: Write a mailing-list post to osrm-talk@openstreetmap.org to announce the release
10. Wait until the travis build has been completed and check if the node binaries were published by doing:
`rm -rf node_modules && npm install` locally.
11. For final releases run `npm publish` or `npm publish --tag next` for release candidates.
+6 -4
View File
@@ -2,10 +2,10 @@
Feature: osrm-extract with a profile containing raster source
Scenario: osrm-extract on a valid profile
Given the profile "rasterbot"
And the node map
"""
a b
"""
And the node locations
| node | lat | lon |
| a | 0.1 | 0.1 |
| b | 0.05 | 0.1 |
And the ways
| nodes |
| ab |
@@ -20,4 +20,6 @@ Feature: osrm-extract with a profile containing raster source
And the data has been saved to disk
When I run "osrm-extract {osm_file} -p {profile_file}"
Then stdout should contain "source loader"
Then stdout should contain "slope: 0.0899"
Then stdout should contain "slope: -0.0899"
And it should exit successfully
+3 -2
View File
@@ -50,8 +50,9 @@ Feature: Raster - weights
And I route I should get
| from | to | route | speed |
| a | b | ab,ab | 8 km/h |
| a | c | ad,dc,dc | 15 km/h |
| b | c | bc,bc | 8 km/h |
| b | a | ab,ab | 22 km/h |
| a | c | ab,bc,bc | 12 km/h |
| b | c | bc,bc | 22 km/h |
| a | d | ad,ad | 15 km/h |
| d | c | dc,dc | 15 km/h |
| d | e | de,de | 10 km/h |
+6 -13
View File
@@ -62,13 +62,6 @@ struct ExtractionWay
forward_restricted = false;
}
// These accessors exists because it's not possible to take the address of a bitfield,
// and LUA therefore cannot read/write the mode attributes directly.
void set_forward_mode(const TravelMode m) { forward_travel_mode = m; }
TravelMode get_forward_mode() const { return forward_travel_mode; }
void set_backward_mode(const TravelMode m) { backward_travel_mode = m; }
TravelMode get_backward_mode() const { return backward_travel_mode; }
// wrappers to allow assigning nil (nullptr) to string values
void SetName(const char *value) { detail::maybeSetString(name, value); }
const char *GetName() const { return name.c_str(); }
@@ -105,14 +98,14 @@ struct ExtractionWay
std::string destinations;
std::string turn_lanes_forward;
std::string turn_lanes_backward;
bool roundabout;
bool circular;
bool is_startpoint;
bool backward_restricted;
bool forward_restricted;
guidance::RoadClassification road_classification;
TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;
guidance::RoadClassification road_classification;
bool roundabout : 1;
bool circular : 1;
bool is_startpoint : 1;
bool forward_restricted : 1;
bool backward_restricted : 1;
};
}
}
@@ -63,6 +63,7 @@ class ExtractorCallbacks
guidance::LaneDescriptionMap lane_description_map;
ExtractionContainers &external_memory;
bool fallback_to_duration;
bool force_split_edges;
public:
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers,
+1
View File
@@ -87,6 +87,7 @@ struct ProfileProperties
//! stores the name of the weight (e.g. 'duration', 'distance', 'safety')
char weight_name[MAX_WEIGHT_NAME_LENGTH + 1];
unsigned weight_precision = 1;
bool force_split_edges = false;
};
}
}
+105
View File
@@ -112,11 +112,18 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
auto params = Nan::To<v8::Object>(args[0]).ToLocalChecked();
auto path = params->Get(Nan::New("path").ToLocalChecked());
if (path.IsEmpty())
return engine_config_ptr();
auto shared_memory = params->Get(Nan::New("shared_memory").ToLocalChecked());
if (shared_memory.IsEmpty())
return engine_config_ptr();
if (!path->IsUndefined())
{
engine_config->storage_config =
osrm::StorageConfig(*v8::String::Utf8Value(Nan::To<v8::String>(path).ToLocalChecked()));
engine_config->use_shared_memory = false;
}
if (!shared_memory->IsUndefined())
{
@@ -138,6 +145,37 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
return engine_config_ptr();
}
auto algorithm = params->Get(Nan::New("algorithm").ToLocalChecked());
if (algorithm.IsEmpty())
return engine_config_ptr();
if (algorithm->IsString())
{
auto algorithm_str = Nan::To<v8::String>(algorithm).ToLocalChecked();
if (*v8::String::Utf8Value(algorithm_str) == std::string("CH"))
{
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
}
else if (*v8::String::Utf8Value(algorithm_str) == std::string("CoreCH"))
{
engine_config->algorithm = osrm::EngineConfig::Algorithm::CoreCH;
}
else if (*v8::String::Utf8Value(algorithm_str) == std::string("MLD"))
{
engine_config->algorithm = osrm::EngineConfig::Algorithm::MLD;
}
else
{
Nan::ThrowError("algorithm option must be one of 'CH', 'CoreCH', or 'MLD'.");
return engine_config_ptr();
}
}
else if (!algorithm->IsUndefined())
{
Nan::ThrowError("algorithm option must be a string and one of 'CH', 'CoreCH', or 'MLD'.");
return engine_config_ptr();
}
return engine_config;
}
@@ -151,6 +189,8 @@ parseCoordinateArray(const v8::Local<v8::Array> &coordinates_array)
for (uint32_t i = 0; i < coordinates_array->Length(); ++i)
{
v8::Local<v8::Value> coordinate = coordinates_array->Get(i);
if (coordinate.IsEmpty())
return resulting_coordinates;
if (!coordinate->IsArray())
{
@@ -218,6 +258,9 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked();
v8::Local<v8::Value> coordinates = obj->Get(Nan::New("coordinates").ToLocalChecked());
if (coordinates.IsEmpty())
return false;
if (coordinates->IsUndefined())
{
Nan::ThrowError("Must provide a coordinates property");
@@ -258,6 +301,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (obj->Has(Nan::New("bearings").ToLocalChecked()))
{
v8::Local<v8::Value> bearings = obj->Get(Nan::New("bearings").ToLocalChecked());
if (bearings.IsEmpty())
return false;
if (!bearings->IsArray())
{
@@ -276,6 +321,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
for (uint32_t i = 0; i < bearings_array->Length(); ++i)
{
v8::Local<v8::Value> bearing_raw = bearings_array->Get(i);
if (bearing_raw.IsEmpty())
return false;
if (bearing_raw->IsNull())
{
@@ -320,6 +367,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (obj->Has(Nan::New("hints").ToLocalChecked()))
{
v8::Local<v8::Value> hints = obj->Get(Nan::New("hints").ToLocalChecked());
if (hints.IsEmpty())
return false;
if (!hints->IsArray())
{
@@ -338,6 +387,9 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
for (uint32_t i = 0; i < hints_array->Length(); ++i)
{
v8::Local<v8::Value> hint = hints_array->Get(i);
if (hint.IsEmpty())
return false;
if (hint->IsString())
{
if (hint->ToString()->Length() == 0)
@@ -364,6 +416,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (obj->Has(Nan::New("radiuses").ToLocalChecked()))
{
v8::Local<v8::Value> radiuses = obj->Get(Nan::New("radiuses").ToLocalChecked());
if (radiuses.IsEmpty())
return false;
if (!radiuses->IsArray())
{
@@ -382,6 +436,9 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
for (uint32_t i = 0; i < radiuses_array->Length(); ++i)
{
v8::Local<v8::Value> radius = radiuses_array->Get(i);
if (radius.IsEmpty())
return false;
if (radius->IsNull())
{
params->radiuses.emplace_back();
@@ -401,6 +458,8 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
if (obj->Has(Nan::New("generate_hints").ToLocalChecked()))
{
v8::Local<v8::Value> generate_hints = obj->Get(Nan::New("generate_hints").ToLocalChecked());
if (generate_hints.IsEmpty())
return false;
if (!generate_hints->IsBoolean())
{
@@ -420,6 +479,9 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (obj->Has(Nan::New("steps").ToLocalChecked()))
{
auto steps = obj->Get(Nan::New("steps").ToLocalChecked());
if (steps.IsEmpty())
return false;
if (steps->IsBoolean())
{
params->steps = steps->BooleanValue();
@@ -434,6 +496,9 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (obj->Has(Nan::New("annotations").ToLocalChecked()))
{
auto annotations = obj->Get(Nan::New("annotations").ToLocalChecked());
if (annotations.IsEmpty())
return false;
if (annotations->IsBoolean())
{
params->annotations = annotations->BooleanValue();
@@ -494,6 +559,8 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (obj->Has(Nan::New("geometries").ToLocalChecked()))
{
v8::Local<v8::Value> geometries = obj->Get(Nan::New("geometries").ToLocalChecked());
if (geometries.IsEmpty())
return false;
if (!geometries->IsString())
{
@@ -526,6 +593,8 @@ inline bool parseCommonParameters(const v8::Local<v8::Object> &obj, ParamType &p
if (obj->Has(Nan::New("overview").ToLocalChecked()))
{
v8::Local<v8::Value> overview = obj->Get(Nan::New("overview").ToLocalChecked());
if (overview.IsEmpty())
return false;
if (!overview->IsString())
{
@@ -572,9 +641,13 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("continue_straight").ToLocalChecked()))
{
auto value = obj->Get(Nan::New("continue_straight").ToLocalChecked());
if (value.IsEmpty())
return route_parameters_ptr();
if (!value->IsBoolean() && !value->IsNull())
{
Nan::ThrowError("'continue_straight' parama must be boolean or null");
return route_parameters_ptr();
}
if (value->IsBoolean())
{
@@ -585,9 +658,13 @@ argumentsToRouteParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("alternatives").ToLocalChecked()))
{
auto value = obj->Get(Nan::New("alternatives").ToLocalChecked());
if (value.IsEmpty())
return route_parameters_ptr();
if (!value->IsBoolean())
{
Nan::ThrowError("'alternatives' parama must be boolean");
return route_parameters_ptr();
}
params->alternatives = value->BooleanValue();
}
@@ -629,6 +706,8 @@ argumentsToTileParameters(const Nan::FunctionCallbackInfo<v8::Value> &args, bool
v8::Local<v8::Value> x = array->Get(0);
v8::Local<v8::Value> y = array->Get(1);
v8::Local<v8::Value> z = array->Get(2);
if (x.IsEmpty() || y.IsEmpty() || z.IsEmpty())
return tile_parameters_ptr();
if (!x->IsUint32() && !x->IsUndefined())
{
@@ -669,6 +748,8 @@ argumentsToNearestParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return nearest_parameters_ptr();
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked();
if (obj.IsEmpty())
return nearest_parameters_ptr();
if (obj->Has(Nan::New("number").ToLocalChecked()))
{
@@ -706,10 +787,14 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
return table_parameters_ptr();
v8::Local<v8::Object> obj = Nan::To<v8::Object>(args[0]).ToLocalChecked();
if (obj.IsEmpty())
return table_parameters_ptr();
if (obj->Has(Nan::New("sources").ToLocalChecked()))
{
v8::Local<v8::Value> sources = obj->Get(Nan::New("sources").ToLocalChecked());
if (sources.IsEmpty())
return table_parameters_ptr();
if (!sources->IsArray())
{
@@ -721,6 +806,9 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
for (uint32_t i = 0; i < sources_array->Length(); ++i)
{
v8::Local<v8::Value> source = sources_array->Get(i);
if (source.IsEmpty())
return table_parameters_ptr();
if (source->IsUint32())
{
size_t source_value = static_cast<size_t>(source->NumberValue());
@@ -744,6 +832,8 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("destinations").ToLocalChecked()))
{
v8::Local<v8::Value> destinations = obj->Get(Nan::New("destinations").ToLocalChecked());
if (destinations.IsEmpty())
return table_parameters_ptr();
if (!destinations->IsArray())
{
@@ -755,6 +845,9 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
for (uint32_t i = 0; i < destinations_array->Length(); ++i)
{
v8::Local<v8::Value> destination = destinations_array->Get(i);
if (destination.IsEmpty())
return table_parameters_ptr();
if (destination->IsUint32())
{
size_t destination_value = static_cast<size_t>(destination->NumberValue());
@@ -798,6 +891,9 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("roundtrip").ToLocalChecked()))
{
auto roundtrip = obj->Get(Nan::New("roundtrip").ToLocalChecked());
if (roundtrip.IsEmpty())
return trip_parameters_ptr();
if (roundtrip->IsBoolean())
{
params->roundtrip = roundtrip->BooleanValue();
@@ -812,6 +908,8 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("source").ToLocalChecked()))
{
v8::Local<v8::Value> source = obj->Get(Nan::New("source").ToLocalChecked());
if (source.IsEmpty())
return trip_parameters_ptr();
if (!source->IsString())
{
@@ -839,6 +937,8 @@ argumentsToTripParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("destination").ToLocalChecked()))
{
v8::Local<v8::Value> destination = obj->Get(Nan::New("destination").ToLocalChecked());
if (destination.IsEmpty())
return trip_parameters_ptr();
if (!destination->IsString())
{
@@ -880,6 +980,8 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
if (obj->Has(Nan::New("timestamps").ToLocalChecked()))
{
v8::Local<v8::Value> timestamps = obj->Get(Nan::New("timestamps").ToLocalChecked());
if (timestamps.IsEmpty())
return match_parameters_ptr();
if (!timestamps->IsArray())
{
@@ -899,6 +1001,9 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
for (uint32_t i = 0; i < timestamps_array->Length(); ++i)
{
v8::Local<v8::Value> timestamp = timestamps_array->Get(i);
if (timestamp.IsEmpty())
return match_parameters_ptr();
if (!timestamp->IsNumber())
{
Nan::ThrowError("Timestamps array items must be numbers");
+22 -26
View File
@@ -1,25 +1,12 @@
{
"name": "osrm",
"version": "5.7.0",
"private": true,
"version": "5.7.0-latest.2",
"private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": {
"chalk": "^1.1.3",
"cucumber": "^1.2.1",
"d3-queue": "^2.0.3",
"mkdirp": "^0.5.1",
"node-timeout": "0.0.4",
"polyline": "^0.2.0",
"request": "^2.69.0",
"rimraf": "^2.5.4",
"xmlbuilder": "^4.2.1",
"nan": "^2.1.0",
"node-cmake": "^1.2.1",
"node-pre-gyp": "~0.6.30"
},
"bin": {
"cucumber": "./node_modules/cucumber/bin/cucumber.js"
"node-pre-gyp": "^0.6.34"
},
"browserify": {
"transform": [
@@ -30,19 +17,16 @@
"scripts": {
"lint": "eslint -c ./.eslintrc features/step_definitions/ features/support/",
"test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld",
"clean-test": "rm -rf test/cache",
"cucumber": "./node_modules/cucumber/bin/cucumber.js",
"build-api-docs": "./scripts/build_api_docs.sh",
"preinstall": "npm install node-pre-gyp",
"clean": "rm -rf test/cache",
"docs": "./scripts/build_api_docs.sh",
"install": "node-pre-gyp install --fallback-to-build=false"
},
"repository": {
"type": "git",
"url": "https://github.com/Project-OSRM/osrm-backend.git"
},
"author": "",
"license": "ISC",
"author": "Project OSRM Team",
"license": "BSD 2-Clause",
"bugs": {
"url": "https://github.com/Project-OSRM/osrm-backend/issues"
},
@@ -51,12 +35,24 @@
"node": ">=4.0.0"
},
"devDependencies": {
"docbox": "^1.0.2",
"docbox": "^1.0.5",
"documentation": "^4.0.0-beta.18",
"eslint": "^2.4.0",
"chalk": "^1.1.3",
"cucumber": "^1.2.1",
"d3-queue": "^2.0.3",
"mkdirp": "^0.5.1",
"aws-sdk": "~2.0.31",
"tape": "^4.2.2"
"tape": "^4.2.2",
"node-timeout": "0.0.4",
"polyline": "^0.2.0",
"request": "^2.69.0",
"rimraf": "^2.5.4",
"xmlbuilder": "^4.2.1"
},
"bundleDependencies": [
"node-pre-gyp"
],
"main": "lib/index.js",
"binary": {
"module_name": "node-osrm",
+3 -1
View File
@@ -1,6 +1,8 @@
api_version = 1
-- Rasterbot profile
properties.force_split_edges = true
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
function node_function (node, result)
@@ -46,7 +48,7 @@ function segment_function (segment)
local scaled_duration = segment.duration
if sourceData.datum ~= invalid and targetData.datum ~= invalid then
local slope = math.abs(sourceData.datum - targetData.datum) / segment.distance
local slope = (targetData.datum - sourceData.datum) / segment.distance
scaled_weight = scaled_weight / (1.0 - (slope * 5.0))
scaled_duration = scaled_duration / (1.0 - (slope * 5.0))
io.write(" slope: " .. slope .. "\n")
+2
View File
@@ -14,6 +14,8 @@ 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
# Clean up previous version
rm -rf build/docs
-99
View File
@@ -1,99 +0,0 @@
#!/usr/bin/env bash
set -eu
set -o pipefail
# defaults
export ENABLE_COVERAGE=${ENABLE_COVERAGE:-"Off"}
export BUILD_TYPE=${BUILD_TYPE:-"Release"}
export NODE=${NODE:-4}
export CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEPS_DIR="$(pwd)/deps"
export PATH=${DEPS_DIR}/bin:${PATH}
mkdir -p ${DEPS_DIR}
export CLANG_VERSION="${CLANG_VERSION:-4.0.0}"
export CCACHE_VERSION=3.3.1
export CMAKE_VERSION=3.7.2
source ${CURRENT_DIR}/travis_helper.sh
# ensure we start inside the root directory (two level up)
cd ${CURRENT_DIR}/../../
if [[ ! $(which wget) ]]; then
echo "echo wget must be installed";
exit 1;
fi;
SYSTEM_NAME=$(uname -s)
if [[ "${SYSTEM_NAME}" == "Darwin" ]]; then
OS_NAME="osx"
elif [[ "${SYSTEM_NAME}" == "Linux" ]]; then
OS_NAME="linux"
fi
# FIXME This should be replaced by proper calls to mason but we currently have a chicken-egg problem
# since we rely on osrm-backend to ship mason for us. Once we merged this into osrm-backend this will not be needed.
CMAKE_URL="https://s3.amazonaws.com/mason-binaries/${OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz"
echo "Downloading cmake from ${CMAKE_URL} ..."
wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR} || exit 1
CCACHE_URL="https://s3.amazonaws.com/mason-binaries/${OS_NAME}-x86_64/ccache/${CCACHE_VERSION}.tar.gz"
echo "Downloading ccache from ${CCACHE_URL} ..."
wget --quiet -O - ${CCACHE_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR} || exit 1
# install clang for linux but use the xcode version on OSX
if [[ "${OS_NAME}" != "osx" ]]; then
CLANG_URL="https://s3.amazonaws.com/mason-binaries/${OS_NAME}-x86_64/clang++/${CLANG_VERSION}.tar.gz"
echo "Downloading clang from ${CLANG_URL} ..."
wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xz -C ${DEPS_DIR} || exit 1
export CCOMPILER='clang'
export CXXCOMPILER='clang++'
export CC='clang'
export CXX='clang++'
fi
if [[ "${OS_NAME}" == "osx" ]]; then
if [[ -f /etc/sysctl.conf ]] && [[ $(grep shmmax /etc/sysctl.conf) ]]; then
echo "Note: found shmmax setting in /etc/sysctl.conf, not modifying"
else
echo "WARNING: Did not find shmmax setting in /etc/sysctl.conf, adding now (requires sudo and restarting)..."
sudo sysctl -w kern.sysv.shmmax=4294967296
sudo sysctl -w kern.sysv.shmall=1048576
sudo sysctl -w kern.sysv.shmseg=128
fi
fi
echo "Now build node-osrm and dependencies"
export VERBOSE=1
if [[ "${ENABLE_COVERAGE}" == "On" ]]; then
mapbox_time "make" make -j4 coverage
else
mkdir -p build
pushd build
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_NODE_BINDINGS=On -DENABLE_MASON=On
mapbox_time "make" make -j4
popd
fi
## run tests, with backtrace support
#if [[ "${OS_NAME}" == "linux" ]]; then
# ulimit -c unlimited -S
# RESULT=0
# mapbox_time "make-test" make tests || RESULT=$?
# for i in $(find ./ -maxdepth 1 -name 'core*' -print);
# do gdb $(which node) $i -ex "thread apply all bt" -ex "set pagination 0" -batch;
# done;
# if [[ ${RESULT} != 0 ]]; then exit $RESULT; fi
#else
# # todo: coredump support on OS X
# RESULT=0
# mapbox_time "make-test" make tests || RESULT=$?
# if [[ ${RESULT} != 0 ]]; then exit $RESULT; fi
#fi
set +eu
set +o pipefail
+21 -39
View File
@@ -3,49 +3,31 @@
set -eu
set -o pipefail
# should be set for debug builds
export NPM_FLAGS=${NPM_FLAGS:-}
if [[ ${PUBLISH} == 'On' ]]; then
echo "PUBLISH is set to '${PUBLISH}', publishing!"
echo "node version is:"
which node
node -v
echo "node version is:"
which node
node -v
echo "dumping binary meta..."
./node_modules/.bin/node-pre-gyp reveal ${NPM_FLAGS}
echo "dumping binary meta..."
./node_modules/.bin/node-pre-gyp reveal
# enforce that binary has proper ORIGIN flags so that
# it can portably find libtbb.so in the same directory
if [[ $(uname -s) == 'Linux' ]]; then
readelf -d ./lib/binding/node-osrm.node > readelf-output.txt
if grep -q 'Flags: ORIGIN' readelf-output.txt; then
echo "Found ORIGIN flag in readelf output"
cat readelf-output.txt
else
echo "*** Error: Could not found ORIGIN flag in readelf output"
cat readelf-output.txt
exit 1
# enforce that binary has proper ORIGIN flags so that
# it can portably find libtbb.so in the same directory
if [[ $(uname -s) == 'Linux' ]]; then
readelf -d ./lib/binding/node-osrm.node > readelf-output.txt
if grep -q 'Flags: ORIGIN' readelf-output.txt; then
echo "Found ORIGIN flag in readelf output"
cat readelf-output.txt
else
echo "*** Error: Could not found ORIGIN flag in readelf output"
cat readelf-output.txt
exit 1
fi
fi
fi
echo "determining publishing status..."
if [[ $(./scripts/travis/is_pr_merge.sh) ]]; then
echo "Skipping publishing because this is a PR merge commit"
./node_modules/.bin/node-pre-gyp package publish info
else
echo "This is a push commit, continuing to package..."
./node_modules/.bin/node-pre-gyp package ${NPM_FLAGS}
export COMMIT_MESSAGE=$(git log --format=%B --no-merges | head -n 1 | tr -d '\n')
echo "Commit message: ${COMMIT_MESSAGE}"
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
echo "Publishing"
./node_modules/.bin/node-pre-gyp publish ${NPM_FLAGS}
elif [[ ${COMMIT_MESSAGE} =~ "[republish binary]" ]]; then
echo "*** Error: Republishing is disallowed for this repository"
exit 1
#./node_modules/.bin/node-pre-gyp unpublish publish ${NPM_FLAGS}
else
echo "Skipping publishing"
fi;
echo "PUBLISH is set to '${PUBLISH}', skipping."
fi
+14 -11
View File
@@ -388,21 +388,24 @@ void ExtractionContainers::PrepareEdges(ScriptingEnvironment &scripting_environm
BOOST_ASSERT(edge_iterator->source_coordinate.lon !=
util::FixedLongitude{std::numeric_limits<std::int32_t>::min()});
const util::Coordinate target_coord{node_iterator->lon, node_iterator->lat};
const double distance = util::coordinate_calculation::greatCircleDistance(
edge_iterator->source_coordinate, target_coord);
util::Coordinate source_coord(edge_iterator->source_coordinate);
util::Coordinate target_coord{node_iterator->lon, node_iterator->lat};
auto weight = edge_iterator->weight_data(distance);
auto duration = edge_iterator->duration_data(distance);
// flip source and target coordinates if segment is in backward direction only
if (!edge_iterator->result.forward && edge_iterator->result.backward)
std::swap(source_coord, target_coord);
ExtractionSegment extracted_segment(
edge_iterator->source_coordinate, target_coord, distance, weight, duration);
scripting_environment.ProcessSegment(extracted_segment);
const auto distance =
util::coordinate_calculation::greatCircleDistance(source_coord, target_coord);
const auto weight = edge_iterator->weight_data(distance);
const auto duration = edge_iterator->duration_data(distance);
ExtractionSegment segment(source_coord, target_coord, distance, weight, duration);
scripting_environment.ProcessSegment(segment);
auto &edge = edge_iterator->result;
edge.weight =
std::max<EdgeWeight>(1, std::round(extracted_segment.weight * weight_multiplier));
edge.duration = std::max<EdgeWeight>(1, std::round(extracted_segment.duration * 10.));
edge.weight = std::max<EdgeWeight>(1, std::round(segment.weight * weight_multiplier));
edge.duration = std::max<EdgeWeight>(1, std::round(segment.duration * 10.));
// assign new node id
auto id_iter = external_to_internal_node_id_map.find(node_iterator->node_id);
+12 -9
View File
@@ -35,7 +35,9 @@ namespace TurnLaneType = guidance::TurnLaneType;
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers_,
const ProfileProperties &properties)
: external_memory(extraction_containers_), fallback_to_duration(properties.fallback_to_duration)
: external_memory(extraction_containers_),
fallback_to_duration(properties.fallback_to_duration),
force_split_edges(properties.force_split_edges)
{
// we reserved 0, 1, 2, 3 for the empty case
string_map[MapKey("", "", "", "")] = 0;
@@ -323,14 +325,15 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE);
// split an edge into two edges if forwards/backwards behavior differ
const bool split_edge = in_forward_direction && in_backward_direction &&
((parsed_way.forward_rate != parsed_way.backward_rate) ||
(parsed_way.forward_speed != parsed_way.backward_speed) ||
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode) ||
(turn_lane_id_forward != turn_lane_id_backward));
const bool split_edge =
in_forward_direction && in_backward_direction &&
(force_split_edges || (parsed_way.forward_rate != parsed_way.backward_rate) ||
(parsed_way.forward_speed != parsed_way.backward_speed) ||
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode) ||
(turn_lane_id_forward != turn_lane_id_backward));
if (in_forward_direction)
{
{ // add (forward) segments or (forward,backward) for non-split edges in backward direction
util::for_each_pair(
nodes.cbegin(),
nodes.cend(),
@@ -355,8 +358,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
});
}
if (in_backward_direction || split_edge)
{
if (in_backward_direction && (!in_forward_direction || split_edge))
{ // add (backward) segments for split edges or not in forward direction
util::for_each_pair(
nodes.cbegin(),
nodes.cend(),
+20 -11
View File
@@ -247,7 +247,9 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"weight_name",
sol::property(&ProfileProperties::SetWeightName, &ProfileProperties::GetWeightName),
"max_turn_weight",
sol::property(&ProfileProperties::GetMaxTurnWeight));
sol::property(&ProfileProperties::GetMaxTurnWeight),
"force_split_edges",
&ProfileProperties::force_split_edges);
context.state.new_usertype<std::vector<std::string>>(
"vector",
@@ -330,12 +332,6 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property(&ExtractionWay::GetTurnLanesForward, &ExtractionWay::SetTurnLanesForward),
"turn_lanes_backward",
sol::property(&ExtractionWay::GetTurnLanesBackward, &ExtractionWay::SetTurnLanesBackward),
"roundabout",
&ExtractionWay::roundabout,
"circular",
&ExtractionWay::circular,
"is_startpoint",
&ExtractionWay::is_startpoint,
"duration",
&ExtractionWay::duration,
"weight",
@@ -343,13 +339,26 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"road_classification",
&ExtractionWay::road_classification,
"forward_mode",
sol::property(&ExtractionWay::get_forward_mode, &ExtractionWay::set_forward_mode),
sol::property([](const ExtractionWay &way) { return way.forward_travel_mode; },
[](ExtractionWay &way, TravelMode mode) { way.forward_travel_mode = mode; }),
"backward_mode",
sol::property(&ExtractionWay::get_backward_mode, &ExtractionWay::set_backward_mode),
sol::property([](const ExtractionWay &way) { return way.backward_travel_mode; },
[](ExtractionWay &way, TravelMode mode) { way.backward_travel_mode = mode; }),
"roundabout",
sol::property([](const ExtractionWay &way) { return way.roundabout; },
[](ExtractionWay &way, bool flag) { way.roundabout = flag; }),
"circular",
sol::property([](const ExtractionWay &way) { return way.circular; },
[](ExtractionWay &way, bool flag) { way.circular = flag; }),
"is_startpoint",
sol::property([](const ExtractionWay &way) { return way.is_startpoint; },
[](ExtractionWay &way, bool flag) { way.is_startpoint = flag; }),
"forward_restricted",
&ExtractionWay::forward_restricted,
sol::property([](const ExtractionWay &way) { return way.forward_restricted; },
[](ExtractionWay &way, bool flag) { way.forward_restricted = flag; }),
"backward_restricted",
&ExtractionWay::backward_restricted);
sol::property([](const ExtractionWay &way) { return way.backward_restricted; },
[](ExtractionWay &way, bool flag) { way.backward_restricted = flag; }));
context.state.new_usertype<ExtractionSegment>("ExtractionSegment",
"source",
+1 -1
View File
@@ -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
View File
@@ -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)
*
*/
+36 -4
View File
@@ -1,6 +1,8 @@
var OSRM = require('../../');
var test = require('tape');
var berlin_path = require('./osrm-data-path').data_path;
var berlin_mld_path = require('./osrm-data-path').mld_data_path;
var berlin_corech_path = require('./osrm-data-path').corech_data_path;
test('constructor: throws if new keyword is not used', function(assert) {
assert.plan(1);
@@ -23,7 +25,7 @@ test('constructor: does not accept more than one parameter', function(assert) {
test('constructor: throws if necessary files do not exist', function(assert) {
assert.plan(1);
assert.throws(function() { new OSRM("missing.osrm"); },
/Invalid file paths/);
/Error opening missing.osrm.names/);
});
test('constructor: takes a shared memory argument', function(assert) {
@@ -34,22 +36,52 @@ test('constructor: takes a shared memory argument', function(assert) {
test('constructor: throws if shared_memory==false with no path defined', function(assert) {
assert.plan(1);
assert.throws(function() { var osrm = new OSRM({shared_memory: false}); },
assert.throws(function() { new OSRM({shared_memory: false}); },
/Shared_memory must be enabled if no path is specified/);
});
test('constructor: throws if given a non-bool shared_memory option', function(assert) {
assert.plan(1);
assert.throws(function() { var osrm = new OSRM({path: berlin_path, shared_memory: "a"}); },
assert.throws(function() { new OSRM({path: berlin_path, shared_memory: 'a'}); },
/Shared_memory option must be a boolean/);
});
test('constructor: throws if given a non-string/obj argument', function(assert) {
assert.plan(1);
assert.throws(function() { var osrm = new OSRM(true); },
assert.throws(function() { new OSRM(true); },
/Parameter must be a path or options object/);
});
test('constructor: throws if given an unkown algorithm', function(assert) {
assert.plan(1);
assert.throws(function() { new OSRM({algorithm: 'Foo', shared_memory: true}); },
/algorithm option must be one of 'CH', 'CoreCH', or 'MLD'/);
});
test('constructor: throws if given an invalid algorithm', function(assert) {
assert.plan(1);
assert.throws(function() { new OSRM({algorithm: 3, shared_memory: true}); },
/algorithm option must be a string and one of 'CH', 'CoreCH', or 'MLD'/);
});
test('constructor: loads MLD if given as algorithm', function(assert) {
assert.plan(1);
var osrm = new OSRM({algorithm: 'MLD', path: berlin_mld_path});
assert.ok(osrm);
});
test('constructor: loads CH if given as algorithm', function(assert) {
assert.plan(1);
var osrm = new OSRM({algorithm: 'CH', path: berlin_path});
assert.ok(osrm);
});
test('constructor: loads CoreCH if given as algorithm', function(assert) {
assert.plan(1);
var osrm = new OSRM({algorithm: 'CoreCH', path: berlin_corech_path});
assert.ok(osrm);
});
require('./route.js');
require('./trip.js');
require('./match.js');
+4
View File
@@ -2,7 +2,11 @@ var path = require('path');
if (process.env.OSRM_DATA_PATH !== undefined) {
exports.data_path = path.join(path.resolve(process.env.OSRM_DATA_PATH), "ch/berlin.osrm");
exports.mld_data_path = path.join(path.resolve(process.env.OSRM_DATA_PATH), "mld/berlin.osrm");
exports.corech_data_path = path.join(path.resolve(process.env.OSRM_DATA_PATH), "corech/berlin.osrm");
console.log('Setting custom data path to ' + exports.data_path);
} else {
exports.data_path = path.resolve(path.join(__dirname, "../data/ch/berlin.osrm"));
exports.mld_data_path = path.resolve(path.join(__dirname, "../data/mld/berlin.osrm"));
exports.corech_data_path = path.resolve(path.join(__dirname, "../data/corech/berlin.osrm"));
}
+26
View File
@@ -1,6 +1,8 @@
var OSRM = require('../../');
var test = require('tape');
var berlin_path = require('./osrm-data-path').data_path;
var berlin_mld_path = require('./osrm-data-path').mld_data_path;
var berlin_corech_path = require('./osrm-data-path').corech_data_path;
test('route: routes Berlin', function(assert) {
assert.plan(5);
@@ -14,6 +16,30 @@ test('route: routes Berlin', function(assert) {
});
});
test('route: routes Berlin on MLD', function(assert) {
assert.plan(5);
var osrm = new OSRM({path: berlin_mld_path, algorithm: 'MLD'});
osrm.route({coordinates: [[13.43864,52.51993],[13.415852,52.513191]]}, function(err, route) {
assert.ifError(err);
assert.ok(route.waypoints);
assert.ok(route.routes);
assert.ok(route.routes.length);
assert.ok(route.routes[0].geometry);
});
});
test('route: routes Berlin on CoreCH', function(assert) {
assert.plan(5);
var osrm = new OSRM({path: berlin_corech_path, algorithm: 'CoreCH'});
osrm.route({coordinates: [[13.43864,52.51993],[13.415852,52.513191]]}, function(err, route) {
assert.ifError(err);
assert.ok(route.waypoints);
assert.ok(route.routes);
assert.ok(route.routes.length);
assert.ok(route.routes[0].geometry);
});
});
test('route: throws with too few or invalid args', function(assert) {
assert.plan(3);
var osrm = new OSRM(berlin_path);
+6179
View File
File diff suppressed because it is too large Load Diff