diff --git a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp index 8ae26c6d5..c33b73e0e 100644 --- a/include/engine/datafacade/contiguous_internalmem_datafacade.hpp +++ b/include/engine/datafacade/contiguous_internalmem_datafacade.hpp @@ -651,54 +651,59 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, - const float max_distance) const override final + const float max_distance, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance); + return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance, approach); } std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const float max_distance, const int bearing, - const int bearing_range) const override final + const int bearing_range, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodesInRange( - input_coordinate, max_distance, bearing, bearing_range); - } - - std::vector - NearestPhantomNodes(const util::Coordinate input_coordinate, - const unsigned max_results) const override final - { - BOOST_ASSERT(m_geospatial_query.get()); - - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results); + input_coordinate, max_distance, bearing, bearing_range, approach); } std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, - const double max_distance) const override final + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); - return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance); + return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, approach); + } + + std::vector + NearestPhantomNodes(const util::Coordinate input_coordinate, + const unsigned max_results, + const double max_distance, + const engine::Approach approach) const override final + { + BOOST_ASSERT(m_geospatial_query.get()); + + return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance, approach); } std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, const int bearing, - const int bearing_range) const override final + const int bearing_range, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodes( - input_coordinate, max_results, bearing, bearing_range); + input_coordinate, max_results, bearing, bearing_range, approach); } std::vector @@ -706,12 +711,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade const unsigned max_results, const double max_distance, const int bearing, - const int bearing_range) const override final + const int bearing_range, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodes( - input_coordinate, max_results, max_distance, bearing, bearing_range); + input_coordinate, max_results, max_distance, bearing, bearing_range, approach); } std::pair @@ -725,35 +731,37 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade } std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, const double max_distance) const override final + const util::Coordinate input_coordinate, const double max_distance, const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, max_distance); + input_coordinate, max_distance, approach); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, const int bearing, - const int bearing_range) const override final + const int bearing_range, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, max_distance, bearing, bearing_range); + input_coordinate, max_distance, bearing, bearing_range, approach); } std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const int bearing, - const int bearing_range) const override final + const int bearing_range, + const engine::Approach approach) const override final { BOOST_ASSERT(m_geospatial_query.get()); return m_geospatial_query->NearestPhantomNodeWithAlternativeFromBigComponent( - input_coordinate, bearing, bearing_range); + input_coordinate, bearing, bearing_range, approach); } unsigned GetCheckSum() const override final { return m_check_sum; } diff --git a/include/engine/datafacade/datafacade_base.hpp b/include/engine/datafacade/datafacade_base.hpp index d1fe8d968..b8056a9ba 100644 --- a/include/engine/datafacade/datafacade_base.hpp +++ b/include/engine/datafacade/datafacade_base.hpp @@ -94,45 +94,54 @@ class BaseDataFacade NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const float max_distance, const int bearing, - const int bearing_range) const = 0; + const int bearing_range, + const engine::Approach approach) const = 0; virtual std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, - const float max_distance) const = 0; + const float max_distance, + const engine::Approach approach) const = 0; virtual std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, const double max_distance, const int bearing, - const int bearing_range) const = 0; + const int bearing_range, + const engine::Approach approach) const = 0; virtual std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, const int bearing, - const int bearing_range) const = 0; - virtual std::vector - NearestPhantomNodes(const util::Coordinate input_coordinate, - const unsigned max_results) const = 0; + const int bearing_range, + const engine::Approach approach) const = 0; virtual std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, - const double max_distance) const = 0; + const engine::Approach approach) const = 0; + virtual std::vector + NearestPhantomNodes(const util::Coordinate input_coordinate, + const unsigned max_results, + const double max_distance, + const engine::Approach approach) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const engine::Approach approach) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, - const double max_distance) const = 0; + const double max_distance, + const engine::Approach approach) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, const int bearing, - const int bearing_range) const = 0; + const int bearing_range, + const engine::Approach approach) const = 0; virtual std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const int bearing, - const int bearing_range) const = 0; + const int bearing_range, + const engine::Approach approach) const = 0; virtual bool HasLaneData(const EdgeID id) const = 0; virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0; diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index 2873dde6c..6b7d27522 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -53,14 +53,17 @@ template class GeospatialQuery // Does not filter by small/big component! std::vector NearestPhantomNodesInRange(const util::Coordinate input_coordinate, - const double max_distance) const + const double max_distance, + const engine::Approach approach) const { auto results = rtree.Nearest(input_coordinate, - [this](const CandidateSegment &segment) { return HasValidEdge(segment); }, + [this, approach, &input_coordinate](const CandidateSegment &segment) { + return boolPairAnd(HasValidEdge(segment), approach_usage(input_coordinate, segment, approach)); + }, [this, max_distance, input_coordinate](const std::size_t, const CandidateSegment &segment) { - return CheckSegmentDistance(input_coordinate, segment, max_distance); + return CheckSegmentDistance(input_coordinate, segment, max_distance); }); return MakePhantomNodes(input_coordinate, results); @@ -72,13 +75,17 @@ template class GeospatialQuery NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance, const int bearing, - const int bearing_range) const + const int bearing_range, + const engine::Approach approach) const { auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, max_distance](const CandidateSegment &segment) { - return boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), - HasValidEdge(segment)); + [this, approach, &input_coordinate, bearing, bearing_range, max_distance](const CandidateSegment &segment) { + auto use_direction = boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), + HasValidEdge(segment)); + use_direction = boolPairAnd(use_direction, + approach_usage(input_coordinate, segment, approach)); + return use_direction; }, [this, max_distance, input_coordinate](const std::size_t, const CandidateSegment &segment) { @@ -94,13 +101,15 @@ template class GeospatialQuery NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, const int bearing, - const int bearing_range) const + const int bearing_range, + const engine::Approach approach) const { auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range](const CandidateSegment &segment) { - return boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), + [this, approach, &input_coordinate, bearing, bearing_range](const CandidateSegment &segment) { + auto use_direction = boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), HasValidEdge(segment)); + return boolPairAnd(use_direction, approach_usage(input_coordinate, segment, approach)); }, [max_results](const std::size_t num_results, const CandidateSegment &) { return num_results >= max_results; @@ -117,13 +126,15 @@ template class GeospatialQuery const unsigned max_results, const double max_distance, const int bearing, - const int bearing_range) const + const int bearing_range, + const engine::Approach approach) const { auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range](const CandidateSegment &segment) { - return boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), + [this, approach, &input_coordinate, bearing, bearing_range](const CandidateSegment &segment) { + auto use_direction = boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), HasValidEdge(segment)); + return boolPairAnd(use_direction, approach_usage(input_coordinate, segment, approach)); }, [this, max_distance, max_results, input_coordinate](const std::size_t num_results, const CandidateSegment &segment) { @@ -137,11 +148,15 @@ template class GeospatialQuery // Returns max_results nearest PhantomNodes. // Does not filter by small/big component! std::vector - NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) const + NearestPhantomNodes(const util::Coordinate input_coordinate, + const unsigned max_results, + const engine::Approach approach) const { auto results = rtree.Nearest(input_coordinate, - [this](const CandidateSegment &segment) { return HasValidEdge(segment); }, + [this, approach, &input_coordinate](const CandidateSegment &segment) { + return boolPairAnd(HasValidEdge(segment), approach_usage(input_coordinate, segment, approach)); + }, [max_results](const std::size_t num_results, const CandidateSegment &) { return num_results >= max_results; }); @@ -154,11 +169,14 @@ template class GeospatialQuery std::vector NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results, - const double max_distance) const + const double max_distance, + const engine::Approach approach) const { auto results = rtree.Nearest(input_coordinate, - [this](const CandidateSegment &segment) { return HasValidEdge(segment); }, + [this, approach, &input_coordinate](const CandidateSegment &segment) { + return boolPairAnd(HasValidEdge(segment), approach_usage(input_coordinate, segment, approach)); + }, [this, max_distance, max_results, input_coordinate]( const std::size_t num_results, const CandidateSegment &segment) { return num_results >= max_results || @@ -172,24 +190,27 @@ 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 double max_distance) const + const double max_distance, + const engine::Approach approach) const { bool has_small_component = false; bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, &has_big_component, &has_small_component](const CandidateSegment &segment) { + [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); const auto valid_edges = HasValidEdge(segment); + use_directions = boolPairAnd(use_directions, valid_edges); + use_directions = boolPairAnd(use_directions, approach_usage(input_coordinate, segment, approach)); - if (valid_edges.first || valid_edges.second) + if (use_directions.first || use_directions.second) { has_big_component = has_big_component || !IsTinyComponent(segment); has_small_component = has_small_component || IsTinyComponent(segment); } - use_directions = boolPairAnd(use_directions, valid_edges); + return use_directions; }, [this, &has_big_component, max_distance, input_coordinate]( @@ -218,45 +239,23 @@ template class GeospatialQuery bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, &approach, &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 && approach != UNRESTRICTED) - { - // Check the counter clockwise - // - // input_coordinate - // | - // | - // segment.data.u ---------------- segment.data.v - bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW( - coordinates[segment.data.u], coordinates[segment.data.v], input_coordinate); - - if(datafacade.IsLeftHandDriving()) - input_coordinate_is_at_right = !input_coordinate_is_at_right; - - // 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; - } - - if (!use_directions.first && !use_directions.second) - return use_directions; const auto valid_edges = HasValidEdge(segment); + use_directions = boolPairAnd(use_directions, valid_edges); + use_directions = boolPairAnd(use_directions, + approach_usage(input_coordinate, segment, approach)); - if (valid_edges.first || valid_edges.second) + if (use_directions.first || use_directions.second) { - has_big_component = has_big_component || !IsTinyComponent(segment); has_small_component = has_small_component || IsTinyComponent(segment); } - use_directions = boolPairAnd(use_directions, valid_edges); return use_directions; }, [&has_big_component](const std::size_t num_results, const CandidateSegment &) { @@ -276,13 +275,13 @@ template class GeospatialQuery // Returns the nearest phantom node. If this phantom node is not from a big component // a second phantom node is return that is the nearest coordinate in a big component. std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::Coordinate input_coordinate, const int bearing, const int bearing_range) const + const util::Coordinate input_coordinate, const int bearing, const int bearing_range, const engine::Approach approach) const { bool has_small_component = false; bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, &has_big_component, &has_small_component]( + [this, approach, &input_coordinate, bearing, bearing_range, &has_big_component, &has_small_component]( const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !IsTinyComponent(segment))); @@ -294,6 +293,9 @@ template class GeospatialQuery use_directions = boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), HasValidEdge(segment)); + use_directions = boolPairAnd(use_directions, + approach_usage(input_coordinate, segment, approach)); + if (use_directions.first || use_directions.second) { has_big_component = has_big_component || !IsTinyComponent(segment); @@ -323,13 +325,14 @@ template class GeospatialQuery NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate, const double max_distance, const int bearing, - const int bearing_range) const + const int bearing_range, + const engine::Approach approach) const { bool has_small_component = false; bool has_big_component = false; auto results = rtree.Nearest( input_coordinate, - [this, bearing, bearing_range, &has_big_component, &has_small_component]( + [this, approach, &input_coordinate, bearing, bearing_range, &has_big_component, &has_small_component]( const CandidateSegment &segment) { auto use_segment = (!has_small_component || (!has_big_component && !IsTinyComponent(segment))); @@ -341,6 +344,9 @@ template class GeospatialQuery use_directions = boolPairAnd(CheckSegmentBearing(segment, bearing, bearing_range), HasValidEdge(segment)); + use_directions = boolPairAnd(use_directions, + approach_usage(input_coordinate, segment, approach)); + if (use_directions.first || use_directions.second) { has_big_component = has_big_component || !IsTinyComponent(segment); @@ -572,6 +578,32 @@ template class GeospatialQuery return datafacade.GetComponentID(data.forward_segment_id.id).is_tiny; } + std::pair approach_usage(const util::Coordinate &input_coordinate, + const CandidateSegment &segment, + const engine::Approach approach) const + { + bool isOnewaySegment = !(segment.data.forward_segment_id.enabled && + segment.data.reverse_segment_id.enabled); + if (!isOnewaySegment && approach == CURB) + { + // Check the counter clockwise + // + // input_coordinate + // | + // | + // segment.data.u ---------------- segment.data.v + + bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW( + coordinates[segment.data.u], coordinates[segment.data.v], input_coordinate); + + if(datafacade.IsLeftHandDriving()) + input_coordinate_is_at_right = !input_coordinate_is_at_right; + + return std::make_pair(input_coordinate_is_at_right, (!input_coordinate_is_at_right)); + } + return std::make_pair(true, true); + } + const RTreeT &rtree; const CoordinateList &coordinates; DataFacadeT &datafacade; diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 5605926ad..fc29ea48b 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -120,9 +120,14 @@ class BasePlugin const bool use_hints = !parameters.hints.empty(); const bool use_bearings = !parameters.bearings.empty(); + const bool use_approaches = !parameters.approaches.empty(); for (const auto i : util::irange(0UL, parameters.coordinates.size())) { + Approach approach = engine::Approach::UNRESTRICTED; + 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)) { @@ -139,12 +144,13 @@ class BasePlugin facade.NearestPhantomNodesInRange(parameters.coordinates[i], radiuses[i], parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + parameters.bearings[i]->range, + approach); } else { phantom_nodes[i] = - facade.NearestPhantomNodesInRange(parameters.coordinates[i], radiuses[i]); + facade.NearestPhantomNodesInRange(parameters.coordinates[i], radiuses[i], approach); } } @@ -162,10 +168,15 @@ 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_approaches = !parameters.approaches.empty(); BOOST_ASSERT(parameters.IsValid()); for (const auto i : util::irange(0UL, parameters.coordinates.size())) { + Approach approach = engine::Approach::UNRESTRICTED; + 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)) { @@ -185,14 +196,16 @@ class BasePlugin number_of_results, *parameters.radiuses[i], parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + parameters.bearings[i]->range, + approach); } else { phantom_nodes[i] = facade.NearestPhantomNodes(parameters.coordinates[i], number_of_results, parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + parameters.bearings[i]->range, + approach); } } else @@ -200,12 +213,12 @@ class BasePlugin if (use_radiuses && parameters.radiuses[i]) { phantom_nodes[i] = facade.NearestPhantomNodes( - parameters.coordinates[i], number_of_results, *parameters.radiuses[i]); + parameters.coordinates[i], number_of_results, *parameters.radiuses[i], approach); } else { phantom_nodes[i] = - facade.NearestPhantomNodes(parameters.coordinates[i], number_of_results); + facade.NearestPhantomNodes(parameters.coordinates[i], number_of_results, approach); } } @@ -252,7 +265,8 @@ class BasePlugin parameters.coordinates[i], *parameters.radiuses[i], parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + parameters.bearings[i]->range, + approach); } else { @@ -260,7 +274,9 @@ class BasePlugin facade.NearestPhantomNodeWithAlternativeFromBigComponent( parameters.coordinates[i], parameters.bearings[i]->bearing, - parameters.bearings[i]->range); + parameters.bearings[i]->range, + approach + ); } } else @@ -269,7 +285,7 @@ class BasePlugin { phantom_node_pairs[i] = facade.NearestPhantomNodeWithAlternativeFromBigComponent( - parameters.coordinates[i], *parameters.radiuses[i]); + parameters.coordinates[i], *parameters.radiuses[i], approach); } else { diff --git a/src/server/service/nearest_service.cpp b/src/server/service/nearest_service.cpp index 4393abc08..67ca91b7e 100644 --- a/src/server/service/nearest_service.cpp +++ b/src/server/service/nearest_service.cpp @@ -28,6 +28,8 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters) PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help); constrainParamSize( PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help); return help; } diff --git a/src/server/service/table_service.cpp b/src/server/service/table_service.cpp index 5873a9442..9a9ce0ab2 100644 --- a/src/server/service/table_service.cpp +++ b/src/server/service/table_service.cpp @@ -47,7 +47,9 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters) constrainParamSize( PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || constrainParamSize( - PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) || + constrainParamSize( + PARAMETER_SIZE_MISMATCH_MSG, "approaches", parameters.approaches, coord_size, help); if (!param_size_mismatch && parameters.coordinates.size() < 2) { diff --git a/src/server/service/trip_service.cpp b/src/server/service/trip_service.cpp index 9726d367c..2a7d315a1 100644 --- a/src/server/service/trip_service.cpp +++ b/src/server/service/trip_service.cpp @@ -28,7 +28,9 @@ std::string getWrongOptionHelp(const engine::api::TripParameters ¶meters) constrainParamSize( PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) || constrainParamSize( - PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help); + PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) || + constrainParamSize( + 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 5402c1f56..bc91cc32f 100644 --- a/unit_tests/mocks/mock_datafacade.hpp +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -99,14 +99,16 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade NearestPhantomNodesInRange(const util::Coordinate /*input_coordinate*/, const float /*max_distance*/, const int /*bearing*/, - const int /*bearing_range*/) const override + const int /*bearing_range*/, + const engine::Approach /*approach*/) const override { return {}; } std::vector NearestPhantomNodesInRange(const util::Coordinate /*input_coordinate*/, - const float /*max_distance*/) const override + const float /*max_distance*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -116,7 +118,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade const unsigned /*max_results*/, const double /*max_distance*/, const int /*bearing*/, - const int /*bearing_range*/) const override + const int /*bearing_range*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -125,14 +128,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, const unsigned /*max_results*/, const int /*bearing*/, - const int /*bearing_range*/) const override - { - return {}; - } - - std::vector - NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, - const unsigned /*max_results*/) const override + const int /*bearing_range*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -140,7 +137,16 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::vector NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, const unsigned /*max_results*/, - const double /*max_distance*/) const override + const engine::Approach /*approach*/) const override + { + return {}; + } + + std::vector + NearestPhantomNodes(const util::Coordinate /*input_coordinate*/, + const unsigned /*max_results*/, + const double /*max_distance*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -154,7 +160,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, - const double /*max_distance*/) const override + const double /*max_distance*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -163,7 +170,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const double /*max_distance*/, const int /*bearing*/, - const int /*bearing_range*/) const override + const int /*bearing_range*/, + const engine::Approach /*approach*/) const override { return {}; } @@ -171,7 +179,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade std::pair NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate /*input_coordinate*/, const int /*bearing*/, - const int /*bearing_range*/) const override + const int /*bearing_range*/, + const engine::Approach /*approach*/) const override { return {}; } diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index 954788882..516ba8e3c 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -363,7 +363,7 @@ BOOST_AUTO_TEST_CASE(radius_regression_test) Coordinate input(FloatLongitude{5.2}, FloatLatitude{5.0}); { - auto results = query.NearestPhantomNodesInRange(input, 0.01); + auto results = query.NearestPhantomNodesInRange(input, 0.01, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 0); } } @@ -390,19 +390,19 @@ BOOST_AUTO_TEST_CASE(bearing_tests) Coordinate input(FloatLongitude{5.1}, FloatLatitude{5.0}); { - auto results = query.NearestPhantomNodes(input, 5); + auto results = query.NearestPhantomNodes(input, 5, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 2); BOOST_CHECK_EQUAL(results.back().phantom_node.forward_segment_id.id, 0); BOOST_CHECK_EQUAL(results.back().phantom_node.reverse_segment_id.id, 1); } { - auto results = query.NearestPhantomNodes(input, 5, 270, 10); + auto results = query.NearestPhantomNodes(input, 5, 270, 10, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 0); } { - auto results = query.NearestPhantomNodes(input, 5, 45, 10); + auto results = query.NearestPhantomNodes(input, 5, 45, 10, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 2); BOOST_CHECK(results[0].phantom_node.forward_segment_id.enabled); @@ -415,17 +415,17 @@ BOOST_AUTO_TEST_CASE(bearing_tests) } { - auto results = query.NearestPhantomNodesInRange(input, 11000); + auto results = query.NearestPhantomNodesInRange(input, 11000, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 2); } { - auto results = query.NearestPhantomNodesInRange(input, 11000, 270, 10); + auto results = query.NearestPhantomNodesInRange(input, 11000, 270, 10, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 0); } { - auto results = query.NearestPhantomNodesInRange(input, 11000, 45, 10); + auto results = query.NearestPhantomNodesInRange(input, 11000, 45, 10, osrm::engine::UNRESTRICTED); BOOST_CHECK_EQUAL(results.size(), 2); BOOST_CHECK(results[0].phantom_node.forward_segment_id.enabled);