Skip to main content

Crate loose_dms

Crate loose_dms 

Source
Expand description

§loose_dms

This crate provides functionality to parse coordinates from strings in Degrees Minutes Seconds (DMS) or decimal degrees format, accommodating various separators and hemisphere indicators. It aims to be “loose” in the sense of allowing flexible formatting while ensuring that the parsed values are valid geographical coordinates.

Note: This crate is a direct port of the parse-dms javascript library by gmaclennan. Big thanks to the original author for their work.

§Features

  • Supports DMS strings with degrees, minutes, and seconds.
  • Accommodates hemispheres (N, E, S, W) in various positions.
  • Parses decimal degrees directly.
  • Returns structured Coordinate objects with lat and lng fields.

§Example

use loose_dms::parse;

let coord = parse("59°12'7.7\"N 02°15'39.6\"W").unwrap();
assert_eq!(coord.lat, 59.20213888888889);
assert_eq!(coord.lng, -2.261);

Structs§

Coordinate
A geographical coordinate expressed as latitude and longitude in decimal degrees.

Enums§

Error

Functions§

parse
Parse coordinates from a variety of string formats.