Rename sky vector to ddmmss
This commit is contained in:
parent
e32e8e00ee
commit
c9c39828a2
@ -7,7 +7,7 @@ use crate::{
|
||||
dmm,
|
||||
dms,
|
||||
plus, //xpin
|
||||
sky_vector,
|
||||
ddmmss,
|
||||
utm,
|
||||
Coordinate,
|
||||
Error,
|
||||
@ -26,7 +26,7 @@ pub struct Coordinates {
|
||||
pub utm: utm::Coordinate,
|
||||
// pub xpin: xpin::Xpin,
|
||||
pub plus: plus::Coordinate,
|
||||
pub sky_vector: sky_vector::Coordinate,
|
||||
pub ddmmss: ddmmss::Coordinate,
|
||||
}
|
||||
|
||||
impl TryFrom<LatLon> for Coordinates {
|
||||
@ -40,7 +40,7 @@ impl TryFrom<LatLon> for Coordinates {
|
||||
dmm: dmm::Coordinate::from(latlon),
|
||||
utm: utm::Coordinate::try_from(latlon)?,
|
||||
plus: plus::Coordinate::try_from(latlon)?,
|
||||
sky_vector: sky_vector::Coordinate::from(latlon),
|
||||
ddmmss: ddmmss::Coordinate::from(latlon),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
common::parse_direction,
|
||||
dms::{self, DMS},
|
||||
Direction, Error, LatLon,
|
||||
Error, LatLon,
|
||||
};
|
||||
use nom::{
|
||||
bytes::complete::take,
|
||||
@ -51,29 +51,11 @@ impl Coordinate {
|
||||
let dms = dms::Coordinate::from_components(lat, lon)?;
|
||||
let latlon = LatLon::from(&dms);
|
||||
|
||||
// let lat = Self::dms_to_f64_helper(lat_d, lat_m, lat_s, &lat_direction);
|
||||
// let lon = Self::dms_to_f64_helper(lon_d, lon_m, lon_s, &lon_direction);
|
||||
|
||||
// let latlon = DMS {};
|
||||
// LatLon::new(lat, lon)?;
|
||||
Ok(Coordinate(Self::latlon_to_string(&latlon), latlon))
|
||||
},
|
||||
)(i)
|
||||
}
|
||||
|
||||
/// Helper to convert u8, Option<u8>, Option<u8> into an f64
|
||||
// fn dms_to_f64_helper(d: u8, m: Option<u8>, s: Option<u8>, direction: &Direction) -> f64 {
|
||||
|
||||
// (d as f64
|
||||
// + m.map(|m| m as f64 / 100.0_f64).unwrap_or(0.0_f64)
|
||||
// + s.map(|s| s as f64 / 10_000.0_f64).unwrap_or(0.0_f64))
|
||||
// * if direction.is_positive() {
|
||||
// 1.0_f64
|
||||
// } else {
|
||||
// -1.0_f64
|
||||
// }
|
||||
// }
|
||||
|
||||
/// Takes n digits from the input and parses it as a u8
|
||||
fn parse_n_digits<const C: u8>(i: &str) -> IResult<&str, u8> {
|
||||
map_parser(take(C), complete::u8)(i)
|
||||
@ -87,16 +69,16 @@ impl Coordinate {
|
||||
"{:02.0}{:02.0}{:02.0}{}{:03.0}{:02.0}{:02.0}{}",
|
||||
lat.degrees,
|
||||
lat.minutes,
|
||||
lat.seconds.trunc(),
|
||||
lat.seconds.round(),
|
||||
lat.direction,
|
||||
lon.degrees,
|
||||
lon.minutes,
|
||||
lon.seconds.trunc(),
|
||||
lon.seconds.round(),
|
||||
lon.direction,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_sky_vector(&self) -> &str {
|
||||
pub fn get_ddmmss(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ pub mod dmm;
|
||||
pub mod dms;
|
||||
pub mod latlon;
|
||||
pub mod plus;
|
||||
pub mod sky_vector;
|
||||
pub mod ddmmss;
|
||||
pub mod urls;
|
||||
pub mod utm;
|
||||
pub use error::Error;
|
||||
@ -88,7 +88,7 @@ pub enum Coordinate {
|
||||
UTM(utm::Coordinate),
|
||||
// Xpin(xpin::Xpin),
|
||||
Plus(plus::Coordinate),
|
||||
SkyVector(sky_vector::Coordinate),
|
||||
DDMMSS(ddmmss::Coordinate),
|
||||
}
|
||||
|
||||
impl Coordinate {
|
||||
@ -108,7 +108,7 @@ impl Coordinate {
|
||||
map(dd::Coordinate::parse, Coordinate::DD),
|
||||
// map(xpin::Coordinate::parse, Cordinate::Xpin),
|
||||
map(plus::Coordinate::parse, Coordinate::Plus),
|
||||
map(sky_vector::Coordinate::parse, Coordinate::SkyVector),
|
||||
map(ddmmss::Coordinate::parse, Coordinate::DDMMSS),
|
||||
// Try to parse as a URL last
|
||||
map(urls::CoordinateUrls::parse, |coordinate_urls| {
|
||||
Coordinate::DD(dd::Coordinate::from(coordinate_urls.latlon))
|
||||
@ -130,7 +130,7 @@ impl Coordinate {
|
||||
CoordinateType::DMM => Self::DMM(dmm::Coordinate::from(lat_lon)),
|
||||
CoordinateType::UTM => Self::UTM(utm::Coordinate::try_from(lat_lon)?),
|
||||
CoordinateType::Plus => Self::Plus(plus::Coordinate::try_from(lat_lon)?),
|
||||
CoordinateType::SkyVector => Self::SkyVector(sky_vector::Coordinate::from(lat_lon)),
|
||||
CoordinateType::DDMMSS => Self::DDMMSS(ddmmss::Coordinate::from(lat_lon)),
|
||||
})
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ impl Coordinate {
|
||||
Self::UTM(_) => CoordinateType::UTM,
|
||||
// Self::Xpin(_) => CoordinateType::Xpin,
|
||||
Self::Plus(_) => CoordinateType::Plus,
|
||||
Self::SkyVector(_) => CoordinateType::SkyVector,
|
||||
Self::DDMMSS(_) => CoordinateType::DDMMSS,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ impl From<&Coordinate> for LatLon {
|
||||
Coordinate::UTM(utm) => utm.into(),
|
||||
// Coordinate::Xpin(xpin) => xpin.into(),
|
||||
Coordinate::Plus(plus) => plus.into(),
|
||||
Coordinate::SkyVector(sky_vector) => sky_vector.into(),
|
||||
Coordinate::DDMMSS(ddmmss) => ddmmss.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,9 +206,9 @@ impl From<plus::Coordinate> for Coordinate {
|
||||
Self::Plus(c)
|
||||
}
|
||||
}
|
||||
impl From<sky_vector::Coordinate> for Coordinate {
|
||||
fn from(c: sky_vector::Coordinate) -> Self {
|
||||
Self::SkyVector(c)
|
||||
impl From<ddmmss::Coordinate> for Coordinate {
|
||||
fn from(c: ddmmss::Coordinate) -> Self {
|
||||
Self::DDMMSS(c)
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ impl fmt::Display for Coordinate {
|
||||
Coordinate::DMS(dms) => write!(f, "{}", dms),
|
||||
Coordinate::UTM(utm) => write!(f, "{}", utm),
|
||||
Coordinate::Plus(plus) => write!(f, "{}", plus),
|
||||
Coordinate::SkyVector(sky_vector) => write!(f, "{}", sky_vector),
|
||||
Coordinate::DDMMSS(ddmmss) => write!(f, "{}", ddmmss),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,8 @@
|
||||
#![allow(clippy::module_name_repetitions)]
|
||||
|
||||
pub mod v0;
|
||||
pub mod wide;
|
||||
// TODO: Add wide support
|
||||
// pub mod wide;
|
||||
use conversions::lat_lon_to_cellid;
|
||||
pub use s2::s1::angle::Angle;
|
||||
use std::{
|
||||
|
@ -74,8 +74,8 @@ pub struct Coordinates {
|
||||
// pub xpin: String,
|
||||
#[wasm_bindgen(js_name = "Plus")]
|
||||
pub plus: String,
|
||||
#[wasm_bindgen(js_name = "SkyVector")]
|
||||
pub sky_vector: String,
|
||||
#[wasm_bindgen(js_name = "DDMMSS")]
|
||||
pub ddmmss: String,
|
||||
}
|
||||
|
||||
impl From<&spatial_coordinate_systems::all::Coordinates> for Coordinates {
|
||||
@ -86,7 +86,7 @@ impl From<&spatial_coordinate_systems::all::Coordinates> for Coordinates {
|
||||
dmm: value.dmm.to_string(),
|
||||
utm: value.utm.to_string(),
|
||||
plus: value.plus.to_string(),
|
||||
sky_vector: value.sky_vector.to_string(),
|
||||
ddmmss: value.ddmmss.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user