Skip to content

Commit

Permalink
make it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Apr 6, 2018
1 parent 808066c commit ada526e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
12 changes: 2 additions & 10 deletions include/engine/geospatial_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
forward_duration_range.begin() + data.fwd_segment_position,
EdgeDuration{0});

// const auto forward_geometries_offset =
// std::accumulate(forward_geometry_range.begin(),
// forward_geometry_range.begin() + data.fwd_segment_position,
// EdgeDistance{0});

EdgeDistance forward_distance_offset = 0;
for (auto current = forward_geometry_range.begin() + 1;
current != forward_geometry_range.begin() + data.fwd_segment_position + 1;
Expand Down Expand Up @@ -496,11 +491,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_duration_range.end() - data.fwd_segment_position - 1,
EdgeDuration{0});

// const auto reverse_geometries_offset =
// std::accumulate(reverse_geometry_range.begin(),
// reverse_geometry_range.begin() + data.fwd_segment_position,
// EdgeDistance{0});

EdgeDistance reverse_distance_offset = 0;
for (auto current = reverse_geometry_range.begin() + 1;
current != reverse_geometry_range.begin() + data.fwd_segment_position + 1;
Expand All @@ -526,11 +516,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
forward_weight = static_cast<EdgeWeight>(forward_weight * ratio);
forward_duration = static_cast<EdgeDuration>(forward_duration * ratio);
forward_distance = static_cast<EdgeDistance>(forward_distance * ratio);
}
if (data.reverse_segment_id.id != SPECIAL_SEGMENTID)
{
reverse_weight -= static_cast<EdgeWeight>(reverse_weight * ratio);
reverse_duration -= static_cast<EdgeDuration>(reverse_duration * ratio);
reverse_distance -= static_cast<EdgeDistance>(reverse_distance * ratio);
}

// check phantom node segments validity
Expand Down
38 changes: 37 additions & 1 deletion src/engine/routing_algorithms/many_to_many_ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
std::vector<NodeID> packed_leg;

engine_working_data.InitializeOrClearUnpackingCacheThreadLocalStorage(
facade.GetTimestamp()); // always pass in the timestamp and clear if it's different
facade.GetTimestamp());

// Populate buckets with paths from all accessible nodes to destinations via backward searches
for (std::uint32_t column_idx = 0; column_idx < target_indices.size(); ++column_idx)
Expand Down Expand Up @@ -353,6 +353,29 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
EdgeDuration offset = target_phantom.GetReverseDuration();
durations_table[row_idx * number_of_targets + column_idx] += offset;
}

// check the direction of travel to figure out how to calculate the offset to/from
// the source/target
if (source_phantom.forward_segment_id.id == packed_leg.front())
{ // direction of travel is forward
EdgeDistance offset = source_phantom.GetForwardDistance();
disctance_table[row_idx * number_of_targets + column_idx] -= offset;
}
if (source_phantom.reverse_segment_id.id == packed_leg.front())
{
EdgeDistance offset = source_phantom.GetReverseDistance();
disctance_table[row_idx * number_of_targets + column_idx] -= offset;
}
if (target_phantom.forward_segment_id.id == packed_leg.back())
{ // direction of travel is forward
EdgeDistance offset = target_phantom.GetForwardDistance();
disctance_table[row_idx * number_of_targets + column_idx] += offset;
}
if (target_phantom.reverse_segment_id.id == packed_leg.back())
{
EdgeDistance offset = target_phantom.GetReverseDistance();
disctance_table[row_idx * number_of_targets + column_idx] += offset;
}
}
else
{
Expand All @@ -368,6 +391,19 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
target_phantom.GetReverseDuration() - source_phantom.GetReverseDuration();
durations_table[row_idx * number_of_targets + column_idx] += offset;
}

if (target_phantom.GetForwardDistance() > source_phantom.GetForwardDistance())
{
EdgeDuration offset =
target_phantom.GetForwardDistance() - source_phantom.GetForwardDistance();
distance_table[row_idx * number_of_targets + column_idx] += offset;
}
else
{
EdgeDuration offset =
target_phantom.GetReverseDistance() - source_phantom.GetReverseDistance();
distance_table[row_idx * number_of_targets + column_idx] += offset;
}
}
packed_leg.clear();
}
Expand Down

0 comments on commit ada526e

Please sign in to comment.