From 364e35af069856b427d7dc3bd4b73b37f961aa7c Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Fri, 2 Nov 2018 01:06:54 -0700 Subject: [PATCH] Remove estimated_cells value in the response. --- docs/http.md | 5 --- docs/nodejs/api.md | 1 - features/step_definitions/distance_matrix.js | 32 +++++--------------- features/testbot/duration_matrix.feature | 7 ----- include/engine/api/table_api.hpp | 28 ----------------- src/engine/plugins/table.cpp | 6 +--- test/nodejs/table.js | 6 ++-- 7 files changed, 10 insertions(+), 75 deletions(-) diff --git a/docs/http.md b/docs/http.md index 78f9ba459..cd4fb9885 100644 --- a/docs/http.md +++ b/docs/http.md @@ -284,7 +284,6 @@ curl 'http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397 the i-th waypoint to the j-th waypoint. Values are given in meters. Can be `null` if no route between `i` and `j` can be found. Note that computing the `distances` table is currently only implemented for CH. If `annotations=distance` or `annotations=duration,distance` is requested when running a MLD router, a `NotImplemented` error will be returned. - `sources` array of `Waypoint` objects describing all sources in order - `destinations` array of `Waypoint` objects describing all destinations in order -- `estimated_cells` (optional) array of arrays containing `i,j` pairs indicating which cells contain estimated values based on `fallback_speed`. Will be absent if `fallback_speed` is not used. In case of error the following `code`s are supported in addition to the general ones: @@ -385,10 +384,6 @@ All other properties might be undefined. 2361.73, 0 ] - ], - "estimated_cells": [ - [ 0, 1 ], - [ 1, 0 ] ] } ``` diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index e7bb6e9de..1f9765e08 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -156,7 +156,6 @@ Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer 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. -**`estimated_cells`**: (optional) if `fallback_speed` is used, will be an array of arrays of `row,column` values, indicating which cells contain estimated values. ### tile diff --git a/features/step_definitions/distance_matrix.js b/features/step_definitions/distance_matrix.js index aac4f3183..fde80679f 100644 --- a/features/step_definitions/distance_matrix.js +++ b/features/step_definitions/distance_matrix.js @@ -3,25 +3,22 @@ var util = require('util'); module.exports = function () { const durationsRegex = new RegExp(/^I request a travel time matrix I should get$/); const distancesRegex = new RegExp(/^I request a travel distance matrix I should get$/); - const estimatesRegex = new RegExp(/^I request a travel time matrix I should get estimates for$/); const DURATIONS_NO_ROUTE = 2147483647; // MAX_INT const DISTANCES_NO_ROUTE = 3.40282e+38; // MAX_FLOAT this.When(durationsRegex, function(table, callback) {tableParse.call(this, table, DURATIONS_NO_ROUTE, 'durations', callback);}.bind(this)); this.When(distancesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'distances', callback);}.bind(this)); - this.When(estimatesRegex, function(table, callback) {tableParse.call(this, table, DISTANCES_NO_ROUTE, 'estimated_cells', callback);}.bind(this)); }; const durationsParse = function(v) { return isNaN(parseInt(v)); }; const distancesParse = function(v) { return isNaN(parseFloat(v)); }; -const estimatesParse = function(v) { return isNaN(parseFloat(v)); }; function tableParse(table, noRoute, annotation, callback) { - const parse = annotation == 'distances' ? distancesParse : (annotation == 'durations' ? durationsParse : estimatesParse); + const parse = annotation == 'distances' ? distancesParse : durationsParse; const params = this.queryParams; - params.annotations = ['durations','estimated_cells'].includes(annotation) ? 'duration' : 'distance'; + params.annotations = annotation == 'distances' ? 'distance' : 'duration'; var tableRows = table.raw(); @@ -64,26 +61,11 @@ function tableParse(table, noRoute, annotation, callback) { var json = JSON.parse(response.body); - var result = {}; - if (annotation === 'estimated_cells') { - result = table.raw().map(row => row.map(cell => '')); - json[annotation].forEach(pair => { - result[pair[0]+1][pair[1]+1] = 'Y'; - }); - result = result.slice(1).map(row => { - var hashes = {}; - row.slice(1).forEach((v,i) => { - hashes[tableRows[0][i+1]] = v; - }); - return hashes; - }); - } else { - result = json[annotation].map(row => { - var hashes = {}; - row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; }); - return hashes; - }); - } + var result = json[annotation].map(row => { + var hashes = {}; + row.forEach((v, i) => { hashes[tableRows[0][i+1]] = parse(v) ? '' : v; }); + return hashes; + }); var testRow = (row, ri, cb) => { for (var k in result[ri]) { diff --git a/features/testbot/duration_matrix.feature b/features/testbot/duration_matrix.feature index b3c65d364..629a9f3f9 100644 --- a/features/testbot/duration_matrix.feature +++ b/features/testbot/duration_matrix.feature @@ -534,13 +534,6 @@ Feature: Basic Duration Matrix | f | 18 | 12 | 0 | 30 | | 1 | 30 | 24 | 30 | 0 | - When I request a travel time matrix I should get estimates for - | | a | b | f | 1 | - | a | | | Y | Y | - | b | | | Y | Y | - | f | Y | Y | | | - | 1 | Y | Y | | | - Scenario: Testbot - Filling in noroutes with estimates - use input coordinate Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 4667482e6..7f8cb7706 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -31,15 +31,6 @@ namespace api class TableAPI final : public BaseAPI { public: - struct TableCellRef - { - TableCellRef(const std::size_t &row, const std::size_t &column) : row{row}, column{column} - { - } - std::size_t row; - std::size_t column; - }; - TableAPI(const datafacade::BaseDataFacade &facade_, const TableParameters ¶meters_) : BaseAPI(facade_, parameters_), parameters(parameters_) { @@ -48,7 +39,6 @@ class TableAPI final : public BaseAPI virtual void MakeResponse(const std::pair, std::vector> &tables, const std::vector &phantoms, - const std::vector &estimated_cells, util::json::Object &response) const { auto number_of_sources = parameters.sources.size(); @@ -87,11 +77,6 @@ class TableAPI final : public BaseAPI MakeDistanceTable(tables.second, number_of_sources, number_of_destinations); } - if (parameters.fallback_speed > 0) - { - response.values["estimated_cells"] = MakeEstimatesTable(estimated_cells); - } - response.values["code"] = "Ok"; } @@ -178,19 +163,6 @@ class TableAPI final : public BaseAPI return json_table; } - virtual util::json::Array - MakeEstimatesTable(const std::vector &estimated_cells) const - { - util::json::Array json_table; - std::for_each(estimated_cells.begin(), estimated_cells.end(), [&](const auto &cell) { - util::json::Array row; - row.values.push_back(util::json::Number(cell.row)); - row.values.push_back(util::json::Number(cell.column)); - json_table.values.push_back(std::move(row)); - }); - return json_table; - } - const TableParameters ¶meters; }; diff --git a/src/engine/plugins/table.cpp b/src/engine/plugins/table.cpp index 41c3ebd5d..d1d7786ee 100644 --- a/src/engine/plugins/table.cpp +++ b/src/engine/plugins/table.cpp @@ -95,8 +95,6 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, return Error("NoTable", "No table found", result); } - std::vector estimated_pairs; - // Scan table for null results - if any exist, replace with distance estimates if (params.fallback_speed > 0) { @@ -127,15 +125,13 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, { result_tables_pair.second[table_index] = distance_estimate; } - - estimated_pairs.emplace_back(row, column); } } } } api::TableAPI table_api{facade, params}; - table_api.MakeResponse(result_tables_pair, snapped_phantoms, estimated_pairs, result); + table_api.MakeResponse(result_tables_pair, snapped_phantoms, result); return Status::Ok; } diff --git a/test/nodejs/table.js b/test/nodejs/table.js index c8f888438..e8142e6bc 100644 --- a/test/nodejs/table.js +++ b/test/nodejs/table.js @@ -234,7 +234,7 @@ tables.forEach(function(annotation) { }); test('table: ' + annotation + ' table in Monaco without motorways', function(assert) { - assert.plan(2); + assert.plan(1); var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); var options = { coordinates: two_test_coordinates, @@ -243,12 +243,11 @@ tables.forEach(function(annotation) { }; osrm.table(options, function(err, response) { assert.equal(response[annotation].length, 2); - assert.strictEqual(response.estimated_cells, undefined); }); }); test('table: ' + annotation + ' table in Monaco with fallback speeds', function(assert) { - assert.plan(2); + assert.plan(1); var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); var options = { coordinates: two_test_coordinates, @@ -258,7 +257,6 @@ tables.forEach(function(annotation) { }; osrm.table(options, function(err, response) { assert.equal(response[annotation].length, 2); - assert.equal(response['estimated_cells'].length, 0); }); });