diff --git a/spatial-coordinate-systems/src/dm.rs b/spatial-coordinate-systems/src/dmm.rs similarity index 83% rename from spatial-coordinate-systems/src/dm.rs rename to spatial-coordinate-systems/src/dmm.rs index 652e14a..d59798f 100644 --- a/spatial-coordinate-systems/src/dm.rs +++ b/spatial-coordinate-systems/src/dmm.rs @@ -13,10 +13,10 @@ use nom::{ use std::str::FromStr; #[derive(PartialEq, Debug)] -pub struct Coordinate(pub DM, pub DM); +pub struct Coordinate(pub DMM, pub DMM); #[derive(PartialEq, Debug)] -pub struct DM { +pub struct DMM { pub degrees: i16, pub minutes: f64, pub direction: Direction, @@ -36,7 +36,7 @@ pub fn parse_coordinate(i: &str) -> IResult<&str, Coordinate> { )(i) } -pub fn parse(i: &str) -> IResult<&str, DM> { +pub fn parse(i: &str) -> IResult<&str, DMM> { map( tuple(( // Degrees @@ -48,7 +48,7 @@ pub fn parse(i: &str) -> IResult<&str, DM> { // Direction parse_direction, )), - |(degrees, (), minutes, (), direction)| DM { + |(degrees, (), minutes, (), direction)| DMM { degrees, minutes, direction, @@ -56,7 +56,7 @@ pub fn parse(i: &str) -> IResult<&str, DM> { )(i) } -impl FromStr for DM { +impl FromStr for DMM { type Err = (); /// Recognizes DMS in the formats: @@ -65,16 +65,16 @@ impl FromStr for DM { /// * `40 31 21 N, 105 5 39 W` /// /// ```rust - /// use spatial_coordinate_systems::dm::DM; + /// use spatial_coordinate_systems::dmm::DMM; /// use spatial_coordinate_systems::Direction; /// use std::str::FromStr; /// - /// assert_eq!(DM::from_str("40 31.3 N").unwrap(), DM { + /// assert_eq!(DMM::from_str("40 31.3 N").unwrap(), DMM { /// degrees: 40, /// minutes: 31.3_f64, /// direction: Direction::North, /// }); - /// assert_eq!(DM::from_str("40°31' N").unwrap(), DM { + /// assert_eq!(DMM::from_str("40°31' N").unwrap(), DMM { /// degrees: 40, /// minutes: 31_f64, /// direction: Direction::North, diff --git a/spatial-coordinate-systems/src/lib.rs b/spatial-coordinate-systems/src/lib.rs index 922a45a..62ea435 100644 --- a/spatial-coordinate-systems/src/lib.rs +++ b/spatial-coordinate-systems/src/lib.rs @@ -3,10 +3,10 @@ use std::str::FromStr; mod common; pub mod dd; -pub mod dm; +pub mod dmm; pub mod dms; -use dm::DM; +use dmm::DMM; use dms::DMS; use nom::{ branch::alt, @@ -49,7 +49,7 @@ impl Direction { pub enum Coordinate { DD(dd::Coordinate), DMS(dms::Coordinate), - DM(dm::Coordinate), + DM(dmm::Coordinate), // UTM(utm::UTMCoordinate), // Plus(plus::PlusCoordinate), } @@ -67,7 +67,7 @@ impl FromStr for Coordinate { alt(( map(dd::parse_coordinate, Coordinate::DD), map(dms::parse_coordinate, Coordinate::DMS), - map(dm::parse_coordinate, Coordinate::DM), + map(dmm::parse_coordinate, Coordinate::DM), // map(utm::parse_coordinate, Coordinate::UTM), // map(plus::parse_coordinate, Coordinate::PLUS), )),