[Bugfix] Fix the day part arcs for locations on the western hemisphere

This commit is contained in:
Gergely Polonkai 2022-05-19 08:45:29 +02:00
parent 8a4c25bd80
commit b07361d392
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
1 changed files with 9 additions and 6 deletions

View File

@ -23,6 +23,9 @@ const HOUR_NAMES: [&str; 24] = [
"Blossom", "Ladybug", "Geese", "Dust", "Peach", "Fog", "Acorn", "Gourd", "Soup", "Crow",
"Mushroom", "Thunder", "Frost", "Lantern",
];
// TODO: Make these configurable
const LATITUDE: f64 = 47.655235;
const LONGITUDE: f64 = 19.2868815;
enum Season {
Spring,
@ -175,7 +178,11 @@ fn get_range_path(
let end_delta_x = radius * end_deg.to_radians().sin();
let end_delta_y = radius * (1.0 - end_deg.to_radians().cos());
let large_arc_flag = if deg_diff.abs() >= 180.0 { 0 } else { 1 };
let large_arc_flag = if start_deg < end_deg {
if deg_diff.abs() >= 180.0 { 0 } else { 1 }
} else {
if deg_diff.abs() >= 180.0 { 1 } else { 0 }
};
let path_data = PathData::new()
.move_to((image_width / 2, image_width / 2))
@ -248,10 +255,6 @@ fn gen_svg() -> Document {
let local_time = local_timestamp.time().num_seconds_from_midnight() as i32;
let utc_rotation = seconds_to_degrees(utc_offset);
// TODO: Make these configurable
let lat = 47.655235;
let long = 19.2868815;
// TODO: These should be calculated instead of hardcoded
let image_width = 700u32;
@ -261,7 +264,7 @@ fn gen_svg() -> Document {
let moon_radius = image_width as f32 * 0.071428571;
let moon_phase = moon_illumination.phase * 28.0;
let sun_times = suncalc::get_times(unixtime, lat, long, None);
let sun_times = suncalc::get_times(unixtime, LATITUDE, LONGITUDE, None);
let noon = Utc
.timestamp_millis(sun_times.solar_noon.0)
.time()