eneylon

Hacking Sunrise

In general on March 15, 2010 at 9:51 pm

Sunrise is my hack from wherecamp.eu.

It’s a calculator of sunrise and sunset times that can be used to build location-based applications. Potential users of such applications are anyone needing to know when surise or sunset will occur at their location – or another specified location. This could be photographers wanting to capture landscapes bathed in colour, farmers who wake a specified time before sunrise (if farmers still do that), religious observers with dietary or worship practices based on sunrise or sunset, etc.

Timings are calculated using an algorithm from the Almanac for Computers, 1990, published by Nautical Almanac Office, United States Naval Observatory. It makes sense to use an approach driven from a need for precision informtion so this seemed a good starting point. Implementation in code was trickier than originally thought because the trignomatric functions need converting between degrees and radians – fortunately there is a worked example available which also led to the discovery of an an error in the algorithm. Additionally there is the need to account for step changes in time zones when factoring in summer time.

The hack took this data and cycled through the days of the year. For each returned value a line was drawn on an SVG canvas – showing the variation across the year. Near the equator this variation is minimal (the days tend to be around 12 hours), but once we deviate into seasonally-affected areas the utility of knowing each days twilight tmes becomes more apparent.

The calculator source code is posted on github and I welcome implementations in other languages, extensions and improvements. If you would like to get involved ping me on twitter where my username is eneylon. Next steps on this are to figure how could the latitude and longitude can be retrieved: they could be provided by the application, entered into a web form, supplied from gps access, or accessed with a javascript library. There is also more work needed on calculating summer time change dates.

Unfortunately I’m not patient enough to be a graphic designer – so to move this forward it would be good to work with someone skilled in design to collaborate on rendition of an attractive interface to the data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: