Rename DM to DMM

This commit is contained in:
Austen Adler 2023-03-19 18:54:49 -04:00
parent 23d48b2a7b
commit cda11079e4
2 changed files with 12 additions and 12 deletions

View File

@ -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,

View File

@ -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),
)),