expose lanes as enums, adjusted for comments
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#ifndef OSRM_ENGINE_GUIDANCE_DEBUG_HPP_
|
||||
#define OSRM_ENGINE_GUIDANCE_DEBUG_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "engine/guidance/route_step.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
inline void print(const engine::guidance::RouteStep &step)
|
||||
{
|
||||
std::cout << static_cast<int>(step.maneuver.instruction.type) << " "
|
||||
<< static_cast<int>(step.maneuver.instruction.direction_modifier) << " "
|
||||
<< static_cast<int>(step.maneuver.waypoint_type) << " Duration: " << step.duration
|
||||
<< " Distance: " << step.distance << " Geometry: " << step.geometry_begin << " "
|
||||
<< step.geometry_end << " exit: " << step.maneuver.exit
|
||||
<< " Intersections: " << step.intersections.size() << " [";
|
||||
|
||||
for (const auto &intersection : step.intersections)
|
||||
{
|
||||
std::cout << "(bearings:";
|
||||
for (auto bearing : intersection.bearings)
|
||||
std::cout << " " << bearing;
|
||||
std::cout << ", entry: ";
|
||||
for (auto entry : intersection.entry)
|
||||
std::cout << " " << (entry ? "true" : "false");
|
||||
std::cout << ")";
|
||||
}
|
||||
std::cout << "] name[" << step.name_id << "]: " << step.name;
|
||||
}
|
||||
|
||||
inline void print(const std::vector<engine::guidance::RouteStep> &steps)
|
||||
{
|
||||
std::cout << "Path\n";
|
||||
int segment = 0;
|
||||
for (const auto &step : steps)
|
||||
{
|
||||
std::cout << "\t[" << segment++ << "]: ";
|
||||
print(step);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
inline void print(const extractor::guidance::lanes::LaneDataVector &turn_lane_data)
|
||||
{
|
||||
std::cout << " Tags:\n";
|
||||
for (auto entry : turn_lane_data)
|
||||
std::cout << "\t" << entry.tag << "("
|
||||
<< extractor::guidance::TurnLaneType::toString(entry.tag)
|
||||
<< ") from: " << static_cast<int>(entry.from)
|
||||
<< " to: " << static_cast<int>(entry.to) << "\n";
|
||||
std::cout << std::flush;
|
||||
}
|
||||
|
||||
inline void
|
||||
printTurnAssignmentData(const NodeID at,
|
||||
const extractor::guidance::lanes::LaneDataVector &turn_lane_data,
|
||||
const extractor::guidance::Intersection &intersection,
|
||||
const std::vector<extractor::QueryNode> &node_info_list)
|
||||
{
|
||||
std::cout << "[Turn Assignment Progress]\nLocation:";
|
||||
auto coordinate = node_info_list[at];
|
||||
std::cout << std::setprecision(12) << toFloating(coordinate.lat) << " "
|
||||
<< toFloating(coordinate.lon) << "\n";
|
||||
|
||||
std::cout << " Intersection:\n";
|
||||
for (const auto &road : intersection)
|
||||
std::cout << "\t" << toString(road) << "\n";
|
||||
|
||||
// flushes as well
|
||||
print(turn_lane_data);
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_ENGINE_GUIDANCE_DEBUG_HPP_*/
|
||||
@@ -74,7 +74,7 @@ class LaneTupel
|
||||
}
|
||||
};
|
||||
|
||||
using LaneTupelIdPair = std::pair<util::guidance::LaneTupel, LaneStringID>;
|
||||
using LaneTupelIdPair = std::pair<util::guidance::LaneTupel, LaneDescriptionID>;
|
||||
} // namespace guidance
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <bitset>
|
||||
#include <fstream>
|
||||
#include <stxxl/vector>
|
||||
#include <vector>
|
||||
|
||||
#include "util/fingerprint.hpp"
|
||||
@@ -88,6 +90,84 @@ bool deserializeVector(std::istream &stream, std::vector<simple_type> &data)
|
||||
return static_cast<bool>(stream);
|
||||
}
|
||||
|
||||
// serializes a vector of vectors into an adjacency array (creates a copy of the data internally)
|
||||
template <typename simple_type>
|
||||
bool serializeVectorIntoAdjacencyArray(const std::string &filename,
|
||||
const std::vector<std::vector<simple_type>> &data)
|
||||
{
|
||||
std::ofstream out_stream(filename, std::ios::binary);
|
||||
std::vector<std::uint32_t> offsets;
|
||||
offsets.reserve(data.size() + 1);
|
||||
std::uint64_t current_offset = 0;
|
||||
offsets.push_back(current_offset);
|
||||
for (auto const &vec : data)
|
||||
{
|
||||
current_offset += vec.size();
|
||||
offsets.push_back(boost::numeric_cast<std::uint32_t>(current_offset));
|
||||
}
|
||||
if (!serializeVector(out_stream, offsets))
|
||||
return false;
|
||||
|
||||
std::vector<simple_type> all_data;
|
||||
all_data.reserve(offsets.back());
|
||||
for (auto const &vec : data)
|
||||
all_data.insert(all_data.end(), vec.begin(), vec.end());
|
||||
|
||||
if (!serializeVector(out_stream, all_data))
|
||||
return false;
|
||||
|
||||
return static_cast<bool>(out_stream);
|
||||
}
|
||||
|
||||
template <typename simple_type, std::size_t WRITE_BLOCK_BUFFER_SIZE = 1024>
|
||||
bool serializeVector(std::ofstream &out_stream, const stxxl::vector<simple_type> &data)
|
||||
{
|
||||
const std::uint64_t size = data.size();
|
||||
out_stream.write(reinterpret_cast<const char *>(&size), sizeof(size));
|
||||
|
||||
simple_type write_buffer[WRITE_BLOCK_BUFFER_SIZE];
|
||||
std::size_t buffer_len = 0;
|
||||
|
||||
for (const auto entry : data)
|
||||
{
|
||||
write_buffer[buffer_len++] = entry;
|
||||
|
||||
if (buffer_len >= WRITE_BLOCK_BUFFER_SIZE)
|
||||
{
|
||||
out_stream.write(reinterpret_cast<const char *>(write_buffer),
|
||||
WRITE_BLOCK_BUFFER_SIZE * sizeof(simple_type));
|
||||
buffer_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// write remaining entries
|
||||
if (buffer_len > 0)
|
||||
out_stream.write(reinterpret_cast<const char *>(write_buffer),
|
||||
buffer_len * sizeof(simple_type));
|
||||
|
||||
return static_cast<bool>(out_stream);
|
||||
}
|
||||
|
||||
template <typename simple_type>
|
||||
bool deserializeAdjacencyArray(const std::string &filename,
|
||||
std::vector<std::uint32_t> &offsets,
|
||||
std::vector<simple_type>& data)
|
||||
{
|
||||
std::ifstream in_stream(filename, std::ios::binary);
|
||||
|
||||
if (!deserializeVector(in_stream, offsets))
|
||||
return false;
|
||||
|
||||
if (!deserializeVector(in_stream, data))
|
||||
return false;
|
||||
|
||||
// offsets have to match up with the size of the data
|
||||
if (offsets.empty() || (offsets.back() != boost::numeric_cast<std::uint32_t>(data.size())))
|
||||
return false;
|
||||
|
||||
return static_cast<bool>(in_stream);
|
||||
}
|
||||
|
||||
inline bool serializeFlags(const boost::filesystem::path &path, const std::vector<bool> &flags)
|
||||
{
|
||||
// TODO this should be replaced with a FILE-based write using error checking
|
||||
|
||||
@@ -21,7 +21,7 @@ struct NodeBasedEdgeData
|
||||
: distance(INVALID_EDGE_WEIGHT), edge_id(SPECIAL_NODEID),
|
||||
name_id(std::numeric_limits<unsigned>::max()), access_restricted(false), reversed(false),
|
||||
roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
lane_string_id(INVALID_LANE_STRINGID)
|
||||
lane_description_id(INVALID_LANE_DESCRIPTIONID)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ struct NodeBasedEdgeData
|
||||
bool roundabout,
|
||||
bool startpoint,
|
||||
extractor::TravelMode travel_mode,
|
||||
const LaneStringID lane_string_id)
|
||||
const LaneDescriptionID lane_description_id)
|
||||
: distance(distance), edge_id(edge_id), name_id(name_id),
|
||||
access_restricted(access_restricted), reversed(reversed), roundabout(roundabout),
|
||||
startpoint(startpoint), travel_mode(travel_mode), lane_string_id(lane_string_id)
|
||||
startpoint(startpoint), travel_mode(travel_mode), lane_description_id(lane_description_id)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ struct NodeBasedEdgeData
|
||||
bool roundabout : 1;
|
||||
bool startpoint : 1;
|
||||
extractor::TravelMode travel_mode : 4;
|
||||
LaneStringID lane_string_id;
|
||||
LaneDescriptionID lane_description_id;
|
||||
extractor::guidance::RoadClassificationData road_classification;
|
||||
|
||||
bool IsCompatibleTo(const NodeBasedEdgeData &other) const
|
||||
@@ -83,7 +83,7 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
|
||||
output_edge.data.travel_mode = input_edge.travel_mode;
|
||||
output_edge.data.startpoint = input_edge.startpoint;
|
||||
output_edge.data.road_classification = input_edge.road_classification;
|
||||
output_edge.data.lane_string_id = input_edge.lane_string_id;
|
||||
output_edge.data.lane_description_id = input_edge.lane_description_id;
|
||||
});
|
||||
|
||||
tbb::parallel_sort(edges_list.begin(), edges_list.end());
|
||||
|
||||
@@ -59,12 +59,12 @@ using EdgeID = std::uint32_t;
|
||||
using NameID = std::uint32_t;
|
||||
using EdgeWeight = std::int32_t;
|
||||
|
||||
using LaneStringID = std::uint16_t;
|
||||
static const LaneStringID INVALID_LANE_STRINGID = std::numeric_limits<LaneStringID>::max();
|
||||
using LaneID = std::uint8_t;
|
||||
static const LaneID INVALID_LANEID = std::numeric_limits<LaneID>::max();
|
||||
using LaneDataID = std::uint16_t;
|
||||
static const LaneDataID INVALID_LANE_DATAID = std::numeric_limits<LaneStringID>::max();
|
||||
static const LaneDataID INVALID_LANE_DATAID = std::numeric_limits<LaneDataID>::max();
|
||||
using LaneDescriptionID = std::uint16_t;
|
||||
static const LaneDescriptionID INVALID_LANE_DESCRIPTIONID = std::numeric_limits<LaneDescriptionID>::max();
|
||||
|
||||
using BearingClassID = std::uint32_t;
|
||||
static const BearingClassID INVALID_BEARING_CLASSID = std::numeric_limits<BearingClassID>::max();
|
||||
|
||||
Reference in New Issue
Block a user