Rename DM to DMM
This commit is contained in:
parent
23d48b2a7b
commit
cda11079e4
@ -13,10 +13,10 @@ use nom::{
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub struct Coordinate(pub DM, pub DM);
|
pub struct Coordinate(pub DMM, pub DMM);
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub struct DM {
|
pub struct DMM {
|
||||||
pub degrees: i16,
|
pub degrees: i16,
|
||||||
pub minutes: f64,
|
pub minutes: f64,
|
||||||
pub direction: Direction,
|
pub direction: Direction,
|
||||||
@ -36,7 +36,7 @@ pub fn parse_coordinate(i: &str) -> IResult<&str, Coordinate> {
|
|||||||
)(i)
|
)(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(i: &str) -> IResult<&str, DM> {
|
pub fn parse(i: &str) -> IResult<&str, DMM> {
|
||||||
map(
|
map(
|
||||||
tuple((
|
tuple((
|
||||||
// Degrees
|
// Degrees
|
||||||
@ -48,7 +48,7 @@ pub fn parse(i: &str) -> IResult<&str, DM> {
|
|||||||
// Direction
|
// Direction
|
||||||
parse_direction,
|
parse_direction,
|
||||||
)),
|
)),
|
||||||
|(degrees, (), minutes, (), direction)| DM {
|
|(degrees, (), minutes, (), direction)| DMM {
|
||||||
degrees,
|
degrees,
|
||||||
minutes,
|
minutes,
|
||||||
direction,
|
direction,
|
||||||
@ -56,7 +56,7 @@ pub fn parse(i: &str) -> IResult<&str, DM> {
|
|||||||
)(i)
|
)(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for DM {
|
impl FromStr for DMM {
|
||||||
type Err = ();
|
type Err = ();
|
||||||
|
|
||||||
/// Recognizes DMS in the formats:
|
/// Recognizes DMS in the formats:
|
||||||
@ -65,16 +65,16 @@ impl FromStr for DM {
|
|||||||
/// * `40 31 21 N, 105 5 39 W`
|
/// * `40 31 21 N, 105 5 39 W`
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use spatial_coordinate_systems::dm::DM;
|
/// use spatial_coordinate_systems::dmm::DMM;
|
||||||
/// use spatial_coordinate_systems::Direction;
|
/// use spatial_coordinate_systems::Direction;
|
||||||
/// use std::str::FromStr;
|
/// 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,
|
/// degrees: 40,
|
||||||
/// minutes: 31.3_f64,
|
/// minutes: 31.3_f64,
|
||||||
/// direction: Direction::North,
|
/// 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,
|
/// degrees: 40,
|
||||||
/// minutes: 31_f64,
|
/// minutes: 31_f64,
|
||||||
/// direction: Direction::North,
|
/// direction: Direction::North,
|
@ -3,10 +3,10 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
mod common;
|
mod common;
|
||||||
pub mod dd;
|
pub mod dd;
|
||||||
pub mod dm;
|
pub mod dmm;
|
||||||
pub mod dms;
|
pub mod dms;
|
||||||
|
|
||||||
use dm::DM;
|
use dmm::DMM;
|
||||||
use dms::DMS;
|
use dms::DMS;
|
||||||
use nom::{
|
use nom::{
|
||||||
branch::alt,
|
branch::alt,
|
||||||
@ -49,7 +49,7 @@ impl Direction {
|
|||||||
pub enum Coordinate {
|
pub enum Coordinate {
|
||||||
DD(dd::Coordinate),
|
DD(dd::Coordinate),
|
||||||
DMS(dms::Coordinate),
|
DMS(dms::Coordinate),
|
||||||
DM(dm::Coordinate),
|
DM(dmm::Coordinate),
|
||||||
// UTM(utm::UTMCoordinate),
|
// UTM(utm::UTMCoordinate),
|
||||||
// Plus(plus::PlusCoordinate),
|
// Plus(plus::PlusCoordinate),
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ impl FromStr for Coordinate {
|
|||||||
alt((
|
alt((
|
||||||
map(dd::parse_coordinate, Coordinate::DD),
|
map(dd::parse_coordinate, Coordinate::DD),
|
||||||
map(dms::parse_coordinate, Coordinate::DMS),
|
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(utm::parse_coordinate, Coordinate::UTM),
|
||||||
// map(plus::parse_coordinate, Coordinate::PLUS),
|
// map(plus::parse_coordinate, Coordinate::PLUS),
|
||||||
)),
|
)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user