Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 986252c4f9 | |||
| aed7df6173 | |||
| e3b09875c6 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrm",
|
||||
"version": "5.21.0-customsnapping.7",
|
||||
"version": "5.21.0-customsnapping.9",
|
||||
"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": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -325,19 +325,19 @@ tables.forEach(function(annotation) {
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
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.;
|
||||
assert.ok(()=>osrm.table(options, (err, res) => {}), "should work with zero");
|
||||
@@ -356,7 +356,7 @@ tables.forEach(function(annotation) {
|
||||
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");
|
||||
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