Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd69986976 | |||
| c49fd202d0 | |||
| 49e40ee621 | |||
| a89d0e616f | |||
| 986252c4f9 | |||
| aed7df6173 | |||
| e3b09875c6 |
@@ -728,7 +728,7 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
|
||||
if (acceleration_profile.IsEmpty())
|
||||
return false;
|
||||
|
||||
if (!acceleration_profile->IsNumber() || !acceleration_profile->IsString())
|
||||
if (!acceleration_profile->IsNumber() && !acceleration_profile->IsString())
|
||||
{
|
||||
Nan::ThrowError("acceleration_profile must be a decimal number or one of 'car', 'fast_car', 'slow_car', 'truck', or 'tractor_trailer'");
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.21.0-customsnapping.7",
|
||||
"version": "5.21.0-customsnapping.11",
|
||||
"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": {
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "node ./node_modules/eslint/bin/eslint.js -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 verify -m mmap && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld && node ./node_modules/cucumber/bin/cucumber.js features/ -p mld -m mmap",
|
||||
"test": "npm run lint && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify && node ./node_modules/cucumber/bin/cucumber.js features/ -p verify -m mmap",
|
||||
"clean": "rm -rf test/cache",
|
||||
"docs": "./scripts/build_api_docs.sh",
|
||||
"install": "node-pre-gyp install --fallback-to-build=false || ./scripts/node_install.sh",
|
||||
|
||||
@@ -112,7 +112,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
// here, but tiny numbers is what this adjustment lambda is all about,
|
||||
// so we do try to be reasonable.
|
||||
const auto average_speed =
|
||||
duration == 0 ? 10 : distance /
|
||||
duration == 0 ? 10 : std::abs(distance) /
|
||||
(duration / 10.); // duration is in deciseconds, we need m/sec
|
||||
|
||||
// The following reference has a nice model (equations 9 through 12)
|
||||
@@ -141,7 +141,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
|
||||
BOOST_ASSERT(distance_to_full_speed >= 0);
|
||||
|
||||
if (distance_to_full_speed > distance / 2)
|
||||
if (distance_to_full_speed > std::abs(distance) / 2)
|
||||
{
|
||||
// Because equation 12 requires velocity at halfway, and
|
||||
// solving equation 11 for t requires a Lambert W function,
|
||||
@@ -149,13 +149,13 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
// over distance_to_full_speed using s = ut + 1/2at^2
|
||||
const auto average_acceleration =
|
||||
2 * distance_to_full_speed / (time_to_full_speed * time_to_full_speed);
|
||||
const auto time_to_halfway = std::sqrt(distance / average_acceleration);
|
||||
const auto time_to_halfway = std::sqrt(std::abs(distance) / average_acceleration);
|
||||
BOOST_ASSERT(time_to_halfway >= 0);
|
||||
return (2 * time_to_halfway) * 10; // result is in deciseconds
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto cruising_distance = distance - 2 * distance_to_full_speed;
|
||||
const auto cruising_distance = std::abs(distance) - 2 * distance_to_full_speed;
|
||||
const auto cruising_time = cruising_distance / average_speed;
|
||||
BOOST_ASSERT(cruising_time >= 0);
|
||||
return (cruising_time + 2 * time_to_full_speed) * 10; // result is in deciseconds
|
||||
|
||||
+18
-18
@@ -319,44 +319,44 @@ tables.forEach(function(annotation) {
|
||||
|
||||
});
|
||||
|
||||
test('table: ' + annotation + ' table in Monaco with start_stop_acceleration_factor values', function(assert) {
|
||||
test('table: ' + annotation + ' table in Monaco with acceleration_profile values', function(assert) {
|
||||
assert.plan(12);
|
||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||
var options = {
|
||||
coordinates: two_test_coordinates,
|
||||
annotations: [annotation.slice(0,-1)],
|
||||
start_stop_acceleration_factor: []
|
||||
acceleration_profile: []
|
||||
};
|
||||
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /start_stop_acceleration_factor must be a decimal number or one of/, "should throw on empty array");
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on empty array");
|
||||
|
||||
options.start_stop_acceleration_factor = 'a';
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /start_stop_acceleration_factor must be a decimal number or one of/, "should throw on non-numeric value");
|
||||
options.acceleration_profile = 'a';
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
||||
|
||||
options.start_stop_acceleration_factor = [1];
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /start_stop_acceleration_factor must be a decimal number or one of/, "should throw on non-numeric value");
|
||||
options.acceleration_profile = [1];
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-numeric value");
|
||||
|
||||
options.start_stop_acceleration_factor = -0.1;
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /start_stop_acceleration_factor must be a decimal number or one of/, "should throw on non-numeric value");
|
||||
options.acceleration_profile = -0.1;
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile cannot be negative/, "should throw on non-numeric value");
|
||||
|
||||
options.start_stop_acceleration_factor = 0.;
|
||||
options.acceleration_profile = 0.;
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "should work with zero");
|
||||
|
||||
options.start_stop_acceleration_factor = 2.0;
|
||||
options.acceleration_profile = 2.0;
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with positive numeric values");
|
||||
options.start_stop_acceleration_factor = 'car';
|
||||
options.acceleration_profile = 'car';
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with car defaults");
|
||||
options.start_stop_acceleration_factor = 'fast_car';
|
||||
options.acceleration_profile = 'fast_car';
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with fast car defaults");
|
||||
options.start_stop_acceleration_factor = 'slow_car';
|
||||
options.acceleration_profile = 'slow_car';
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with slow car defaults");
|
||||
options.start_stop_acceleration_factor = 'truck';
|
||||
options.acceleration_profile = 'truck';
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with truck defaults");
|
||||
options.start_stop_acceleration_factor = 'tractor_trailer';
|
||||
options.acceleration_profile = 'tractor_trailer';
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "Should work with tractor trailer defaults");
|
||||
|
||||
options.start_stop_acceleration_factor = 'yes';
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /start_stop_acceleration_factor must be a decimal number or one of/, "should throw on non-recognized string");
|
||||
options.acceleration_profile = 'yes';
|
||||
assert.throws(()=>osrm.table(options, (err, res) => {}), /acceleration_profile must be a decimal number or one of/, "should throw on non-recognized string");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user