Use ranges in datafacade instead of vectors
Range type must use immutable references due to a regression in `boost::any_range`. References: https://svn.boost.org/trac10/ticket/10493 https://stackoverflow.com/questions/42427395/boostany-range-with-optimization-level-o2-causes-crash/42427662
This commit is contained in:
committed by
Patrick Niklaus
parent
282415bbc1
commit
be123cd72f
@@ -34,56 +34,55 @@ class NearestAPI final : public BaseAPI
|
||||
|
||||
util::json::Array waypoints;
|
||||
waypoints.values.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
auto waypoint = MakeWaypoint(phantom_node);
|
||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
||||
std::transform(
|
||||
phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
auto waypoint = MakeWaypoint(phantom_node);
|
||||
waypoint.values["distance"] = phantom_with_distance.distance;
|
||||
|
||||
util::json::Array nodes;
|
||||
util::json::Array nodes;
|
||||
|
||||
std::uint64_t from_node = 0;
|
||||
std::uint64_t to_node = 0;
|
||||
std::uint64_t from_node = 0;
|
||||
std::uint64_t to_node = 0;
|
||||
|
||||
std::vector<NodeID> forward_geometry;
|
||||
if (phantom_node.forward_segment_id.enabled)
|
||||
{
|
||||
auto segment_id = phantom_node.forward_segment_id.id;
|
||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||
forward_geometry =
|
||||
facade.GetUncompressedForwardGeometry(geometry_id);
|
||||
datafacade::BaseDataFacade::NodesIDRangeT forward_geometry;
|
||||
if (phantom_node.forward_segment_id.enabled)
|
||||
{
|
||||
auto segment_id = phantom_node.forward_segment_id.id;
|
||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
||||
|
||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||
forward_geometry[phantom_node.fwd_segment_position]);
|
||||
to_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||
forward_geometry[phantom_node.fwd_segment_position]);
|
||||
to_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
|
||||
if (phantom_node.reverse_segment_id.enabled)
|
||||
{
|
||||
auto segment_id = phantom_node.reverse_segment_id.id;
|
||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||
std::vector<NodeID> geometry =
|
||||
facade.GetUncompressedForwardGeometry(geometry_id);
|
||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||
geometry[phantom_node.fwd_segment_position + 1]);
|
||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
else if (phantom_node.forward_segment_id.enabled &&
|
||||
phantom_node.fwd_segment_position > 0)
|
||||
{
|
||||
// In the case of one way, rely on forward segment only
|
||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||
forward_geometry[phantom_node.fwd_segment_position - 1]);
|
||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
nodes.values.push_back(from_node);
|
||||
nodes.values.push_back(to_node);
|
||||
waypoint.values["nodes"] = std::move(nodes);
|
||||
if (phantom_node.reverse_segment_id.enabled)
|
||||
{
|
||||
auto segment_id = phantom_node.reverse_segment_id.id;
|
||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||
const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
||||
auto osm_node_id =
|
||||
facade.GetOSMNodeIDOfNode(geometry[phantom_node.fwd_segment_position + 1]);
|
||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
else if (phantom_node.forward_segment_id.enabled &&
|
||||
phantom_node.fwd_segment_position > 0)
|
||||
{
|
||||
// In the case of one way, rely on forward segment only
|
||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||
forward_geometry[phantom_node.fwd_segment_position - 1]);
|
||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||
}
|
||||
nodes.values.push_back(from_node);
|
||||
nodes.values.push_back(to_node);
|
||||
waypoint.values["nodes"] = std::move(nodes);
|
||||
|
||||
return waypoint;
|
||||
});
|
||||
return waypoint;
|
||||
});
|
||||
|
||||
response.values["code"] = "Ok";
|
||||
response.values["waypoints"] = std::move(waypoints);
|
||||
|
||||
@@ -239,72 +239,57 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
return m_osmnodeid_list[id];
|
||||
}
|
||||
|
||||
std::vector<NodeID> GetUncompressedForwardGeometry(const EdgeID id) const override final
|
||||
NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID id) const override final
|
||||
{
|
||||
|
||||
auto range = segment_data.GetForwardGeometry(id);
|
||||
return std::vector<NodeID>{range.begin(), range.end()};
|
||||
return segment_data.GetForwardGeometry(id);
|
||||
}
|
||||
|
||||
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const override final
|
||||
NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetReverseGeometry(id);
|
||||
return std::vector<NodeID>{range.begin(), range.end()};
|
||||
return segment_data.GetReverseGeometry(id);
|
||||
}
|
||||
|
||||
virtual std::vector<EdgeWeight>
|
||||
GetUncompressedForwardDurations(const EdgeID id) const override final
|
||||
DurationsRangeT GetUncompressedForwardDurations(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetForwardDurations(id);
|
||||
return std::vector<EdgeWeight>{range.begin(), range.end()};
|
||||
return segment_data.GetForwardDurations(id);
|
||||
}
|
||||
|
||||
virtual std::vector<EdgeWeight>
|
||||
GetUncompressedReverseDurations(const EdgeID id) const override final
|
||||
DurationsRangeT GetUncompressedReverseDurations(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetReverseDurations(id);
|
||||
return std::vector<EdgeWeight>{range.begin(), range.end()};
|
||||
return segment_data.GetReverseDurations(id);
|
||||
}
|
||||
|
||||
virtual std::vector<EdgeWeight>
|
||||
GetUncompressedForwardWeights(const EdgeID id) const override final
|
||||
WeightsRangeT GetUncompressedForwardWeights(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetForwardWeights(id);
|
||||
return std::vector<EdgeWeight>{range.begin(), range.end()};
|
||||
return segment_data.GetForwardWeights(id);
|
||||
}
|
||||
|
||||
virtual std::vector<EdgeWeight>
|
||||
GetUncompressedReverseWeights(const EdgeID id) const override final
|
||||
WeightsRangeT GetUncompressedReverseWeights(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetReverseWeights(id);
|
||||
return std::vector<EdgeWeight>{range.begin(), range.end()};
|
||||
return segment_data.GetReverseWeights(id);
|
||||
}
|
||||
|
||||
// Returns the data source ids that were used to supply the edge
|
||||
// weights.
|
||||
virtual std::vector<DatasourceID>
|
||||
GetUncompressedForwardDatasources(const EdgeID id) const override final
|
||||
DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetForwardDatasources(id);
|
||||
return std::vector<DatasourceID>{range.begin(), range.end()};
|
||||
return segment_data.GetForwardDatasources(id);
|
||||
}
|
||||
|
||||
// Returns the data source ids that were used to supply the edge
|
||||
// weights.
|
||||
virtual std::vector<DatasourceID>
|
||||
GetUncompressedReverseDatasources(const EdgeID id) const override final
|
||||
DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID id) const override final
|
||||
{
|
||||
auto range = segment_data.GetReverseDatasources(id);
|
||||
return std::vector<DatasourceID>{range.begin(), range.end()};
|
||||
return segment_data.GetReverseDatasources(id);
|
||||
}
|
||||
|
||||
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const override final
|
||||
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_turn_weight_penalties.size() > id);
|
||||
return m_turn_weight_penalties[id];
|
||||
}
|
||||
|
||||
virtual TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const override final
|
||||
TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_turn_duration_penalties.size() > id);
|
||||
return m_turn_duration_penalties[id];
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
|
||||
#include "extractor/class_data.hpp"
|
||||
#include "extractor/edge_based_node_segment.hpp"
|
||||
//#include "extractor/guidance/turn_lane_types.hpp"
|
||||
#include "extractor/maneuver_override.hpp"
|
||||
//#include "extractor/original_edge_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "extractor/turn_lane_types.hpp"
|
||||
@@ -31,6 +29,8 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
#include <boost/range/any_range.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <string>
|
||||
@@ -50,6 +50,14 @@ class BaseDataFacade
|
||||
{
|
||||
public:
|
||||
using RTreeLeaf = extractor::EdgeBasedNodeSegment;
|
||||
|
||||
template <typename T>
|
||||
using RangeT = boost::any_range<T, boost::random_access_traversal_tag, const T, std::ptrdiff_t>;
|
||||
using NodesIDRangeT = RangeT<NodeID>;
|
||||
using WeightsRangeT = RangeT<SegmentWeight>;
|
||||
using DurationsRangeT = RangeT<SegmentDuration>;
|
||||
using DatasourceIDRangeT = RangeT<DatasourceID>;
|
||||
|
||||
BaseDataFacade() {}
|
||||
virtual ~BaseDataFacade() {}
|
||||
|
||||
@@ -64,9 +72,8 @@ class BaseDataFacade
|
||||
|
||||
virtual ComponentID GetComponentID(const NodeID id) const = 0;
|
||||
|
||||
virtual std::vector<NodeID> GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||
|
||||
virtual std::vector<NodeID> GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||
virtual NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||
virtual NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||
|
||||
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
@@ -74,18 +81,18 @@ class BaseDataFacade
|
||||
|
||||
// Gets the weight values for each segment in an uncompressed geometry.
|
||||
// Should always be 1 shorter than GetUncompressedGeometry
|
||||
virtual std::vector<EdgeWeight> GetUncompressedForwardWeights(const EdgeID id) const = 0;
|
||||
virtual std::vector<EdgeWeight> GetUncompressedReverseWeights(const EdgeID id) const = 0;
|
||||
virtual WeightsRangeT GetUncompressedForwardWeights(const EdgeID id) const = 0;
|
||||
virtual WeightsRangeT GetUncompressedReverseWeights(const EdgeID id) const = 0;
|
||||
|
||||
// Gets the duration values for each segment in an uncompressed geometry.
|
||||
// Should always be 1 shorter than GetUncompressedGeometry
|
||||
virtual std::vector<EdgeWeight> GetUncompressedForwardDurations(const EdgeID id) const = 0;
|
||||
virtual std::vector<EdgeWeight> GetUncompressedReverseDurations(const EdgeID id) const = 0;
|
||||
virtual DurationsRangeT GetUncompressedForwardDurations(const EdgeID id) const = 0;
|
||||
virtual DurationsRangeT GetUncompressedReverseDurations(const EdgeID id) const = 0;
|
||||
|
||||
// Returns the data source ids that were used to supply the edge
|
||||
// weights. Will return an empty array when only the base profile is used.
|
||||
virtual std::vector<DatasourceID> GetUncompressedForwardDatasources(const EdgeID id) const = 0;
|
||||
virtual std::vector<DatasourceID> GetUncompressedReverseDatasources(const EdgeID id) const = 0;
|
||||
virtual DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID id) const = 0;
|
||||
virtual DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID id) const = 0;
|
||||
|
||||
// Gets the name of a datasource
|
||||
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;
|
||||
|
||||
@@ -434,11 +434,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Find the node-based-edge that this belongs to, and directly
|
||||
// calculate the forward_weight, forward_offset, reverse_weight, reverse_offset
|
||||
|
||||
EdgeWeight forward_weight_offset = 0, forward_weight = 0;
|
||||
EdgeWeight reverse_weight_offset = 0, reverse_weight = 0;
|
||||
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 ==
|
||||
@@ -446,35 +441,42 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
|
||||
const auto component_id = datafacade.GetComponentID(data.forward_segment_id.id);
|
||||
|
||||
const std::vector<EdgeWeight> forward_weight_vector =
|
||||
datafacade.GetUncompressedForwardWeights(geometry_id);
|
||||
const std::vector<EdgeWeight> reverse_weight_vector =
|
||||
datafacade.GetUncompressedReverseWeights(geometry_id);
|
||||
const std::vector<EdgeWeight> forward_duration_vector =
|
||||
datafacade.GetUncompressedForwardDurations(geometry_id);
|
||||
const std::vector<EdgeWeight> reverse_duration_vector =
|
||||
datafacade.GetUncompressedReverseDurations(geometry_id);
|
||||
const auto forward_weights = datafacade.GetUncompressedForwardWeights(geometry_id);
|
||||
const auto reverse_weights = datafacade.GetUncompressedReverseWeights(geometry_id);
|
||||
|
||||
for (std::size_t i = 0; i < data.fwd_segment_position; i++)
|
||||
{
|
||||
forward_weight_offset += forward_weight_vector[i];
|
||||
forward_duration_offset += forward_duration_vector[i];
|
||||
}
|
||||
forward_weight = forward_weight_vector[data.fwd_segment_position];
|
||||
forward_duration = forward_duration_vector[data.fwd_segment_position];
|
||||
const auto forward_durations = datafacade.GetUncompressedForwardDurations(geometry_id);
|
||||
const auto reverse_durations = datafacade.GetUncompressedReverseDurations(geometry_id);
|
||||
|
||||
BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size());
|
||||
const auto forward_weight_offset =
|
||||
std::accumulate(forward_weights.begin(),
|
||||
forward_weights.begin() + data.fwd_segment_position,
|
||||
EdgeWeight{0});
|
||||
|
||||
for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1;
|
||||
i++)
|
||||
{
|
||||
reverse_weight_offset += reverse_weight_vector[i];
|
||||
reverse_duration_offset += reverse_duration_vector[i];
|
||||
}
|
||||
reverse_weight =
|
||||
reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1];
|
||||
reverse_duration =
|
||||
reverse_duration_vector[reverse_duration_vector.size() - data.fwd_segment_position - 1];
|
||||
const auto forward_duration_offset =
|
||||
std::accumulate(forward_durations.begin(),
|
||||
forward_durations.begin() + data.fwd_segment_position,
|
||||
EdgeDuration{0});
|
||||
|
||||
EdgeWeight forward_weight = forward_weights[data.fwd_segment_position];
|
||||
EdgeDuration forward_duration = forward_durations[data.fwd_segment_position];
|
||||
|
||||
BOOST_ASSERT(data.fwd_segment_position <
|
||||
std::distance(forward_durations.begin(), forward_durations.end()));
|
||||
|
||||
const auto reverse_weight_offset =
|
||||
std::accumulate(reverse_weights.begin(),
|
||||
reverse_weights.end() - data.fwd_segment_position - 1,
|
||||
EdgeWeight{0});
|
||||
|
||||
const auto reverse_duration_offset =
|
||||
std::accumulate(reverse_durations.begin(),
|
||||
reverse_durations.end() - data.fwd_segment_position - 1,
|
||||
EdgeDuration{0});
|
||||
|
||||
EdgeWeight reverse_weight =
|
||||
reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1];
|
||||
EdgeDuration reverse_duration =
|
||||
reverse_durations[reverse_durations.size() - data.fwd_segment_position - 1];
|
||||
|
||||
ratio = std::min(1.0, std::max(0.0, ratio));
|
||||
if (data.forward_segment_id.id != SPECIAL_SEGMENTID)
|
||||
@@ -493,14 +495,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
return std::find(first, last, INVALID_SEGMENT_WEIGHT) == last;
|
||||
};
|
||||
bool is_forward_valid_source =
|
||||
areSegmentsValid(forward_weight_vector.begin(), forward_weight_vector.end());
|
||||
bool is_forward_valid_target =
|
||||
areSegmentsValid(forward_weight_vector.begin(),
|
||||
forward_weight_vector.begin() + data.fwd_segment_position + 1);
|
||||
areSegmentsValid(forward_weights.begin(), forward_weights.end());
|
||||
bool is_forward_valid_target = areSegmentsValid(
|
||||
forward_weights.begin(), forward_weights.begin() + data.fwd_segment_position + 1);
|
||||
bool is_reverse_valid_source =
|
||||
areSegmentsValid(reverse_weight_vector.begin(), reverse_weight_vector.end());
|
||||
areSegmentsValid(reverse_weights.begin(), reverse_weights.end());
|
||||
bool is_reverse_valid_target = areSegmentsValid(
|
||||
reverse_weight_vector.begin(), reverse_weight_vector.end() - data.fwd_segment_position);
|
||||
reverse_weights.begin(), reverse_weights.end() - data.fwd_segment_position);
|
||||
|
||||
auto transformed = PhantomNodeWithDistance{
|
||||
PhantomNode{data,
|
||||
@@ -605,17 +606,14 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
BOOST_ASSERT(data.forward_segment_id.id != SPECIAL_NODEID);
|
||||
const auto geometry_id = datafacade.GetGeometryIndex(data.forward_segment_id.id).id;
|
||||
|
||||
const std::vector<EdgeWeight> forward_weight_vector =
|
||||
datafacade.GetUncompressedForwardWeights(geometry_id);
|
||||
|
||||
if (forward_weight_vector[data.fwd_segment_position] != INVALID_SEGMENT_WEIGHT)
|
||||
const auto forward_weights = datafacade.GetUncompressedForwardWeights(geometry_id);
|
||||
if (forward_weights[data.fwd_segment_position] != INVALID_SEGMENT_WEIGHT)
|
||||
{
|
||||
forward_edge_valid = data.forward_segment_id.enabled;
|
||||
}
|
||||
|
||||
const std::vector<EdgeWeight> reverse_weight_vector =
|
||||
datafacade.GetUncompressedReverseWeights(geometry_id);
|
||||
if (reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1] !=
|
||||
const auto reverse_weights = datafacade.GetUncompressedReverseWeights(geometry_id);
|
||||
if (reverse_weights[reverse_weights.size() - data.fwd_segment_position - 1] !=
|
||||
INVALID_SEGMENT_WEIGHT)
|
||||
{
|
||||
reverse_edge_valid = data.reverse_segment_id.enabled;
|
||||
|
||||
@@ -55,7 +55,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
||||
const auto source_node_id =
|
||||
reversed_source ? source_node.reverse_segment_id.id : source_node.forward_segment_id.id;
|
||||
const auto source_geometry_id = facade.GetGeometryIndex(source_node_id).id;
|
||||
std::vector<NodeID> source_geometry = facade.GetUncompressedForwardGeometry(source_geometry_id);
|
||||
const auto source_geometry = facade.GetUncompressedForwardGeometry(source_geometry_id);
|
||||
|
||||
geometry.osm_node_ids.push_back(
|
||||
facade.GetOSMNodeIDOfNode(source_geometry[source_segment_start_coordinate]));
|
||||
@@ -111,8 +111,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
||||
const auto target_node_id =
|
||||
reversed_target ? target_node.reverse_segment_id.id : target_node.forward_segment_id.id;
|
||||
const auto target_geometry_id = facade.GetGeometryIndex(target_node_id).id;
|
||||
const std::vector<DatasourceID> forward_datasources =
|
||||
facade.GetUncompressedForwardDatasources(target_geometry_id);
|
||||
const auto forward_datasources = facade.GetUncompressedForwardDatasources(target_geometry_id);
|
||||
|
||||
// This happens when the source/target are on the same edge-based-node
|
||||
// There will be no entries in the unpacked path, thus no annotations.
|
||||
@@ -158,8 +157,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
||||
// target node rev: 1 1 <- 2 <- 3
|
||||
const auto target_segment_end_coordinate =
|
||||
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
|
||||
const std::vector<NodeID> target_geometry =
|
||||
facade.GetUncompressedForwardGeometry(target_geometry_id);
|
||||
const auto target_geometry = facade.GetUncompressedForwardGeometry(target_geometry_id);
|
||||
geometry.osm_node_ids.push_back(
|
||||
facade.GetOSMNodeIDOfNode(target_geometry[target_segment_end_coordinate]));
|
||||
|
||||
|
||||
@@ -135,25 +135,25 @@ void annotatePath(const FacadeT &facade,
|
||||
phantom_node_pair.target_phantom.reverse_segment_id.id == target_node_id);
|
||||
|
||||
// datastructures to hold extracted data from geometry
|
||||
std::vector<NodeID> id_vector;
|
||||
std::vector<EdgeWeight> weight_vector;
|
||||
std::vector<EdgeWeight> duration_vector;
|
||||
std::vector<DatasourceID> datasource_vector;
|
||||
datafacade::ContiguousInternalMemoryDataFacadeBase::NodesIDRangeT id_range;
|
||||
datafacade::ContiguousInternalMemoryDataFacadeBase::WeightsRangeT weight_range;
|
||||
datafacade::ContiguousInternalMemoryDataFacadeBase::DurationsRangeT duration_range;
|
||||
datafacade::ContiguousInternalMemoryDataFacadeBase::DatasourceIDRangeT datasource_range;
|
||||
|
||||
const auto get_segment_geometry = [&](const auto geometry_index) {
|
||||
if (geometry_index.forward)
|
||||
{
|
||||
id_vector = facade.GetUncompressedForwardGeometry(geometry_index.id);
|
||||
weight_vector = facade.GetUncompressedForwardWeights(geometry_index.id);
|
||||
duration_vector = facade.GetUncompressedForwardDurations(geometry_index.id);
|
||||
datasource_vector = facade.GetUncompressedForwardDatasources(geometry_index.id);
|
||||
id_range = facade.GetUncompressedForwardGeometry(geometry_index.id);
|
||||
weight_range = facade.GetUncompressedForwardWeights(geometry_index.id);
|
||||
duration_range = facade.GetUncompressedForwardDurations(geometry_index.id);
|
||||
datasource_range = facade.GetUncompressedForwardDatasources(geometry_index.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
id_vector = facade.GetUncompressedReverseGeometry(geometry_index.id);
|
||||
weight_vector = facade.GetUncompressedReverseWeights(geometry_index.id);
|
||||
duration_vector = facade.GetUncompressedReverseDurations(geometry_index.id);
|
||||
datasource_vector = facade.GetUncompressedReverseDatasources(geometry_index.id);
|
||||
id_range = facade.GetUncompressedReverseGeometry(geometry_index.id);
|
||||
weight_range = facade.GetUncompressedReverseWeights(geometry_index.id);
|
||||
duration_range = facade.GetUncompressedReverseDurations(geometry_index.id);
|
||||
datasource_range = facade.GetUncompressedReverseDatasources(geometry_index.id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -172,19 +172,19 @@ void annotatePath(const FacadeT &facade,
|
||||
const auto geometry_index = facade.GetGeometryIndex(node_id);
|
||||
get_segment_geometry(geometry_index);
|
||||
|
||||
BOOST_ASSERT(id_vector.size() > 0);
|
||||
BOOST_ASSERT(datasource_vector.size() > 0);
|
||||
BOOST_ASSERT(weight_vector.size() == id_vector.size() - 1);
|
||||
BOOST_ASSERT(duration_vector.size() == id_vector.size() - 1);
|
||||
BOOST_ASSERT(id_range.size() > 0);
|
||||
BOOST_ASSERT(datasource_range.size() > 0);
|
||||
BOOST_ASSERT(weight_range.size() + 1 == id_range.size());
|
||||
BOOST_ASSERT(duration_range.size() + 1 == id_range.size());
|
||||
const bool is_first_segment = unpacked_path.empty();
|
||||
|
||||
const std::size_t start_index =
|
||||
(is_first_segment ? ((start_traversed_in_reverse)
|
||||
? weight_vector.size() -
|
||||
? weight_range.size() -
|
||||
phantom_node_pair.source_phantom.fwd_segment_position - 1
|
||||
: phantom_node_pair.source_phantom.fwd_segment_position)
|
||||
: 0);
|
||||
const std::size_t end_index = weight_vector.size();
|
||||
const std::size_t end_index = weight_range.size();
|
||||
|
||||
bool is_left_hand_driving = facade.IsLeftHandDriving(node_id);
|
||||
|
||||
@@ -193,19 +193,19 @@ void annotatePath(const FacadeT &facade,
|
||||
for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx)
|
||||
{
|
||||
unpacked_path.push_back(PathData{*node_from,
|
||||
id_vector[segment_idx + 1],
|
||||
id_range[segment_idx + 1],
|
||||
name_index,
|
||||
is_segregated,
|
||||
weight_vector[segment_idx],
|
||||
static_cast<EdgeWeight>(weight_range[segment_idx]),
|
||||
0,
|
||||
duration_vector[segment_idx],
|
||||
static_cast<EdgeDuration>(duration_range[segment_idx]),
|
||||
0,
|
||||
guidance::TurnInstruction::NO_TURN(),
|
||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||
travel_mode,
|
||||
classes,
|
||||
EMPTY_ENTRY_CLASS,
|
||||
datasource_vector[segment_idx],
|
||||
datasource_range[segment_idx],
|
||||
osrm::guidance::TurnBearing(0),
|
||||
osrm::guidance::TurnBearing(0),
|
||||
is_left_hand_driving});
|
||||
@@ -239,10 +239,9 @@ void annotatePath(const FacadeT &facade,
|
||||
if (is_local_path)
|
||||
{
|
||||
start_index =
|
||||
weight_vector.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1;
|
||||
weight_range.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1;
|
||||
}
|
||||
end_index =
|
||||
weight_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position - 1;
|
||||
end_index = weight_range.size() - phantom_node_pair.target_phantom.fwd_segment_position - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,23 +263,23 @@ void annotatePath(const FacadeT &facade,
|
||||
for (std::size_t segment_idx = start_index; segment_idx != end_index;
|
||||
(start_index < end_index ? ++segment_idx : --segment_idx))
|
||||
{
|
||||
BOOST_ASSERT(segment_idx < id_vector.size() - 1);
|
||||
BOOST_ASSERT(segment_idx < static_cast<std::size_t>(id_range.size() - 1));
|
||||
BOOST_ASSERT(facade.GetTravelMode(target_node_id) > 0);
|
||||
unpacked_path.push_back(
|
||||
PathData{target_node_id,
|
||||
id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
|
||||
id_range[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
|
||||
facade.GetNameIndex(target_node_id),
|
||||
facade.IsSegregated(target_node_id),
|
||||
weight_vector[segment_idx],
|
||||
static_cast<EdgeWeight>(weight_range[segment_idx]),
|
||||
0,
|
||||
duration_vector[segment_idx],
|
||||
static_cast<EdgeDuration>(duration_range[segment_idx]),
|
||||
0,
|
||||
guidance::TurnInstruction::NO_TURN(),
|
||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||
facade.GetTravelMode(target_node_id),
|
||||
facade.GetClassData(target_node_id),
|
||||
EMPTY_ENTRY_CLASS,
|
||||
datasource_vector[segment_idx],
|
||||
datasource_range[segment_idx],
|
||||
guidance::TurnBearing(0),
|
||||
guidance::TurnBearing(0),
|
||||
is_target_left_hand_driving});
|
||||
|
||||
@@ -56,7 +56,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
using DirectionalGeometryID = std::uint32_t;
|
||||
using SegmentOffset = std::uint32_t;
|
||||
using SegmentWeightVector = PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
||||
using SegmentDurationVector = PackedVector<SegmentDuration, SEGMENT_DURAITON_BITS>;
|
||||
using SegmentDurationVector = PackedVector<SegmentDuration, SEGMENT_DURATION_BITS>;
|
||||
using SegmentDatasourceVector = Vector<DatasourceID>;
|
||||
|
||||
SegmentDataContainerImpl() = default;
|
||||
|
||||
@@ -105,9 +105,9 @@ static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
|
||||
static const NameID EMPTY_NAMEID = 0;
|
||||
static const unsigned INVALID_COMPONENTID = 0;
|
||||
static const std::size_t SEGMENT_WEIGHT_BITS = 22;
|
||||
static const std::size_t SEGMENT_DURAITON_BITS = 22;
|
||||
static const std::size_t SEGMENT_DURATION_BITS = 22;
|
||||
static const SegmentWeight INVALID_SEGMENT_WEIGHT = (1u << SEGMENT_WEIGHT_BITS) - 1;
|
||||
static const SegmentDuration INVALID_SEGMENT_DURATION = (1u << SEGMENT_DURAITON_BITS) - 1;
|
||||
static const SegmentDuration INVALID_SEGMENT_DURATION = (1u << SEGMENT_DURATION_BITS) - 1;
|
||||
static const SegmentWeight MAX_SEGMENT_WEIGHT = INVALID_SEGMENT_WEIGHT - 1;
|
||||
static const SegmentDuration MAX_SEGMENT_DURATION = INVALID_SEGMENT_DURATION - 1;
|
||||
static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max();
|
||||
|
||||
Reference in New Issue
Block a user