Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flosse/rust-sun
A Rust library for calculating sun positions
https://github.com/flosse/rust-sun
geo sun sun-position sunrise sunset
Last synced: 27 days ago
JSON representation
A Rust library for calculating sun positions
- Host: GitHub
- URL: https://github.com/flosse/rust-sun
- Owner: flosse
- Created: 2015-07-16T23:19:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-21T00:40:31.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T09:38:39.761Z (8 months ago)
- Topics: geo, sun, sun-position, sunrise, sunset
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 45
- Watchers: 4
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-rust-cn - flosse/rust-sun - ci.org/flosse/rust-sun.svg?branch=master">](https://travis-ci.org/flosse/rust-sun) (Libraries / Astronomy)
- awesome-rust - flosse/rust-sun - ci.org/flosse/rust-sun.svg?branch=master">](https://travis-ci.org/flosse/rust-sun) (Libraries / Astronomy)
- awesome-rust - flosse/rust-sun
- awesome-rust-cn - flosse/rust-sun - (库 Libraries / 天文学 Astronomy)
- awesome-rust-zh - flosse/rust-sun - JS 库 suncalc 的螃蟹端口[<img src="https://api.travis-ci.org/flosse/rust-sun.svg?branch=master">](https://travis-ci.org/flosse/rust-sun) (库 / 天文学)
- awesome-rust - flosse/rust-sun - A rust port of the JS library suncalc (Libraries / Astronomy)
- awesome-rust - flosse/rust-sun - ci.org/flosse/rust-sun.svg?branch=master">](https://travis-ci.org/flosse/rust-sun) (库 Libraries / 天文 Astronomy)
- awesome-rust-zh-cn - flosse/rust-sun - ci.org/flosse/rust-sun.svg?branch=master">](https://travis-ci.org/flosse/rust-sun) (人工智能(Artificial Intelligence) / 天文(Astronomy))
- fucking-awesome-rust - flosse/rust-sun - A rust port of the JS library suncalc (Libraries / Astronomy)
- fucking-awesome-rust - flosse/rust-sun - A rust port of the JS library suncalc (Libraries / Astronomy)
README
# sun
A [Rust](https://www.rust-lang.org) port of the JS library [suncalc](https://github.com/mourner/suncalc/).
[![Crates.io](https://img.shields.io/crates/v/sun.svg)](https://crates.io/crates/sun)
[![Docs.rs](https://docs.rs/sun/badge.svg)](https://docs.rs/sun/)## Install
Add the following to your `Cargo.toml`
[dependencies]
sun = "0.3"## Usage
```rust
pub fn main() {
let unixtime = 1_362_441_600_000.0;
let lat = 48.0;
let lon = 9.0;
let pos = sun::pos(unixtime,lat,lon);
let az = pos.azimuth.to_degrees();
let alt = pos.altitude.to_degrees();
println!("The position of the sun is {az}/{alt}");let time_ms = sun::time_at_phase(unixtime, sun::SunPhase::Sunrise, lat, lon, 0.0);
println!("Sunrise is at {time_ms}");
}
```