Allow users to specify a class for each way
This adds the ability to mark ways with a user-defined class in the profile. This class information will be included in the response as property of the RouteStep object.
This commit is contained in:
committed by
Patrick Niklaus
parent
d52d530cbe
commit
44739f2dc3
@@ -53,7 +53,8 @@ BOOST_AUTO_TEST_CASE(trim_short_segments)
|
||||
0},
|
||||
0,
|
||||
3,
|
||||
{intersection1}},
|
||||
{intersection1},
|
||||
{}},
|
||||
{324,
|
||||
"Central Park West",
|
||||
"",
|
||||
@@ -74,7 +75,8 @@ BOOST_AUTO_TEST_CASE(trim_short_segments)
|
||||
0},
|
||||
2,
|
||||
3,
|
||||
{intersection2}}};
|
||||
{intersection2},
|
||||
{}}};
|
||||
|
||||
LegGeometry geometry;
|
||||
geometry.locations = {{FloatLongitude{-73.981492}, FloatLatitude{40.768258}},
|
||||
|
||||
@@ -36,6 +36,7 @@ inline InputEdge MakeUnitEdge(const NodeID from, const NodeID to)
|
||||
false,
|
||||
true,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
0,
|
||||
INVALID_LANE_DESCRIPTIONID};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
// implements all data storage when shared memory _IS_ used
|
||||
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "extractor/class_data.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
|
||||
#include "engine/algorithm.hpp"
|
||||
#include "engine/datafacade/algorithm_datafacade.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "util/guidance/entry_class.hpp"
|
||||
#include "util/guidance/turn_bearing.hpp"
|
||||
@@ -195,6 +199,14 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
{
|
||||
return TRAVEL_MODE_INACCESSIBLE;
|
||||
}
|
||||
|
||||
extractor::ClassData GetClassData(const NodeID /*id*/) const override final { return 0; }
|
||||
|
||||
std::vector<std::string> GetClasses(const extractor::ClassData /*data*/) const override final
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
NameID GetNameIndex(const NodeID /* id */) const override { return 0; }
|
||||
|
||||
StringView GetNameForID(const NameID) const override final { return {}; }
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "util/bit_range.hpp"
|
||||
|
||||
#include "../common/range_tools.hpp"
|
||||
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(bit_range_test)
|
||||
|
||||
using namespace osrm;
|
||||
using namespace osrm::util;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bit_range_8bit_test)
|
||||
{
|
||||
std::uint8_t value_1 = (1UL << 0) | (1UL << 1) | (1UL << 5) | (1UL << 7);
|
||||
std::uint8_t value_2 = (1UL << 0);
|
||||
std::uint8_t value_3 =
|
||||
(1UL << 0) | (1UL << 1) | (1UL << 2) | (1UL << 3) | (1UL << 4) | (1UL << 5);
|
||||
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint8_t>(value_1), 7, 5, 1, 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint8_t>(value_2), 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint8_t>(value_3), 5, 4, 3, 2, 1, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint8_t>(value_3).size(), 6);
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint8_t>(0).size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bit_range_16bit_test)
|
||||
{
|
||||
std::uint16_t value_1 = (1UL << 0) | (1UL << 1) | (1UL << 9) | (1UL << 15);
|
||||
std::uint16_t value_2 = (1UL << 0);
|
||||
std::uint16_t value_3 =
|
||||
(1UL << 0) | (1UL << 1) | (1UL << 2) | (1UL << 3) | (1UL << 4) | (1UL << 5);
|
||||
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint16_t>(value_1), 15, 9, 1, 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint16_t>(value_2), 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint16_t>(value_3), 5, 4, 3, 2, 1, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint16_t>(value_3).size(), 6);
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint16_t>(0).size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bit_range_32bit_test)
|
||||
{
|
||||
std::uint32_t value_1 = (1UL << 0) | (1UL << 1) | (1UL << 17) | (1UL << 31);
|
||||
std::uint32_t value_2 = (1UL << 0);
|
||||
std::uint32_t value_3 =
|
||||
(1UL << 0) | (1UL << 1) | (1UL << 2) | (1UL << 3) | (1UL << 4) | (1UL << 5);
|
||||
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint32_t>(value_1), 31, 17, 1, 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint32_t>(value_2), 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint32_t>(value_3), 5, 4, 3, 2, 1, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint32_t>(value_3).size(), 6);
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint32_t>(0).size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bit_range_64bit_test)
|
||||
{
|
||||
std::uint64_t value_1 = (1ULL << 0) | (1ULL << 1) | (1ULL << 33) | (1ULL << 63);
|
||||
std::uint64_t value_2 = (1ULL << 0);
|
||||
std::uint64_t value_3 =
|
||||
(1ULL << 0) | (1ULL << 1) | (1ULL << 2) | (1ULL << 3) | (1ULL << 4) | (1ULL << 5);
|
||||
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint64_t>(value_1), 63, 33, 1, 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint64_t>(value_2), 0);
|
||||
CHECK_EQUAL_RANGE(makeBitRange<std::uint64_t>(value_3), 5, 4, 3, 2, 1, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint64_t>(value_3).size(), 6);
|
||||
BOOST_CHECK_EQUAL(makeBitRange<std::uint64_t>(0).size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user