Add:Core:Support for through traffic limit
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 1 Jul 2010 15:09:55 +0000 (15:09 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 1 Jul 2010 15:09:55 +0000 (15:09 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3465 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/attr_def.h
navit/navit/route.c
navit/navit/vehicleprofile.c
navit/navit/vehicleprofile.h

index e4ff8b3..6e4ce9a 100644 (file)
@@ -152,6 +152,7 @@ ATTR(shmoffset)
 ATTR(speed_category)
 ATTR(static_speed)
 ATTR(static_distance)
+ATTR(through_traffic_penalty)
 ATTR2(0x00027500,type_rel_abs_begin)
 /* These attributes are int that can either hold relative              *
  * or absolute values. A relative value is indicated by                *
index ee147e6..263a2d2 100644 (file)
@@ -1614,6 +1614,8 @@ route_value_seg(struct vehicleprofile *profile, struct route_graph_point *from,
                return INT_MAX;
        if (from && from->seg == over)
                return INT_MAX;
+       if (over->data.flags & AF_THROUGH_TRAFFIC_LIMIT)
+               return profile->through_traffic_penalty;
        if ((over->start->flags & RP_TRAFFIC_DISTORTION) && (over->end->flags & RP_TRAFFIC_DISTORTION)) {
                struct route_traffic_distortion dist;
                if (route_get_traffic_distortion(over, &dist))
@@ -1882,7 +1884,7 @@ 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) {
+                       if (val != INT_MAX && !item_is_equal(s->data.item,p_min->seg->data.item)) {
                                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);
@@ -1910,7 +1912,7 @@ 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) {
+                       if (val != INT_MAX && !item_is_equal(s->data.item,p_min->seg->data.item)) {
                                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);
@@ -2144,6 +2146,8 @@ is_turn_allowed(struct route_graph_point *p, struct route_graph_segment *from, s
 {
        struct route_graph_point *prev,*next;
        struct route_graph_segment *tmp1,*tmp2;
+       if (item_is_equal(from->data.item, to->data.item))
+               return 0;
        if (from->start == p)
                prev=from->end;
        else
index c80a5de..3a6db48 100644 (file)
@@ -72,6 +72,9 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
        case attr_static_distance:
                this_->static_distance=attr->u.num;
                break;
+       case attr_through_traffic_penalty:
+               this_->through_traffic_penalty=attr->u.num;
+               break;
        default:
                break;
        }
@@ -93,6 +96,7 @@ vehicleprofile_new(struct attr *parent, struct attr **attrs)
        this_->height=-1;
        this_->weight=-1;
        this_->axle_weight=-1;
+       this_->through_traffic_penalty=9000;
        for (attr=attrs;*attr; attr++)
                vehicleprofile_set_attr_do(this_, *attr);
        return this_;
index d8eb4ca..41bd268 100644 (file)
@@ -36,6 +36,7 @@ struct vehicleprofile {
        int weight;                             /**< Weight of the vehicle in kg */
        int axle_weight;                        /**< Axle Weight of the vehicle in kg */
        int dangerous_goods;                    /**< Flags of dangerous goods present */
+       int through_traffic_penalty;            /**< Penalty when driving on a through traffic limited road */
        struct attr **attrs;
        GHashTable *roadprofile_hash;
 };