1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::{coordinates::QuantizedCoordinates, prelude::Epoch};
/// [Key] allows efficient IONEX data storage.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Key {
/// [Epoch] of the attached TEC estimation.
pub epoch: Epoch,
/// [QuantizedCoordinates] of the attached TEC estimate.
pub(crate) coordinates: QuantizedCoordinates,
}
impl Key {
/// Creates a new index [Key] from datetime as [Epoch],
/// latitude and longitude in decimal degrees and altitude
/// in kilometers.
pub fn from_decimal_degrees_km(
epoch: Epoch,
lat_ddeg: f64,
long_ddeg: f64,
alt_km: f64,
) -> Self {
Self {
epoch,
coordinates: QuantizedCoordinates::from_decimal_degrees(lat_ddeg, long_ddeg, alt_km),
}
}
/// Creates a new index [Key] from datetime as [Epoch],
/// latitude and longitude angles in radians, altitude in kilometers.
pub fn from_radians_km(epoch: Epoch, lat_rad: f64, long_rad: f64, alt_km: f64) -> Self {
Self {
epoch,
coordinates: QuantizedCoordinates::from_decimal_degrees(
lat_rad.to_degrees(),
long_rad.to_degrees(),
alt_km,
),
}
}
/// Returns latitude angle in decimal degrees
pub fn latitude_ddeg(&self) -> f64 {
self.coordinates.latitude_ddeg()
}
/// Returns longitude angle in decimal degrees
pub fn longitude_ddeg(&self) -> f64 {
self.coordinates.longitude_ddeg()
}
/// Returns altitude in kilometers
pub fn altitude_km(&self) -> f64 {
self.coordinates.altitude_km()
}
}