add a toolkit function to find lanes to the left/right of turn lanes

This commit is contained in:
karenzshea
2016-10-04 15:28:13 -04:00
committed by Moritz Kobitzsch
parent 17eb664597
commit 72fa35da10
16 changed files with 99 additions and 70 deletions
@@ -147,7 +147,7 @@ class BaseDataFacade
const int bearing_range) const = 0;
virtual bool hasLaneData(const EdgeID id) const = 0;
virtual util::guidance::LaneTupelIdPair GetLaneData(const EdgeID id) const = 0;
virtual util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const = 0;
virtual extractor::guidance::TurnLaneDescription
GetTurnDescription(const LaneDescriptionID lane_description_id) const = 0;
@@ -80,7 +80,7 @@ class InternalDataFacade final : public BaseDataFacade
util::ShM<unsigned, false>::vector m_name_ID_list;
util::ShM<extractor::guidance::TurnInstruction, false>::vector m_turn_instruction_list;
util::ShM<LaneDataID, false>::vector m_lane_data_id;
util::ShM<util::guidance::LaneTupelIdPair, false>::vector m_lane_tupel_id_pairs;
util::ShM<util::guidance::LaneTupleIdPair, false>::vector m_lane_tuple_id_pairs;
util::ShM<extractor::TravelMode, false>::vector m_travel_mode_list;
util::ShM<char, false>::vector m_names_char_list;
util::ShM<unsigned, false>::vector m_geometry_indices;
@@ -123,7 +123,7 @@ class InternalDataFacade final : public BaseDataFacade
sizeof(m_profile_properties));
}
void LoadLaneTupelIdPairs(const boost::filesystem::path &lane_data_path)
void LoadLaneTupleIdPairs(const boost::filesystem::path &lane_data_path)
{
boost::filesystem::ifstream in_stream(lane_data_path);
if (!in_stream)
@@ -132,9 +132,9 @@ class InternalDataFacade final : public BaseDataFacade
}
std::uint64_t size;
in_stream.read(reinterpret_cast<char *>(&size), sizeof(size));
m_lane_tupel_id_pairs.resize(size);
in_stream.read(reinterpret_cast<char *>(&m_lane_tupel_id_pairs[0]),
sizeof(m_lane_tupel_id_pairs) * size);
m_lane_tuple_id_pairs.resize(size);
in_stream.read(reinterpret_cast<char *>(&m_lane_tuple_id_pairs[0]),
sizeof(m_lane_tuple_id_pairs) * size);
}
void LoadTimestamp(const boost::filesystem::path &timestamp_path)
@@ -426,7 +426,7 @@ class InternalDataFacade final : public BaseDataFacade
LoadIntersectionClasses(config.intersection_class_path);
util::SimpleLogger().Write() << "Loading Lane Data Pairs";
LoadLaneTupelIdPairs(config.turn_lane_data_path);
LoadLaneTupleIdPairs(config.turn_lane_data_path);
}
// search graph access
@@ -921,10 +921,10 @@ class InternalDataFacade final : public BaseDataFacade
return m_lane_data_id[id] != INVALID_LANE_DATAID;
}
util::guidance::LaneTupelIdPair GetLaneData(const EdgeID id) const override final
util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const override final
{
BOOST_ASSERT(hasLaneData(id));
return m_lane_tupel_id_pairs[m_lane_data_id[id]];
return m_lane_tuple_id_pairs[m_lane_data_id[id]];
}
extractor::guidance::TurnLaneDescription
@@ -96,7 +96,7 @@ class SharedDataFacade final : public BaseDataFacade
util::ShM<char, true>::vector m_datasource_name_data;
util::ShM<std::size_t, true>::vector m_datasource_name_offsets;
util::ShM<std::size_t, true>::vector m_datasource_name_lengths;
util::ShM<util::guidance::LaneTupelIdPair, true>::vector m_lane_tupel_id_pairs;
util::ShM<util::guidance::LaneTupleIdPair, true>::vector m_lane_tupel_id_pairs;
std::unique_ptr<SharedRTree> m_static_rtree;
std::unique_ptr<SharedGeospatialQuery> m_geospatial_query;
@@ -198,9 +198,9 @@ class SharedDataFacade final : public BaseDataFacade
lane_data_id_ptr, data_layout->num_entries[storage::SharedDataLayout::LANE_DATA_ID]);
m_lane_data_id = std::move(lane_data_id);
auto lane_tupel_id_pair_ptr = data_layout->GetBlockPtr<util::guidance::LaneTupelIdPair>(
auto lane_tupel_id_pair_ptr = data_layout->GetBlockPtr<util::guidance::LaneTupleIdPair>(
shared_memory, storage::SharedDataLayout::TURN_LANE_DATA);
util::ShM<util::guidance::LaneTupelIdPair, true>::vector lane_tupel_id_pair(
util::ShM<util::guidance::LaneTupleIdPair, true>::vector lane_tupel_id_pair(
lane_tupel_id_pair_ptr,
data_layout->num_entries[storage::SharedDataLayout::TURN_LANE_DATA]);
m_lane_tupel_id_pairs = std::move(lane_tupel_id_pair);
@@ -960,7 +960,7 @@ class SharedDataFacade final : public BaseDataFacade
return INVALID_LANE_DATAID != m_lane_data_id.at(id);
}
util::guidance::LaneTupelIdPair GetLaneData(const EdgeID id) const override final
util::guidance::LaneTupleIdPair GetLaneData(const EdgeID id) const override final
{
BOOST_ASSERT(hasLaneData(id));
return m_lane_tupel_id_pairs.at(m_lane_data_id.at(id));
+2 -2
View File
@@ -79,7 +79,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
std::vector<bool>({true}),
Intersection::NO_INDEX,
0,
util::guidance::LaneTupel(),
util::guidance::LaneTuple(),
{}};
if (leg_data.size() > 0)
@@ -227,7 +227,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
std::vector<bool>({true}),
0,
Intersection::NO_INDEX,
util::guidance::LaneTupel(),
util::guidance::LaneTuple(),
{}};
BOOST_ASSERT(!leg_geometry.locations.empty());
+2 -2
View File
@@ -39,7 +39,7 @@ struct Intersection
std::size_t out;
// turn lane information
util::guidance::LaneTupel lanes;
util::guidance::LaneTuple lanes;
extractor::guidance::TurnLaneDescription lane_description;
};
@@ -50,7 +50,7 @@ inline Intersection getInvalidIntersection()
{},
Intersection::NO_INDEX,
Intersection::NO_INDEX,
util::guidance::LaneTupel(),
util::guidance::LaneTuple(),
{}};
}
+1 -1
View File
@@ -28,7 +28,7 @@ struct PathData
// instruction to execute at the turn
extractor::guidance::TurnInstruction turn_instruction;
// turn lane data
util::guidance::LaneTupelIdPair lane_data;
util::guidance::LaneTupleIdPair lane_data;
// travel mode of the street that leads to the turn
extractor::TravelMode travel_mode : 4;
// entry class of the turn, indicating possibility of turns
+31 -2
View File
@@ -16,6 +16,8 @@
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/guidance/route_step.hpp"
#include <algorithm>
#include <cmath>
#include <cstdint>
@@ -26,6 +28,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/functional/hash.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/tokenizer.hpp>
namespace osrm
@@ -35,8 +38,8 @@ namespace extractor
namespace guidance
{
using util::guidance::LaneTupelIdPair;
using LaneDataIdMap = std::unordered_map<LaneTupelIdPair, LaneDataID, boost::hash<LaneTupelIdPair>>;
using util::guidance::LaneTupleIdPair;
using LaneDataIdMap = std::unordered_map<LaneTupleIdPair, LaneDataID, boost::hash<LaneTupleIdPair>>;
using util::guidance::angularDeviation;
using util::guidance::entersRoundabout;
@@ -285,6 +288,32 @@ inline std::string applyAccessTokens(std::string lane_string, const std::string
return result_string;
}
LaneID inline numLanesToTheRight(const engine::guidance::RouteStep &step)
{
return step.intersections.front().lanes.first_lane_from_the_right;
}
LaneID inline numLanesToTheLeft(const engine::guidance::RouteStep &step)
{
LaneID const total = step.intersections.front().lane_description.size();
return total - (step.intersections.front().lanes.lanes_in_turn +
step.intersections.front().lanes.first_lane_from_the_right);
}
auto inline lanesToTheLeft(const engine::guidance::RouteStep &step)
{
const auto &description = step.intersections.front().lane_description;
LaneID num_lanes_left = numLanesToTheLeft(step);
return boost::make_iterator_range(description.begin(), description.begin() + num_lanes_left);
}
auto inline lanesToTheRight(const engine::guidance::RouteStep &step)
{
const auto &description = step.intersections.front().lane_description;
LaneID num_lanes_right = numLanesToTheRight(step);
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
}
} // namespace guidance
} // namespace extractor
} // namespace osrm
@@ -71,7 +71,7 @@ const constexpr Enum MaxTurnType = 27; // Special value for static asserts
// turn angle in 1.40625 degree -> 128 == 180 degree
struct TurnInstruction
{
using LaneTupel = util::guidance::LaneTupel;
using LaneTuple = util::guidance::LaneTuple;
TurnInstruction(const TurnType::Enum type = TurnType::Invalid,
const DirectionModifier::Enum direction_modifier = DirectionModifier::UTurn)
: type(type), direction_modifier(direction_modifier)
+10 -10
View File
@@ -16,16 +16,16 @@ namespace util
{
namespace guidance
{
class LaneTupel;
class LaneTuple;
} // namespace guidance
} // namespace util
} // namespace osrm
namespace std
{
template <> struct hash<::osrm::util::guidance::LaneTupel>
template <> struct hash<::osrm::util::guidance::LaneTuple>
{
inline std::size_t operator()(const ::osrm::util::guidance::LaneTupel &bearing_class) const;
inline std::size_t operator()(const ::osrm::util::guidance::LaneTuple &bearing_class) const;
};
} // namespace std
@@ -52,19 +52,19 @@ namespace guidance
//
// we generate a set of tuples in the form of:
// (2,1), (1,1), (1,0) for left, through and right respectively
class LaneTupel
class LaneTuple
{
public:
LaneTupel();
LaneTupel(const LaneID lanes_in_turn, const LaneID first_lane_from_the_right);
LaneTuple();
LaneTuple(const LaneID lanes_in_turn, const LaneID first_lane_from_the_right);
bool operator==(const LaneTupel other) const;
bool operator!=(const LaneTupel other) const;
bool operator==(const LaneTuple other) const;
bool operator!=(const LaneTuple other) const;
LaneID lanes_in_turn;
LaneID first_lane_from_the_right;
friend std::size_t hash_value(const LaneTupel &tup)
friend std::size_t hash_value(const LaneTuple &tup)
{
std::size_t seed{0};
boost::hash_combine(seed, tup.lanes_in_turn);
@@ -73,7 +73,7 @@ class LaneTupel
}
};
using LaneTupelIdPair = std::pair<util::guidance::LaneTupel, LaneDescriptionID>;
using LaneTupleIdPair = std::pair<util::guidance::LaneTuple, LaneDescriptionID>;
} // namespace guidance
} // namespace util
} // namespace osrm