Skip to content

Commit

Permalink
neo
Browse files Browse the repository at this point in the history
  • Loading branch information
p4ken committed Jul 2, 2024
1 parent 8d4f50c commit d61b685
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ mod crs;
mod earth;
mod grid;
mod island;
pub mod neo10;
pub mod neo2;
pub mod neo5;
pub mod neo6;
Expand Down
26 changes: 26 additions & 0 deletions src/neo10.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![allow(unused)]

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

struct LatLon(f64, f64);

fn usage() {
let LatLon(lat, lon) = Tokyo::new(LatLon(0., 0.))
.to_jgd2000()
.to_jgd2011()
.into_inner(); // 微妙〜
}
8 changes: 4 additions & 4 deletions src/neo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ mod tests {
// APIが2系統あるのが微妙
let (lat, lon) = crate::from_tokyo(1., 2.).to_jgd2000().degrees().into();

// LatLon じゃなくなり LatLon に戻す...難解
let LatLon(lat, lon) = LatLon(1., 2.).in_tokyo().to_jgd2000().degrees();
// let LatLon(lat, lon) = LatLon(1., 2.).in_tokyo().to_jgd2000().degrees();
// 変換できたと勘違い!
let LatLon(lat, lon) = LatLon(1., 2.).in_jgd2000().degrees();
// let LatLon(lat, lon) = LatLon(1., 2.).from_tokyo().to_jgd2000().to_degrees();
// let LatLon(lat, lon) = LatLon(1., 2.).in_jgd2000().degrees();
// LatLon じゃなくなり LatLon に戻す...難解
let LatLon(lat, lon) = LatLon(1., 2.).from_tokyo().to_jgd2000().to_degrees();
// let LatLon(lat, lon) = LatLon(1., 2.).transform_from_tokyo().to_jgd2000().degrees();

let (lat, lon) = LatLon::from_secs(1., 2.)
Expand Down
18 changes: 9 additions & 9 deletions src/neo6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Degrees for Tokyo {
fn with_degrees(degrees: impl Into<LatLon>) -> Self {
Self
}
fn degrees(&self) -> LatLon {
fn as_degrees(&self) -> LatLon {
LatLon(0., 0.)
}
}
Expand All @@ -26,7 +26,7 @@ impl Degrees for Jgd2011 {
fn with_degrees(degrees: impl Into<LatLon>) -> Self {
Self
}
fn degrees(&self) -> LatLon {
fn as_degrees(&self) -> LatLon {
LatLon(0., 0.)
}
}
Expand All @@ -38,9 +38,9 @@ pub trait Degrees: Sized {
fn with_secs(secs: LatLon) -> Self {
Self::with_degrees(secs)
}
fn degrees(&self) -> LatLon;
fn secs(&self) -> LatLon {
self.degrees()
fn as_degrees(&self) -> LatLon;
fn as_secs(&self) -> LatLon {
self.as_degrees()
}
}
pub struct LatLon<T = f64>(T, T);
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn usage() {
let LatLon(lat, lon) = Tokyo::with_degrees(LatLon(0., 0.))
.to_jgd2000()
.to_jgd2011()
.degrees();
.as_degrees();

// let [lat, lon] = Tokyo::with_degrees([0., 0.])
// .to_jgd2000()
Expand All @@ -111,14 +111,14 @@ pub fn usage() {
let LatLon(lat, lon) = Tokyo::with_secs(LatLon(0., 0.))
.to_jgd2000()
.to_jgd2011()
.secs();
.as_secs();

// geo に偏りすぎ。他にも geojson は vec だったり色々ある。
let mut p = Point::new(1., 2.);
p = Tokyo::with_degrees(LatLon::from_rev(p))
.to_jgd2000()
.to_jgd2011()
.degrees()
.as_degrees()
.into_rev();
// p = Tokyo::with_degrees(XY::from(p.x_y()))
// .to_jgd2000()
Expand All @@ -130,6 +130,6 @@ pub fn usage() {
let LatLon(y, x) = Tokyo::with_degrees(LatLon(p.y(), p.x()))
.to_jgd2000()
.to_jgd2011()
.degrees();
.as_degrees();
p = Point::new(x, y);
}

0 comments on commit d61b685

Please sign in to comment.