-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters