use crate::{DegreesError, LatLon, BESSEL, ECEF, GRS80};
#[cfg(feature = "tky2jgd")]
use crate::TKY2JGD;
#[cfg(feature = "patchjgd")]
use crate::TOUHOKUTAIHEIYOUOKI2011;
#[derive(Debug)]
pub struct Tokyo {
degrees: LatLon,
}
impl Tokyo {
pub fn new(degrees: LatLon) -> Result<Self, DegreesError> {
degrees.validate_degrees()?;
Ok(Self { degrees })
}
#[cfg(feature = "tky2jgd")]
pub fn to_jgd2000(&self) -> Jgd2000 {
match TKY2JGD.bilinear(self.degrees) {
Some(shift) => Jgd2000::new_unchecked(self.degrees + shift),
None => Tokyo97::new_unchecked(self.degrees).to_jgd2000(),
}
}
pub fn degrees(&self) -> LatLon {
self.degrees
}
}
#[derive(Debug)]
pub struct Tokyo97 {
degrees: LatLon,
}
impl Tokyo97 {
pub const TO_ITRF94: ECEF = ECEF::new(-146.414, 507.337, 680.507);
pub fn new(degrees: LatLon) -> Result<Self, DegreesError> {
degrees.validate_degrees()?;
Ok(Self { degrees })
}
fn new_unchecked(degrees: LatLon) -> Self {
Self { degrees }
}
pub fn to_jgd2000(&self) -> Jgd2000 {
let itrf94 = BESSEL.to_ecef(self.degrees) + Self::TO_ITRF94;
Jgd2000::new_unchecked(GRS80.to_geodetic(itrf94))
}
pub fn degrees(&self) -> LatLon {
self.degrees
}
}
#[derive(Debug)]
pub struct Jgd2000 {
degrees: LatLon,
}
impl Jgd2000 {
pub fn new(degrees: LatLon) -> Result<Self, DegreesError> {
degrees.validate_degrees()?;
Ok(Self { degrees })
}
fn new_unchecked(degrees: LatLon) -> Self {
Self { degrees }
}
#[cfg(feature = "patchjgd")]
pub fn to_jgd2011(&self) -> Jgd2011 {
let shift = TOUHOKUTAIHEIYOUOKI2011
.bilinear(self.degrees)
.unwrap_or_default();
Jgd2011::new_unchecked(self.degrees + shift)
}
fn _to_tokyo(&self) {
}
pub fn to_tokyo97(&self) -> Tokyo97 {
let itrf94 = GRS80.to_ecef(self.degrees) - Tokyo97::TO_ITRF94;
Tokyo97::new_unchecked(BESSEL.to_geodetic(itrf94))
}
pub fn degrees(&self) -> LatLon {
self.degrees
}
}
#[derive(Debug)]
pub struct Jgd2011 {
degrees: LatLon,
}
impl Jgd2011 {
#[allow(dead_code)]
fn new_unchecked(degrees: LatLon) -> Self {
Self { degrees }
}
fn _to_jgd2000(&self) {
}
pub fn degrees(&self) -> LatLon {
self.degrees
}
}
struct _PlaneRectangular {}