Skip to content

Commit

Permalink
use offset functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Apr 6, 2018
1 parent ada526e commit fec6b08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/engine/geospatial_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_duration_range[reverse_duration_range.size() - data.fwd_segment_position - 1];
EdgeDistance reverse_distance = util::coordinate_calculation::haversineDistance(
datafacade.GetCoordinateOfNode(reverse_geometry_range[reverse_geometry_range.size() -
data.fwd_segment_position - 1]),
data.fwd_segment_position - 1]),
point_on_segment);

ratio = std::min(1.0, std::max(0.0, ratio));
Expand Down
14 changes: 7 additions & 7 deletions include/engine/phantom_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ struct PhantomNode
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
forward_distance(MAXIMAL_EDGE_DISTANCE), reverse_distance(MAXIMAL_EDGE_DISTANCE),
forward_distance_offset(0), reverse_distance_offset(0),
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION), forward_duration_offset(0),
reverse_duration_offset(0), fwd_segment_position(0), is_valid_forward_source{false},
is_valid_forward_target{false}, is_valid_reverse_source{false},
is_valid_reverse_target{false}, bearing(0)
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
forward_duration_offset(0), reverse_duration_offset(0), fwd_segment_position(0),
is_valid_forward_source{false}, is_valid_forward_target{false},
is_valid_reverse_source{false}, is_valid_reverse_target{false}, bearing(0)

{
}
Expand Down Expand Up @@ -83,13 +83,13 @@ struct PhantomNode

// DO THIS FOR DISTANCE

EdgeWeight GetForwardDistance() const
EdgeDistance GetForwardDistance() const
{
BOOST_ASSERT(forward_segment_id.enabled);
return forward_distance + forward_distance_offset;
}

EdgeWeight GetReverseDistance() const
EdgeDistance GetReverseDistance() const
{
BOOST_ASSERT(reverse_segment_id.enabled);
return reverse_distance + reverse_distance_offset;
Expand Down Expand Up @@ -171,7 +171,7 @@ struct PhantomNode
reverse_distance{reverse_distance}, forward_distance_offset{forward_distance_offset},
reverse_distance_offset{reverse_distance_offset}, forward_duration{forward_duration},
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
reverse_duration_offset{reverse_duration_offset},
reverse_duration_offset{reverse_duration_offset},
component{component.id, component.is_tiny}, location{location},
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
is_valid_forward_source{is_valid_forward_source},
Expand Down
20 changes: 10 additions & 10 deletions src/engine/routing_algorithms/many_to_many_ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
std::vector<NodeBucket> search_space_with_buckets;
std::vector<NodeID> packed_leg;

engine_working_data.InitializeOrClearUnpackingCacheThreadLocalStorage(
facade.GetTimestamp());
engine_working_data.InitializeOrClearUnpackingCacheThreadLocalStorage(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 @@ -354,31 +353,31 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
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
// SAME THING BUT FOR DISTANCE
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;
distance_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;
distance_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;
distance_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;
distance_table[row_idx * number_of_targets + column_idx] += offset;
}
}
else
{
// OFFSET DURATIONS
if (target_phantom.GetForwardDuration() > source_phantom.GetForwardDuration())
{
EdgeDuration offset =
Expand All @@ -392,15 +391,16 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
durations_table[row_idx * number_of_targets + column_idx] += offset;
}

// SAME EXACT CALCULATIONS FOR DISTANCE
if (target_phantom.GetForwardDistance() > source_phantom.GetForwardDistance())
{
EdgeDuration offset =
EdgeDistance offset =
target_phantom.GetForwardDistance() - source_phantom.GetForwardDistance();
distance_table[row_idx * number_of_targets + column_idx] += offset;
}
else
{
EdgeDuration offset =
EdgeDistance offset =
target_phantom.GetReverseDistance() - source_phantom.GetReverseDistance();
distance_table[row_idx * number_of_targets + column_idx] += offset;
}
Expand Down

0 comments on commit fec6b08

Please sign in to comment.