Propagate is_left_hand_driving from profile to data facade
This commit is contained in:
parent
fca00fa09e
commit
3c399e5c28
@ -39,6 +39,7 @@
|
||||
- BREAKING: Traffic signals will no longer be represented as turns internally. This requires re-processing of data but enables via-way turn restrictions across highway=traffic_signals
|
||||
- Additional checks for empty segments when loading traffic data files
|
||||
- Tunes the constants for turns in sharp curves just a tiny bit to circumvent a mix-up in fork directions at a specific intersection (https://github.com/Project-OSRM/osrm-backend/issues/4331)
|
||||
- BREAKING: added `is_left_hand_driving` vector to `.ebg_nodes` file
|
||||
- Infrastructure
|
||||
- Refactor datafacade to make implementing additional DataFacades simpler
|
||||
- Bugfixes
|
||||
|
@ -202,9 +202,15 @@ Feature: Approach parameter
|
||||
|
||||
|
||||
Scenario: Start End same approach, option unrestricted for Start and curb for End, left-hand driving
|
||||
Given the profile file "testbot" initialized with
|
||||
Given the profile file
|
||||
"""
|
||||
profile.properties.left_hand_driving = true
|
||||
local functions = require('testbot')
|
||||
local testbot_process_way = functions.process_way
|
||||
functions.process_way = function(profile, way, result)
|
||||
testbot_process_way(profile, way, result)
|
||||
result.is_left_hand_driving = true
|
||||
end
|
||||
return functions
|
||||
"""
|
||||
And the node map
|
||||
"""
|
||||
|
@ -362,11 +362,18 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
util::vector_view<extractor::ClassData> classes(
|
||||
classes_list_ptr, layout.num_entries[storage::DataLayout::CLASSES_LIST]);
|
||||
|
||||
auto is_left_hand_driving_ptr = layout.GetBlockPtr<unsigned>(
|
||||
memory_ptr, storage::DataLayout::IS_LEFT_HAND_DRIVING_LIST);
|
||||
util::vector_view<bool> is_left_hand_driving(
|
||||
is_left_hand_driving_ptr,
|
||||
layout.num_entries[storage::DataLayout::IS_LEFT_HAND_DRIVING_LIST]);
|
||||
|
||||
edge_based_node_data = extractor::EdgeBasedNodeDataView(std::move(geometry_ids),
|
||||
std::move(name_ids),
|
||||
std::move(component_ids),
|
||||
std::move(travel_modes),
|
||||
std::move(classes));
|
||||
std::move(classes),
|
||||
std::move(is_left_hand_driving));
|
||||
}
|
||||
|
||||
void InitializeEdgeInformationPointers(storage::DataLayout &layout, char *memory_ptr)
|
||||
@ -939,9 +946,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
m_lane_description_offsets[lane_description_id + 1]);
|
||||
}
|
||||
|
||||
bool IsLeftHandDriving() const override final
|
||||
bool IsLeftHandDriving(const NodeID id) const override final
|
||||
{
|
||||
return m_profile_properties->left_hand_driving; // TODO: remove
|
||||
// TODO: can be moved to a data block indexed by GeometryID
|
||||
return edge_based_node_data.IsLeftHandDriving(id);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -190,7 +190,7 @@ class BaseDataFacade
|
||||
|
||||
virtual util::guidance::EntryClass GetEntryClass(const EdgeID turn_id) const = 0;
|
||||
|
||||
virtual bool IsLeftHandDriving() const = 0;
|
||||
virtual bool IsLeftHandDriving(const NodeID id) const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
bool input_coordinate_is_at_right = !util::coordinate_calculation::isCCW(
|
||||
coordinates[segment.data.u], coordinates[segment.data.v], input_coordinate);
|
||||
|
||||
if (datafacade.IsLeftHandDriving())
|
||||
if (datafacade.IsLeftHandDriving(segment.data.forward_segment_id.id))
|
||||
input_coordinate_is_at_right = !input_coordinate_is_at_right;
|
||||
|
||||
return std::make_pair(input_coordinate_is_at_right, (!input_coordinate_is_at_right));
|
||||
|
@ -42,7 +42,8 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
EdgeBasedNodeDataContainerImpl() = default;
|
||||
|
||||
EdgeBasedNodeDataContainerImpl(std::size_t size)
|
||||
: geometry_ids(size), name_ids(size), component_ids(size), travel_modes(size), classes(size)
|
||||
: geometry_ids(size), name_ids(size), component_ids(size), travel_modes(size),
|
||||
classes(size), is_left_hand_driving(size)
|
||||
{
|
||||
}
|
||||
|
||||
@ -50,10 +51,11 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
Vector<NameID> name_ids,
|
||||
Vector<ComponentID> component_ids,
|
||||
Vector<TravelMode> travel_modes,
|
||||
Vector<ClassData> classes)
|
||||
Vector<ClassData> classes,
|
||||
Vector<bool> is_left_hand_driving)
|
||||
: geometry_ids(std::move(geometry_ids)), name_ids(std::move(name_ids)),
|
||||
component_ids(std::move(component_ids)), travel_modes(std::move(travel_modes)),
|
||||
classes(std::move(classes))
|
||||
classes(std::move(classes)), is_left_hand_driving(std::move(is_left_hand_driving))
|
||||
{
|
||||
}
|
||||
|
||||
@ -67,18 +69,25 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
|
||||
ClassData GetClassData(const NodeID node_id) const { return classes[node_id]; }
|
||||
|
||||
ClassData IsLeftHandDriving(const NodeID node_id) const
|
||||
{
|
||||
return is_left_hand_driving[node_id];
|
||||
}
|
||||
|
||||
// Used by EdgeBasedGraphFactory to fill data structure
|
||||
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||
void SetData(NodeID node_id,
|
||||
GeometryID geometry_id,
|
||||
NameID name_id,
|
||||
TravelMode travel_mode,
|
||||
ClassData class_data)
|
||||
ClassData class_data,
|
||||
bool is_left_hand_driving_flag)
|
||||
{
|
||||
geometry_ids[node_id] = geometry_id;
|
||||
name_ids[node_id] = name_id;
|
||||
travel_modes[node_id] = travel_mode;
|
||||
classes[node_id] = class_data;
|
||||
is_left_hand_driving[node_id] = is_left_hand_driving_flag;
|
||||
}
|
||||
|
||||
// Used by EdgeBasedGraphFactory to fill data structure
|
||||
@ -102,6 +111,8 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
util::inplacePermutation(component_ids.begin(), component_ids.end(), permutation);
|
||||
util::inplacePermutation(travel_modes.begin(), travel_modes.end(), permutation);
|
||||
util::inplacePermutation(classes.begin(), classes.end(), permutation);
|
||||
util::inplacePermutation(
|
||||
is_left_hand_driving.begin(), is_left_hand_driving.end(), permutation);
|
||||
}
|
||||
|
||||
// all containers have the exact same size
|
||||
@ -111,6 +122,7 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
BOOST_ASSERT(geometry_ids.size() == component_ids.size());
|
||||
BOOST_ASSERT(geometry_ids.size() == travel_modes.size());
|
||||
BOOST_ASSERT(geometry_ids.size() == classes.size());
|
||||
BOOST_ASSERT(geometry_ids.size() == is_left_hand_driving.size());
|
||||
return geometry_ids.size();
|
||||
}
|
||||
|
||||
@ -120,6 +132,7 @@ template <storage::Ownership Ownership> class EdgeBasedNodeDataContainerImpl
|
||||
Vector<ComponentID> component_ids;
|
||||
Vector<TravelMode> travel_modes;
|
||||
Vector<ClassData> classes;
|
||||
Vector<bool> is_left_hand_driving;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,7 @@ inline void read(storage::io::FileReader &reader,
|
||||
storage::serialization::read(reader, node_data_container.component_ids);
|
||||
storage::serialization::read(reader, node_data_container.travel_modes);
|
||||
storage::serialization::read(reader, node_data_container.classes);
|
||||
storage::serialization::read(reader, node_data_container.is_left_hand_driving);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
@ -136,6 +137,7 @@ inline void write(storage::io::FileWriter &writer,
|
||||
storage::serialization::write(writer, node_data_container.component_ids);
|
||||
storage::serialization::write(writer, node_data_container.travel_modes);
|
||||
storage::serialization::write(writer, node_data_container.classes);
|
||||
storage::serialization::write(writer, node_data_container.is_left_hand_driving);
|
||||
}
|
||||
|
||||
inline void read(storage::io::FileReader &reader, NodeRestriction &restriction)
|
||||
|
@ -137,7 +137,7 @@ template <> inline void write<bool>(io::FileWriter &writer, const util::vector_v
|
||||
template <> inline void read<bool>(io::FileReader &reader, std::vector<bool> &data)
|
||||
{
|
||||
const auto count = reader.ReadElementCount64();
|
||||
BOOST_ASSERT(data.size() == count);
|
||||
data.resize(count);
|
||||
for (const auto index : util::irange<std::uint64_t>(0, count))
|
||||
{
|
||||
data[index] = reader.ReadOne<bool>();
|
||||
|
@ -24,6 +24,7 @@ const constexpr char *block_id_to_name[] = {"NAME_CHAR_DATA",
|
||||
"COMPONENT_ID_LIST",
|
||||
"TRAVEL_MODE_LIST",
|
||||
"CLASSES_LIST",
|
||||
"IS_LEFT_HAND_DRIVING_LIST",
|
||||
"CH_GRAPH_NODE_LIST",
|
||||
"CH_GRAPH_EDGE_LIST",
|
||||
"CH_EDGE_FILTER_0",
|
||||
@ -111,6 +112,7 @@ struct DataLayout
|
||||
COMPONENT_ID_LIST,
|
||||
TRAVEL_MODE_LIST,
|
||||
CLASSES_LIST,
|
||||
IS_LEFT_HAND_DRIVING_LIST,
|
||||
CH_GRAPH_NODE_LIST,
|
||||
CH_GRAPH_EDGE_LIST,
|
||||
CH_EDGE_FILTER_0,
|
||||
|
@ -168,14 +168,16 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
||||
GeometryID{packed_geometry_id, true},
|
||||
forward_data.name_id,
|
||||
forward_data.travel_mode,
|
||||
forward_data.classes);
|
||||
forward_data.classes,
|
||||
forward_data.is_left_hand_driving);
|
||||
if (reverse_data.edge_id != SPECIAL_EDGEID)
|
||||
{
|
||||
m_edge_based_node_container.SetData(reverse_data.edge_id,
|
||||
GeometryID{packed_geometry_id, false},
|
||||
reverse_data.name_id,
|
||||
reverse_data.travel_mode,
|
||||
reverse_data.classes);
|
||||
reverse_data.classes,
|
||||
reverse_data.is_left_hand_driving);
|
||||
}
|
||||
|
||||
// Add segments of edge-based nodes
|
||||
@ -378,7 +380,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
||||
m_edge_based_node_container.GetGeometryID(static_cast<NodeID>(edge_data.edge_id)),
|
||||
edge_data.name_id,
|
||||
edge_data.travel_mode,
|
||||
edge_data.classes);
|
||||
edge_data.classes,
|
||||
edge_data.is_left_hand_driving);
|
||||
|
||||
m_edge_based_node_weights.push_back(m_edge_based_node_weights[eid]);
|
||||
|
||||
|
@ -259,6 +259,7 @@ void Storage::PopulateLayout(DataLayout &layout)
|
||||
layout.SetBlockSize<ComponentID>(DataLayout::COMPONENT_ID_LIST, nodes_number);
|
||||
layout.SetBlockSize<extractor::TravelMode>(DataLayout::TRAVEL_MODE_LIST, nodes_number);
|
||||
layout.SetBlockSize<extractor::ClassData>(DataLayout::CLASSES_LIST, nodes_number);
|
||||
layout.SetBlockSize<unsigned>(DataLayout::IS_LEFT_HAND_DRIVING_LIST, nodes_number);
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(config.GetPath(".osrm.hsgr")))
|
||||
@ -733,11 +734,18 @@ void Storage::PopulateData(const DataLayout &layout, char *memory_ptr)
|
||||
util::vector_view<extractor::ClassData> classes(
|
||||
classes_list_ptr, layout.num_entries[storage::DataLayout::CLASSES_LIST]);
|
||||
|
||||
auto is_left_hand_driving_ptr = layout.GetBlockPtr<unsigned, true>(
|
||||
memory_ptr, storage::DataLayout::IS_LEFT_HAND_DRIVING_LIST);
|
||||
util::vector_view<bool> is_left_hand_driving(
|
||||
is_left_hand_driving_ptr,
|
||||
layout.num_entries[storage::DataLayout::IS_LEFT_HAND_DRIVING_LIST]);
|
||||
|
||||
extractor::EdgeBasedNodeDataView node_data(std::move(geometry_ids),
|
||||
std::move(name_ids),
|
||||
std::move(component_ids),
|
||||
std::move(travel_modes),
|
||||
std::move(classes));
|
||||
std::move(classes),
|
||||
std::move(is_left_hand_driving));
|
||||
|
||||
extractor::files::readNodeData(config.GetPath(".osrm.ebg_nodes"), node_data);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
}
|
||||
|
||||
util::guidance::EntryClass GetEntryClass(const EdgeID /*turn_id*/) const override { return {}; }
|
||||
bool IsLeftHandDriving() const override { return false; }
|
||||
bool IsLeftHandDriving(const NodeID /*id*/) const override { return false; }
|
||||
};
|
||||
|
||||
} // datafacade
|
||||
|
@ -223,7 +223,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
const char *GetWeightName() const override final { return "duration"; }
|
||||
unsigned GetWeightPrecision() const override final { return 1; }
|
||||
double GetWeightMultiplier() const override final { return 10.; }
|
||||
bool IsLeftHandDriving() const override { return false; }
|
||||
bool IsLeftHandDriving(const NodeID /*id*/) const override { return false; }
|
||||
|
||||
util::guidance::TurnBearing PreTurnBearing(const EdgeID /*eid*/) const override final
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user