Allow specifing a weight for routing that is independent of duration

This commit is contained in:
Patrick Niklaus
2016-05-12 18:50:10 +02:00
committed by Patrick Niklaus
parent e463733138
commit 279f8aabfb
85 changed files with 2100 additions and 853 deletions
+25 -5
View File
@@ -101,6 +101,14 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c
// write compressed geometry reverse weights
geometry_out_stream.write((char *)(m_compressed_geometry_rev_weights.data()),
sizeof(EdgeWeight) * m_compressed_geometry_rev_weights.size());
// write compressed geometry forward durations
geometry_out_stream.write((char *)(m_compressed_geometry_fwd_durations.data()),
sizeof(EdgeWeight) * m_compressed_geometry_fwd_durations.size());
// write compressed geometry reverse durations
geometry_out_stream.write((char *)(m_compressed_geometry_rev_durations.data()),
sizeof(EdgeWeight) * m_compressed_geometry_rev_durations.size());
}
// Adds info for a compressed edge to the container. edge_id_2
@@ -111,12 +119,15 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c
// edge_id_1 edge_id_2
// ----------> via_node_id -----------> target_node_id
// weight_1 weight_2
// duration_1 duration_2
void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
const EdgeID edge_id_2,
const NodeID via_node_id,
const NodeID target_node_id,
const EdgeWeight weight1,
const EdgeWeight weight2)
const EdgeWeight weight2,
const EdgeWeight duration1,
const EdgeWeight duration2)
{
// remove super-trivial geometries
BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1);
@@ -161,7 +172,7 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
// weight1 is the distance to the (currently) last coordinate in the bucket
if (edge_bucket_list1.empty())
{
edge_bucket_list1.emplace_back(OnewayCompressedEdge{via_node_id, weight1});
edge_bucket_list1.emplace_back(OnewayCompressedEdge{via_node_id, weight1, duration1});
}
BOOST_ASSERT(0 < edge_bucket_list1.size());
@@ -192,13 +203,14 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
else
{
// we are certain that the second edge is atomic.
edge_bucket_list1.emplace_back(OnewayCompressedEdge{target_node_id, weight2});
edge_bucket_list1.emplace_back(OnewayCompressedEdge{target_node_id, weight2, duration2});
}
}
void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
const NodeID target_node_id,
const EdgeWeight weight)
const EdgeWeight weight,
const EdgeWeight duration)
{
// remove super-trivial geometries
BOOST_ASSERT(SPECIAL_EDGEID != edge_id);
@@ -234,7 +246,7 @@ void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
// Don't re-add this if it's already in there.
if (edge_bucket_list.empty())
{
edge_bucket_list.emplace_back(OnewayCompressedEdge{target_node_id, weight});
edge_bucket_list.emplace_back(OnewayCompressedEdge{target_node_id, weight, duration});
}
}
@@ -244,6 +256,8 @@ void CompressedEdgeContainer::InitializeBothwayVector()
m_compressed_geometry_nodes.reserve(m_compressed_oneway_geometries.size());
m_compressed_geometry_fwd_weights.reserve(m_compressed_oneway_geometries.size());
m_compressed_geometry_rev_weights.reserve(m_compressed_oneway_geometries.size());
m_compressed_geometry_fwd_durations.reserve(m_compressed_oneway_geometries.size());
m_compressed_geometry_rev_durations.reserve(m_compressed_oneway_geometries.size());
}
unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID r_edge_id)
@@ -264,6 +278,8 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
m_compressed_geometry_nodes.emplace_back(first_node.node_id);
m_compressed_geometry_fwd_weights.emplace_back(INVALID_EDGE_WEIGHT);
m_compressed_geometry_rev_weights.emplace_back(first_node.weight);
m_compressed_geometry_fwd_durations.emplace_back(INVALID_EDGE_WEIGHT);
m_compressed_geometry_rev_durations.emplace_back(first_node.duration);
for (std::size_t i = 0; i < forward_bucket.size() - 1; ++i)
{
@@ -275,6 +291,8 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
m_compressed_geometry_nodes.emplace_back(fwd_node.node_id);
m_compressed_geometry_fwd_weights.emplace_back(fwd_node.weight);
m_compressed_geometry_rev_weights.emplace_back(rev_node.weight);
m_compressed_geometry_fwd_durations.emplace_back(fwd_node.duration);
m_compressed_geometry_rev_durations.emplace_back(rev_node.duration);
}
const auto &last_node = forward_bucket.back();
@@ -282,6 +300,8 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
m_compressed_geometry_nodes.emplace_back(last_node.node_id);
m_compressed_geometry_fwd_weights.emplace_back(last_node.weight);
m_compressed_geometry_rev_weights.emplace_back(INVALID_EDGE_WEIGHT);
m_compressed_geometry_fwd_durations.emplace_back(last_node.duration);
m_compressed_geometry_rev_durations.emplace_back(INVALID_EDGE_WEIGHT);
return zipped_geometry_id;
}