Fix:Core:Reworked routing code a bit
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 22 Aug 2008 19:21:49 +0000 (19:21 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 22 Aug 2008 19:21:49 +0000 (19:21 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1302 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/navigation.c
navit/navit/transform.c
navit/navit/transform.h

index 01964a5..cff831e 100644 (file)
@@ -684,27 +684,33 @@ navigation_update(struct navigation *this_, struct route *route)
        dbg(1,"enter\n");
        ritem=map_rect_get_item(mr);
        if (ritem) {
-               if (item_attr_get(ritem, attr_street_item, &street_item)) {
-                       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);
-                       navigation_destroy_itms_cmds(this_, itm);
-                       if (itm) {
-                               incr=1;
-                               navigation_itm_update(itm, ritem);
-                       } else {
-                               dbg(1,"not on track\n");
-                               do {
-                                       dbg(1,"item\n");
-                                       navigation_itm_new(this_, ritem);
-                                       ritem=map_rect_get_item(mr);
-                               } while (ritem);
-                               itm=navigation_itm_new(this_, NULL);
-                               make_maneuvers(this_);
+               if (!item_attr_get(ritem, attr_street_item, &street_item)) {
+                       ritem=map_rect_get_item(mr);
+                       if (! ritem) {
+                               return;
                        }
-               } else
-                       dbg(0,"no street_item\n");
+                       if (!item_attr_get(ritem, attr_street_item, &street_item)) {
+                               dbg(0,"no street item\n");
+                       }       
+               }
+               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);
+               navigation_destroy_itms_cmds(this_, itm);
+               if (itm) {
+                       incr=1;
+                       navigation_itm_update(itm, ritem);
+               } else {
+                       dbg(1,"not on track\n");
+                       do {
+                               dbg(1,"item\n");
+                               navigation_itm_new(this_, ritem);
+                               ritem=map_rect_get_item(mr);
+                       } while (ritem);
+                       itm=navigation_itm_new(this_, NULL);
+                       make_maneuvers(this_);
+               }
                calculate_dest_distance(this_, incr);
                dbg(2,"destination distance old=%d new=%d\n", this_->distance_last, this_->first->dest_length);
                if (this_->first->dest_length > this_->distance_last && this_->distance_last >= 0) 
index 5aed2dd..fea9d30 100644 (file)
@@ -560,6 +560,17 @@ transform_distance(enum projection pro, struct coord *c1, struct coord *c2)
        }
 }
 
+double
+transform_polyline_length(enum projection pro, struct coord *c, int count)
+{
+       double ret=0;
+       int i;
+
+       for (i = 0 ; i < count-1 ; i++) 
+               ret+=transform_distance(pro, &c[i], &c[i+1]);
+       return ret;
+}
+
 int
 transform_distance_sq(struct coord *c1, struct coord *c2)
 {
index d305ea7..e770df3 100644 (file)
@@ -59,6 +59,7 @@ int transform_get_order(struct transformation *t);
 void transform_geo_text(struct coord_geo *g, char *buffer);
 double transform_scale(int y);
 double transform_distance(enum projection pro, struct coord *c1, struct coord *c2);
+double transform_polyline_length(enum projection pro, struct coord *c, int count);
 int transform_distance_sq(struct coord *c1, struct coord *c2);
 int transform_distance_line_sq(struct coord *l0, struct coord *l1, struct coord *ref, struct coord *lpnt);
 int transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, struct coord *lpnt, int *pos);