martinc/daylight

Enhancement - Location is in Daylight

Danny-SS opened this issue · 0 comments

I stumbled across this looking for a map overlay for MapKit to show daylight/night over map of the world. I am glad to see a solid foundation in this project.

Here's an enhancement I'd like to see:

Given a longitude and latitude, at the current time, is that location in daylight or darkness.

[User could choose what they consider daylight from the SolarEvent enum. It would be great if we did not have to worry about time zone and just a location on earth at the current time.]

So maybe something like:

let currentLocation = CLLocationCoordinate2D(latitude: 40.642, longitude: -74.017)
let inDaylight: Bool = currentLocation.inDaylight(usingDawn: .civilDawn, andDusk: .civilDusk)

I'll be playing around with what you have. Beats starting from NASA's codeI've seen since this is already migrated to Swift.