From f65299d665e78365f9eab87ded4394fec3183702 Mon Sep 17 00:00:00 2001 From: FILLAU Jean-Maxime Date: Mon, 22 May 2017 16:07:12 +0200 Subject: [PATCH] Rename side API Side -> Approach - DEFAULT -> CURB - BOTH -> UNRESTRICTED - remove OPPOSITE param Signed-off-by: FILLAU Jean-Maxime --- CMakeLists.txt | 2 +- features/support/route.js | 12 +- features/support/shared_steps.js | 22 +- features/testbot/approach_param.feature | 192 ++++++++++++++ features/testbot/side_param.feature | 245 ------------------ include/engine/api/base_parameters.hpp | 12 +- include/engine/{side.hpp => approach.hpp} | 11 +- .../contiguous_internalmem_datafacade.hpp | 6 +- include/engine/datafacade/datafacade_base.hpp | 4 +- include/engine/geospatial_query.hpp | 18 +- include/engine/plugins/plugin_base.hpp | 10 +- .../server/api/base_parameters_grammar.hpp | 14 +- src/server/service/route_service.cpp | 2 +- unit_tests/mocks/mock_datafacade.hpp | 2 +- unit_tests/server/parameters_io.hpp | 6 +- unit_tests/server/parameters_parser.cpp | 44 ++-- 16 files changed, 272 insertions(+), 330 deletions(-) create mode 100644 features/testbot/approach_param.feature delete mode 100644 features/testbot/side_param.feature rename include/engine/{side.hpp => approach.hpp} (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f23fb28a..173576c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -728,7 +728,7 @@ set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE) file(GLOB VariantGlob third_party/variant/include/mapbox/*.hpp) file(GLOB LibraryGlob include/osrm/*.hpp) file(GLOB ParametersGlob include/engine/api/*_parameters.hpp) -set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/side.hpp include/engine/phantom_node.hpp) +set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp) set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp) set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) set(PartitionerHeader include/partition/partitioner.hpp include/partition/partition_config.hpp) diff --git a/features/support/route.js b/features/support/route.js index b5e108cce..5bee6dac1 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -46,9 +46,9 @@ module.exports = function () { return waypoints.map(w => [w.lon, w.lat].map(ensureDecimal).join(',')); }; - this.requestRoute = (waypoints, bearings, sides, userParams, callback) => { + this.requestRoute = (waypoints, bearings, approaches, userParams, callback) => { if (bearings.length && bearings.length !== waypoints.length) throw new Error('*** number of bearings does not equal the number of waypoints'); - if (sides.length && sides.length !== waypoints.length) throw new Error('*** number of sides does not equal the number of waypoints'); + if (approaches.length && approaches.length !== waypoints.length) throw new Error('*** number of approaches does not equal the number of waypoints'); var defaults = { output: 'json', @@ -68,8 +68,8 @@ module.exports = function () { }).join(';'); } - if (sides.length) { - params.sides = sides.join(';'); + if (approaches.length) { + params.approaches = approaches.join(';'); } return this.requestPath('route', params, callback); }; @@ -167,8 +167,8 @@ module.exports = function () { ('out' in s.intersections[0] ? s.intersections[0].bearings[s.intersections[0].out] : 0)); }; - this.sideList = (instructions) => { - return this.extractInstructionList(instructions, s => s.sides || ''); + this.approachList = (instructions) => { + return this.extractInstructionList(instructions, s => s.approaches || ''); }; this.annotationList = (instructions) => { diff --git a/features/support/shared_steps.js b/features/support/shared_steps.js index c87d21a93..d56dbc4d4 100644 --- a/features/support/shared_steps.js +++ b/features/support/shared_steps.js @@ -35,7 +35,7 @@ module.exports = function () { if (err) return cb(err); if (body && body.length) { let destinations, pronunciations, instructions, refs, bearings, turns, modes, times, - distances, summary, intersections, lanes, locations, annotation, weight_name, weights, sides; + distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches; let json = JSON.parse(body); @@ -60,7 +60,7 @@ module.exports = function () { annotation = this.annotationList(json.routes[0]); weight_name = this.weightName(json.routes[0]); weights = this.weightList(json.routes[0]); - sides = this.sideList(json.routes[0]); + approaches = this.approachList(json.routes[0]); } if (headers.has('status')) { @@ -148,8 +148,8 @@ module.exports = function () { got.locations = (locations || '').trim(); } /* - if (headers.has('sides')){ - got.sides = (sides || '').trim(); + if (headers.has('approaches')){ + got.approaches = (approaches || '').trim(); }*/ // if header matches 'a:*', parse out the values for * // and return in that header @@ -180,7 +180,7 @@ module.exports = function () { putValue('weight_name', weight_name); putValue('weights', weights); putValue('weight', weight); - putValue('side', sides); + putValue('approach', approaches); for (var key in row) { if (this.FuzzyMatch.match(got[key], row[key])) { @@ -216,16 +216,16 @@ module.exports = function () { var params = this.overwriteParams(defaultParams, userParams), waypoints = [], bearings = [], - sides = []; + approaches = []; if (row.bearings) { got.bearings = row.bearings; bearings = row.bearings.split(' ').filter(b => !!b); } - if (row.sides) { - got.sides = row.sides; - sides = row.sides.split(' ').filter(b => !!b); + if (row.approaches) { + got.approaches = row.approaches; + approaches = row.approaches.split(' ').filter(b => !!b); } if (row.from && row.to) { @@ -239,7 +239,7 @@ module.exports = function () { got.from = row.from; got.to = row.to; - this.requestRoute(waypoints, bearings, sides, params, afterRequest); + this.requestRoute(waypoints, bearings, approaches, params, afterRequest); } else if (row.waypoints) { row.waypoints.split(',').forEach((n) => { var node = this.findNodeByName(n.trim()); @@ -247,7 +247,7 @@ module.exports = function () { waypoints.push(node); }); got.waypoints = row.waypoints; - this.requestRoute(waypoints, bearings, sides, params, afterRequest); + this.requestRoute(waypoints, bearings, approaches, params, afterRequest); } else { return cb(new Error('*** no waypoints')); } diff --git a/features/testbot/approach_param.feature b/features/testbot/approach_param.feature new file mode 100644 index 000000000..2ecfa50e1 --- /dev/null +++ b/features/testbot/approach_param.feature @@ -0,0 +1,192 @@ +@routing @approach_param @testbot +Feature: Approach parameter + + Background: + Given the profile "car" + And a grid size of 10 meters + + Scenario: Testbot - Start End same approach, option unrestricted for Start and End + Given the node map + """ + s e + a------b------c + """ + + And the ways + | nodes | + | ab | + | bc | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted unrestricted | ab,bc | + + Scenario: Testbot - Start End same approach, option unrestricted for Start and curb for End + Given the node map + """ + s e + a------b------c + """ + + And the ways + | nodes | + | ab | + | bc | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | ab,bc,bc | + + Scenario: Testbot - Start End opposite approach, option unrestricted for Start and End + Given the node map + """ + s + a------b------c + e + """ + + And the ways + | nodes | + | ab | + | bc | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted unrestricted | ab,bc | + + Scenario: Testbot - Start End opposite approach, option unrestricted for Start and curb for End + Given the node map + """ + s + a------b------c + e + """ + + And the ways + | nodes | + | ab | + | bc | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | ab,bc | + + ############### + # Oneway Test # + ############### + + + Scenario: Testbot - Test on oneway segment, Start End same approach, option unrestricted for Start and End + Given the node map + """ + s e + a------b------c + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted unrestricted | ab,bc | + + Scenario: Testbot - Test on oneway segment, Start End same approach, option unrestricted for Start and curb for End + Given the node map + """ + s e + a------b------c + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | ab,bc | + + Scenario: Testbot - Test on oneway segment, Start End opposite approach, option unrestricted for Start and End + Given the node map + """ + s + a------b------c + e + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted unrestricted | ab,bc | + + Scenario: Testbot - Test on oneway segment, Start End opposite approach, option unrestricted for Start and curb for End + Given the node map + """ + s + a------b------c + e + """ + + And the ways + | nodes | oneway | + | ab | yes | + | bc | yes | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | ab,bc | + + ############## + # UTurn Test # + ############## + + Scenario: Testbot - UTurn test, router can't found a route because uturn unauthorized on the segment selected + Given the node map + """ + s e + a------b------c + """ + + And the ways + | nodes | + | ab | + | bc | + + And the relations + | type | way:from | way:to | node:via | restriction | + | restriction | bc | bc | c | no_u_turn | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | | + + + Scenario: Testbot - UTurn test, router can found a route because he can use the roundabout + Given the node map + """ + h + s e / \ + a------b------c g + \ / + f + """ + + And the ways + | nodes | junction | + | ab | | + | bc | | + | cfghc | roundabout | + + And the relations + | type | way:from | way:to | node:via | restriction | + | restriction | bc | bc | c | no_u_turn | + + When I route I should get + | from | to | approaches | route | + | s | e | unrestricted curb | ab,bc,bc | diff --git a/features/testbot/side_param.feature b/features/testbot/side_param.feature deleted file mode 100644 index a4ef8793b..000000000 --- a/features/testbot/side_param.feature +++ /dev/null @@ -1,245 +0,0 @@ -@routing @side_param @testbot -Feature: Side parameter - - Background: - Given the profile "car" - And a grid size of 10 meters - - Scenario: Testbot - Start End same side, option both for Start and End - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b b | ab,bc | - - Scenario: Testbot - Start End same side, option both for Start and Default for End - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b d | ab,bc,bc | - - Scenario: Testbot - Start End same side, option both for Start and Opposite for End - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b o | ab,bc | - - Scenario: Testbot - Start End opposite side, option both for Start and End - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b b | ab,bc | - - Scenario: Testbot - Start End opposite side, option both for Start and Default for End - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b d | ab,bc | - - Scenario: Testbot - Start End opposite side, option both for Start and Opposite for End - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | - | ab | - | bc | - - When I route I should get - | from | to | sides | route | - | s | e | b o | ab,bc,bc | - - ############### - # Oneway Test # - ############### - Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and End, - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b b | ab,bc | - - Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and Default for End - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b d | ab,bc | - - Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and Opposite for End - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b o | ab,bc | - - Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and End, - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b b | ab,bc | - - Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and Default for End - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b d | ab,bc | - - Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and Opposite for End - Given the node map - """ - s - a------b------c - e - """ - - And the ways - | nodes | oneway | - | ab | yes | - | bc | yes | - - When I route I should get - | from | to | sides | route | - | s | e | b o | ab,bc | - - - - - Scenario: Testbot - UTurn test, router can't found a route because uturn unauthorized on the segment selected - Given the node map - """ - s e - a------b------c - """ - - And the ways - | nodes | - | ab | - | bc | - - - And the relations - | type | way:from | way:to | node:via | restriction | - | restriction | bc | bc | c | no_u_turn | - - When I route I should get - | from | to | sides | route | - | s | e | b d | | - - - - - - - - - - - - - - \ No newline at end of file diff --git a/include/engine/api/base_parameters.hpp b/include/engine/api/base_parameters.hpp index a0ab986d2..3335a994f 100644 --- a/include/engine/api/base_parameters.hpp +++ b/include/engine/api/base_parameters.hpp @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "engine/bearing.hpp" #include "engine/hint.hpp" -#include "engine/side.hpp" +#include "engine/approach.hpp" #include "util/coordinate.hpp" #include @@ -56,7 +56,7 @@ namespace api * optional per coordinate * - bearings: limits the search for segments in the road network to given bearing(s) in degree * towards true north in clockwise direction, optional per coordinate - * - sides: force the phantom node to start towards the node with the road country side. + * - approaches: force the phantom node to start towards the node with the road country side. * * \see OSRM, Coordinate, Hint, Bearing, RouteParame, RouteParameters, TableParameters, * NearestParameters, TripParameters, MatchParameters and TileParameters @@ -67,7 +67,7 @@ struct BaseParameters std::vector> hints; std::vector> radiuses; std::vector> bearings; - std::vector> sides; + std::vector> approaches; // Adds hints to response which can be included in subsequent requests, see `hints` above. bool generate_hints = true; @@ -76,10 +76,10 @@ struct BaseParameters const std::vector> hints_ = {}, std::vector> radiuses_ = {}, std::vector> bearings_ = {}, - std::vector> sides_ = {}, + std::vector> approaches_ = {}, bool generate_hints_ = true) : coordinates(coordinates_), hints(hints_), radiuses(radiuses_), bearings(bearings_), - sides(sides_), generate_hints(generate_hints_) + approaches(approaches_), generate_hints(generate_hints_) { } @@ -89,7 +89,7 @@ struct BaseParameters return (hints.empty() || hints.size() == coordinates.size()) && (bearings.empty() || bearings.size() == coordinates.size()) && (radiuses.empty() || radiuses.size() == coordinates.size()) && - (sides.empty() || sides.size() == coordinates.size()) && + (approaches.empty() || approaches.size() == coordinates.size()) && std::all_of(bearings.begin(), bearings.end(), [](const boost::optional bearing_and_range) { diff --git a/include/engine/side.hpp b/include/engine/approach.hpp similarity index 92% rename from include/engine/side.hpp rename to include/engine/approach.hpp index b1cf8a666..f41bee5fb 100644 --- a/include/engine/side.hpp +++ b/include/engine/approach.hpp @@ -25,19 +25,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef OSRM_ENGINE_SIDE_HPP -#define OSRM_ENGINE_SIDE_HPP +#ifndef OSRM_ENGINE_APPROACH_HPP +#define OSRM_ENGINE_APPROACH_HPP namespace osrm { namespace engine { -enum Side +enum Approach { - DEFAULT, - OPPOSITE, - BOTH + CURB, + UNRESTRICTED }; } diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index a66d53fd9..ec404e71f 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -7,7 +7,7 @@ #include "engine/algorithm.hpp" #include "engine/geospatial_query.hpp" -#include "engine/side.hpp" +#include "engine/approach.hpp" #include "customizer/edge_based_graph.hpp" @@ -716,12 +716,12 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const engine::Side side) const override final + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, side); + input_coordinate, approach); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent( diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index cd467478e..9a3fe2919 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -10,7 +10,7 @@ #include "extractor/guidance/turn_lane_types.hpp" #include "extractor/original_edge_data.hpp" #include "engine/phantom_node.hpp" -#include "engine/side.hpp" +#include "engine/approach.hpp" #include "util/exception.hpp" #include "util/guidance/bearing_class.hpp" #include "util/guidance/entry_class.hpp" @@ -120,7 +120,7 @@ class BaseDataFacade virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const engine::Side side) const = 0; + const engine::Approach approach) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance) const = 0; diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index fff633f7f..d4b8da47c 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -2,7 +2,7 @@ #define GEOSPATIAL_QUERY_HPP #include "engine/phantom_node.hpp" -#include "engine/side.hpp" +#include "engine/approach.hpp" #include "util/bearing.hpp" #include "util/coordinate_calculation.hpp" #include "util/rectangle.hpp" @@ -212,20 +212,20 @@ template class GeospatialQuery // a second phantom node is return that is the nearest coordinate in a big component. std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const engine::Side side) const + const engine::Approach approach) const { bool has_small_component = false; bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, &side, &input_coordinate, &has_big_component, &has_small_component]( + [this, &approach, &input_coordinate, &has_big_component, &has_small_component]( const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !IsTinyComponent(segment))); auto use_directions = std::make_pair(use_segment, use_segment); bool isOnewaySegment = !(segment.data.forward_segment_id.enabled && segment.data.reverse_segment_id.enabled); - if (!isOnewaySegment && side != BOTH) + if (!isOnewaySegment && approach != UNRESTRICTED) { // Check the counter clockwise // @@ -237,16 +237,12 @@ template class GeospatialQuery bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW( coordinates[segment.data.u], coordinates[segment.data.v], input_coordinate); - // TODO Check the country side, for the moment right is the default country - // side. + // TODO Check the country approach, for the moment right is the default country + // approach. // if drive left // input_coordinate_is_at_right = !input_coordinate_is_at_right - // We reverse goCountrySide if side is OPPOSITE - if (side == OPPOSITE) - input_coordinate_is_at_right = !input_coordinate_is_at_right; - - // Apply the side. + // Apply the approach. use_directions.first = use_directions.first && input_coordinate_is_at_right; use_directions.second = use_directions.second && !input_coordinate_is_at_right; } diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 4717a4733..6587a5f22 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -226,16 +226,16 @@ class BasePlugin const bool use_hints = !parameters.hints.empty(); const bool use_bearings = !parameters.bearings.empty(); const bool use_radiuses = !parameters.radiuses.empty(); - const bool use_sides = !parameters.sides.empty(); + const bool use_approaches = !parameters.approaches.empty(); BOOST_ASSERT(parameters.IsValid()); for (const auto i : util::irange(0UL, parameters.coordinates.size())) { - Side side = engine::Side::BOTH; + Approach approach = engine::Approach::UNRESTRICTED; // TODO init at SIDE for test // SideValue side = engine::SideValue::DEFAULT; - if (use_sides && parameters.sides[i]) - side = parameters.sides[i].get(); + if (use_approaches && parameters.approaches[i]) + approach = parameters.approaches[i].get(); if (use_hints && parameters.hints[i] && parameters.hints[i]->IsValid(parameters.coordinates[i], facade)) @@ -277,7 +277,7 @@ class BasePlugin { phantom_node_pairs[i] = facade.NearestPhantomNodeWithAlternativeFromBigComponent( - parameters.coordinates[i], side); + parameters.coordinates[i], approach); } } diff --git a/include/server/api/base_parameters_grammar.hpp b/include/server/api/base_parameters_grammar.hpp index 7d57e3d9c..f446de67a 100644 --- a/include/server/api/base_parameters_grammar.hpp +++ b/include/server/api/base_parameters_grammar.hpp @@ -149,16 +149,16 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::lit("bearings=") > (-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'; - side_type.add("d", engine::Side::DEFAULT)("o", engine::Side::OPPOSITE)("b", engine::Side::BOTH); - sides_rule = - qi::lit("sides=") > - (-side_type % ';')[ph::bind(&engine::api::BaseParameters::sides, qi::_r1) = qi::_1]; + approach_type.add("unrestricted", engine::Approach::UNRESTRICTED)("curb", engine::Approach::CURB); + approach_rule = + qi::lit("approaches=") > + (-approach_type % ';')[ph::bind(&engine::api::BaseParameters::approaches, qi::_r1) = qi::_1]; base_rule = radiuses_rule(qi::_r1) // | hints_rule(qi::_r1) // | bearings_rule(qi::_r1) // | generate_hints_rule(qi::_r1) - | sides_rule(qi::_r1); + | approach_rule(qi::_r1); } protected: @@ -171,7 +171,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::rule hints_rule; qi::rule generate_hints_rule; - qi::rule sides_rule; + qi::rule approach_rule; qi::rule bearing_rule; qi::rule location_rule; @@ -182,7 +182,7 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar qi::rule unlimited_rule; qi::real_parser double_; - qi::symbols side_type; + qi::symbols approach_type; }; } } diff --git a/src/server/service/route_service.cpp b/src/server/service/route_service.cpp index 466e8e4d3..98a8e5b5a 100644 --- a/src/server/service/route_service.cpp +++ b/src/server/service/route_service.cpp @@ -28,7 +28,7 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters) constrainParamSize( PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) || constrainParamSize( - PARAMETER_SIZE_MISMATCH_MSG, "sides", parameters.sides, coord_size, help); + PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp index 972b78042..ed21e02c0 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -147,7 +147,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, - const engine::Side /*side*/) const override + const engine::Approach /*approach*/) const override { return {}; } diff --git a/unit_tests/server/parameters_io.hpp b/unit_tests/server/parameters_io.hpp index e044cbe77..ad601984c 100644 --- a/unit_tests/server/parameters_io.hpp +++ b/unit_tests/server/parameters_io.hpp @@ -3,7 +3,7 @@ #include "engine/api/route_parameters.hpp" #include "engine/bearing.hpp" -#include "engine/side.hpp" +#include "engine/approach.hpp" #include @@ -55,9 +55,9 @@ inline std::ostream &operator<<(std::ostream &out, Bearing bearing) return out; } -inline std::ostream &operator<<(std::ostream &out, Side side) +inline std::ostream &operator<<(std::ostream &out, Approach approach) { - out << side; + out << approach; return out; } } diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index d8f8eab84..341055f0f 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -45,8 +45,8 @@ BOOST_AUTO_TEST_CASE(invalid_route_urls) testInvalidOptions("1,2;3,4?overview=false&continue_straight=foo"), 41UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&radiuses=foo"), 32UL); - BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&sides=foo"), - 29UL); + BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&approaches=foo"), + 34UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&hints=foo"), 29UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?overview=false&hints=;;; ;"), @@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_1.continue_straight, result_1->continue_straight); CHECK_EQUAL_RANGE(reference_1.bearings, result_1->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); - CHECK_EQUAL_RANGE(reference_1.sides, result_1->sides); + CHECK_EQUAL_RANGE(reference_1.approaches, result_1->approaches); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); CHECK_EQUAL_RANGE(reference_1.hints, result_1->hints); @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_2.continue_straight, result_2->continue_straight); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); - CHECK_EQUAL_RANGE(reference_2.sides, result_2->sides); + CHECK_EQUAL_RANGE(reference_2.approaches, result_2->approaches); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); CHECK_EQUAL_RANGE(reference_2.hints, result_2->hints); BOOST_CHECK_EQUAL(result_2->annotations_type == RouteParameters::AnnotationsType::All, true); @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_3.continue_straight, result_3->continue_straight); CHECK_EQUAL_RANGE(reference_3.bearings, result_3->bearings); CHECK_EQUAL_RANGE(reference_3.radiuses, result_3->radiuses); - CHECK_EQUAL_RANGE(reference_3.sides, result_3->sides); + CHECK_EQUAL_RANGE(reference_3.approaches, result_3->approaches); CHECK_EQUAL_RANGE(reference_3.coordinates, result_3->coordinates); CHECK_EQUAL_RANGE(reference_3.hints, result_3->hints); @@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_4.continue_straight, result_4->continue_straight); CHECK_EQUAL_RANGE(reference_4.bearings, result_4->bearings); CHECK_EQUAL_RANGE(reference_4.radiuses, result_4->radiuses); - CHECK_EQUAL_RANGE(reference_4.sides, result_4->sides); + CHECK_EQUAL_RANGE(reference_4.approaches, result_4->approaches); CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates); CHECK_EQUAL_RANGE(reference_4.hints, result_4->hints); @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_5.continue_straight, result_5->continue_straight); CHECK_EQUAL_RANGE(reference_5.bearings, result_5->bearings); CHECK_EQUAL_RANGE(reference_5.radiuses, result_5->radiuses); - CHECK_EQUAL_RANGE(reference_5.sides, result_5->sides); + CHECK_EQUAL_RANGE(reference_5.approaches, result_5->approaches); CHECK_EQUAL_RANGE(reference_5.coordinates, result_5->coordinates); CHECK_EQUAL_RANGE(reference_5.hints, result_5->hints); @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_6.continue_straight, result_6->continue_straight); CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings); CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses); - CHECK_EQUAL_RANGE(reference_6.sides, result_6->sides); + CHECK_EQUAL_RANGE(reference_6.approaches, result_6->approaches); CHECK_EQUAL_RANGE(reference_6.coordinates, result_6->coordinates); CHECK_EQUAL_RANGE(reference_6.hints, result_6->hints); @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_7.continue_straight, result_7->continue_straight); CHECK_EQUAL_RANGE(reference_7.bearings, result_7->bearings); CHECK_EQUAL_RANGE(reference_7.radiuses, result_7->radiuses); - CHECK_EQUAL_RANGE(reference_7.sides, result_7->sides); + CHECK_EQUAL_RANGE(reference_7.approaches, result_7->approaches); CHECK_EQUAL_RANGE(reference_7.coordinates, result_7->coordinates); CHECK_EQUAL_RANGE(reference_7.hints, result_7->hints); @@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_10.continue_straight, result_10->continue_straight); CHECK_EQUAL_RANGE(reference_10.bearings, result_10->bearings); CHECK_EQUAL_RANGE(reference_10.radiuses, result_10->radiuses); - CHECK_EQUAL_RANGE(reference_10.sides, result_10->sides); + CHECK_EQUAL_RANGE(reference_10.approaches, result_10->approaches); CHECK_EQUAL_RANGE(reference_10.coordinates, result_10->coordinates); CHECK_EQUAL_RANGE(reference_10.hints, result_10->hints); @@ -399,8 +399,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(result_2->annotations_type == RouteParameters::AnnotationsType::All, true); BOOST_CHECK_EQUAL(result_17->annotations, true); - std::vector> sides_18 = { - boost::none, engine::Side::DEFAULT, engine::Side::BOTH, engine::Side::OPPOSITE, + std::vector> approaches_18 = { + boost::none, engine::Approach::CURB, engine::Approach::UNRESTRICTED, engine::Approach::CURB, }; RouteParameters reference_18{false, false, @@ -412,9 +412,9 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) std::vector>{}, std::vector>{}, std::vector>{}, - sides_18}; + approaches_18}; - auto result_18 = parseParameters("1,2;3,4;5,6;7,8?steps=false&sides=;d;b;o"); + auto result_18 = parseParameters("1,2;3,4;5,6;7,8?steps=false&approaches=;curb;unrestricted;curb"); BOOST_CHECK(result_18); BOOST_CHECK_EQUAL(reference_18.steps, result_18->steps); BOOST_CHECK_EQUAL(reference_18.alternatives, result_18->alternatives); @@ -424,7 +424,7 @@ BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_CHECK_EQUAL(reference_18.continue_straight, result_18->continue_straight); CHECK_EQUAL_RANGE(reference_18.bearings, result_18->bearings); CHECK_EQUAL_RANGE(reference_18.radiuses, result_18->radiuses); - CHECK_EQUAL_RANGE(reference_18.sides, result_18->sides); + CHECK_EQUAL_RANGE(reference_18.approaches, result_18->approaches); CHECK_EQUAL_RANGE(reference_18.coordinates, result_18->coordinates); CHECK_EQUAL_RANGE(reference_18.hints, result_18->hints); } @@ -442,7 +442,7 @@ BOOST_AUTO_TEST_CASE(valid_table_urls) CHECK_EQUAL_RANGE(reference_1.destinations, result_1->destinations); CHECK_EQUAL_RANGE(reference_1.bearings, result_1->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); - CHECK_EQUAL_RANGE(reference_1.sides, result_1->sides); + CHECK_EQUAL_RANGE(reference_1.approaches, result_1->approaches); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); std::vector sources_2 = {1, 2, 3}; @@ -455,7 +455,7 @@ BOOST_AUTO_TEST_CASE(valid_table_urls) CHECK_EQUAL_RANGE(reference_2.destinations, result_2->destinations); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); - CHECK_EQUAL_RANGE(reference_2.sides, result_2->sides); + CHECK_EQUAL_RANGE(reference_2.approaches, result_2->approaches); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); auto result_3 = parseParameters("1,2;3,4?sources=all&destinations=all"); @@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(valid_table_urls) CHECK_EQUAL_RANGE(reference_1.destinations, result_3->destinations); CHECK_EQUAL_RANGE(reference_1.bearings, result_3->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_3->radiuses); - CHECK_EQUAL_RANGE(reference_1.sides, result_3->sides); + CHECK_EQUAL_RANGE(reference_1.approaches, result_3->approaches); CHECK_EQUAL_RANGE(reference_1.coordinates, result_3->coordinates); } @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(valid_match_urls) CHECK_EQUAL_RANGE(reference_1.timestamps, result_1->timestamps); CHECK_EQUAL_RANGE(reference_1.bearings, result_1->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); - CHECK_EQUAL_RANGE(reference_1.sides, result_1->sides); + CHECK_EQUAL_RANGE(reference_1.approaches, result_1->approaches); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); MatchParameters reference_2{}; @@ -491,7 +491,7 @@ BOOST_AUTO_TEST_CASE(valid_match_urls) CHECK_EQUAL_RANGE(reference_2.timestamps, result_2->timestamps); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); - CHECK_EQUAL_RANGE(reference_2.sides, result_2->sides); + CHECK_EQUAL_RANGE(reference_2.approaches, result_2->approaches); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); } @@ -506,7 +506,7 @@ BOOST_AUTO_TEST_CASE(valid_nearest_urls) BOOST_CHECK_EQUAL(reference_1.number_of_results, result_1->number_of_results); CHECK_EQUAL_RANGE(reference_1.bearings, result_1->bearings); CHECK_EQUAL_RANGE(reference_1.radiuses, result_1->radiuses); - CHECK_EQUAL_RANGE(reference_1.sides, result_1->sides); + CHECK_EQUAL_RANGE(reference_1.approaches, result_1->approaches); CHECK_EQUAL_RANGE(reference_1.coordinates, result_1->coordinates); NearestParameters reference_2{}; @@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE(valid_nearest_urls) BOOST_CHECK_EQUAL(reference_2.number_of_results, result_2->number_of_results); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); - CHECK_EQUAL_RANGE(reference_2.sides, result_2->sides); + CHECK_EQUAL_RANGE(reference_2.approaches, result_2->approaches); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); }