Coder Social home page Coder Social logo

martinc / daylight Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 5.0 42 KB

A swift package that provides NOAA astronomical algorithms for sunrise and sunset times

License: MIT License

Swift 96.58% Ruby 3.42%
swift sunrise sunset dawn dusk noaa astronomy

daylight's Issues

Enhancement - Location is in Daylight

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.

Daylight framework crashes app if the location is inside polar ring.

Locations inside polar ring, will have polar days (sun never sets) and polar nights (sun never rises).

private func hourAngleOfSunrise(latitude: Float64, solarDeclination: Float64, solarElevation: Float64) throws -> Float64

This function return NAN when sun never rises or sun never sets.

I have made a work around to solve this problem by throw an error from there (and re-throw it along the method chain). I don't have a better solution to handle this situation, so I hope you can look into it.

The workaround I've made was in commit eca031c.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.