pub struct Lon(/* private fields */);
Expand description
Latitude and Longitude are stored internally as a 32-bit signed integer, in units
of COORD_PRECISION_NANOS
.
This gives us 7 decimal places of precision - the same precision that OSM uses.
use std::convert::TryFrom;
use osmio::Lat;
let lat = Lat::try_from(1.0).unwrap();
let float_lat: f64 = lat.into();
assert_eq!(float_lat, 1.);
Implementations§
source§impl Lon
impl Lon
sourcepub fn from_inner(inner: i32) -> Self
pub fn from_inner(inner: i32) -> Self
Build a Lat/Lon from it’s inner representation, which is degrees * 1e7
.
use osmio::Lat;
// build a Lat for 1.2345678 degrees South
let lat = Lat::from_inner(12345678);
pub fn inner(&self) -> i32
sourcepub fn degrees(&self) -> f64
pub fn degrees(&self) -> f64
Returns the number of degrees as a 64-bit float.
Note: The actual precision is COORD_PRECISION_NANOS
, which is less than
64-bits. It is derived from an inner i32 representation, which mirrors the
precision used by OpenStreetMap.org
Trait Implementations§
source§impl<'de> Deserialize<'de> for Lon
impl<'de> Deserialize<'de> for Lon
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl FromStr for Lon
impl FromStr for Lon
use osmio::Lat;
use std::str::FromStr;
let lat = Lat::from_str("1.23").unwrap();
assert_eq!(1.23, lat.degrees());
assert_eq!(12300000, lat.inner());
assert!(Lat::from_str("-180.0").is_ok());
assert!(Lat::from_str("xxxx").is_err());
assert!(Lat::from_str("600.0").is_err());
source§impl Ord for Lon
impl Ord for Lon
source§impl PartialOrd for Lon
impl PartialOrd for Lon
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Lon
impl Eq for Lon
impl StructuralEq for Lon
impl StructuralPartialEq for Lon
Auto Trait Implementations§
impl RefUnwindSafe for Lon
impl Send for Lon
impl Sync for Lon
impl Unpin for Lon
impl UnwindSafe for Lon
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more