Skip to content

Commit

Permalink
neo
Browse files Browse the repository at this point in the history
  • Loading branch information
p4ken committed Jul 5, 2024
1 parent 5c082dc commit 0310156
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/neo13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ mod jgd {

pub struct Tokyo;
impl Tokyo {
pub fn new(lat_lon: LatLon) -> Self {
pub fn new(degrees: LatLon) -> Self {
todo!()
}
pub fn lat_lon(self) -> LatLon {
pub fn to_jgd2000(self) -> Self {
todo!()
}
pub fn degrees(self) -> LatLon {
todo!()
}
}

pub struct Dms(pub i32, pub i32, pub f64);
impl Dms {
pub fn to_degrees(self) -> f64 {
fn to_degrees(self) -> f64 {
todo!()
}
pub fn from_degrees(degrees: f64) -> Self {
fn from_degrees(degrees: f64) -> Self {
todo!()
}
}
Expand All @@ -40,9 +43,9 @@ mod jgd {
pub fn to_dms(&self) -> (Dms, Dms) {
todo!()
}
pub fn as_array(&self) -> [f64; 2] {
todo!()
}
// pub fn as_array(&self) -> [f64; 2] {
// todo!()
// }
}
impl Mul<f64> for LatLon {
type Output = LatLon;
Expand All @@ -67,17 +70,23 @@ mod tests {
use super::jgd::{Dms, LatLon, Tokyo};

fn usage() {
let LatLon(lat, lon) = Tokyo::new(LatLon(1., 2.)).lat_lon();
let LatLon(lat, lon) = Tokyo::new(LatLon(1., 2.)).to_jgd2000().degrees();

// ミリ秒はノーサポート
let [lat, lon] = [1, 2].map(f64::from);
let lat_lon = Tokyo::new(LatLon(1., 2.) / 3_600_000.).lat_lon() * 3_600_000.;
let [lat, lon] = lat_lon.as_array().map(|deg| deg.round() as i32);
assert_abs_diff_eq!(lat_lon.as_array()[..], [1., 2.]);
let LatLon(lat, lon) = Tokyo::new(LatLon(lat, lon) / 3_600_000.)
.to_jgd2000()
.degrees()
* 3_600_000.;
assert_abs_diff_eq!([lat, lon][..], [1., 2.]);
let [lat, lon] = [lat, lon].map(|deg| deg.round() as i32);

// 度分秒はサポート
let lat = Dms(1, 2, 3.into());
let lon = Dms(4, 5, 6.into());
let (lat, lon) = Tokyo::new(LatLon::from_dms(lat, lon)).lat_lon().to_dms();
let (lat, lon) = Tokyo::new(LatLon::from_dms(lat, lon))
.to_jgd2000()
.degrees()
.to_dms();
}
}

0 comments on commit 0310156

Please sign in to comment.