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
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct Record {
pub name: String,
pub nvec: Nvec,
#[serde(rename = "country code")]
pub country: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Nvec {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Nvec {
pub fn from_lat_long(lat: f32, long: f32) -> Nvec {
let x = lat.to_radians().cos() * long.to_radians().cos();
let y = lat.to_radians().cos() * long.to_radians().sin();
let z = lat.to_radians().sin();
Nvec{x,y,z}
}
}