Fix:Core:Added a direction attribute to make navigation recognize the change of route...
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 29 Sep 2008 18:30:59 +0000 (18:30 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 29 Sep 2008 18:30:59 +0000 (18:30 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1422 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/attr_def.h
navit/navigation.c
navit/route.c

index 2b4dcf5..887a0ae 100644 (file)
@@ -83,6 +83,7 @@ ATTR(postdraw)
 ATTR(button)
 ATTR(ondemand)
 ATTR(menu_on_map_click)
+ATTR(direction)
 ATTR2(0x0002ffff,type_int_end)
 ATTR2(0x00030000,type_string_begin)
 ATTR(type)
index 649675d..093e733 100644 (file)
@@ -131,6 +131,7 @@ struct navigation_itm {
        char *name1;
        char *name2;
        struct item item;
+       int direction;
        int angle_start;
        int angle_end;
        struct coord c;
@@ -268,7 +269,7 @@ navigation_itm_new(struct navigation *this_, struct item *ritem)
        struct navigation_itm *ret=g_new0(struct navigation_itm, 1);
        int l,i=0;
        struct item *sitem;
-       struct attr street_item;
+       struct attr street_item,direction;
        struct map_rect *mr;
        struct attr attr;
        struct coord c[5];
@@ -279,6 +280,10 @@ navigation_itm_new(struct navigation *this_, struct item *ritem)
                        dbg(0,"no street item\n");
                        return NULL;
                }
+               if (item_attr_get(ritem, attr_direction, &direction))
+                       ret->direction=direction.u.num;
+               else
+                       ret->direction=0;
                sitem=street_item.u.item;
                ret->item=*sitem;
                item_hash_insert(this_->hash, sitem, ret);
@@ -694,7 +699,7 @@ navigation_update(struct navigation *this_, struct route *route)
        struct map *map;
        struct map_rect *mr;
        struct item *ritem,*sitem;
-       struct attr street_item;
+       struct attr street_item,street_direction;
        struct navigation_itm *itm;
        int incr=0;
 
@@ -718,10 +723,16 @@ navigation_update(struct navigation *this_, struct route *route)
                                dbg(0,"no street item\n");
                        }       
                }
+               if (!item_attr_get(ritem, attr_direction, &street_direction))
+                       street_direction.u.num=0;
                sitem=street_item.u.item;
                dbg(1,"sitem=%p\n", sitem);
                itm=item_hash_lookup(this_->hash, sitem);
                dbg(2,"itm for item with id (0x%x,0x%x) is %p\n", sitem->id_hi, sitem->id_lo, itm);
+               if (itm && itm->direction != street_direction.u.num) {
+                       dbg(2,"wrong direction\n");
+                       itm=NULL;
+               }
                navigation_destroy_itms_cmds(this_, itm);
                if (itm) {
                        incr=1;
index 9087cf6..a55804a 100644 (file)
@@ -78,6 +78,7 @@ struct route_path_segment {
        struct item item;
        int length;
        int offset;
+       int direction;
        unsigned ncoords;
        struct coord c[0];
 };
@@ -582,6 +583,7 @@ route_path_add_item(struct route_path *this, struct item *item, int len, struct
        
        segment=g_malloc0(sizeof(*segment) + sizeof(struct coord) * ccount);
        segment->ncoords=ccount;
+       segment->direction=dir;
        if (first)
                segment->c[idx++]=*first;
        if (dir > 0) {
@@ -623,6 +625,7 @@ route_path_add_item_from_graph(struct route_path *this, struct route_path *oldpa
                printf("%s:Out of memory\n", __FUNCTION__);
                return;
        }
+       segment->direction=dir;
        if (dir > 0) {
                for (i = 0 ; i < ccnt ; i++)
                        segment->c[i]=ca[i];
@@ -1229,12 +1232,19 @@ rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
                        }
                        return 0;
                case attr_street_item:
-                       mr->attr_next=attr_length;
+                       mr->attr_next=attr_direction;
                        if (seg && seg->item.map)
                                attr->u.item=&seg->item;
                        else
                                return 0;
                        return 1;
+               case attr_direction:
+                       mr->attr_next=attr_length;
+                       if (seg) 
+                               attr->u.num=seg->direction;
+                       else
+                               return 0;
+                       return 1;
                case attr_length:
                        if (seg)
                                attr->u.num=seg->length;