diff --git a/backend/Cargo.lock b/backend/Cargo.lock index c1cc5f82..767cab6b 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -2312,9 +2312,9 @@ dependencies = [ [[package]] name = "solar-positioning" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d6872cbbd3f5ae24ef8e5f759b235a080d3592c8ddbc0c38c8985b19f6c34a" +checksum = "33e67ad3108959c32cd9ab2515f7ced367e640c0454c6277f67c3dacc7d1d0a2" dependencies = [ "chrono", ] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 320659e4..04241697 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -25,7 +25,7 @@ chrono = { version = "0.4", features = ["serde"] } chrono-tz = "0.10" quick-xml = "0.42" sun = "0.3" -solar-positioning = "0.6" +solar-positioning = "0.7" hmac = "0.13.0" sha1 = "0.11.0" md5 = "0.8.0" diff --git a/backend/src/pv/forecast/solar.rs b/backend/src/pv/forecast/solar.rs index 0fdc4815..8c41705b 100644 --- a/backend/src/pv/forecast/solar.rs +++ b/backend/src/pv/forecast/solar.rs @@ -5,7 +5,7 @@ //! zenith is degrees from vertical. use chrono::{DateTime, Datelike, Utc}; -use solar_positioning::{spa, RefractionCorrection}; +use solar_positioning::{Location, RefractionCorrection, SolarPositions}; /// Observer elevation, atmosphere and ΔT used for the sun position. Refraction /// depends on the first three, but only near the horizon, so standard sea-level @@ -38,15 +38,18 @@ pub fn sun_state(time: DateTime, latitude: f64, longitude: f64) -> SunState let refraction = RefractionCorrection::new(PRESSURE_MBAR, TEMPERATURE_C) .expect("standard pressure and temperature are in range"); - let position = spa::solar_position( - time, - latitude, - longitude, - OBSERVER_ELEVATION_M, - DELTA_T_SECONDS, - Some(refraction), - ) - .expect("site coordinates are validated at settings load"); + let position = SolarPositions::new() + .at( + &time, + Location { + latitude, + longitude, + }, + OBSERVER_ELEVATION_M, + DELTA_T_SECONDS, + Some(refraction), + ) + .expect("site coordinates are validated at settings load"); let apparent_zenith = position.zenith_angle();