Use ranges with fixed types
This commit is contained in:
parent
be123cd72f
commit
8d8042ebae
@ -48,7 +48,7 @@ class NearestAPI final : public BaseAPI
|
|||||||
std::uint64_t from_node = 0;
|
std::uint64_t from_node = 0;
|
||||||
std::uint64_t to_node = 0;
|
std::uint64_t to_node = 0;
|
||||||
|
|
||||||
datafacade::BaseDataFacade::NodesIDRangeT forward_geometry;
|
datafacade::BaseDataFacade::NodeForwardRange forward_geometry;
|
||||||
if (phantom_node.forward_segment_id.enabled)
|
if (phantom_node.forward_segment_id.enabled)
|
||||||
{
|
{
|
||||||
auto segment_id = phantom_node.forward_segment_id.id;
|
auto segment_id = phantom_node.forward_segment_id.id;
|
||||||
@ -56,7 +56,7 @@ class NearestAPI final : public BaseAPI
|
|||||||
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
forward_geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
||||||
|
|
||||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||||
forward_geometry[phantom_node.fwd_segment_position]);
|
forward_geometry(phantom_node.fwd_segment_position));
|
||||||
to_node = static_cast<std::uint64_t>(osm_node_id);
|
to_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class NearestAPI final : public BaseAPI
|
|||||||
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
const auto geometry_id = facade.GetGeometryIndex(segment_id).id;
|
||||||
const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
const auto geometry = facade.GetUncompressedForwardGeometry(geometry_id);
|
||||||
auto osm_node_id =
|
auto osm_node_id =
|
||||||
facade.GetOSMNodeIDOfNode(geometry[phantom_node.fwd_segment_position + 1]);
|
facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1));
|
||||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
else if (phantom_node.forward_segment_id.enabled &&
|
else if (phantom_node.forward_segment_id.enabled &&
|
||||||
@ -74,7 +74,7 @@ class NearestAPI final : public BaseAPI
|
|||||||
{
|
{
|
||||||
// In the case of one way, rely on forward segment only
|
// In the case of one way, rely on forward segment only
|
||||||
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
auto osm_node_id = facade.GetOSMNodeIDOfNode(
|
||||||
forward_geometry[phantom_node.fwd_segment_position - 1]);
|
forward_geometry(phantom_node.fwd_segment_position - 1));
|
||||||
from_node = static_cast<std::uint64_t>(osm_node_id);
|
from_node = static_cast<std::uint64_t>(osm_node_id);
|
||||||
}
|
}
|
||||||
nodes.values.push_back(from_node);
|
nodes.values.push_back(from_node);
|
||||||
|
@ -239,46 +239,46 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
|||||||
return m_osmnodeid_list[id];
|
return m_osmnodeid_list[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID id) const override final
|
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetForwardGeometry(id);
|
return segment_data.GetForwardGeometry(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID id) const override final
|
NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetReverseGeometry(id);
|
return segment_data.GetReverseGeometry(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
DurationsRangeT GetUncompressedForwardDurations(const EdgeID id) const override final
|
DurationForwardRange GetUncompressedForwardDurations(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetForwardDurations(id);
|
return segment_data.GetForwardDurations(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
DurationsRangeT GetUncompressedReverseDurations(const EdgeID id) const override final
|
DurationReverseRange GetUncompressedReverseDurations(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetReverseDurations(id);
|
return segment_data.GetReverseDurations(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
WeightsRangeT GetUncompressedForwardWeights(const EdgeID id) const override final
|
WeightForwardRange GetUncompressedForwardWeights(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetForwardWeights(id);
|
return segment_data.GetForwardWeights(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
WeightsRangeT GetUncompressedReverseWeights(const EdgeID id) const override final
|
WeightReverseRange GetUncompressedReverseWeights(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetReverseWeights(id);
|
return segment_data.GetReverseWeights(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the data source ids that were used to supply the edge
|
// Returns the data source ids that were used to supply the edge
|
||||||
// weights.
|
// weights.
|
||||||
DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID id) const override final
|
DatasourceForwardRange GetUncompressedForwardDatasources(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetForwardDatasources(id);
|
return segment_data.GetForwardDatasources(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the data source ids that were used to supply the edge
|
// Returns the data source ids that were used to supply the edge
|
||||||
// weights.
|
// weights.
|
||||||
DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID id) const override final
|
DatasourceReverseRange GetUncompressedReverseDatasources(const EdgeID id) const override final
|
||||||
{
|
{
|
||||||
return segment_data.GetReverseDatasources(id);
|
return segment_data.GetReverseDatasources(id);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "extractor/edge_based_node_segment.hpp"
|
#include "extractor/edge_based_node_segment.hpp"
|
||||||
#include "extractor/maneuver_override.hpp"
|
#include "extractor/maneuver_override.hpp"
|
||||||
#include "extractor/query_node.hpp"
|
#include "extractor/query_node.hpp"
|
||||||
|
#include "extractor/segment_data_container.hpp"
|
||||||
#include "extractor/travel_mode.hpp"
|
#include "extractor/travel_mode.hpp"
|
||||||
#include "extractor/turn_lane_types.hpp"
|
#include "extractor/turn_lane_types.hpp"
|
||||||
|
|
||||||
@ -23,12 +24,14 @@
|
|||||||
#include "util/guidance/entry_class.hpp"
|
#include "util/guidance/entry_class.hpp"
|
||||||
#include "util/guidance/turn_lanes.hpp"
|
#include "util/guidance/turn_lanes.hpp"
|
||||||
#include "util/integer_range.hpp"
|
#include "util/integer_range.hpp"
|
||||||
|
#include "util/packed_vector.hpp"
|
||||||
#include "util/string_util.hpp"
|
#include "util/string_util.hpp"
|
||||||
#include "util/string_view.hpp"
|
#include "util/string_view.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include "osrm/coordinate.hpp"
|
#include "osrm/coordinate.hpp"
|
||||||
|
|
||||||
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include <boost/range/any_range.hpp>
|
#include <boost/range/any_range.hpp>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -51,12 +54,21 @@ class BaseDataFacade
|
|||||||
public:
|
public:
|
||||||
using RTreeLeaf = extractor::EdgeBasedNodeSegment;
|
using RTreeLeaf = extractor::EdgeBasedNodeSegment;
|
||||||
|
|
||||||
template <typename T>
|
using NodeForwardRange =
|
||||||
using RangeT = boost::any_range<T, boost::random_access_traversal_tag, const T, std::ptrdiff_t>;
|
boost::iterator_range<extractor::SegmentDataView::SegmentNodeVector::const_iterator>;
|
||||||
using NodesIDRangeT = RangeT<NodeID>;
|
using NodeReverseRange = boost::reversed_range<const NodeForwardRange>;
|
||||||
using WeightsRangeT = RangeT<SegmentWeight>;
|
|
||||||
using DurationsRangeT = RangeT<SegmentDuration>;
|
using WeightForwardRange =
|
||||||
using DatasourceIDRangeT = RangeT<DatasourceID>;
|
boost::iterator_range<extractor::SegmentDataView::SegmentWeightVector::const_iterator>;
|
||||||
|
using WeightReverseRange = boost::reversed_range<const WeightForwardRange>;
|
||||||
|
|
||||||
|
using DurationForwardRange =
|
||||||
|
boost::iterator_range<extractor::SegmentDataView::SegmentDurationVector::const_iterator>;
|
||||||
|
using DurationReverseRange = boost::reversed_range<const DurationForwardRange>;
|
||||||
|
|
||||||
|
using DatasourceForwardRange =
|
||||||
|
boost::iterator_range<extractor::SegmentDataView::SegmentDatasourceVector::const_iterator>;
|
||||||
|
using DatasourceReverseRange = boost::reversed_range<const DatasourceForwardRange>;
|
||||||
|
|
||||||
BaseDataFacade() {}
|
BaseDataFacade() {}
|
||||||
virtual ~BaseDataFacade() {}
|
virtual ~BaseDataFacade() {}
|
||||||
@ -72,8 +84,8 @@ class BaseDataFacade
|
|||||||
|
|
||||||
virtual ComponentID GetComponentID(const NodeID id) const = 0;
|
virtual ComponentID GetComponentID(const NodeID id) const = 0;
|
||||||
|
|
||||||
virtual NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
virtual NodeForwardRange GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||||
virtual NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
virtual NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||||
|
|
||||||
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const = 0;
|
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
@ -81,18 +93,18 @@ class BaseDataFacade
|
|||||||
|
|
||||||
// Gets the weight values for each segment in an uncompressed geometry.
|
// Gets the weight values for each segment in an uncompressed geometry.
|
||||||
// Should always be 1 shorter than GetUncompressedGeometry
|
// Should always be 1 shorter than GetUncompressedGeometry
|
||||||
virtual WeightsRangeT GetUncompressedForwardWeights(const EdgeID id) const = 0;
|
virtual WeightForwardRange GetUncompressedForwardWeights(const EdgeID id) const = 0;
|
||||||
virtual WeightsRangeT GetUncompressedReverseWeights(const EdgeID id) const = 0;
|
virtual WeightReverseRange GetUncompressedReverseWeights(const EdgeID id) const = 0;
|
||||||
|
|
||||||
// Gets the duration values for each segment in an uncompressed geometry.
|
// Gets the duration values for each segment in an uncompressed geometry.
|
||||||
// Should always be 1 shorter than GetUncompressedGeometry
|
// Should always be 1 shorter than GetUncompressedGeometry
|
||||||
virtual DurationsRangeT GetUncompressedForwardDurations(const EdgeID id) const = 0;
|
virtual DurationForwardRange GetUncompressedForwardDurations(const EdgeID id) const = 0;
|
||||||
virtual DurationsRangeT GetUncompressedReverseDurations(const EdgeID id) const = 0;
|
virtual DurationReverseRange GetUncompressedReverseDurations(const EdgeID id) const = 0;
|
||||||
|
|
||||||
// Returns the data source ids that were used to supply the edge
|
// 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.
|
// weights. Will return an empty array when only the base profile is used.
|
||||||
virtual DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID id) const = 0;
|
virtual DatasourceForwardRange GetUncompressedForwardDatasources(const EdgeID id) const = 0;
|
||||||
virtual DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID id) const = 0;
|
virtual DatasourceReverseRange GetUncompressedReverseDatasources(const EdgeID id) const = 0;
|
||||||
|
|
||||||
// Gets the name of a datasource
|
// Gets the name of a datasource
|
||||||
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;
|
virtual StringView GetDatasourceName(const DatasourceID id) const = 0;
|
||||||
|
@ -58,7 +58,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
|||||||
const auto source_geometry = facade.GetUncompressedForwardGeometry(source_geometry_id);
|
const auto source_geometry = facade.GetUncompressedForwardGeometry(source_geometry_id);
|
||||||
|
|
||||||
geometry.osm_node_ids.push_back(
|
geometry.osm_node_ids.push_back(
|
||||||
facade.GetOSMNodeIDOfNode(source_geometry[source_segment_start_coordinate]));
|
facade.GetOSMNodeIDOfNode(source_geometry(source_segment_start_coordinate)));
|
||||||
|
|
||||||
auto cumulative_distance = 0.;
|
auto cumulative_distance = 0.;
|
||||||
auto current_distance = 0.;
|
auto current_distance = 0.;
|
||||||
@ -135,7 +135,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
|||||||
LegGeometry::Annotation{current_distance,
|
LegGeometry::Annotation{current_distance,
|
||||||
duration,
|
duration,
|
||||||
weight,
|
weight,
|
||||||
forward_datasources[target_node.fwd_segment_position]});
|
forward_datasources(target_node.fwd_segment_position)});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
|||||||
(reversed_target ? target_node.reverse_duration : target_node.forward_duration) / 10.,
|
(reversed_target ? target_node.reverse_duration : target_node.forward_duration) / 10.,
|
||||||
(reversed_target ? target_node.reverse_weight : target_node.forward_weight) /
|
(reversed_target ? target_node.reverse_weight : target_node.forward_weight) /
|
||||||
facade.GetWeightMultiplier(),
|
facade.GetWeightMultiplier(),
|
||||||
forward_datasources[target_node.fwd_segment_position]});
|
forward_datasources(target_node.fwd_segment_position)});
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry.segment_offsets.push_back(geometry.locations.size());
|
geometry.segment_offsets.push_back(geometry.locations.size());
|
||||||
@ -159,7 +159,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
|||||||
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
|
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
|
||||||
const auto target_geometry = facade.GetUncompressedForwardGeometry(target_geometry_id);
|
const auto target_geometry = facade.GetUncompressedForwardGeometry(target_geometry_id);
|
||||||
geometry.osm_node_ids.push_back(
|
geometry.osm_node_ids.push_back(
|
||||||
facade.GetOSMNodeIDOfNode(target_geometry[target_segment_end_coordinate]));
|
facade.GetOSMNodeIDOfNode(target_geometry(target_segment_end_coordinate)));
|
||||||
|
|
||||||
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
|
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
|
||||||
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());
|
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());
|
||||||
|
@ -135,25 +135,30 @@ void annotatePath(const FacadeT &facade,
|
|||||||
phantom_node_pair.target_phantom.reverse_segment_id.id == target_node_id);
|
phantom_node_pair.target_phantom.reverse_segment_id.id == target_node_id);
|
||||||
|
|
||||||
// datastructures to hold extracted data from geometry
|
// datastructures to hold extracted data from geometry
|
||||||
datafacade::ContiguousInternalMemoryDataFacadeBase::NodesIDRangeT id_range;
|
std::vector<NodeID> id_vector;
|
||||||
datafacade::ContiguousInternalMemoryDataFacadeBase::WeightsRangeT weight_range;
|
std::vector<SegmentWeight> weight_vector;
|
||||||
datafacade::ContiguousInternalMemoryDataFacadeBase::DurationsRangeT duration_range;
|
std::vector<SegmentDuration> duration_vector;
|
||||||
datafacade::ContiguousInternalMemoryDataFacadeBase::DatasourceIDRangeT datasource_range;
|
std::vector<DatasourceID> datasource_vector;
|
||||||
|
|
||||||
const auto get_segment_geometry = [&](const auto geometry_index) {
|
const auto get_segment_geometry = [&](const auto geometry_index) {
|
||||||
|
const auto copy = [](auto &vector, const auto range) {
|
||||||
|
vector.resize(range.size());
|
||||||
|
std::copy(range.begin(), range.end(), vector.begin());
|
||||||
|
};
|
||||||
|
|
||||||
if (geometry_index.forward)
|
if (geometry_index.forward)
|
||||||
{
|
{
|
||||||
id_range = facade.GetUncompressedForwardGeometry(geometry_index.id);
|
copy(id_vector, facade.GetUncompressedForwardGeometry(geometry_index.id));
|
||||||
weight_range = facade.GetUncompressedForwardWeights(geometry_index.id);
|
copy(weight_vector, facade.GetUncompressedForwardWeights(geometry_index.id));
|
||||||
duration_range = facade.GetUncompressedForwardDurations(geometry_index.id);
|
copy(duration_vector, facade.GetUncompressedForwardDurations(geometry_index.id));
|
||||||
datasource_range = facade.GetUncompressedForwardDatasources(geometry_index.id);
|
copy(datasource_vector, facade.GetUncompressedForwardDatasources(geometry_index.id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
id_range = facade.GetUncompressedReverseGeometry(geometry_index.id);
|
copy(id_vector, facade.GetUncompressedReverseGeometry(geometry_index.id));
|
||||||
weight_range = facade.GetUncompressedReverseWeights(geometry_index.id);
|
copy(weight_vector, facade.GetUncompressedReverseWeights(geometry_index.id));
|
||||||
duration_range = facade.GetUncompressedReverseDurations(geometry_index.id);
|
copy(duration_vector, facade.GetUncompressedReverseDurations(geometry_index.id));
|
||||||
datasource_range = facade.GetUncompressedReverseDatasources(geometry_index.id);
|
copy(datasource_vector, facade.GetUncompressedReverseDatasources(geometry_index.id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,19 +177,19 @@ void annotatePath(const FacadeT &facade,
|
|||||||
const auto geometry_index = facade.GetGeometryIndex(node_id);
|
const auto geometry_index = facade.GetGeometryIndex(node_id);
|
||||||
get_segment_geometry(geometry_index);
|
get_segment_geometry(geometry_index);
|
||||||
|
|
||||||
BOOST_ASSERT(id_range.size() > 0);
|
BOOST_ASSERT(id_vector.size() > 0);
|
||||||
BOOST_ASSERT(datasource_range.size() > 0);
|
BOOST_ASSERT(datasource_vector.size() > 0);
|
||||||
BOOST_ASSERT(weight_range.size() + 1 == id_range.size());
|
BOOST_ASSERT(weight_vector.size() + 1 == id_vector.size());
|
||||||
BOOST_ASSERT(duration_range.size() + 1 == id_range.size());
|
BOOST_ASSERT(duration_vector.size() + 1 == id_vector.size());
|
||||||
const bool is_first_segment = unpacked_path.empty();
|
const bool is_first_segment = unpacked_path.empty();
|
||||||
|
|
||||||
const std::size_t start_index =
|
const std::size_t start_index =
|
||||||
(is_first_segment ? ((start_traversed_in_reverse)
|
(is_first_segment ? ((start_traversed_in_reverse)
|
||||||
? weight_range.size() -
|
? weight_vector.size() -
|
||||||
phantom_node_pair.source_phantom.fwd_segment_position - 1
|
phantom_node_pair.source_phantom.fwd_segment_position - 1
|
||||||
: phantom_node_pair.source_phantom.fwd_segment_position)
|
: phantom_node_pair.source_phantom.fwd_segment_position)
|
||||||
: 0);
|
: 0);
|
||||||
const std::size_t end_index = weight_range.size();
|
const std::size_t end_index = weight_vector.size();
|
||||||
|
|
||||||
bool is_left_hand_driving = facade.IsLeftHandDriving(node_id);
|
bool is_left_hand_driving = facade.IsLeftHandDriving(node_id);
|
||||||
|
|
||||||
@ -192,23 +197,24 @@ void annotatePath(const FacadeT &facade,
|
|||||||
BOOST_ASSERT(start_index < end_index);
|
BOOST_ASSERT(start_index < end_index);
|
||||||
for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx)
|
for (std::size_t segment_idx = start_index; segment_idx < end_index; ++segment_idx)
|
||||||
{
|
{
|
||||||
unpacked_path.push_back(PathData{*node_from,
|
unpacked_path.push_back(
|
||||||
id_range[segment_idx + 1],
|
PathData{*node_from,
|
||||||
name_index,
|
id_vector[segment_idx + 1],
|
||||||
is_segregated,
|
name_index,
|
||||||
static_cast<EdgeWeight>(weight_range[segment_idx]),
|
is_segregated,
|
||||||
0,
|
static_cast<EdgeWeight>(weight_vector[segment_idx]),
|
||||||
static_cast<EdgeDuration>(duration_range[segment_idx]),
|
0,
|
||||||
0,
|
static_cast<EdgeDuration>(duration_vector[segment_idx]),
|
||||||
guidance::TurnInstruction::NO_TURN(),
|
0,
|
||||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
guidance::TurnInstruction::NO_TURN(),
|
||||||
travel_mode,
|
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||||
classes,
|
travel_mode,
|
||||||
EMPTY_ENTRY_CLASS,
|
classes,
|
||||||
datasource_range[segment_idx],
|
EMPTY_ENTRY_CLASS,
|
||||||
osrm::guidance::TurnBearing(0),
|
datasource_vector[segment_idx],
|
||||||
osrm::guidance::TurnBearing(0),
|
osrm::guidance::TurnBearing(0),
|
||||||
is_left_hand_driving});
|
osrm::guidance::TurnBearing(0),
|
||||||
|
is_left_hand_driving});
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(unpacked_path.size() > 0);
|
BOOST_ASSERT(unpacked_path.size() > 0);
|
||||||
if (facade.HasLaneData(turn_id))
|
if (facade.HasLaneData(turn_id))
|
||||||
@ -239,9 +245,10 @@ void annotatePath(const FacadeT &facade,
|
|||||||
if (is_local_path)
|
if (is_local_path)
|
||||||
{
|
{
|
||||||
start_index =
|
start_index =
|
||||||
weight_range.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1;
|
weight_vector.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1;
|
||||||
}
|
}
|
||||||
end_index = weight_range.size() - phantom_node_pair.target_phantom.fwd_segment_position - 1;
|
end_index =
|
||||||
|
weight_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -263,23 +270,23 @@ void annotatePath(const FacadeT &facade,
|
|||||||
for (std::size_t segment_idx = start_index; segment_idx != end_index;
|
for (std::size_t segment_idx = start_index; segment_idx != end_index;
|
||||||
(start_index < end_index ? ++segment_idx : --segment_idx))
|
(start_index < end_index ? ++segment_idx : --segment_idx))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(segment_idx < static_cast<std::size_t>(id_range.size() - 1));
|
BOOST_ASSERT(segment_idx < static_cast<std::size_t>(id_vector.size() - 1));
|
||||||
BOOST_ASSERT(facade.GetTravelMode(target_node_id) > 0);
|
BOOST_ASSERT(facade.GetTravelMode(target_node_id) > 0);
|
||||||
unpacked_path.push_back(
|
unpacked_path.push_back(
|
||||||
PathData{target_node_id,
|
PathData{target_node_id,
|
||||||
id_range[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
|
id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
|
||||||
facade.GetNameIndex(target_node_id),
|
facade.GetNameIndex(target_node_id),
|
||||||
facade.IsSegregated(target_node_id),
|
facade.IsSegregated(target_node_id),
|
||||||
static_cast<EdgeWeight>(weight_range[segment_idx]),
|
static_cast<EdgeWeight>(weight_vector[segment_idx]),
|
||||||
0,
|
0,
|
||||||
static_cast<EdgeDuration>(duration_range[segment_idx]),
|
static_cast<EdgeDuration>(duration_vector[segment_idx]),
|
||||||
0,
|
0,
|
||||||
guidance::TurnInstruction::NO_TURN(),
|
guidance::TurnInstruction::NO_TURN(),
|
||||||
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
{{0, INVALID_LANEID}, INVALID_LANE_DESCRIPTIONID},
|
||||||
facade.GetTravelMode(target_node_id),
|
facade.GetTravelMode(target_node_id),
|
||||||
facade.GetClassData(target_node_id),
|
facade.GetClassData(target_node_id),
|
||||||
EMPTY_ENTRY_CLASS,
|
EMPTY_ENTRY_CLASS,
|
||||||
datasource_range[segment_idx],
|
datasource_vector[segment_idx],
|
||||||
guidance::TurnBearing(0),
|
guidance::TurnBearing(0),
|
||||||
guidance::TurnBearing(0),
|
guidance::TurnBearing(0),
|
||||||
is_target_left_hand_driving});
|
is_target_left_hand_driving});
|
||||||
|
@ -55,6 +55,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
|||||||
// FIXME We should change the indexing to Edge-Based-Node id
|
// FIXME We should change the indexing to Edge-Based-Node id
|
||||||
using DirectionalGeometryID = std::uint32_t;
|
using DirectionalGeometryID = std::uint32_t;
|
||||||
using SegmentOffset = std::uint32_t;
|
using SegmentOffset = std::uint32_t;
|
||||||
|
using SegmentNodeVector = Vector<NodeID>;
|
||||||
using SegmentWeightVector = PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
using SegmentWeightVector = PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
||||||
using SegmentDurationVector = PackedVector<SegmentDuration, SEGMENT_DURATION_BITS>;
|
using SegmentDurationVector = PackedVector<SegmentDuration, SEGMENT_DURATION_BITS>;
|
||||||
using SegmentDatasourceVector = Vector<DatasourceID>;
|
using SegmentDatasourceVector = Vector<DatasourceID>;
|
||||||
@ -62,7 +63,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
|||||||
SegmentDataContainerImpl() = default;
|
SegmentDataContainerImpl() = default;
|
||||||
|
|
||||||
SegmentDataContainerImpl(Vector<std::uint32_t> index_,
|
SegmentDataContainerImpl(Vector<std::uint32_t> index_,
|
||||||
Vector<NodeID> nodes_,
|
SegmentNodeVector nodes_,
|
||||||
SegmentWeightVector fwd_weights_,
|
SegmentWeightVector fwd_weights_,
|
||||||
SegmentWeightVector rev_weights_,
|
SegmentWeightVector rev_weights_,
|
||||||
SegmentDurationVector fwd_durations_,
|
SegmentDurationVector fwd_durations_,
|
||||||
@ -212,7 +213,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<std::uint32_t> index;
|
Vector<std::uint32_t> index;
|
||||||
Vector<NodeID> nodes;
|
SegmentNodeVector nodes;
|
||||||
SegmentWeightVector fwd_weights;
|
SegmentWeightVector fwd_weights;
|
||||||
SegmentWeightVector rev_weights;
|
SegmentWeightVector rev_weights;
|
||||||
SegmentDurationVector fwd_durations;
|
SegmentDurationVector fwd_durations;
|
||||||
|
@ -31,11 +31,13 @@ namespace util
|
|||||||
template <typename DataT>
|
template <typename DataT>
|
||||||
class VectorViewIterator : public boost::iterator_facade<VectorViewIterator<DataT>,
|
class VectorViewIterator : public boost::iterator_facade<VectorViewIterator<DataT>,
|
||||||
DataT,
|
DataT,
|
||||||
boost::random_access_traversal_tag>
|
boost::random_access_traversal_tag,
|
||||||
|
DataT &>
|
||||||
{
|
{
|
||||||
typedef boost::iterator_facade<VectorViewIterator<DataT>,
|
typedef boost::iterator_facade<VectorViewIterator<DataT>,
|
||||||
DataT,
|
DataT,
|
||||||
boost::random_access_traversal_tag>
|
boost::random_access_traversal_tag,
|
||||||
|
DataT &>
|
||||||
base_t;
|
base_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -401,10 +401,10 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
const auto reverse_datasource_range = facade.GetUncompressedReverseDatasources(geometry_id);
|
const auto reverse_datasource_range = facade.GetUncompressedReverseDatasources(geometry_id);
|
||||||
|
|
||||||
BOOST_ASSERT(edge.fwd_segment_position < forward_datasource_range.size());
|
BOOST_ASSERT(edge.fwd_segment_position < forward_datasource_range.size());
|
||||||
const auto forward_datasource = forward_datasource_range[edge.fwd_segment_position];
|
const auto forward_datasource = forward_datasource_range(edge.fwd_segment_position);
|
||||||
BOOST_ASSERT(edge.fwd_segment_position < reverse_datasource_range.size());
|
BOOST_ASSERT(edge.fwd_segment_position < reverse_datasource_range.size());
|
||||||
const auto reverse_datasource = reverse_datasource_range[reverse_datasource_range.size() -
|
const auto reverse_datasource = reverse_datasource_range(reverse_datasource_range.size() -
|
||||||
edge.fwd_segment_position - 1];
|
edge.fwd_segment_position - 1);
|
||||||
|
|
||||||
// Keep track of the highest datasource seen so that we don't write unnecessary
|
// Keep track of the highest datasource seen so that we don't write unnecessary
|
||||||
// data to the layer attribute values
|
// data to the layer attribute values
|
||||||
@ -518,10 +518,9 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
edge.fwd_segment_position - 1];
|
edge.fwd_segment_position - 1];
|
||||||
|
|
||||||
const auto forward_datasource_idx =
|
const auto forward_datasource_idx =
|
||||||
forward_datasource_range[edge.fwd_segment_position];
|
forward_datasource_range(edge.fwd_segment_position);
|
||||||
const auto reverse_datasource_idx =
|
const auto reverse_datasource_idx = reverse_datasource_range(
|
||||||
reverse_datasource_range[reverse_datasource_range.size() -
|
reverse_datasource_range.size() - edge.fwd_segment_position - 1);
|
||||||
edge.fwd_segment_position - 1];
|
|
||||||
|
|
||||||
const auto component_id = facade.GetComponentID(edge.forward_segment_id.id);
|
const auto component_id = facade.GetComponentID(edge.forward_segment_id.id);
|
||||||
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
|
const auto name_id = facade.GetNameIndex(edge.forward_segment_id.id);
|
||||||
@ -925,16 +924,18 @@ void encodeVectorTile(const DataFacadeBase &facade,
|
|||||||
for (auto edgeNodeID : segregated_nodes)
|
for (auto edgeNodeID : segregated_nodes)
|
||||||
{
|
{
|
||||||
auto const geomIndex = facade.GetGeometryIndex(edgeNodeID);
|
auto const geomIndex = facade.GetGeometryIndex(edgeNodeID);
|
||||||
DataFacadeBase::NodesIDRangeT geometry;
|
|
||||||
|
|
||||||
if (geomIndex.forward)
|
|
||||||
geometry = facade.GetUncompressedForwardGeometry(geomIndex.id);
|
|
||||||
else
|
|
||||||
geometry = facade.GetUncompressedReverseGeometry(geomIndex.id);
|
|
||||||
|
|
||||||
std::vector<util::Coordinate> points;
|
std::vector<util::Coordinate> points;
|
||||||
for (auto const nodeID : geometry)
|
if (geomIndex.forward)
|
||||||
points.push_back(facade.GetCoordinateOfNode(nodeID));
|
{
|
||||||
|
for (auto const nodeID : facade.GetUncompressedForwardGeometry(geomIndex.id))
|
||||||
|
points.push_back(facade.GetCoordinateOfNode(nodeID));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto const nodeID : facade.GetUncompressedReverseGeometry(geomIndex.id))
|
||||||
|
points.push_back(facade.GetCoordinateOfNode(nodeID));
|
||||||
|
}
|
||||||
|
|
||||||
const auto encode_tile_line = [&line_layer_writer, &id](
|
const auto encode_tile_line = [&line_layer_writer, &id](
|
||||||
const FixedLine &tile_line, std::int32_t &start_x, std::int32_t &start_y) {
|
const FixedLine &tile_line, std::int32_t &start_x, std::int32_t &start_y) {
|
||||||
|
@ -101,8 +101,6 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
|
|||||||
// w
|
// w
|
||||||
// uv is the "approach"
|
// uv is the "approach"
|
||||||
// vw is the "exit"
|
// vw is the "exit"
|
||||||
typename datafacade::BaseDataFacade::WeightsRangeT approach_weight_range;
|
|
||||||
typename datafacade::BaseDataFacade::DurationsRangeT approach_duration_range;
|
|
||||||
|
|
||||||
// Look at every node in the directed graph we created
|
// Look at every node in the directed graph we created
|
||||||
for (const auto &startnode : sorted_startnodes)
|
for (const auto &startnode : sorted_startnodes)
|
||||||
@ -148,30 +146,32 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
|
|||||||
const auto &data = facade.GetEdgeData(edge_based_edge_id);
|
const auto &data = facade.GetEdgeData(edge_based_edge_id);
|
||||||
|
|
||||||
// Now, calculate the sum of the weight of all the segments.
|
// Now, calculate the sum of the weight of all the segments.
|
||||||
if (edge_based_node_info.find(approachedge.edge_based_node_id)
|
const auto &geometry =
|
||||||
->second.is_geometry_forward)
|
edge_based_node_info.find(approachedge.edge_based_node_id)->second;
|
||||||
|
EdgeWeight sum_node_weight = 0;
|
||||||
|
EdgeDuration sum_node_duration = 0;
|
||||||
|
if (geometry.is_geometry_forward)
|
||||||
{
|
{
|
||||||
approach_weight_range = facade.GetUncompressedForwardWeights(
|
const auto approach_weight =
|
||||||
edge_based_node_info.find(approachedge.edge_based_node_id)
|
facade.GetUncompressedForwardWeights(geometry.packed_geometry_id);
|
||||||
->second.packed_geometry_id);
|
const auto approach_duration =
|
||||||
approach_duration_range = facade.GetUncompressedForwardDurations(
|
facade.GetUncompressedForwardDurations(geometry.packed_geometry_id);
|
||||||
edge_based_node_info.find(approachedge.edge_based_node_id)
|
sum_node_weight = std::accumulate(
|
||||||
->second.packed_geometry_id);
|
approach_weight.begin(), approach_weight.end(), EdgeWeight{0});
|
||||||
|
sum_node_duration = std::accumulate(
|
||||||
|
approach_duration.begin(), approach_duration.end(), EdgeDuration{0});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
approach_weight_range = facade.GetUncompressedReverseWeights(
|
const auto approach_weight =
|
||||||
edge_based_node_info.find(approachedge.edge_based_node_id)
|
facade.GetUncompressedReverseWeights(geometry.packed_geometry_id);
|
||||||
->second.packed_geometry_id);
|
const auto approach_duration =
|
||||||
approach_duration_range = facade.GetUncompressedReverseDurations(
|
facade.GetUncompressedReverseDurations(geometry.packed_geometry_id);
|
||||||
edge_based_node_info.find(approachedge.edge_based_node_id)
|
sum_node_weight = std::accumulate(
|
||||||
->second.packed_geometry_id);
|
approach_weight.begin(), approach_weight.end(), EdgeWeight{0});
|
||||||
|
sum_node_duration = std::accumulate(
|
||||||
|
approach_duration.begin(), approach_duration.end(), EdgeDuration{0});
|
||||||
}
|
}
|
||||||
const auto sum_node_weight = std::accumulate(
|
|
||||||
approach_weight_range.begin(), approach_weight_range.end(), EdgeWeight{0});
|
|
||||||
const auto sum_node_duration = std::accumulate(approach_duration_range.begin(),
|
|
||||||
approach_duration_range.end(),
|
|
||||||
EdgeWeight{0});
|
|
||||||
|
|
||||||
// The edge.weight is the whole edge weight, which includes the turn
|
// The edge.weight is the whole edge weight, which includes the turn
|
||||||
// cost.
|
// cost.
|
||||||
|
@ -156,9 +156,15 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
|||||||
|
|
||||||
GeometryID GetGeometryIndex(const NodeID /*id*/) const override { return GeometryID{0, false}; }
|
GeometryID GetGeometryIndex(const NodeID /*id*/) const override { return GeometryID{0, false}; }
|
||||||
|
|
||||||
NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID /*id*/) const override { return {}; }
|
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /*id*/) const override
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID /*id*/) const override { return {}; }
|
NodeReverseRange GetUncompressedReverseGeometry(const EdgeID /*id*/) const override
|
||||||
|
{
|
||||||
|
return NodeReverseRange(NodeForwardRange());
|
||||||
|
}
|
||||||
|
|
||||||
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned /*id*/) const override
|
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned /*id*/) const override
|
||||||
{
|
{
|
||||||
@ -170,28 +176,34 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
|||||||
return INVALID_TURN_PENALTY;
|
return INVALID_TURN_PENALTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
WeightsRangeT GetUncompressedForwardWeights(const EdgeID /*id*/) const override { return {}; }
|
WeightForwardRange GetUncompressedForwardWeights(const EdgeID /*id*/) const override
|
||||||
|
|
||||||
WeightsRangeT GetUncompressedReverseWeights(const EdgeID /*id*/) const override { return {}; }
|
|
||||||
|
|
||||||
DurationsRangeT GetUncompressedForwardDurations(const EdgeID /*geomID*/) const override
|
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
DurationsRangeT GetUncompressedReverseDurations(const EdgeID /*geomID*/) const override
|
WeightReverseRange GetUncompressedReverseWeights(const EdgeID /*id*/) const override
|
||||||
|
{
|
||||||
|
return WeightReverseRange(WeightForwardRange());
|
||||||
|
}
|
||||||
|
|
||||||
|
DurationForwardRange GetUncompressedForwardDurations(const EdgeID /*geomID*/) const override
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID /*id*/) const override
|
DurationReverseRange GetUncompressedReverseDurations(const EdgeID /*geomID*/) const override
|
||||||
|
{
|
||||||
|
return DurationReverseRange(DurationForwardRange());
|
||||||
|
}
|
||||||
|
|
||||||
|
DatasourceForwardRange GetUncompressedForwardDatasources(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID /*id*/) const override
|
DatasourceReverseRange GetUncompressedReverseDatasources(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
return {};
|
return DatasourceReverseRange(DatasourceForwardRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView GetDatasourceName(const DatasourceID /*id*/) const override { return StringView{}; }
|
StringView GetDatasourceName(const DatasourceID /*id*/) const override { return StringView{}; }
|
||||||
|
@ -54,41 +54,44 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NodesIDRangeT GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
NodeForwardRange GetUncompressedForwardGeometry(const EdgeID /* id */) const override
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
NodesIDRangeT GetUncompressedReverseGeometry(const EdgeID /* id */) const override
|
NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const override
|
||||||
{
|
{
|
||||||
return {};
|
return NodeReverseRange(GetUncompressedForwardGeometry(id));
|
||||||
}
|
}
|
||||||
WeightsRangeT GetUncompressedForwardWeights(const EdgeID /* id */) const override
|
WeightForwardRange GetUncompressedForwardWeights(const EdgeID /* id */) const override
|
||||||
{
|
{
|
||||||
static const std::vector<SegmentWeight> result_weights{1, 2, 3};
|
static std::uint64_t data[] = {1, 2, 3};
|
||||||
return result_weights;
|
static const extractor::SegmentDataView::SegmentWeightVector weights(
|
||||||
|
util::vector_view<std::uint64_t>(data, 3), 3);
|
||||||
|
return WeightForwardRange(weights.begin(), weights.end());
|
||||||
}
|
}
|
||||||
WeightsRangeT GetUncompressedReverseWeights(const EdgeID id) const override
|
WeightReverseRange GetUncompressedReverseWeights(const EdgeID id) const override
|
||||||
{
|
{
|
||||||
return GetUncompressedForwardWeights(id);
|
return WeightReverseRange(GetUncompressedForwardWeights(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
DurationsRangeT GetUncompressedForwardDurations(const EdgeID /*id*/) const override
|
DurationForwardRange GetUncompressedForwardDurations(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
static const std::vector<SegmentDuration> data{1, 2, 3};
|
static std::uint64_t data[] = {1, 2, 3};
|
||||||
return data;
|
static const extractor::SegmentDataView::SegmentDurationVector durations(
|
||||||
|
util::vector_view<std::uint64_t>(data, 3), 3);
|
||||||
|
return DurationForwardRange(durations.begin(), durations.end());
|
||||||
}
|
}
|
||||||
DurationsRangeT GetUncompressedReverseDurations(const EdgeID /*id*/) const override
|
DurationReverseRange GetUncompressedReverseDurations(const EdgeID id) const override
|
||||||
{
|
{
|
||||||
static const std::vector<SegmentDuration> data{1, 2, 3};
|
return DurationReverseRange(GetUncompressedForwardDurations(id));
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
DatasourceIDRangeT GetUncompressedForwardDatasources(const EdgeID /*id*/) const override
|
DatasourceForwardRange GetUncompressedForwardDatasources(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
DatasourceIDRangeT GetUncompressedReverseDatasources(const EdgeID /*id*/) const override
|
DatasourceReverseRange GetUncompressedReverseDatasources(const EdgeID /*id*/) const override
|
||||||
{
|
{
|
||||||
return {};
|
return DatasourceReverseRange(DatasourceForwardRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView GetDatasourceName(const DatasourceID) const override final { return {}; }
|
StringView GetDatasourceName(const DatasourceID) const override final { return {}; }
|
||||||
|
@ -209,22 +209,22 @@ BOOST_AUTO_TEST_CASE(packed_vector_33bit_continious)
|
|||||||
BOOST_AUTO_TEST_CASE(packed_weights_container_with_type_erasure)
|
BOOST_AUTO_TEST_CASE(packed_weights_container_with_type_erasure)
|
||||||
{
|
{
|
||||||
using Vector = PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
using Vector = PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
||||||
using WeightsRangeT = boost::any_range<SegmentWeight,
|
using WeightsAnyRange = boost::any_range<SegmentWeight,
|
||||||
boost::random_access_traversal_tag,
|
boost::random_access_traversal_tag,
|
||||||
const typename Vector::internal_reference,
|
const typename Vector::internal_reference,
|
||||||
std::ptrdiff_t>;
|
std::ptrdiff_t>;
|
||||||
|
|
||||||
PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS> vector(7);
|
PackedVector<SegmentWeight, SEGMENT_WEIGHT_BITS> vector(7);
|
||||||
|
|
||||||
std::iota(vector.begin(), vector.end(), 0);
|
std::iota(vector.begin(), vector.end(), 0);
|
||||||
|
|
||||||
auto forward = boost::make_iterator_range(vector.begin() + 1, vector.begin() + 6);
|
auto forward = boost::make_iterator_range(vector.begin() + 1, vector.begin() + 6);
|
||||||
auto forward_any = WeightsRangeT(forward.begin(), forward.end());
|
auto forward_any = WeightsAnyRange(forward.begin(), forward.end());
|
||||||
CHECK_EQUAL_RANGE(forward, 1, 2, 3, 4, 5);
|
CHECK_EQUAL_RANGE(forward, 1, 2, 3, 4, 5);
|
||||||
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3, 4, 5);
|
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3, 4, 5);
|
||||||
|
|
||||||
auto reverse = boost::adaptors::reverse(forward);
|
auto reverse = boost::adaptors::reverse(forward);
|
||||||
auto reverse_any = WeightsRangeT(reverse);
|
auto reverse_any = WeightsAnyRange(reverse);
|
||||||
CHECK_EQUAL_RANGE(reverse, 5, 4, 3, 2, 1);
|
CHECK_EQUAL_RANGE(reverse, 5, 4, 3, 2, 1);
|
||||||
CHECK_EQUAL_RANGE(reverse_any, 5, 4, 3, 2, 1);
|
CHECK_EQUAL_RANGE(reverse_any, 5, 4, 3, 2, 1);
|
||||||
}
|
}
|
||||||
@ -233,21 +233,21 @@ BOOST_AUTO_TEST_CASE(packed_weights_view_with_type_erasure)
|
|||||||
{
|
{
|
||||||
using View = PackedVectorView<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
using View = PackedVectorView<SegmentWeight, SEGMENT_WEIGHT_BITS>;
|
||||||
using PackedDataWord = std::uint64_t; // PackedVectorView<>::WordT
|
using PackedDataWord = std::uint64_t; // PackedVectorView<>::WordT
|
||||||
using WeightsRangeT = boost::any_range<SegmentWeight,
|
using WeightsAnyRange = boost::any_range<SegmentWeight,
|
||||||
boost::random_access_traversal_tag,
|
boost::random_access_traversal_tag,
|
||||||
const typename View::internal_reference,
|
const typename View::internal_reference,
|
||||||
std::ptrdiff_t>;
|
std::ptrdiff_t>;
|
||||||
|
|
||||||
PackedDataWord data[] = {0x200000400000, 0xc, 0};
|
PackedDataWord data[] = {0x200000400000, 0xc, 0};
|
||||||
View view(vector_view<PackedDataWord>(data, 3), 7);
|
View view(vector_view<PackedDataWord>(data, 3), 7);
|
||||||
|
|
||||||
auto forward = boost::make_iterator_range(view.begin() + 1, view.begin() + 4);
|
auto forward = boost::make_iterator_range(view.begin() + 1, view.begin() + 4);
|
||||||
auto forward_any = WeightsRangeT(forward.begin(), forward.end());
|
auto forward_any = WeightsAnyRange(forward.begin(), forward.end());
|
||||||
CHECK_EQUAL_RANGE(forward, 1, 2, 3);
|
CHECK_EQUAL_RANGE(forward, 1, 2, 3);
|
||||||
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3);
|
CHECK_EQUAL_RANGE(forward_any, 1, 2, 3);
|
||||||
|
|
||||||
auto reverse = boost::adaptors::reverse(forward);
|
auto reverse = boost::adaptors::reverse(forward);
|
||||||
auto reverse_any = WeightsRangeT(reverse);
|
auto reverse_any = WeightsAnyRange(reverse);
|
||||||
CHECK_EQUAL_RANGE(reverse, 3, 2, 1);
|
CHECK_EQUAL_RANGE(reverse, 3, 2, 1);
|
||||||
CHECK_EQUAL_RANGE(reverse_any, 3, 2, 1);
|
CHECK_EQUAL_RANGE(reverse_any, 3, 2, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user