i am using appcelerator titanium to develop an IOS app and i want to let my app send local notification to the users in sunrise and sunset
a good tool to solve this is Yahoo weather using YQL ; however, yahoo weather is for non-commercial use only!!
i am trying to find a javascript library to calculate the sunrise/set + a database of the world's countries and cities with the latitude and longtude
have anyone ever needed the same?
Any idea.
This algorithm looks pretty wicked to solve exactly what you're looking to do.
Use NOAA's javascript routines for the solar position: here
They include a short list of cities with latitude and longitude. I think you can also get that from iOS, but here's another answer on getting it from city, state, etc.
I wrote a Google Gadget (javascript) for sunrise and sunset calculation based on lat/lon located here.
It was written from algorithms in Duffett-Smith 'Practical Astronomy with your Calculator'.
With iOS (and likely other location enabled devices) you can get the users current location if they allow it. You can then use the local time and timezone offset to calculate the sunrise and sunset from their latitude and longitude.
It won't take into account local geographic effects on the horizon (e.g. if they are in a valley the sun will rise or set earlier than if they are on a hill) but it should be close enough. Use Google, I'm sure you'll find it - ah, I see Demian has done it for you.