Skip to content

Commit

Permalink
neo
Browse files Browse the repository at this point in the history
  • Loading branch information
p4ken committed Jul 3, 2024
1 parent d61b685 commit 3571586
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 13 deletions.
81 changes: 68 additions & 13 deletions src/neo10.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,81 @@
#![allow(unused)]

struct Tokyo {}
impl Tokyo {
fn new(degrees: LatLon) -> Self {
todo!()
pub mod jgd {
use std::ops::{Div, Mul};

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

pub mod degree {
/// 1度あたりの秒。
pub const SECOND: f64 = 3_600.;

/// 1度あたりのミリ秒。
pub const MILLI_SECOND: f64 = 3_600_000.;
}

/// 緯度と経度のペア。
pub struct LatLon<T = f64>(pub T, pub T);
impl LatLon {
pub fn new<T: Into<f64>>(lat: T, lon: T) -> Self {
todo!()
}
// pub fn from_secs<T>(lat: T, lon: T) -> Self {
// todo!()
// }
// pub fn to_secs(self) -> LatLon {
// todo!()
// }
}
fn to_jgd2000(&self) -> Self {
todo!()
impl<T: Into<f64>> LatLon<T> {
// pub fn round(self) -> LatLon<i32> {
// todo!()
// }
pub fn map<U: Into<f64>>(self, f: impl Fn(T) -> U) -> LatLon<U> {
todo!()
}
}
fn to_jgd2011(&self) -> Self {
todo!()
impl Mul<f64> for LatLon {
type Output = LatLon;
fn mul(self, rhs: f64) -> Self::Output {
todo!()
}
}
fn into_inner(&self) -> LatLon {
todo!()
impl Div<f64> for LatLon {
type Output = LatLon;
fn div(self, rhs: f64) -> Self::Output {
todo!()
}
}
}

struct LatLon(f64, f64);

#[cfg(test)]
fn usage() {
use std::ops::Mul;

use jgd::{degree::MILLI_SECOND, LatLon, Tokyo};

let LatLon(lat, lon) = Tokyo::new(LatLon(0., 0.))
.to_jgd2000()
.to_jgd2011()
.into_inner(); // 微妙〜
.degrees();

let LatLon(lat, lon) = Tokyo::new(LatLon::new(0, 0) / MILLI_SECOND)
.to_jgd2000()
.to_jgd2011()
.degrees()
.map(|x| (x * MILLI_SECOND).round() as i32);
}
2 changes: 2 additions & 0 deletions src/neo4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ pub fn usage() {
.to_jgd2000()
.to_jgd2011()
.degrees();

TOKYO.ToJgd2000().ToJgd2011().transform(LatLon(0., 0.));
}

0 comments on commit 3571586

Please sign in to comment.