Skip to content

Commit baaf824

Browse files
committed
Fix withPoints fraction=1 logic: use prev_rfraction for reverse cost; regenerate NEWS.md with correct line endings
1 parent 1ae3de8 commit baaf824

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/withPoints/withPoints.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,23 +404,27 @@ Pg_points_graph::create_new_edges() {
404404
// Also create edge from previous target to this point
405405
// This allows Dijkstra to find the direct path through this edge
406406
double delta = point.fraction - prev_fraction;
407+
double rdelta = point.fraction - prev_rfraction;
407408
if (delta > 0) {
408409
if (edge.cost >= 0) {
409410
double cost_to_point = delta * edge.cost;
410411
Edge_t cost_edge = {edge.id, prev_target, point.vertex_id, cost_to_point, -1};
411412
m_new_edges.push_back(cost_edge);
412413
last_cost = cost_to_point;
413414
}
415+
// Update forward tracking variables
416+
prev_target = point.vertex_id;
417+
prev_fraction = point.fraction;
418+
agg_cost += last_cost;
419+
}
420+
if (rdelta > 0) {
414421
if (edge.reverse_cost >= 0) {
415-
double rcost_to_point = delta * edge.reverse_cost;
422+
double rcost_to_point = rdelta * edge.reverse_cost;
416423
Edge_t rcost_edge = {edge.id, prev_rtarget, point.vertex_id, -1, rcost_to_point};
417424
m_new_edges.push_back(rcost_edge);
418425
last_rcost = rcost_to_point;
419426
}
420-
// Update tracking variables
421-
prev_target = point.vertex_id;
422-
prev_fraction = point.fraction;
423-
agg_cost += last_cost;
427+
// Update reverse tracking variables
424428
prev_rtarget = point.vertex_id;
425429
prev_rfraction = point.fraction;
426430
agg_rcost += last_rcost;

0 commit comments

Comments
 (0)