fix incorrect parameter parsing for node osrm and add tests
This commit is contained in:
parent
14860b62e9
commit
4dbe65b37d
@ -1077,6 +1077,8 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
|
||||
return table_parameters_ptr();
|
||||
}
|
||||
|
||||
params->annotations = osrm::TableParameters::AnnotationsType::None;
|
||||
|
||||
v8::Local<v8::Array> annotations_array = v8::Local<v8::Array>::Cast(annotations);
|
||||
for (std::size_t i = 0; i < annotations_array->Length(); ++i)
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
auto result_tables_pair = algorithms.ManyToManySearch(
|
||||
snapped_phantoms, params.sources, params.destinations, request_distance, request_duration);
|
||||
|
||||
if ((request_duration & result_tables_pair.first.empty()) ||
|
||||
if ((request_duration && result_tables_pair.first.empty()) ||
|
||||
(request_distance && result_tables_pair.second.empty()))
|
||||
{
|
||||
return Error("NoTable", "No table found", result);
|
||||
|
||||
@ -5,6 +5,48 @@ var mld_data_path = require('./constants').mld_data_path;
|
||||
var three_test_coordinates = require('./constants').three_test_coordinates;
|
||||
var two_test_coordinates = require('./constants').two_test_coordinates;
|
||||
|
||||
test('table: test annotations paramater combination', function(assert) {
|
||||
assert.plan(12);
|
||||
var osrm = new OSRM(data_path);
|
||||
var options = {
|
||||
coordinates: [three_test_coordinates[0], three_test_coordinates[1]],
|
||||
annotations: ['distance']
|
||||
};
|
||||
osrm.table(options, function(err, table) {
|
||||
assert.ifError(err);
|
||||
assert.ok(table['distances'], 'distances table result should exist');
|
||||
assert.notOk(table['durations'], 'durations table result should not exist');
|
||||
});
|
||||
|
||||
options = {
|
||||
coordinates: [three_test_coordinates[0], three_test_coordinates[1]],
|
||||
annotations: ['duration']
|
||||
};
|
||||
osrm.table(options, function(err, table) {
|
||||
assert.ifError(err);
|
||||
assert.ok(table['durations'], 'durations table result should exist');
|
||||
assert.notOk(table['distances'], 'distances table result should not exist');
|
||||
});
|
||||
|
||||
options = {
|
||||
coordinates: [three_test_coordinates[0], three_test_coordinates[1]],
|
||||
annotations: ['duration', 'distance']
|
||||
};
|
||||
osrm.table(options, function(err, table) {
|
||||
assert.ifError(err);
|
||||
assert.ok(table['durations'], 'durations table result should exist');
|
||||
assert.ok(table['distances'], 'distances table result should exist');
|
||||
});
|
||||
|
||||
options = {
|
||||
coordinates: [three_test_coordinates[0], three_test_coordinates[1]]
|
||||
};
|
||||
osrm.table(options, function(err, table) {
|
||||
assert.ifError(err);
|
||||
assert.ok(table['durations'], 'durations table result should exist');
|
||||
assert.notOk(table['distances'], 'distances table result should not exist');
|
||||
});
|
||||
});
|
||||
|
||||
var tables = ['distances', 'durations'];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user