summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-09-06 08:23:08 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-09-06 08:23:08 +0000
commitfb3fa2179643c8ad35578373ddd0f1ef890371fb (patch)
treeca32eb4d51ffe28b28658fca6a68dfab575f3160
parent4a28aae57141508ca199b4436224b3c46dff5a8a (diff)
downloadnavit-fb3fa2179643c8ad35578373ddd0f1ef890371fb.tar.gz
Add:Core:Allow to set turn around penalty for route in difficult routing situations
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5631 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--navit/attr_def.h1
-rw-r--r--navit/route.c16
-rw-r--r--navit/vehicleprofile.c3
-rw-r--r--navit/vehicleprofile.h1
4 files changed, 19 insertions, 2 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index 5d6d37a3b..6cc86aad9 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -184,6 +184,7 @@ ATTR(battery_resistance) /* mOhm */
ATTR(battery_temperature) /* mK */
ATTR(turn_around_count)
ATTR(turn_around_penalty)
+ATTR(turn_around_penalty2)
ATTR2(0x00027500,type_rel_abs_begin)
/* These attributes are int that can either hold relative *
* or absolute values. A relative value is indicated by *
diff --git a/navit/route.c b/navit/route.c
index 94306454e..f3e73aca4 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -2307,7 +2307,13 @@ route_graph_flood(struct route_graph *this, struct route_info *dst, struct vehic
s=p_min->start;
while (s) { /* Iterating all the segments leading away from our point to update the points at their ends */
val=route_value_seg(profile, p_min, s, -1);
- if (val != INT_MAX && !item_is_equal(s->data.item,p_min->seg->data.item)) {
+ if (val != INT_MAX && item_is_equal(s->data.item,p_min->seg->data.item)) {
+ if (profile->turn_around_penalty2)
+ val+=profile->turn_around_penalty2;
+ else
+ val=INT_MAX;
+ }
+ if (val != INT_MAX) {
new=min+val;
if (debug_route)
printf("begin %d len %d vs %d (0x%x,0x%x)\n",new,val,s->end->value, s->end->c.x, s->end->c.y);
@@ -2335,7 +2341,13 @@ route_graph_flood(struct route_graph *this, struct route_info *dst, struct vehic
s=p_min->end;
while (s) { /* Doing the same as above with the segments leading towards our point */
val=route_value_seg(profile, p_min, s, 1);
- if (val != INT_MAX && !item_is_equal(s->data.item,p_min->seg->data.item)) {
+ if (val != INT_MAX && item_is_equal(s->data.item,p_min->seg->data.item)) {
+ if (profile->turn_around_penalty2)
+ val+=profile->turn_around_penalty2;
+ else
+ val=INT_MAX;
+ }
+ if (val != INT_MAX) {
new=min+val;
if (debug_route)
printf("end %d len %d vs %d (0x%x,0x%x)\n",new,val,s->start->value,s->start->c.x, s->start->c.y);
diff --git a/navit/vehicleprofile.c b/navit/vehicleprofile.c
index 905044fca..e1ad9c638 100644
--- a/navit/vehicleprofile.c
+++ b/navit/vehicleprofile.c
@@ -88,6 +88,9 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
case attr_turn_around_penalty:
this_->turn_around_penalty=attr->u.num;
break;
+ case attr_turn_around_penalty2:
+ this_->turn_around_penalty2=attr->u.num;
+ break;
default:
break;
}
diff --git a/navit/vehicleprofile.h b/navit/vehicleprofile.h
index 88edad41f..67d3f4fa1 100644
--- a/navit/vehicleprofile.h
+++ b/navit/vehicleprofile.h
@@ -42,6 +42,7 @@ struct vehicleprofile {
GHashTable *roadprofile_hash;
struct attr active_callback;
int turn_around_penalty; /**< Penalty when turning around */
+ int turn_around_penalty2; /**< Penalty when turning around, for planned turn arounds */
};
struct vehicleprofile * vehicleprofile_new(struct attr *parent, struct attr **attrs);