summaryrefslogtreecommitdiff
path: root/navit/traffic.c
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2018-08-04 20:04:49 +0200
committermvglasow <michael -at- vonglasow.com>2018-08-04 20:52:32 +0200
commit7becb7b2fb244cce0673c33710a1c3edaa387009 (patch)
tree35105fc7f88a1e26391e46db11a12db98ea602ec /navit/traffic.c
parentac39fed761c53c199ec821da92bbd2e309f80d81 (diff)
downloadnavit-7becb7b2fb244cce0673c33710a1c3edaa387009.tar.gz
Fix:traffic:Honor turn restrictions when identifying affected segments
Signed-off-by: mvglasow <michael -at- vonglasow.com>
Diffstat (limited to 'navit/traffic.c')
-rw-r--r--navit/traffic.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/navit/traffic.c b/navit/traffic.c
index 03c73da4d..e9b8b25a4 100644
--- a/navit/traffic.c
+++ b/navit/traffic.c
@@ -1315,6 +1315,12 @@ static int traffic_point_match_attributes(struct traffic_point * this_, struct i
static int traffic_route_get_seg_cost(struct route_graph_segment *over, int dir) {
if (over->data.flags & (dir >= 0 ? AF_ONEWAYREV : AF_ONEWAY))
return INT_MAX;
+ if (dir > 0 && (over->start->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if (dir < 0 && (over->end->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if ((over->data.item.type < route_item_first) || (over->data.item.type > route_item_last))
+ return INT_MAX;
return over->data.len * (100 - over->data.score) * (PENALTY_OFFROAD - 1) / 100 + over->data.len;
}
@@ -1502,8 +1508,9 @@ static void traffic_location_populate_route_graph(struct traffic_location * this
continue;
}
while ((item = map_rect_get_item(rg->mr))) {
- /* TODO we might need turn restrictions as well */
- if ((item->type < route_item_first) || (item->type > route_item_last))
+ if (item->type == type_street_turn_restriction_no || item->type == type_street_turn_restriction_only)
+ route_graph_add_turn_restriction(rg, item);
+ else if ((item->type < route_item_first) || (item->type > route_item_last))
continue;
if (item_get_default_flags(item->type)) {
@@ -1583,7 +1590,7 @@ static void traffic_location_populate_route_graph(struct traffic_location * this
map_rect_destroy(rg->mr);
rg->mr = NULL;
}
- route_graph_build_done(rg, 1);
+ route_graph_build_done(rg, 0);
}
/**
@@ -1774,8 +1781,14 @@ static struct route_graph_point * traffic_route_flood_graph(struct route_graph *
p = rg->hash[i];
while (p) {
if (!g_list_find(existing, p)) {
- p->value = PENALTY_OFFROAD * transform_distance(projection_mg, &p->c, c_dst);
- p->el = fh_insertkey(heap, p->value, p);
+ if (!(p->flags & RP_TURN_RESTRICTION)) {
+ p->value = PENALTY_OFFROAD * transform_distance(projection_mg, &p->c, c_dst);
+ p->el = fh_insertkey(heap, p->value, p);
+ } else {
+ /* ignore points which are part of turn restrictions */
+ p->value = INT_MAX;
+ p->el = NULL;
+ }
p->seg = NULL;
}
p = p->hash_next;
@@ -1907,6 +1920,8 @@ static struct route_graph_segment * traffic_route_append(struct route_graph *rg,
continue;
if (s_cmp->data.flags & AF_ONEWAYREV)
continue;
+ if (s_cmp->end->flags & RP_TURN_RESTRICTION)
+ continue;
if ((s_cmp->data.item.id_hi == s->data.item.id_hi)
&& (s_cmp->data.item.id_lo == s->data.item.id_lo)) {
s_next = s_cmp;
@@ -1925,6 +1940,8 @@ static struct route_graph_segment * traffic_route_append(struct route_graph *rg,
continue;
if (s_cmp->data.flags & AF_ONEWAY)
continue;
+ if (s_cmp->end->flags & RP_TURN_RESTRICTION)
+ continue;
if ((s_cmp->data.item.id_hi == s->data.item.id_hi)
&& (s_cmp->data.item.id_lo == s->data.item.id_lo)) {
s_next = s_cmp;
@@ -2155,6 +2172,10 @@ static GList * traffic_location_get_matching_points(struct traffic_location * th
if (!(p = route_graph_get_point(rg, &c)))
continue;
+ /* exclude points where turn restrictions apply */
+ if (p->flags & RP_TURN_RESTRICTION)
+ continue;
+
/* exclude items with a zero score */
if (!(score = traffic_point_match_attributes(trpoint, item)))
continue;