Skip to content

Commit

Permalink
neo
Browse files Browse the repository at this point in the history
  • Loading branch information
p4ken committed Jun 29, 2024
1 parent 5c70d55 commit 9d977c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/neo5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ impl Degrees for Tokyo {
fn with_degrees(lat: f64, lon: f64) -> Self {
Self
}
fn degrees(self) -> (f64, f64) {
(0., 0.)
fn degrees<T: From<LatLon>>(self) -> T {
LatLon(0., 0.).into()
}
}

Expand Down Expand Up @@ -44,8 +44,8 @@ impl Degrees for Jgd2011 {
fn with_degrees(lat: f64, lon: f64) -> Self {
Self
}
fn degrees(self) -> (f64, f64) {
(0., 0.)
fn degrees<T: From<LatLon>>(self) -> T {
LatLon(0., 0.).into()
}
}

Expand All @@ -55,12 +55,25 @@ pub trait Degrees: Sized {
fn with_secs(lat: f64, lon: f64) -> Self {
Self::with_degrees(lat, lon)
}
fn degrees(self) -> (f64, f64);
fn secs(self) -> (f64, f64) {
fn degrees<T: From<LatLon>>(self) -> T;
fn secs<T: From<LatLon>>(self) -> T {
self.degrees()
}
}
pub struct LatLon(f64, f64);
impl LatLon {
pub fn lat(&self) -> f64 {
self.0
}
pub fn lon(&self) -> f64 {
self.1
}
}
impl From<LatLon> for (f64, f64) {
fn from(value: LatLon) -> Self {
todo!()
}
}
// impl Degrees for LatLon {
// fn with_degrees(lat: f64, lon: f64) -> Self {
// todo!()
Expand All @@ -84,6 +97,13 @@ pub fn usage() {
.to_jgd2011()
.degrees();

// 使いにくい 分かりにくい
let jgd2000 = Tokyo::with_degrees(1., 2.)
.to_jgd2000()
.to_jgd2011()
.degrees::<LatLon>();
jgd2000.lat();

let (lat, lon) = Tokyo::with_secs(1., 2.).to_jgd2000().to_jgd2011().secs();

let mut p = Point::new(1., 2.);
Expand Down
1 change: 1 addition & 0 deletions src/neo6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl LatLon {
pub fn usage() {
use geo::Point;

// やはりベストか
let LatLon(lat, lon) = Tokyo::with_degrees(LatLon(0., 0.))
.to_jgd2000()
.to_jgd2011()
Expand Down

0 comments on commit 9d977c2

Please sign in to comment.