Minor bugfixes
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 28 Oct 2007 11:00:55 +0000 (11:00 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 28 Oct 2007 11:00:55 +0000 (11:00 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@481 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/attr.c
navit/src/attr.h
navit/src/attr_def.h
navit/src/coord.c
navit/src/navigation.c
navit/src/route.c
navit/src/transform.c

index 676244c..bf579cf 100644 (file)
@@ -12,7 +12,7 @@ struct attr_name {
 
 
 static struct attr_name attr_names[]={
-#define ATTR2(x,y) ATTR(x)
+#define ATTR2(x,y) ATTR(y)
 #define ATTR(x) { attr_##x, #x },
 #include "attr_def.h"
 #undef ATTR2
index c0703b2..4c39a07 100644 (file)
@@ -10,7 +10,7 @@ extern "C" {
 enum item_type;
 
 enum attr_type {
-#define ATTR2(x,y) attr_##x=y,
+#define ATTR2(x,y) attr_##y=x,
 #define ATTR(x) attr_##x,
 #include "attr_def.h"
 #undef ATTR2
index 6b1f5ab..beb90ea 100644 (file)
@@ -1,19 +1,19 @@
 /* prototypes */
 
 /* common */
-ATTR2(none,0x00000000)
+ATTR2(0x00000000,none)
 ATTR(any)
 
-ATTR2(type_item_begin,0x00010000)
+ATTR2(0x00010000,type_item_begin)
 ATTR(town_streets_item)
 ATTR(street_name_item)
 ATTR(street_name_numbers_item)
 ATTR(street_item)
 ATTR(street_number_item)
 ATTR(item_type)
-ATTR2(type_item_end,0x0001ffff)
+ATTR2(0x0001ffff,type_item_end)
 
-ATTR2(type_int_begin,0x00020000)
+ATTR2(0x00020000,type_int_begin)
 ATTR(h)
 ATTR(id)
 ATTR(limit)
@@ -24,9 +24,9 @@ ATTR(flush_size)
 ATTR(flush_time)
 /* boolean */
 ATTR(overwrite)
-ATTR2(type_int_end,0x0002ffff)
+ATTR2(0x0002ffff,type_int_end)
 
-ATTR2(type_string_begin,0x00030000)
+ATTR2(0x00030000,type_string_begin)
 ATTR(type)
 ATTR(label)
 ATTR(data)
@@ -58,4 +58,4 @@ ATTR(navigation_short)
 ATTR(navigation_long)
 ATTR(navigation_long_exact)
 ATTR(navigation_speech)
-ATTR2(type_string_end,0x0003ffff)
+ATTR2(0x0003ffff,type_string_end)
index 7c1c645..37d8167 100644 (file)
@@ -172,12 +172,14 @@ coord_parse(const char *c_str, enum projection pro, struct coord *c_ret)
                        g.lng=floor(lng/100);
                        lng-=g.lng*100;
                        g.lng+=lng/60;
+                       if (ns == 's' || ns == 'S')
+                               g.lat=-g.lat;
+                       if (ew == 'w' || ew == 'W')
+                               g.lng=-g.lng;
                        transform_from_geo(pro, &g, c_ret);
                }
-               if (debug) {
-                       printf("str='%s' x=%f ns=%c y=%f ew=%c c=%d\n", str, lng, ns, lat, ew, ret);
-                       printf("rest='%s'\n", str+ret);
-               }
+               dbg(3,"str='%s' x=%f ns=%c y=%f ew=%c c=%d\n", str, lng, ns, lat, ew, ret);
+               dbg(3,"rest='%s'\n", str+ret);
        } else {
                double lng, lat;
                args=sscanf(str, "%lf %lf%n", &lng, &lat, &ret);
index 89fceb8..8c7d356 100644 (file)
@@ -629,10 +629,13 @@ navigation_update(struct navigation *this_, struct route *route)
        if (!incr) {
                printf("not on track\n");
                rph=route_path_open(route);
-               while((s=route_path_get_segment(rph))) {
-                       itm=navigation_itm_new(this_, route_path_segment_get_item(s),route_path_segment_get_start(s));
-                       itm->time=route_path_segment_get_time(s);
-                       itm->length=route_path_segment_get_length(s);
+               if (rph) {
+                       while((s=route_path_get_segment(rph))) {
+                               itm=navigation_itm_new(this_, route_path_segment_get_item(s),route_path_segment_get_start(s));
+                               itm->time=route_path_segment_get_time(s);
+                               itm->length=route_path_segment_get_length(s);
+                       }
+                       route_path_close(rph);
                }
                if (end_flag) {
                        len=route_info_length(NULL, dst, 0);
@@ -643,7 +646,6 @@ navigation_update(struct navigation *this_, struct route *route)
                        itm->time=route_time(speedlist, &sd->item, len);
                }
                itm=navigation_itm_new(this_, NULL, NULL);
-               route_path_close(rph);
                make_maneuvers(this_);
        }
        calculate_dest_distance(this_, incr);
index db9d848..356f98f 100644 (file)
@@ -443,7 +443,12 @@ struct route_path_handle {
 struct route_path_handle *
 route_path_open(struct route *this)
 {
-       struct route_path_handle *ret=g_new(struct route_path_handle, 1);
+       struct route_path_handle *ret;
+
+       if (! this->path2 || ! this->path2->path) 
+               return NULL;
+
+       ret=g_new(struct route_path_handle, 1);
 
        ret->s=this->path2->path;       
        return ret;
index abebb69..eb1384e 100644 (file)
@@ -466,7 +466,7 @@ transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, st
        int i,dist,distn;
        struct coord lp;
        if (count < 2)
-               return 0;
+               return INT_MAX;
        if (pos)
                *pos=0;
        dist=transform_distance_line_sq(&c[0], &c[1], ref, lpnt);