Opened 10 years ago
Closed 10 years ago
#637 closed defect/bug (fixed)
patch for sunrise/sunset calculation
Reported by: | chr | Owned by: | number6 |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | core | Version: | git master |
Severity: | Keywords: | layout, car, car-dark, OSD | |
Cc: | nick@… |
Description
Hi,
I am not satisfied with the time, when navit switches day- and nightlayout in Germany. The nightlayout is activated to early. Yesterday Number6, samco, and pb_8 reported similar experiences in the irc chat. Having a look at the source code turns out that latidude and longitude seems to be interchanged. '__sunriset__', an elaborated function, is used in navit.c for calculating sunrise and sunset. The function is well documented in sunriset.c. I suggest the following patch:
--- navit.c.20100817a 2010-08-17 12:54:06.000000000 +0000 +++ navit.c 2010-08-17 13:53:42.000000000 +0000 @@ -2232,8 +2232,9 @@ } //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) { + if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,-5,1,&trise,&tset)!=0) { //near the pole sun never rises/sets, so we should never switch profiles + dbg(1,"trise: %u:%u, sun never visible, never switch profile\n",HOURS(trise),MINUTES(trise)); n->prevTs=currTs; return; } @@ -2251,8 +2252,9 @@ } } if (l->nightname) { - if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lat,geo_attr.u.coord_geo->lng,-24,0,&trise,&tset)!=0) { + if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,-5,1,&trise,&tset)!=0) { //near the pole sun never rises/sets, so we should never switch profiles + dbg(1,"tset: %u:%u, sun always visible, never switch profile\n",HOURS(tset),MINUTES(tset)); n->prevTs=currTs; return; }
Reagards and many thanks for this program!
Christian
Change History (11)
comment:1 Changed 10 years ago by tegzed
comment:2 Changed 10 years ago by chr
Hello David,
thank you for comitting the pacth!
:-)
Christian
comment:3 Changed 10 years ago by chr
- Resolution set to fixed
- Status changed from new to closed
comment:4 Changed 10 years ago by tegzed
Hello Christian,
Unfortunately I don't have svn commit permission, I just applied it to my working copy and reported that this works fine for me. I think the best way to have it committed is to ask some developers on the #navit irc channel.
David
comment:5 Changed 10 years ago by chr
- Resolution fixed deleted
- Status changed from closed to reopened
Hello David,
ok, a minor misunterstanding on my side. Anyhow, its good to here that the patch adjusts the sunrise/sunset timing for you!
@admins: Please check this patch in. It is easy to verify. Just two lines.
Bye, Christian
comment:6 Changed 10 years ago by number6
- Cc nick@… added
- Keywords layout car car-dark OSD added
- Owner changed from KaZeR to Number6
- Status changed from reopened to new
Patch fixed the problem on WinCE, Testing further before commit, One more person, Please confirm!
Assigning ticket to myself, Speaking like Yoda, Because I write ticket in Haiku
comment:7 Changed 10 years ago by number6
- Resolution set to fixed
- Status changed from new to closed
comment:8 Changed 10 years ago by number6
- Resolution fixed deleted
- Status changed from closed to reopened
comment:9 Changed 10 years ago by number6
- Owner changed from Number6 to number6
- Status changed from reopened to new
comment:10 Changed 10 years ago by number6
- Status changed from new to assigned
comment:11 Changed 10 years ago by number6
- Resolution set to fixed
- Status changed from assigned to closed
Hello Christian,
Thanks for your patch. I have applied your modification and it seems to solve the sunset/sunrise problem correctly here in Hungray, too. The values of (-5,1) for altit and upper_limb parameters seems to be reasonable also. So I also recommend committing it to svn.
Thanks, David Tegze