View Single Post
Guest | Posts: n/a | Thanked: 0 times | Joined on
#113
Originally Posted by mbanck View Post
So I took a look at http://en.wikipedia.org/wiki/Sunrise_equation and http://users.electromagnetic.net/bu/...unrise-set.php

The drive-qml approximation for the declination is legit, it is equation 3 from http://solardat.uoregon.edu/SolarRadiationBasics.html

What seems to be missing is probably a better approximation of the sun transit, i.e. the true sun noon.

Otherwise, just some signs were apparently wrong in the sunrise/sunset calculation, with that fixed, it works well enough for me.

This is the patch: http://paste.debian.net/download/178685

Or inline:

Code:
--- /usr/lib/drive-qml/models/MapSettingsModel.qml.orig
+++ /usr/lib/drive-qml/models/MapSettingsModel.qml
@@ -135,8 +135,8 @@
         var lat_rad = pos.latitude * (Math.PI/180);
         var declination = (23.4*Math.PI)/180 * Math.sin(2*Math.PI * (284+dayOfTheYear)/365);
         var omega = Math.acos(-Math.tan(declination) * Math.tan(lat_rad));
-        var sunset = 12 - (1/15) * omega * (180/Math.PI) - pos.longitude/15 + today.getTimezoneOffset()/60;
-        var sunrise = 24  - sunset; //(1/15) * omega * (180/Math.PI) - pos.longitude/15 + today.getTimezoneOffset()/60;
+        var sunset = 12 + (1/15) * omega * (180/Math.PI) - pos.longitude/15 - today.getTimezoneOffset()/60;
+        var sunrise = 12  - (1/15) * omega * (180/Math.PI) - pos.longitude/15 - today.getTimezoneOffset()/60;
 
         console.log("Sunset:" + sunset);
         console.log("Sunrise:" + sunrise);
This works very well.
Now, what seems to be missing is that it will actually refresh the daylight settings on a scheduled basis, or at least at app start.
ATM it seems to only change if you enter settings and press auto :0
 

The Following 2 Users Say Thank You to For This Useful Post: