Use ranges with fixed types

This commit is contained in:
Michael Krasnyk
2018-04-06 15:09:52 +02:00
committed by Patrick Niklaus
parent be123cd72f
commit 8d8042ebae
12 changed files with 190 additions and 152 deletions
+16 -15
View File
@@ -401,10 +401,10 @@ void encodeVectorTile(const DataFacadeBase &facade,
const auto reverse_datasource_range = facade.GetUncompressedReverseDatasources(geometry_id);
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());
const auto reverse_datasource = reverse_datasource_range[reverse_datasource_range.size() -
edge.fwd_segment_position - 1];
const auto reverse_datasource = reverse_datasource_range(reverse_datasource_range.size() -
edge.fwd_segment_position - 1);
// Keep track of the highest datasource seen so that we don't write unnecessary
// data to the layer attribute values
@@ -518,10 +518,9 @@ void encodeVectorTile(const DataFacadeBase &facade,
edge.fwd_segment_position - 1];
const auto forward_datasource_idx =
forward_datasource_range[edge.fwd_segment_position];
const auto reverse_datasource_idx =
reverse_datasource_range[reverse_datasource_range.size() -
edge.fwd_segment_position - 1];
forward_datasource_range(edge.fwd_segment_position);
const auto reverse_datasource_idx = reverse_datasource_range(
reverse_datasource_range.size() - edge.fwd_segment_position - 1);
const auto component_id = facade.GetComponentID(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)
{
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;
for (auto const nodeID : geometry)
points.push_back(facade.GetCoordinateOfNode(nodeID));
if (geomIndex.forward)
{
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 FixedLine &tile_line, std::int32_t &start_x, std::int32_t &start_y) {
+21 -21
View File
@@ -101,8 +101,6 @@ std::vector<TurnData> generateTurns(const datafacade &facade,
// w
// uv is the "approach"
// 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
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);
// Now, calculate the sum of the weight of all the segments.
if (edge_based_node_info.find(approachedge.edge_based_node_id)
->second.is_geometry_forward)
const auto &geometry =
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(
edge_based_node_info.find(approachedge.edge_based_node_id)
->second.packed_geometry_id);
approach_duration_range = facade.GetUncompressedForwardDurations(
edge_based_node_info.find(approachedge.edge_based_node_id)
->second.packed_geometry_id);
const auto approach_weight =
facade.GetUncompressedForwardWeights(geometry.packed_geometry_id);
const auto approach_duration =
facade.GetUncompressedForwardDurations(geometry.packed_geometry_id);
sum_node_weight = std::accumulate(
approach_weight.begin(), approach_weight.end(), EdgeWeight{0});
sum_node_duration = std::accumulate(
approach_duration.begin(), approach_duration.end(), EdgeDuration{0});
}
else
{
approach_weight_range = facade.GetUncompressedReverseWeights(
edge_based_node_info.find(approachedge.edge_based_node_id)
->second.packed_geometry_id);
approach_duration_range = facade.GetUncompressedReverseDurations(
edge_based_node_info.find(approachedge.edge_based_node_id)
->second.packed_geometry_id);
const auto approach_weight =
facade.GetUncompressedReverseWeights(geometry.packed_geometry_id);
const auto approach_duration =
facade.GetUncompressedReverseDurations(geometry.packed_geometry_id);
sum_node_weight = std::accumulate(
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
// cost.