diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index 72bee7ce7..6ffea408b 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -1077,6 +1077,8 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo &args, return table_parameters_ptr(); } + params->annotations = osrm::TableParameters::AnnotationsType::None; + v8::Local annotations_array = v8::Local::Cast(annotations); for (std::size_t i = 0; i < annotations_array->Length(); ++i) { diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index d0c82091a..e10b5461a 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -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); diff --git a/test/nodejs/table.js b/test/nodejs/table.js index f053001ec..28164f99c 100644 --- a/test/nodejs/table.js +++ b/test/nodejs/table.js @@ -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'];