Code review updates.
This commit is contained in:
parent
49441fe204
commit
017ff53702
@ -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_OBJECTS:UTIL>)
|
||||
|
||||
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)
|
||||
|
@ -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 |
|
||||
|
@ -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|
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -172,7 +172,6 @@ template <typename RTreeT, typename DataFacadeT> 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++)
|
||||
|
@ -346,8 +346,6 @@ template <class DataFacadeT, class Derived> 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)
|
||||
{
|
||||
|
@ -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 EdgeDataT> class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
|
||||
{
|
||||
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<EdgeID>(0),static_cast<EdgeID>(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<NodeID> &/* result_nodes */) const {}
|
||||
void GetUncompressedWeights(const EdgeID /* id */,
|
||||
std::vector<EdgeWeight> & /* 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<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
|
||||
const util::FixedPointCoordinate & /*north_east */) {
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const float /* max_distance */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const unsigned /* max_results */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> 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<contractor::QueryEdge::EdgeData>;
|
||||
|
||||
using namespace osrm::test;
|
||||
|
||||
// Choosen by a fair W20 dice roll (this value is completely arbitrary)
|
||||
constexpr unsigned RANDOM_SEED = 13;
|
||||
|
91
unit_tests/mocks/mock_datafacade.hpp
Normal file
91
unit_tests/mocks/mock_datafacade.hpp
Normal file
@ -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 EdgeDataT> class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
|
||||
{
|
||||
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<EdgeID>(0),static_cast<EdgeID>(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<NodeID> &/* result_nodes */) const {}
|
||||
void GetUncompressedWeights(const EdgeID /* id */,
|
||||
std::vector<EdgeWeight> & /* 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<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
|
||||
const util::FixedPointCoordinate & /*north_east */) {
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const float /* max_distance */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const unsigned /* max_results */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> 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<contractor::QueryEdge::EdgeData>;
|
||||
} // osrm::test::
|
||||
} // osrm::
|
||||
|
||||
#endif // MOCK_DATAFACADE_HPP
|
@ -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 <boost/functional/hash.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@ -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<TestData,
|
||||
TEST_LEAF_NODE_SIZE>;
|
||||
using MiniStaticRTree = StaticRTree<TestData, std::vector<FixedPointCoordinate>, false, 2, 3>;
|
||||
|
||||
template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
|
||||
{
|
||||
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<EdgeID>(0),static_cast<EdgeID>(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<NodeID> &/* result_nodes */) const {}
|
||||
void GetUncompressedWeights(const EdgeID /* id */,
|
||||
std::vector<EdgeWeight> & /* 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<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
|
||||
const util::FixedPointCoordinate & /*north_east */) {
|
||||
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const float /* max_distance */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const unsigned /* max_results */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::vector<osrm::engine::PhantomNodeWithDistance> foo;
|
||||
return foo;
|
||||
}
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate /* input_coordinate */,
|
||||
const int /* bearing = 0 */,
|
||||
const int /* bearing_range = 180 */) {
|
||||
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> 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<contractor::QueryEdge::EdgeData>;
|
||||
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user