Refactor turn lane passing
This commit is contained in:
committed by
Patrick Niklaus
parent
4f13208ce8
commit
37b8d3acd4
@@ -83,8 +83,6 @@ class EdgeBasedGraphFactory
|
||||
const extractor::PackedOSMIDs &osm_node_ids,
|
||||
ProfileProperties profile_properties,
|
||||
const util::NameTable &name_table,
|
||||
std::vector<std::uint32_t> &turn_lane_offsets,
|
||||
std::vector<guidance::TurnLaneType::Mask> &turn_lane_masks,
|
||||
guidance::LaneDescriptionMap &lane_description_map);
|
||||
|
||||
void Run(ScriptingEnvironment &scripting_environment,
|
||||
@@ -150,8 +148,6 @@ class EdgeBasedGraphFactory
|
||||
ProfileProperties profile_properties;
|
||||
|
||||
const util::NameTable &name_table;
|
||||
std::vector<std::uint32_t> &turn_lane_offsets;
|
||||
std::vector<guidance::TurnLaneType::Mask> &turn_lane_masks;
|
||||
guidance::LaneDescriptionMap &lane_description_map;
|
||||
|
||||
unsigned RenumberEdges();
|
||||
|
||||
@@ -56,8 +56,8 @@ class Extractor
|
||||
private:
|
||||
ExtractorConfig config;
|
||||
|
||||
std::vector<TurnRestriction> ParseOSMData(ScriptingEnvironment &scripting_environment,
|
||||
const unsigned number_of_threads);
|
||||
std::tuple<guidance::LaneDescriptionMap, std::vector<TurnRestriction>>
|
||||
ParseOSMData(ScriptingEnvironment &scripting_environment, const unsigned number_of_threads);
|
||||
|
||||
std::pair<std::size_t, EdgeID>
|
||||
BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
||||
@@ -69,7 +69,8 @@ class Extractor
|
||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
||||
const std::string &intersection_class_output_file,
|
||||
std::vector<TurnRestriction> &turn_restrictions);
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
guidance::LaneDescriptionMap &turn_lane_map);
|
||||
void FindComponents(unsigned max_edge_id,
|
||||
const util::DeallocatingVector<EdgeBasedEdge> &input_edge_list,
|
||||
const std::vector<EdgeBasedNodeSegment> &input_node_segments,
|
||||
@@ -90,20 +91,10 @@ class Extractor
|
||||
const std::vector<util::guidance::BearingClass> &bearing_classes,
|
||||
const std::vector<util::guidance::EntryClass> &entry_classes) const;
|
||||
|
||||
void WriteTurnLaneData(const std::string &turn_lane_file) const;
|
||||
|
||||
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
|
||||
static void WriteCompressedNodeBasedGraph(const std::string &path,
|
||||
const util::NodeBasedDynamicGraph &graph,
|
||||
const std::vector<util::Coordinate> &coordiantes);
|
||||
|
||||
// globals persisting during the extraction process and the graph generation process
|
||||
|
||||
// during turn lane analysis, we might have to combine lanes for roads that are modelled as two
|
||||
// but are more or less experienced as one. This can be due to solid lines in between lanes, for
|
||||
// example, that genereate a small separation between them. As a result, we might have to
|
||||
// augment the turn lane map during processing, further adding more types.
|
||||
guidance::LaneDescriptionMap turn_lane_map;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@ class TurnLaneHandler
|
||||
typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<std::uint32_t> &turn_lane_offsets,
|
||||
const std::vector<TurnLaneType::Mask> &turn_lane_masks,
|
||||
LaneDescriptionMap &lane_description_map,
|
||||
const TurnAnalysis &turn_analysis,
|
||||
util::guidance::LaneDataIdMap &id_map);
|
||||
@@ -90,8 +88,8 @@ class TurnLaneHandler
|
||||
// we need to be able to look at previous intersections to, in some cases, find the correct turn
|
||||
// lanes for a turn
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const std::vector<std::uint32_t> &turn_lane_offsets;
|
||||
const std::vector<TurnLaneType::Mask> &turn_lane_masks;
|
||||
std::vector<std::uint32_t> turn_lane_offsets;
|
||||
std::vector<TurnLaneType::Mask> turn_lane_masks;
|
||||
LaneDescriptionMap &lane_description_map;
|
||||
const TurnAnalysis &turn_analysis;
|
||||
util::guidance::LaneDataIdMap &id_map;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <numeric> //partial_sum
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
@@ -99,6 +100,34 @@ typedef util::ConcurrentIDMap<guidance::TurnLaneDescription,
|
||||
guidance::TurnLaneDescription_hash>
|
||||
LaneDescriptionMap;
|
||||
|
||||
inline std::tuple<std::vector<std::uint32_t>, std::vector<TurnLaneType::Mask>>
|
||||
transformTurnLaneMapIntoArrays(const LaneDescriptionMap &turn_lane_map)
|
||||
{
|
||||
// could use some additional capacity? To avoid a copy during processing, though small data so
|
||||
// probably not that important.
|
||||
//
|
||||
// From the map, we construct an adjacency array that allows access from all IDs to the list of
|
||||
// associated Turn Lane Masks.
|
||||
//
|
||||
// turn lane offsets points into the locations of the turn_lane_masks array. We use a standard
|
||||
// adjacency array like structure to store the turn lane masks.
|
||||
std::vector<std::uint32_t> turn_lane_offsets(turn_lane_map.data.size() +
|
||||
2); // empty ID + sentinel
|
||||
for (auto entry = turn_lane_map.data.begin(); entry != turn_lane_map.data.end(); ++entry)
|
||||
turn_lane_offsets[entry->second + 1] = entry->first.size();
|
||||
|
||||
// inplace prefix sum
|
||||
std::partial_sum(turn_lane_offsets.begin(), turn_lane_offsets.end(), turn_lane_offsets.begin());
|
||||
|
||||
// allocate the current masks
|
||||
std::vector<guidance::TurnLaneType::Mask> turn_lane_masks(turn_lane_offsets.back());
|
||||
for (auto entry = turn_lane_map.data.begin(); entry != turn_lane_map.data.end(); ++entry)
|
||||
std::copy(entry->first.begin(),
|
||||
entry->first.end(),
|
||||
turn_lane_masks.begin() + turn_lane_offsets[entry->second]);
|
||||
return std::make_tuple(std::move(turn_lane_offsets), std::move(turn_lane_masks));
|
||||
}
|
||||
|
||||
} // guidance
|
||||
} // extractor
|
||||
} // osrm
|
||||
|
||||
@@ -27,6 +27,23 @@ struct ConcurrentIDMap
|
||||
std::unordered_map<KeyType, ValueType, HashType> data;
|
||||
mutable UpgradableMutex mutex;
|
||||
|
||||
ConcurrentIDMap() = default;
|
||||
ConcurrentIDMap(ConcurrentIDMap &&other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
|
||||
data = std::move(other.data);
|
||||
}
|
||||
ConcurrentIDMap& operator=(ConcurrentIDMap &&other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
|
||||
data = std::move(other.data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const ValueType ConcurrentFindOrAdd(const KeyType &key)
|
||||
{
|
||||
{
|
||||
@@ -54,4 +71,4 @@ struct ConcurrentIDMap
|
||||
} // util
|
||||
} // osrm
|
||||
|
||||
#endif // CONCURRENT_ID_MAP_HPP
|
||||
#endif // CONCURRENT_ID_MAP_HPP
|
||||
|
||||
Reference in New Issue
Block a user