More bugfixes
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Dec 2007 14:10:16 +0000 (14:10 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 21 Dec 2007 14:10:16 +0000 (14:10 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@660 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/graphics.c
navit/src/map.h
navit/src/navit.c
navit/src/transform.c

index cd3f8e0..82cb1fe 100644 (file)
@@ -481,14 +481,25 @@ do_draw_map(struct displaylist *displaylist, struct transformation *t, struct ma
                        dbg(1,"poly from map has only %d points\n", count);
                        continue;
                }
-               count=transform(t, pro, ca, pnt, count, 
-                       item->type < type_line ? 1 : (item->type < type_area ? 5 : 7));
-               if (!count) {
-                       dbg(1,"not visible\n");
-                       continue;
+               if (item->type < type_line) {
+                       if (! map_selection_contains_point(sel, &ca[0])) {
+                               dbg(1,"point not visible\n");
+                               continue;
+                       }
+               } else if (item->type < type_area) {
+                       if (! map_selection_contains_polyline(sel, ca, count)) {
+                               dbg(1,"polyline not visible\n");
+                               continue;
+                       }
+               } else {
+                       if (! map_selection_contains_polygon(sel, ca, count)) {
+                               dbg(1,"polygon not visible\n");
+                               continue;
+                       }
                }
                if (count == max) 
                        dbg(0,"point count overflow\n", count);
+               count=transform(t, pro, ca, pnt, count, 1);
                if (item->type >= type_line && count < 2) {
                        dbg(1,"poly from transform has only %d points\n", count);
                        continue;
index 891d602..9392a20 100644 (file)
@@ -44,7 +44,7 @@ map_selection_contains_point(struct map_selection *sel, struct coord *c)
         while (curr) {
                 struct coord_rect *r=&curr->u.c_rect;
                 if (c->x >= r->lu.x && c->x <= r->rl.x &&
-                    c->y >= r->lu.y && c->y <= r->rl.y)
+                    c->y <= r->lu.y && c->y >= r->rl.y)
                         return 1;
                 curr=curr->next;
         }
index b810fb8..d6bea51 100644 (file)
@@ -1143,6 +1143,9 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
        enum projection pro;
        int border=16;
 
+       if (! this_->ready)
+               return;
+
        if (! vehicle_position_attr_get(nv->vehicle, attr_position_direction, &attr_dir) ||
            ! vehicle_position_attr_get(nv->vehicle, attr_position_speed, &attr_speed) ||
            ! vehicle_position_attr_get(nv->vehicle, attr_position_coord_geo, &attr_pos))
@@ -1170,8 +1173,8 @@ navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv)
                }
        }
 
-       if ((!transform(this_->trans, pro, &nv->coord, &cursor_pnt, 1, 1) ||
-            !transform_within_border(this_->trans, &cursor_pnt, border))) {
+       transform(this_->trans, pro, &nv->coord, &cursor_pnt, 1, 0);
+       if (!transform_within_border(this_->trans, &cursor_pnt, border)) {
                if (!this_->cursor_flag)
                        return;
                if (nv->follow_curr != 1) {
index d4dab91..382d7ac 100644 (file)
@@ -70,7 +70,7 @@ transform_from_geo(enum projection pro, struct coord_geo *g, struct coord *c)
 }
 
 int
-transform(struct transformation *t, enum projection pro, struct coord *c, struct point *p, int count, int flags)
+transform(struct transformation *t, enum projection pro, struct coord *c, struct point *p, int count, int unique)
 {
        struct coord c1;
        int xcn, ycn; 
@@ -81,20 +81,6 @@ transform(struct transformation *t, enum projection pro, struct coord *c, struct
         double xc,yc;
 #endif
        int i,j = 0;
-       if (flags & 1) {
-               if (count == 1) {
-                       if (!map_selection_contains_point(t->map_sel, &c[0]))
-                               return 0;
-               } else {
-                       if (flags & 2) {
-                               if (!map_selection_contains_polygon(t->map_sel, c, count))
-                                       return 0;
-                       } else {
-                               if (!map_selection_contains_polyline(t->map_sel, c, count))
-                                       return 0;
-                       }
-               }
-       }
        for (i=0; i < count; i++) {
                if (pro == t->pro) {
                        xc=c[i].x;
@@ -140,7 +126,7 @@ transform(struct transformation *t, enum projection pro, struct coord *c, struct
                        yc=-0x8000;
                if (yc > 0x7fff)
                        yc=0x7fff;
-               if (j == 0 || !(flags & 4) || p[j-1].x != xc || p[j-1].y != yc) {
+               if (j == 0 || !unique || p[j-1].x != xc || p[j-1].y != yc) {
                        p[j].x=xc;
                        p[j].y=yc;
                        j++;
@@ -280,8 +266,8 @@ transform_set_size(struct transformation *t, int width, int height)
 void
 transform_get_size(struct transformation *t, int *width, int *height)
 {
-       struct coord_rect *r=&t->screen_sel->u.p_rect;
-       *width=r->rl.x-r->lu.y;
+       struct point_rect *r=&t->screen_sel->u.p_rect;
+       *width=r->rl.x-r->lu.x;
        *height=r->rl.y-r->lu.y;
 }