Remove data duplicates in .node file

This commit is contained in:
Michael Krasnyk 2017-05-11 09:13:59 +02:00 committed by Patrick Niklaus
parent 8934167e76
commit ca6b1b39b7
15 changed files with 186 additions and 195 deletions

View File

@ -50,14 +50,19 @@ class BaseAPI
{
if (parameters.generate_hints)
{
return json::makeWaypoint(phantom.location,
facade.GetNameForID(phantom.name_id).to_string(),
Hint{phantom, facade.GetCheckSum()});
// TODO: check forward/reverse
return json::makeWaypoint(
phantom.location,
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id)).to_string(),
Hint{phantom, facade.GetCheckSum()});
}
else
{
return json::makeWaypoint(phantom.location,
facade.GetNameForID(phantom.name_id).to_string());
// TODO: check forward/reverse
return json::makeWaypoint(
phantom.location,
facade.GetNameForID(facade.GetNameIndex(phantom.forward_segment_id.id))
.to_string());
}
}

View File

@ -374,14 +374,20 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
EdgeDuration forward_duration_offset = 0, forward_duration = 0;
EdgeDuration reverse_duration_offset = 0, reverse_duration = 0;
BOOST_ASSERT(data.forward_segment_id.enabled || data.reverse_segment_id.enabled);
BOOST_ASSERT(!data.reverse_segment_id.enabled ||
datafacade.GetGeometryIndex(data.forward_segment_id.id).id ==
datafacade.GetGeometryIndex(data.reverse_segment_id.id).id);
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
const std::vector<EdgeWeight> forward_weight_vector =
datafacade.GetUncompressedForwardWeights(data.packed_geometry_id);
datafacade.GetUncompressedForwardWeights(geometry_id);
const std::vector<EdgeWeight> reverse_weight_vector =
datafacade.GetUncompressedReverseWeights(data.packed_geometry_id);
datafacade.GetUncompressedReverseWeights(geometry_id);
const std::vector<EdgeWeight> forward_duration_vector =
datafacade.GetUncompressedForwardDurations(data.packed_geometry_id);
datafacade.GetUncompressedForwardDurations(geometry_id);
const std::vector<EdgeWeight> reverse_duration_vector =
datafacade.GetUncompressedReverseDurations(data.packed_geometry_id);
datafacade.GetUncompressedReverseDurations(geometry_id);
for (std::size_t i = 0; i < data.fwd_segment_position; i++)
{
@ -505,20 +511,25 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool forward_edge_valid = false;
bool reverse_edge_valid = false;
const std::vector<EdgeWeight> forward_weight_vector =
datafacade.GetUncompressedForwardWeights(segment.data.packed_geometry_id);
const auto &data = segment.data;
BOOST_ASSERT(data.forward_segment_id.enabled);
BOOST_ASSERT(data.forward_segment_id.id != SPECIAL_NODEID);
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
if (forward_weight_vector[segment.data.fwd_segment_position] != INVALID_EDGE_WEIGHT)
const std::vector<EdgeWeight> forward_weight_vector =
datafacade.GetUncompressedForwardWeights(geometry_id);
if (forward_weight_vector[data.fwd_segment_position] != INVALID_EDGE_WEIGHT)
{
forward_edge_valid = segment.data.forward_segment_id.enabled;
forward_edge_valid = data.forward_segment_id.enabled;
}
const std::vector<EdgeWeight> reverse_weight_vector =
datafacade.GetUncompressedReverseWeights(segment.data.packed_geometry_id);
if (reverse_weight_vector[reverse_weight_vector.size() - segment.data.fwd_segment_position -
1] != INVALID_EDGE_WEIGHT)
datafacade.GetUncompressedReverseWeights(geometry_id);
if (reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1] !=
INVALID_EDGE_WEIGHT)
{
reverse_edge_valid = segment.data.reverse_segment_id.enabled;
reverse_edge_valid = data.reverse_segment_id.enabled;
}
return std::make_pair(forward_edge_valid, reverse_edge_valid);

View File

@ -51,8 +51,11 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
// source node rev: 2 0 <- 1 <- 2
const auto source_segment_start_coordinate =
source_node.fwd_segment_position + (reversed_source ? 1 : 0);
const auto source_node_id =
reversed_source ? source_node.reverse_segment_id.id : source_node.forward_segment_id.id;
const auto source_gemetry_id = facade.GetGeometryIndex(source_node_id).id;
const std::vector<NodeID> source_geometry =
facade.GetUncompressedForwardGeometry(source_node.packed_geometry_id);
facade.GetUncompressedForwardGeometry(source_gemetry_id);
geometry.osm_node_ids.push_back(
facade.GetOSMNodeIDOfNode(source_geometry[source_segment_start_coordinate]));
@ -89,8 +92,11 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
// segment leading to the target node
geometry.segment_distances.push_back(cumulative_distance);
const auto target_node_id =
reversed_target ? target_node.reverse_segment_id.id : target_node.forward_segment_id.id;
const auto target_gemetry_id = facade.GetGeometryIndex(target_node_id).id;
const std::vector<DatasourceID> forward_datasources =
facade.GetUncompressedForwardDatasources(target_node.packed_geometry_id);
facade.GetUncompressedForwardDatasources(target_gemetry_id);
// FIXME if source and target phantoms are on the same segment then duration and weight
// will be from one projected point till end of segment
@ -113,7 +119,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
const auto target_segment_end_coordinate =
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
const std::vector<NodeID> target_geometry =
facade.GetUncompressedForwardGeometry(target_node.packed_geometry_id);
facade.GetUncompressedForwardGeometry(target_gemetry_id);
geometry.osm_node_ids.push_back(
facade.GetOSMNodeIDOfNode(target_geometry[target_segment_end_coordinate]));

View File

@ -40,7 +40,8 @@ struct NamedSegment
template <std::size_t SegmentNumber>
std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathData> &route_data,
std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDataFacade &facade,
const std::vector<PathData> &route_data,
const PhantomNode &target_node,
const bool target_traversed_in_reverse)
{
@ -80,8 +81,10 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathDa
});
const auto target_duration =
target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration;
const auto target_node_id = target_traversed_in_reverse ? target_node.reverse_segment_id.id
: target_node.forward_segment_id.id;
if (target_duration > 1)
segments.push_back({target_duration, index++, target_node.name_id});
segments.push_back({target_duration, index++, facade.GetNameIndex(target_node_id)});
// this makes sure that the segment with the lowest position comes first
std::sort(
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
@ -183,7 +186,7 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
if (needs_summary)
{
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(
route_data, target_node, target_traversed_in_reverse);
facade, route_data, target_node, target_traversed_in_reverse);
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
BOOST_ASSERT(summary_array.begin() != summary_array.end());

View File

@ -49,15 +49,19 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
const EdgeWeight source_duration =
source_traversed_in_reverse ? source_node.reverse_duration : source_node.forward_duration;
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
: source_node.forward_travel_mode;
const auto source_node_id = source_traversed_in_reverse ? source_node.reverse_segment_id.id
: source_node.forward_segment_id.id;
const auto source_name_id = facade.GetNameIndex(source_node_id);
const auto source_mode = facade.GetTravelMode(source_node_id);
const EdgeWeight target_duration =
target_traversed_in_reverse ? target_node.reverse_duration : target_node.forward_duration;
const EdgeWeight target_weight =
target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight;
const auto target_mode = target_traversed_in_reverse ? target_node.backward_travel_mode
: target_node.forward_travel_mode;
const auto target_node_id = target_traversed_in_reverse ? target_node.reverse_segment_id.id
: target_node.forward_segment_id.id;
const auto target_name_id = facade.GetNameIndex(target_node_id);
const auto target_mode = facade.GetTravelMode(target_node_id);
const auto number_of_segments = leg_geometry.GetNumberOfSegments();
@ -95,7 +99,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
// some name changes are not announced in our processing. For these, we have to keep the
// first name on the segment
auto step_name_id = source_node.name_id;
auto step_name_id = source_name_id;
for (std::size_t leg_data_index = 0; leg_data_index < leg_data.size(); ++leg_data_index)
{
const auto &path_point = leg_data[leg_data_index];
@ -134,7 +138,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
}
else
{
step_name_id = target_node.name_id;
step_name_id = facade.GetNameIndex(target_node_id);
}
// extract bearings
@ -230,11 +234,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
BOOST_ASSERT(target_duration >= source_duration || weight == 0);
const EdgeWeight duration = std::max(0, target_duration - source_duration);
steps.push_back(RouteStep{source_node.name_id,
facade.GetNameForID(source_node.name_id).to_string(),
facade.GetRefForID(source_node.name_id).to_string(),
facade.GetPronunciationForID(source_node.name_id).to_string(),
facade.GetDestinationsForID(source_node.name_id).to_string(),
steps.push_back(RouteStep{source_name_id,
facade.GetNameForID(source_name_id).to_string(),
facade.GetRefForID(source_name_id).to_string(),
facade.GetPronunciationForID(source_name_id).to_string(),
facade.GetDestinationsForID(source_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
@ -268,11 +272,11 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
0};
BOOST_ASSERT(!leg_geometry.locations.empty());
steps.push_back(RouteStep{target_node.name_id,
facade.GetNameForID(target_node.name_id).to_string(),
facade.GetRefForID(target_node.name_id).to_string(),
facade.GetPronunciationForID(target_node.name_id).to_string(),
facade.GetDestinationsForID(target_node.name_id).to_string(),
steps.push_back(RouteStep{target_name_id,
facade.GetNameForID(target_name_id).to_string(),
facade.GetRefForID(target_name_id).to_string(),
facade.GetPronunciationForID(target_name_id).to_string(),
facade.GetDestinationsForID(target_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,

View File

@ -63,8 +63,8 @@ struct Hint
friend std::ostream &operator<<(std::ostream &, const Hint &);
};
static_assert(sizeof(Hint) == 72 + 4, "Hint is bigger than expected");
constexpr std::size_t ENCODED_HINT_SIZE = 104;
static_assert(sizeof(Hint) == 64 + 4, "Hint is bigger than expected");
constexpr std::size_t ENCODED_HINT_SIZE = 92;
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
"ENCODED_HINT_SIZE does not match size of Hint");
}

View File

@ -48,16 +48,13 @@ struct PhantomNode
{
PhantomNode()
: forward_segment_id{SPECIAL_SEGMENTID, false},
reverse_segment_id{SPECIAL_SEGMENTID, false},
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
reverse_segment_id{SPECIAL_SEGMENTID, false}, forward_weight(INVALID_EDGE_WEIGHT),
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0),
packed_geometry_id(SPECIAL_GEOMETRYID), component{INVALID_COMPONENTID, false},
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE), is_valid_forward_source(false),
is_valid_forward_target(false), is_valid_reverse_source(false),
is_valid_reverse_target(false)
component{INVALID_COMPONENTID, false}, fwd_segment_position(0),
is_valid_forward_source(false), is_valid_forward_target(false),
is_valid_reverse_source(false), is_valid_reverse_target(false)
{
}
@ -95,7 +92,7 @@ struct PhantomNode
(reverse_weight != INVALID_EDGE_WEIGHT)) &&
((forward_duration != MAXIMAL_EDGE_DURATION) ||
(reverse_duration != MAXIMAL_EDGE_DURATION)) &&
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
(component.id != INVALID_COMPONENTID);
}
bool IsValid(const unsigned number_of_nodes, const util::Coordinate queried_coordinate) const
@ -103,7 +100,7 @@ struct PhantomNode
return queried_coordinate == input_location && IsValid(number_of_nodes);
}
bool IsValid() const { return location.IsValid() && (name_id != INVALID_NAMEID); }
bool IsValid() const { return location.IsValid(); }
bool IsValidForwardSource() const
{
@ -141,17 +138,13 @@ struct PhantomNode
const util::Coordinate location,
const util::Coordinate input_location)
: forward_segment_id{other.forward_segment_id},
reverse_segment_id{other.reverse_segment_id}, name_id{other.name_id},
forward_weight{forward_weight}, reverse_weight{reverse_weight},
forward_weight_offset{forward_weight_offset},
reverse_segment_id{other.reverse_segment_id}, forward_weight{forward_weight},
reverse_weight{reverse_weight}, forward_weight_offset{forward_weight_offset},
reverse_weight_offset{reverse_weight_offset}, forward_duration{forward_duration},
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
reverse_duration_offset{reverse_duration_offset},
packed_geometry_id{other.packed_geometry_id},
component{other.component.id, other.component.is_tiny}, location{location},
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
forward_travel_mode{other.forward_travel_mode},
backward_travel_mode{other.backward_travel_mode},
is_valid_forward_source{is_valid_forward_source},
is_valid_forward_target{is_valid_forward_target},
is_valid_reverse_source{is_valid_reverse_source},
@ -161,7 +154,6 @@ struct PhantomNode
SegmentID forward_segment_id;
SegmentID reverse_segment_id;
unsigned name_id;
EdgeWeight forward_weight;
EdgeWeight reverse_weight;
EdgeWeight forward_weight_offset; // TODO: try to remove -> requires path unpacking changes
@ -170,7 +162,6 @@ struct PhantomNode
EdgeWeight reverse_duration;
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
unsigned packed_geometry_id;
struct ComponentType
{
std::uint32_t id : 31;
@ -181,10 +172,6 @@ struct PhantomNode
util::Coordinate location;
util::Coordinate input_location;
unsigned short fwd_segment_position;
// note 4 bits would suffice for each,
// but the saved byte would be padding anyway
extractor::TravelMode forward_travel_mode : 4;
extractor::TravelMode backward_travel_mode : 4;
// is phantom node valid to be used as source or target
private:
bool is_valid_forward_source : 1;
@ -193,7 +180,7 @@ struct PhantomNode
bool is_valid_reverse_target : 1;
};
static_assert(sizeof(PhantomNode) == 72, "PhantomNode has more padding then expected");
static_assert(sizeof(PhantomNode) == 64, "PhantomNode has more padding then expected");
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
@ -220,7 +207,6 @@ inline std::ostream &operator<<(std::ostream &out, const PhantomNode &pn)
{
out << "node1: " << pn.forward_segment_id.id << ", "
<< "node2: " << pn.reverse_segment_id.id << ", "
<< "name: " << pn.name_id << ", "
<< "fwd-w: " << pn.forward_weight << ", "
<< "rev-w: " << pn.reverse_weight << ", "
<< "fwd-o: " << pn.forward_weight_offset << ", "
@ -229,7 +215,6 @@ inline std::ostream &operator<<(std::ostream &out, const PhantomNode &pn)
<< "rev-d: " << pn.reverse_duration << ", "
<< "fwd-do: " << pn.forward_duration_offset << ", "
<< "rev-do: " << pn.reverse_duration_offset << ", "
<< "geom: " << pn.packed_geometry_id << ", "
<< "comp: " << pn.component.is_tiny << " / " << pn.component.id << ", "
<< "pos: " << pn.fwd_segment_position << ", "
<< "loc: " << pn.location;

View File

@ -91,15 +91,17 @@ void annotatePath(const FacadeT &facade,
BOOST_ASSERT(!unpacked_nodes.empty());
BOOST_ASSERT(unpacked_nodes.size() == unpacked_edges.size() + 1);
const auto source_node_id = unpacked_nodes.front();
const auto target_node_id = unpacked_nodes.back();
const bool start_traversed_in_reverse =
phantom_node_pair.source_phantom.forward_segment_id.id != unpacked_nodes.front();
phantom_node_pair.source_phantom.forward_segment_id.id != source_node_id;
const bool target_traversed_in_reverse =
phantom_node_pair.target_phantom.forward_segment_id.id != unpacked_nodes.back();
phantom_node_pair.target_phantom.forward_segment_id.id != target_node_id;
BOOST_ASSERT(phantom_node_pair.source_phantom.forward_segment_id.id == unpacked_nodes.front() ||
phantom_node_pair.source_phantom.reverse_segment_id.id == unpacked_nodes.front());
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_segment_id.id == unpacked_nodes.back() ||
phantom_node_pair.target_phantom.reverse_segment_id.id == unpacked_nodes.back());
BOOST_ASSERT(phantom_node_pair.source_phantom.forward_segment_id.id == source_node_id ||
phantom_node_pair.source_phantom.reverse_segment_id.id == source_node_id);
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_segment_id.id == target_node_id ||
phantom_node_pair.target_phantom.reverse_segment_id.id == target_node_id);
auto node_from = unpacked_nodes.begin(), node_last = std::prev(unpacked_nodes.end());
for (auto edge = unpacked_edges.begin(); node_from != node_last; ++node_from, ++edge)
@ -109,10 +111,7 @@ void annotatePath(const FacadeT &facade,
const auto node_id = *node_from; // edge-based graph node index
const auto name_index = facade.GetNameIndex(node_id);
const auto turn_instruction = facade.GetTurnInstructionForEdgeID(turn_id);
const extractor::TravelMode travel_mode =
(unpacked_path.empty() && start_traversed_in_reverse)
? phantom_node_pair.source_phantom.backward_travel_mode
: facade.GetTravelMode(node_id);
const extractor::TravelMode travel_mode = facade.GetTravelMode(node_id);
const auto geometry_index = facade.GetGeometryIndex(node_id);
std::vector<NodeID> id_vector;
@ -181,23 +180,16 @@ void annotatePath(const FacadeT &facade,
std::vector<EdgeWeight> weight_vector;
std::vector<EdgeWeight> duration_vector;
std::vector<DatasourceID> datasource_vector;
const bool is_local_path = (phantom_node_pair.source_phantom.packed_geometry_id ==
phantom_node_pair.target_phantom.packed_geometry_id) &&
unpacked_path.empty();
const auto source_geometry_id = facade.GetGeometryIndex(source_node_id).id;
const auto target_geometry_id = facade.GetGeometryIndex(target_node_id).id;
const auto is_local_path = source_geometry_id == target_geometry_id && unpacked_path.empty();
if (target_traversed_in_reverse)
{
id_vector = facade.GetUncompressedReverseGeometry(
phantom_node_pair.target_phantom.packed_geometry_id);
weight_vector = facade.GetUncompressedReverseWeights(
phantom_node_pair.target_phantom.packed_geometry_id);
duration_vector = facade.GetUncompressedReverseDurations(
phantom_node_pair.target_phantom.packed_geometry_id);
datasource_vector = facade.GetUncompressedReverseDatasources(
phantom_node_pair.target_phantom.packed_geometry_id);
id_vector = facade.GetUncompressedReverseGeometry(target_geometry_id);
weight_vector = facade.GetUncompressedReverseWeights(target_geometry_id);
duration_vector = facade.GetUncompressedReverseDurations(target_geometry_id);
datasource_vector = facade.GetUncompressedReverseDatasources(target_geometry_id);
if (is_local_path)
{
@ -215,17 +207,10 @@ void annotatePath(const FacadeT &facade,
}
end_index = phantom_node_pair.target_phantom.fwd_segment_position;
id_vector = facade.GetUncompressedForwardGeometry(
phantom_node_pair.target_phantom.packed_geometry_id);
weight_vector = facade.GetUncompressedForwardWeights(
phantom_node_pair.target_phantom.packed_geometry_id);
duration_vector = facade.GetUncompressedForwardDurations(
phantom_node_pair.target_phantom.packed_geometry_id);
datasource_vector = facade.GetUncompressedForwardDatasources(
phantom_node_pair.target_phantom.packed_geometry_id);
id_vector = facade.GetUncompressedForwardGeometry(target_geometry_id);
weight_vector = facade.GetUncompressedForwardWeights(target_geometry_id);
duration_vector = facade.GetUncompressedForwardDurations(target_geometry_id);
datasource_vector = facade.GetUncompressedForwardDatasources(target_geometry_id);
}
// Given the following compressed geometry:
@ -239,20 +224,19 @@ void annotatePath(const FacadeT &facade,
(start_index < end_index ? ++segment_idx : --segment_idx))
{
BOOST_ASSERT(segment_idx < id_vector.size() - 1);
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
unpacked_path.push_back(PathData{
id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
phantom_node_pair.target_phantom.name_id,
weight_vector[segment_idx],
duration_vector[segment_idx],
extractor::guidance::TurnInstruction::NO_TURN(),
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
target_traversed_in_reverse ? phantom_node_pair.target_phantom.backward_travel_mode
: phantom_node_pair.target_phantom.forward_travel_mode,
INVALID_ENTRY_CLASSID,
datasource_vector[segment_idx],
util::guidance::TurnBearing(0),
util::guidance::TurnBearing(0)});
BOOST_ASSERT(facade.GetTravelMode(target_node_id) > 0);
unpacked_path.push_back(
PathData{id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
facade.GetNameIndex(target_node_id),
weight_vector[segment_idx],
duration_vector[segment_idx],
extractor::guidance::TurnInstruction::NO_TURN(),
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
facade.GetTravelMode(target_node_id),
INVALID_ENTRY_CLASSID,
datasource_vector[segment_idx],
util::guidance::TurnBearing(0),
util::guidance::TurnBearing(0)});
}
if (unpacked_path.size() > 0)

View File

@ -7,11 +7,11 @@
#include "extractor/edge_based_edge.hpp"
#include "extractor/edge_based_node.hpp"
#include "extractor/extraction_turn.hpp"
#include "extractor/node_data_container.hpp"
#include "extractor/guidance/turn_analysis.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/nbg_to_ebg.hpp"
#include "extractor/node_data_container.hpp"
#include "extractor/original_edge_data.hpp"
#include "extractor/packed_osm_ids.hpp"
#include "extractor/profile_properties.hpp"

View File

@ -22,10 +22,8 @@ struct EdgeBasedNode
EdgeBasedNode()
: forward_segment_id{SPECIAL_SEGMENTID, false},
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
name_id(0), packed_geometry_id(SPECIAL_GEOMETRYID), component{INVALID_COMPONENTID, false},
fwd_segment_position(std::numeric_limits<unsigned short>::max()),
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
component{INVALID_COMPONENTID, false},
fwd_segment_position(std::numeric_limits<unsigned short>::max())
{
}
@ -33,36 +31,27 @@ struct EdgeBasedNode
const SegmentID reverse_segment_id_,
NodeID u,
NodeID v,
unsigned name_id,
unsigned packed_geometry_id_,
bool is_tiny_component,
unsigned component_id,
unsigned short fwd_segment_position,
TravelMode forward_travel_mode,
TravelMode backward_travel_mode)
unsigned short fwd_segment_position)
: forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u),
v(v), name_id(name_id), packed_geometry_id(packed_geometry_id_),
component{component_id, is_tiny_component}, fwd_segment_position(fwd_segment_position),
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
v(v), component{component_id, is_tiny_component},
fwd_segment_position(fwd_segment_position)
{
BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled);
}
SegmentID forward_segment_id; // needed for edge-expanded graph
SegmentID reverse_segment_id; // needed for edge-expanded graph
NodeID u; // indices into the coordinates array
NodeID v; // indices into the coordinates array
NameID name_id; // id of the edge name
SegmentID forward_segment_id; // edge-based graph node ID in forward direction (u->v)
SegmentID reverse_segment_id; // edge-based graph node ID in reverse direction (v->u if exists)
NodeID u; // node-based graph node ID of the start node
NodeID v; // node-based graph node ID of the target node
unsigned packed_geometry_id;
struct
{
unsigned id : 31;
bool is_tiny : 1;
} component;
unsigned short fwd_segment_position; // segment id in a compressed geometry
TravelMode forward_travel_mode : 4;
TravelMode backward_travel_mode : 4;
};
}
}

View File

@ -366,6 +366,10 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
return offset;
};
const auto get_geometry_id = [&facade](auto edge) {
return facade.GetGeometryIndex(edge.forward_segment_id.id).id;
};
// Vector tiles encode feature properties as indexes into a lookup table. So, we need
// to "pre-loop" over all the edges to create the lookup tables. Once we have those, we
// can then encode the features, and we'll know the indexes that feature properties
@ -374,10 +378,11 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
{
const auto &edge = edges[edge_index];
const auto geometry_id = get_geometry_id(edge);
const auto forward_datasource_vector =
facade.GetUncompressedForwardDatasources(edge.packed_geometry_id);
facade.GetUncompressedForwardDatasources(geometry_id);
const auto reverse_datasource_vector =
facade.GetUncompressedReverseDatasources(edge.packed_geometry_id);
facade.GetUncompressedReverseDatasources(geometry_id);
BOOST_ASSERT(edge.fwd_segment_position < forward_datasource_vector.size());
const auto forward_datasource = forward_datasource_vector[edge.fwd_segment_position];
@ -421,12 +426,13 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
for (const auto &edge_index : sorted_edge_indexes)
{
const auto &edge = edges[edge_index];
const auto geometry_id = get_geometry_id(edge);
// Weight values
const auto forward_weight_vector =
facade.GetUncompressedForwardWeights(edge.packed_geometry_id);
facade.GetUncompressedForwardWeights(geometry_id);
const auto reverse_weight_vector =
facade.GetUncompressedReverseWeights(edge.packed_geometry_id);
facade.GetUncompressedReverseWeights(geometry_id);
const auto forward_weight = forward_weight_vector[edge.fwd_segment_position];
const auto reverse_weight = reverse_weight_vector[reverse_weight_vector.size() -
edge.fwd_segment_position - 1];
@ -435,9 +441,9 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
// Duration values
const auto forward_duration_vector =
facade.GetUncompressedForwardDurations(edge.packed_geometry_id);
facade.GetUncompressedForwardDurations(geometry_id);
const auto reverse_duration_vector =
facade.GetUncompressedReverseDurations(edge.packed_geometry_id);
facade.GetUncompressedReverseDurations(geometry_id);
const auto forward_duration = forward_duration_vector[edge.fwd_segment_position];
const auto reverse_duration =
reverse_duration_vector[reverse_duration_vector.size() -
@ -453,6 +459,8 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
for (const auto &edge_index : sorted_edge_indexes)
{
const auto &edge = edges[edge_index];
const auto geometry_id = get_geometry_id(edge);
// Get coordinates for start/end nodes of segment (NodeIDs u and v)
const auto a = facade.GetCoordinateOfNode(edge.u);
const auto b = facade.GetCoordinateOfNode(edge.v);
@ -461,17 +469,17 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
osrm::util::coordinate_calculation::haversineDistance(a, b);
const auto forward_weight_vector =
facade.GetUncompressedForwardWeights(edge.packed_geometry_id);
facade.GetUncompressedForwardWeights(geometry_id);
const auto reverse_weight_vector =
facade.GetUncompressedReverseWeights(edge.packed_geometry_id);
facade.GetUncompressedReverseWeights(geometry_id);
const auto forward_duration_vector =
facade.GetUncompressedForwardDurations(edge.packed_geometry_id);
facade.GetUncompressedForwardDurations(geometry_id);
const auto reverse_duration_vector =
facade.GetUncompressedReverseDurations(edge.packed_geometry_id);
facade.GetUncompressedReverseDurations(geometry_id);
const auto forward_datasource_vector =
facade.GetUncompressedForwardDatasources(edge.packed_geometry_id);
facade.GetUncompressedForwardDatasources(geometry_id);
const auto reverse_datasource_vector =
facade.GetUncompressedReverseDatasources(edge.packed_geometry_id);
facade.GetUncompressedReverseDatasources(geometry_id);
const auto forward_weight = forward_weight_vector[edge.fwd_segment_position];
const auto reverse_weight =
reverse_weight_vector[reverse_weight_vector.size() -
@ -487,7 +495,8 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
reverse_datasource_vector[reverse_datasource_vector.size() -
edge.fwd_segment_position - 1];
auto name = facade.GetNameForID(edge.name_id);
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
auto name = facade.GetNameForID(name_id);
const auto name_offset = [&name, &names, &name_offsets]() {
auto iter = name_offsets.find(name);

View File

@ -37,6 +37,10 @@ getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm>
// it saves us a bunch of re-allocations during iteration.
directed_graph.reserve(edges.size() * 2);
const auto get_geometry_id = [&facade](auto edge) {
return facade.GetGeometryIndex(edge.forward_segment_id.id).id;
};
// Build an adjacency list for all the road segments visible in
// the tile
for (const auto &edge_index : sorted_edge_indexes)
@ -48,14 +52,14 @@ getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm>
directed_graph[edge.u].push_back({edge.v, edge.forward_segment_id.id});
if (edge_based_node_info.count(edge.forward_segment_id.id) == 0)
{
edge_based_node_info[edge.forward_segment_id.id] = {true, edge.packed_geometry_id};
edge_based_node_info[edge.forward_segment_id.id] = {true, get_geometry_id(edge)};
}
else
{
BOOST_ASSERT(edge_based_node_info[edge.forward_segment_id.id].is_geometry_forward ==
true);
BOOST_ASSERT(edge_based_node_info[edge.forward_segment_id.id].packed_geometry_id ==
edge.packed_geometry_id);
get_geometry_id(edge));
}
}
if (edge.reverse_segment_id.enabled)
@ -63,14 +67,14 @@ getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm>
directed_graph[edge.v].push_back({edge.u, edge.reverse_segment_id.id});
if (edge_based_node_info.count(edge.reverse_segment_id.id) == 0)
{
edge_based_node_info[edge.reverse_segment_id.id] = {false, edge.packed_geometry_id};
edge_based_node_info[edge.reverse_segment_id.id] = {false, get_geometry_id(edge)};
}
else
{
BOOST_ASSERT(edge_based_node_info[edge.reverse_segment_id.id].is_geometry_forward ==
false);
BOOST_ASSERT(edge_based_node_info[edge.reverse_segment_id.id].packed_geometry_id ==
edge.packed_geometry_id);
get_geometry_id(edge));
}
}
}

View File

@ -163,13 +163,9 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
edge_id_to_segment_id(reverse_data.edge_id),
current_edge_source_coordinate_id,
current_edge_target_coordinate_id,
forward_data.name_id,
packed_geometry_id,
false,
INVALID_COMPONENTID,
i,
forward_data.travel_mode,
reverse_data.travel_mode);
i);
m_edge_based_node_is_startpoint.push_back(forward_data.startpoint ||
reverse_data.startpoint);
@ -323,16 +319,18 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &node_data_fi
BOOST_ASSERT(is_encoded_forwards || is_encoded_backwards);
auto geometry_id =
is_encoded_forwards
? m_compressed_edge_container.GetZippedPositionForForwardID(nbg_edge_id)
: is_encoded_backwards
? m_compressed_edge_container.GetZippedPositionForReverseID(
nbg_edge_id)
: SPECIAL_GEOMETRYID;
// auto geometry_id =
// is_encoded_forwards
// ? m_compressed_edge_container.GetZippedPositionForForwardID(nbg_edge_id)
// : is_encoded_backwards
// ? m_compressed_edge_container.GetZippedPositionForReverseID(
// nbg_edge_id)
// : SPECIAL_GEOMETRYID;
BOOST_ASSERT(m_ebg_node_data_container.GetNameID(nbg_edge_data.edge_id) == nbg_edge_data.name_id);
BOOST_ASSERT(m_ebg_node_data_container.GetTravelMode(nbg_edge_data.edge_id) == nbg_edge_data.travel_mode);
BOOST_ASSERT(m_ebg_node_data_container.GetNameID(nbg_edge_data.edge_id) ==
nbg_edge_data.name_id);
BOOST_ASSERT(m_ebg_node_data_container.GetTravelMode(nbg_edge_data.edge_id) ==
nbg_edge_data.travel_mode);
// m_ebg_node_data_container.SetData(nbg_edge_data.edge_id,
// GeometryID{geometry_id, is_encoded_forwards},

View File

@ -86,9 +86,8 @@ BOOST_AUTO_TEST_CASE(invalid_table_urls)
BOOST_AUTO_TEST_CASE(valid_route_hint)
{
auto hint = engine::Hint::FromBase64("XAYAgP___3-"
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAA"
"AGpocQC3gpsCO2hxAMuCmwIFAAEBDJujEQ==");
auto hint = engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E=");
BOOST_CHECK_EQUAL(
hint.phantom.input_location,
util::Coordinate(util::FloatLongitude{7.432251}, util::FloatLatitude{43.745995}));
@ -158,14 +157,12 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
CHECK_EQUAL_RANGE(reference_3.hints, result_3->hints);
std::vector<boost::optional<engine::Hint>> hints_4 = {
engine::Hint::FromBase64("XAYAgP___3-"
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3"
"gpsCO2hxAMuCmwIFAAEBDJujEQ=="),
engine::Hint::FromBase64("lgQAgP___3-"
"QAAAAEwAAABgAAAAyAAAAOAAAABMAAAAYAAAAMgAAADgAAAA0AAAAFAAAAJphcQC-"
"c5sC3GFxALtzmwIEAAEBDJujEQ=="),
engine::Hint::FromBase64("OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAF"
"AAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==")};
engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-AAAAHQAAABQAAA"
"BqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E="),
engine::Hint::FromBase64("ngQAgP___38TAAAAGAAAAC8AAAA4AAAAEwAAABgAAAAvAAAAOAAAABQAAA"
"CaYXEAvnObAtxhcQC7c5sCBAAPAJDIe3E="),
engine::Hint::FromBase64("QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAA"
"CDPnEAUFabAog-cQBQVpsCAAAPAJDIe3E=")};
RouteParameters reference_4{false,
false,
false,
@ -178,13 +175,12 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
std::vector<boost::optional<engine::Bearing>>{}};
auto result_4 = parseParameters<RouteParameters>(
"1,2;3,4?steps=false&hints="
"XAYAgP___3-"
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3gpsCO2hxAMuCmwIFAAEBDJujE"
"Q==;"
"lgQAgP___3-QAAAAEwAAABgAAAAyAAAAOAAAABMAAAAYAAAAMgAAADgAAAA0AAAAFAAAAJphcQC-"
"c5sC3GFxALtzmwIEAAEBDJujEQ==;"
"OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAFAAAAIM-"
"cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==");
"ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E=;"
"ngQAgP___"
"38TAAAAGAAAAC8AAAA4AAAAEwAAABgAAAAvAAAAOAAAABQAAACaYXEAvnObAtxhcQC7c5sCBAAPAJDIe3E=;"
"QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAACDPnEAUFabAog-"
"cQBQVpsCAAAPAJDIe3E=");
BOOST_CHECK(result_4);
BOOST_CHECK_EQUAL(reference_4.steps, result_4->steps);
BOOST_CHECK_EQUAL(reference_4.alternatives, result_4->alternatives);
@ -279,12 +275,11 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
{util::FloatLongitude{5}, util::FloatLatitude{6}},
{util::FloatLongitude{7}, util::FloatLatitude{8}}};
std::vector<boost::optional<engine::Hint>> hints_10 = {
engine::Hint::FromBase64("XAYAgP___3-"
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3"
"gpsCO2hxAMuCmwIFAAEBDJujEQ=="),
engine::Hint::FromBase64("ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E="),
boost::none,
engine::Hint::FromBase64("OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAF"
"AAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ=="),
engine::Hint::FromBase64("QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAAACDPnEAU"
"FabAog-cQBQVpsCAAAPAJDIe3E="),
boost::none};
RouteParameters reference_10{false,
false,
@ -298,11 +293,10 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
std::vector<boost::optional<engine::Bearing>>{}};
auto result_10 =
parseParameters<RouteParameters>("1,2;3,4;5,6;7,8?steps=false&hints="
"XAYAgP___3-"
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAA"
"AGpocQC3gpsCO2hxAMuCmwIFAAEBDJujEQ==;;"
"OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BA"
"AC8BAAAFAAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==;");
"ZgYAgP___38EAAAAIAAAAD4AAAAdAAAABAAAACAAAAA-"
"AAAAHQAAABQAAABqaHEAt4KbAjtocQDLgpsCBQAPAJDIe3E=;;"
"QAUAgM0FAIAYAAAABAAAAAAAAADxAAAAGAAAAAQAAAAAAAAA8QAAABQAA"
"ACDPnEAUFabAog-cQBQVpsCAAAPAJDIe3E=;");
BOOST_CHECK(result_10);
BOOST_CHECK_EQUAL(reference_10.steps, result_10->steps);
BOOST_CHECK_EQUAL(reference_10.alternatives, result_10->alternatives);

View File

@ -171,7 +171,6 @@ struct GraphFixture
d.forward_segment_id = {pair.second, true};
d.reverse_segment_id = {pair.first, true};
d.fwd_segment_position = 0;
d.packed_geometry_id = 0;
edges.emplace_back(d);
}
}