Skip to content

Commit 4c08ad1

Browse files
committed
fix(backend): port sun position to solar-positioning 0.7 SolarPositions API
1 parent f7fedda commit 4c08ad1

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎backend/src/pv/forecast/solar.rs‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! zenith is degrees from vertical.
66
77
use chrono::{DateTime, Datelike, Utc};
8-
use solar_positioning::{spa, RefractionCorrection};
8+
use solar_positioning::{Location, RefractionCorrection, SolarPositions};
99

1010
/// Observer elevation, atmosphere and ΔT used for the sun position. Refraction
1111
/// depends on the first three, but only near the horizon, so standard sea-level
@@ -38,15 +38,18 @@ pub fn sun_state(time: DateTime<Utc>, latitude: f64, longitude: f64) -> SunState
3838
let refraction = RefractionCorrection::new(PRESSURE_MBAR, TEMPERATURE_C)
3939
.expect("standard pressure and temperature are in range");
4040

41-
let position = spa::solar_position(
42-
time,
43-
latitude,
44-
longitude,
45-
OBSERVER_ELEVATION_M,
46-
DELTA_T_SECONDS,
47-
Some(refraction),
48-
)
49-
.expect("site coordinates are validated at settings load");
41+
let position = SolarPositions::new()
42+
.at(
43+
&time,
44+
Location {
45+
latitude,
46+
longitude,
47+
},
48+
OBSERVER_ELEVATION_M,
49+
DELTA_T_SECONDS,
50+
Some(refraction),
51+
)
52+
.expect("site coordinates are validated at settings load");
5053

5154
let apparent_zenith = position.zenith_angle();
5255

0 commit comments

Comments
 (0)