diff --git a/CMakeLists.txt b/CMakeLists.txt index d9ccb26bd..7e6e9d2f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,9 @@ add_executable(util-tests EXCLUDE_FROM_ALL unit_tests/util_tests.cpp ${UtilTests # Benchmarks add_executable(rtree-bench EXCLUDE_FROM_ALL src/benchmarks/static_rtree.cpp $) +target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests) +target_include_directories(rtree-bench PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests) + # Check the release mode if(NOT CMAKE_BUILD_TYPE MATCHES Debug) set(CMAKE_BUILD_TYPE Release) diff --git a/features/car/traffic.feature b/features/car/traffic.feature index 6d1a5d4e0..14bb63c67 100644 --- a/features/car/traffic.feature +++ b/features/car/traffic.feature @@ -34,7 +34,7 @@ Feature: Traffic - speeds Scenario: Weighting not based on raster sources Given the profile "testbot" Given the extract extra arguments "--generate-edge-lookup" - Given the prepare extra arguments "--segment-speed-file speeds.csv" + Given the contract extra arguments "--segment-speed-file speeds.csv" And I route I should get | from | to | route | speed | | a | b | ab | 27 km/h | diff --git a/features/step_definitions/data.rb b/features/step_definitions/data.rb index 6d6172bc9..da7857cd6 100644 --- a/features/step_definitions/data.rb +++ b/features/step_definitions/data.rb @@ -10,8 +10,8 @@ Given /^the extract extra arguments "(.*?)"$/ do |args| set_extract_args args end -Given /^the prepare extra arguments "(.*?)"$/ do |args| - set_prepare_args args +Given /^the contract extra arguments "(.*?)"$/ do |args| + set_contract_args args end Given /^a grid size of (\d+) meters$/ do |meters| diff --git a/features/support/config.rb b/features/support/config.rb index 5730baf2b..e4db5fac0 100644 --- a/features/support/config.rb +++ b/features/support/config.rb @@ -15,6 +15,6 @@ def set_extract_args args @extract_args = args end -def set_prepare_args args - @prepare_args = args +def set_contract_args args + @contract_args = args end diff --git a/features/support/data.rb b/features/support/data.rb index f23c6d8aa..c099fef21 100644 --- a/features/support/data.rb +++ b/features/support/data.rb @@ -288,8 +288,8 @@ def prepare_data Dir.chdir TEST_FOLDER do log_preprocess_info log "== Preparing #{extracted_file}.osm...", :preprocess - log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@prepare_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1" - unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@prepare_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1" + log "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@contract_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1" + unless system "#{LOAD_LIBRARIES}#{BIN_PATH}/osrm-contract #{@contract_args} #{extracted_file}.osrm >>#{PREPROCESS_LOG_FILE} 2>&1" log "*** Exited with code #{$?.exitstatus}.", :preprocess raise PrepareError.new $?.exitstatus, "osrm-contract exited with code #{$?.exitstatus}." end diff --git a/include/engine/geospatial_query.hpp b/include/engine/geospatial_query.hpp index 16adcbf52..75972366c 100644 --- a/include/engine/geospatial_query.hpp +++ b/include/engine/geospatial_query.hpp @@ -172,7 +172,6 @@ template class GeospatialQuery datafacade.GetUncompressedWeights(data.reverse_packed_geometry_id, reverse_weight_vector); - //BOOST_ASSERT(reverse_weight_vector.size() == forward_weight_vector.size()); BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size()); for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++) diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 796733d52..8d876a475 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -346,8 +346,6 @@ template class BasicRoutingInterface phantom_node_pair.target_phantom.forward_packed_geometry_id) && unpacked_path.empty(); - std::cout << "Got id vector of size " << id_vector.size() << "\n"; - std::size_t start_index = 0; if (is_local_path) { diff --git a/src/benchmarks/static_rtree.cpp b/src/benchmarks/static_rtree.cpp index d8bbac128..79432f7de 100644 --- a/src/benchmarks/static_rtree.cpp +++ b/src/benchmarks/static_rtree.cpp @@ -3,8 +3,7 @@ #include "extractor/edge_based_node.hpp" #include "engine/geospatial_query.hpp" #include "util/timing_util.hpp" -#include "engine/datafacade/datafacade_base.hpp" -#include "contractor/query_edge.hpp" +#include "mocks/mock_datafacade.hpp" #include "osrm/coordinate.hpp" @@ -16,83 +15,7 @@ namespace osrm namespace benchmarks { -template class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade -{ - private: - EdgeDataT foo; - public: - unsigned GetNumberOfNodes() const { return 0; } - unsigned GetNumberOfEdges() const { return 0; } - unsigned GetOutDegree(const NodeID /* n */) const { return 0; } - NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; } - const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { - return foo; - } - EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } - EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } - osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const { - return util::irange(static_cast(0),static_cast(0)); - } - EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } - EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } - EdgeID - FindEdgeIndicateIfReverse(const NodeID /* from */, const NodeID /* to */, bool & /* result */) const { return SPECIAL_EDGEID; } - util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const { - FixedPointCoordinate foo(0,0); - return foo; - } - bool EdgeIsCompressed(const unsigned /* id */) const { return false; } - unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; } - void GetUncompressedGeometry(const EdgeID /* id */, - std::vector &/* result_nodes */) const {} - void GetUncompressedWeights(const EdgeID /* id */, - std::vector & /* result_weights */) const {} - extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const { - return osrm::extractor::TurnInstruction::NoTurn; - } - extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const - { - return TRAVEL_MODE_DEFAULT; - } - std::vector::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */, - const util::FixedPointCoordinate & /*north_east */) { - std::vector::RTreeLeaf> foo; - return foo; - } - std::vector - NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */, - const float /* max_distance */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::vector foo; - return foo; - } - std::vector - NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */, - const unsigned /* max_results */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::vector foo; - return foo; - } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::FixedPointCoordinate /* input_coordinate */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::pair foo; - return foo; - } - unsigned GetCheckSum() const { return 0; } - bool IsCoreNode(const NodeID /* id */) const { return false; } - unsigned GetNameIndexFromEdgeID(const unsigned /* id */) const { return 0; } - std::string get_name_for_id(const unsigned /* name_id */) const { return ""; } - std::size_t GetCoreSize() const { return 0; } - std::string GetTimestamp() const { return ""; } - -}; - -using MockDataFacade = MockDataFacadeT; - +using namespace osrm::test; // Choosen by a fair W20 dice roll (this value is completely arbitrary) constexpr unsigned RANDOM_SEED = 13; diff --git a/unit_tests/mocks/mock_datafacade.hpp b/unit_tests/mocks/mock_datafacade.hpp new file mode 100644 index 000000000..3c94fa5a9 --- /dev/null +++ b/unit_tests/mocks/mock_datafacade.hpp @@ -0,0 +1,91 @@ +#ifndef MOCK_DATAFACADE_HPP +#define MOCK_DATAFACADE_HPP + +// implements all data storage when shared memory _IS_ used + +#include "engine/datafacade/datafacade_base.hpp" +#include "contractor/query_edge.hpp" + +namespace osrm { +namespace test { + +template class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade +{ + private: + EdgeDataT foo; + public: + unsigned GetNumberOfNodes() const { return 0; } + unsigned GetNumberOfEdges() const { return 0; } + unsigned GetOutDegree(const NodeID /* n */) const { return 0; } + NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; } + const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { + return foo; + } + EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } + EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } + osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const { + return util::irange(static_cast(0),static_cast(0)); + } + EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } + EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } + EdgeID + FindEdgeIndicateIfReverse(const NodeID /* from */, const NodeID /* to */, bool & /* result */) const { return SPECIAL_EDGEID; } + util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const { + FixedPointCoordinate foo(0,0); + return foo; + } + bool EdgeIsCompressed(const unsigned /* id */) const { return false; } + unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; } + void GetUncompressedGeometry(const EdgeID /* id */, + std::vector &/* result_nodes */) const {} + void GetUncompressedWeights(const EdgeID /* id */, + std::vector & /* result_weights */) const {} + extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const { + return osrm::extractor::TurnInstruction::NoTurn; + } + extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const + { + return TRAVEL_MODE_DEFAULT; + } + std::vector::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */, + const util::FixedPointCoordinate & /*north_east */) { + std::vector::RTreeLeaf> foo; + return foo; + } + std::vector + NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */, + const float /* max_distance */, + const int /* bearing = 0 */, + const int /* bearing_range = 180 */) { + std::vector foo; + return foo; + } + std::vector + NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */, + const unsigned /* max_results */, + const int /* bearing = 0 */, + const int /* bearing_range = 180 */) { + std::vector foo; + return foo; + } + std::pair NearestPhantomNodeWithAlternativeFromBigComponent( + const util::FixedPointCoordinate /* input_coordinate */, + const int /* bearing = 0 */, + const int /* bearing_range = 180 */) { + std::pair foo; + return foo; + } + unsigned GetCheckSum() const { return 0; } + bool IsCoreNode(const NodeID /* id */) const { return false; } + unsigned GetNameIndexFromEdgeID(const unsigned /* id */) const { return 0; } + std::string get_name_for_id(const unsigned /* name_id */) const { return ""; } + std::size_t GetCoreSize() const { return 0; } + std::string GetTimestamp() const { return ""; } + +}; + +using MockDataFacade = MockDataFacadeT; +} // osrm::test:: +} // osrm:: + +#endif // MOCK_DATAFACADE_HPP diff --git a/unit_tests/util/static_rtree.cpp b/unit_tests/util/static_rtree.cpp index 6d4cc1171..0dbf8cc36 100644 --- a/unit_tests/util/static_rtree.cpp +++ b/unit_tests/util/static_rtree.cpp @@ -7,8 +7,7 @@ #include "util/rectangle.hpp" #include "util/exception.hpp" -#include "engine/datafacade/datafacade_base.hpp" -#include "contractor/query_edge.hpp" +#include "mocks/mock_datafacade.hpp" #include #include @@ -32,6 +31,7 @@ BOOST_AUTO_TEST_SUITE(static_rtree) using namespace osrm; using namespace osrm::util; +using namespace osrm::test; constexpr uint32_t TEST_BRANCHING_FACTOR = 8; constexpr uint32_t TEST_LEAF_NODE_SIZE = 64; @@ -44,83 +44,6 @@ using TestStaticRTree = StaticRTree; using MiniStaticRTree = StaticRTree, false, 2, 3>; -template class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade -{ - private: - EdgeDataT foo; - public: - unsigned GetNumberOfNodes() const { return 0; } - unsigned GetNumberOfEdges() const { return 0; } - unsigned GetOutDegree(const NodeID /* n */) const { return 0; } - NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; } - const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { - return foo; - } - EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } - EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } - osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const { - return irange(static_cast(0),static_cast(0)); - } - EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } - EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } - EdgeID - FindEdgeIndicateIfReverse(const NodeID /* from */, const NodeID /* to */, bool & /* result */) const { return SPECIAL_EDGEID; } - util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const { - FixedPointCoordinate foo(0,0); - return foo; - } - bool EdgeIsCompressed(const unsigned /* id */) const { return false; } - unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; } - void GetUncompressedGeometry(const EdgeID /* id */, - std::vector &/* result_nodes */) const {} - void GetUncompressedWeights(const EdgeID /* id */, - std::vector & /* result_weights */) const {} - extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const { - return osrm::extractor::TurnInstruction::NoTurn; - } - extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const - { - return TRAVEL_MODE_DEFAULT; - } - std::vector::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */, - const util::FixedPointCoordinate & /*north_east */) { - std::vector::RTreeLeaf> foo; - return foo; - } - std::vector - NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */, - const float /* max_distance */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::vector foo; - return foo; - } - std::vector - NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */, - const unsigned /* max_results */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::vector foo; - return foo; - } - std::pair NearestPhantomNodeWithAlternativeFromBigComponent( - const util::FixedPointCoordinate /* input_coordinate */, - const int /* bearing = 0 */, - const int /* bearing_range = 180 */) { - std::pair foo; - return foo; - } - unsigned GetCheckSum() const { return 0; } - bool IsCoreNode(const NodeID /* id */) const { return false; } - unsigned GetNameIndexFromEdgeID(const unsigned /* id */) const { return 0; } - std::string get_name_for_id(const unsigned /* name_id */) const { return ""; } - std::size_t GetCoreSize() const { return 0; } - std::string GetTimestamp() const { return ""; } - -}; - -using MockDataFacade = MockDataFacadeT; - // Choosen by a fair W20 dice roll (this value is completely arbitrary) constexpr unsigned RANDOM_SEED = 42; static const int32_t WORLD_MIN_LAT = -90 * COORDINATE_PRECISION;