Fix:core:Modified sunrise/set calculation coefficients
[navit-package] / navit / navit.c
index ca43024..c35df53 100644 (file)
@@ -351,6 +351,7 @@ navit_handle_button(struct navit *this_, int pressed, int button, struct point *
 {
        int border=16;
 
+       dbg(1,"enter %d %d (ignore %d)\n",pressed,button,this_->ignore_button);
        callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p);
        if (this_->ignore_button) {
                this_->ignore_button=0;
@@ -417,6 +418,7 @@ static void
 navit_button(void *data, int pressed, int button, struct point *p)
 {
        struct navit *this=data;
+       dbg(1,"enter %d %d ignore %d\n",pressed,button,this->ignore_graphics_events);
        if (!this->ignore_graphics_events) {
                if (! this->popup_callback)
                        this->popup_callback=callback_new_1(callback_cast(navit_popup), this);
@@ -478,6 +480,7 @@ navit_handle_motion(struct navit *this_, struct point *p)
                dx=(p->x-this_->pressed.x);
                dy=(p->y-this_->pressed.y);
                if (dx < -8 || dx > 8 || dy < -8 || dy > 8) {
+                       this_->moved=1;
                        if (this_->button_timeout) {
                                event_remove_timeout(this_->button_timeout);
                                this_->button_timeout=NULL;
@@ -1856,6 +1859,11 @@ navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, stru
        case attr_displaylist:
                attr->u.displaylist=this_->displaylist;
                return (attr->u.displaylist != NULL);
+       case attr_follow:
+               if (!this_->vehicle)
+                       return 0;
+               attr->u.num=this_->vehicle->follow_curr;
+               break;
        case attr_former_destination_map:
                attr->u.map=this_->former_destination;
                break;
@@ -2319,6 +2327,8 @@ navit_layout_switch(struct navit *n)
     if (navit_get_attr(n,attr_layout,&layout_attr,NULL)!=1) {
        return; //No layout - nothing to switch
     }
+    if (!n->vehicle)
+       return;
     l=layout_attr.u.layout;
     
     if (l->dayname || l->nightname) {
@@ -2327,6 +2337,7 @@ navit_layout_switch(struct navit *n)
        //Check that we aren't calculating too fast
        if (vehicle_get_attr(n->vehicle->vehicle, attr_position_time_iso8601,&iso8601_attr,NULL)==1) {
                currTs=iso8601_to_secs(iso8601_attr.u.str);
+               dbg(1,"currTs: %u:%u\n",currTs%86400/3600,((currTs%86400)%3600)/60);
        }
        if (currTs-(n->prevTs)<60) {
            //We've have to wait a little
@@ -2342,7 +2353,7 @@ navit_layout_switch(struct navit *n)
                return; //No valid fix yet
        }
        
-       //We calculate sunrise anyway, cause it is need both for day and for night
+       //We calculate sunrise anyway, cause it is needed both for day and for night
         if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,35,1,&trise,&tset)!=0) {
                //near the pole sun never rises/sets, so we should never switch profiles
                n->prevTs=currTs;
@@ -2350,7 +2361,7 @@ navit_layout_switch(struct navit *n)
            }
        
         trise_actual=trise;
-       
+       dbg(1,"trise: %u:%u\n",HOURS(trise),MINUTES(trise));
        if (l->dayname) {
        
            if ((HOURS(trise)*60+MINUTES(trise)==(currTs%86400)/60) || 
@@ -2362,12 +2373,12 @@ navit_layout_switch(struct navit *n)
            }
        }
        if (l->nightname) {
-           if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,-12,0,&trise,&tset)!=0) {
+           if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,-24,0,&trise,&tset)!=0) {
                //near the pole sun never rises/sets, so we should never switch profiles
                n->prevTs=currTs;
                return;
            }
-           
+           dbg(1,"tset: %u:%u\n",HOURS(tset),MINUTES(tset));
            if (HOURS(tset)*60+MINUTES(tset)==((currTs%86400)/60)
                || (n->prevTs==0 && (((HOURS(tset)*60+MINUTES(tset)<(currTs%86400)/60)) || 
                        ((HOURS(trise_actual)*60+MINUTES(trise_actual)>(currTs%86400)/60))))) {