osrm-backend/include/guidance/turn_lane_handler.hpp

139 lines
6.2 KiB
C++
Raw Normal View History

#ifndef OSRM_GUIDANCE_TURN_LANE_HANDLER_HPP_
#define OSRM_GUIDANCE_TURN_LANE_HANDLER_HPP_
2016-05-13 13:18:00 -04:00
2018-03-21 07:10:02 -04:00
#include "extractor/name_table.hpp"
2016-05-13 13:18:00 -04:00
#include "extractor/query_node.hpp"
#include "extractor/turn_lane_types.hpp"
2018-03-21 07:10:02 -04:00
#include "guidance/intersection.hpp"
#include "guidance/turn_analysis.hpp"
#include "guidance/turn_lane_data.hpp"
2016-05-13 13:18:00 -04:00
#include "util/attributes.hpp"
2016-05-13 13:18:00 -04:00
#include "util/guidance/turn_lanes.hpp"
#include "util/node_based_graph.hpp"
#include "util/typedefs.hpp"
#include <atomic>
#include <cstddef>
#include <cstdint>
2016-05-13 13:18:00 -04:00
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace osrm::guidance::lanes
2016-05-13 13:18:00 -04:00
{
namespace
2016-05-13 13:18:00 -04:00
{
2022-12-10 10:08:22 -05:00
using TurnLaneScenario = enum TurnLaneScenario {
SIMPLE, // a straightforward assignment
PARTITION_LOCAL, // an assignment that requires partitioning, using local turns
SIMPLE_PREVIOUS, // an assignemtnn using the turns specified at the previous road (e.g.
// traffic light, lanes not drawn up to the intersection)
PARTITION_PREVIOUS, // a set of lanes on a turn with a traffic island. The lanes for the
// turn end at the previous turn (parts of it remain valid without being
// shown again)
SLIPROAD, // Sliproads are simple assignments that, for better visual representation should
// include turns from other roads in their listings
MERGE, // Merging Lanes
NONE, // not a turn lane scenario at all
INVALID, // some error might have occurred
UNKNOWN, // UNKNOWN describes all cases that we are currently not able to handle
NUM_SCENARIOS
};
} // namespace
class TurnLaneHandler
{
using UpgradableMutex = boost::interprocess::interprocess_upgradable_mutex;
using ScopedReaderLock = boost::interprocess::sharable_lock<UpgradableMutex>;
using ScopedWriterLock = boost::interprocess::scoped_lock<UpgradableMutex>;
2016-05-13 13:18:00 -04:00
public:
using LaneDataVector = std::vector<TurnLaneData>;
2016-05-13 13:18:00 -04:00
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const extractor::EdgeBasedNodeDataContainer &node_data_container,
const std::vector<util::Coordinate> &node_coordinates,
const extractor::CompressedEdgeContainer &compressed_geometries,
const extractor::RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes,
const extractor::TurnLanesIndexedArray &turn_lanes_data,
extractor::LaneDescriptionMap &lane_description_map,
const TurnAnalysis &turn_analysis,
util::guidance::LaneDataIdMap &id_map);
~TurnLaneHandler();
2016-05-13 13:18:00 -04:00
OSRM_ATTR_WARN_UNUSED
Intersection assignTurnLanes(const NodeID at, const EdgeID via_edge, Intersection intersection);
2016-05-13 13:18:00 -04:00
private:
mutable std::atomic<std::size_t> count_handled;
mutable std::atomic<std::size_t> count_called;
2016-05-13 13:18:00 -04:00
// 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 extractor::EdgeBasedNodeDataContainer &node_data_container;
const std::vector<util::Coordinate> &node_coordinates;
const extractor::CompressedEdgeContainer &compressed_geometries;
const extractor::RestrictionMap &node_restriction_map;
const std::unordered_set<NodeID> &barrier_nodes;
const extractor::TurnLanesIndexedArray &turn_lanes_data;
2017-06-16 08:35:04 -04:00
std::vector<std::uint32_t> turn_lane_offsets;
std::vector<extractor::TurnLaneType::Mask> turn_lane_masks;
extractor::LaneDescriptionMap &lane_description_map;
2016-05-13 13:18:00 -04:00
const TurnAnalysis &turn_analysis;
util::guidance::LaneDataIdMap &id_map;
// Find out which scenario we have to handle
TurnLaneScenario deduceScenario(const NodeID at,
const EdgeID via_edge,
const Intersection &intersection,
// Output Parameters to reduce repeated creation
LaneDescriptionID &lane_description_id,
LaneDataVector &lane_data,
NodeID &previous_node,
EdgeID &previous_id,
Intersection &previous_intersection,
LaneDataVector &previous_lane_data,
LaneDescriptionID &previous_description_id);
2016-05-13 13:18:00 -04:00
// check whether we can handle an intersection
bool isSimpleIntersection(const LaneDataVector &turn_lane_data,
const Intersection &intersection) const;
// in case of a simple intersection, assign the lane entries
OSRM_ATTR_WARN_UNUSED
2016-05-13 13:18:00 -04:00
Intersection simpleMatchTuplesToTurns(Intersection intersection,
2016-06-15 08:38:24 -04:00
const LaneDataVector &lane_data,
const LaneDescriptionID lane_string_id);
2016-05-13 13:18:00 -04:00
// partition lane data into lane data relevant at current turn and at next turn
OSRM_ATTR_WARN_UNUSED
2016-05-13 13:18:00 -04:00
std::pair<TurnLaneHandler::LaneDataVector, TurnLaneHandler::LaneDataVector> partitionLaneData(
const NodeID at, LaneDataVector turn_lane_data, const Intersection &intersection) const;
// Sliproad turns have a separated lane to the right/left of other depicted lanes. These lanes
// are not necessarily separated clearly from the rest of the way. As a result, we combine both
// lane entries for our output, while performing the matching with the separated lanes only.
OSRM_ATTR_WARN_UNUSED
Intersection handleSliproadTurn(Intersection intersection,
const LaneDescriptionID lane_description_id,
LaneDataVector lane_data,
2016-07-08 05:45:36 -04:00
const Intersection &previous_intersection);
// get the lane data for an intersection
void extractLaneData(const EdgeID via_edge,
LaneDescriptionID &lane_description_id,
LaneDataVector &lane_data) const;
2016-05-13 13:18:00 -04:00
};
} // namespace osrm
#endif // OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_