pub struct Location {
pub lat: f64,
pub lon: f64,
pub elevation: Option<f64>,
pub uncertainty_meters: Option<f64>,
pub name: Option<String>,
}Expand description
A geographic location using WGS84 coordinates.
Locations are the fundamental spatial unit in spatial narratives. They support optional elevation and uncertainty for real-world data.
§Examples
use spatial_narrative::core::Location;
// Create a location (New York City)
let nyc = Location::new(40.7128, -74.0060);
assert!(nyc.is_valid());
// With elevation (Mount Everest)
let peak = Location::with_elevation(27.9881, 86.9250, 8848.86);
// Using the builder for more options
let approximate = Location::builder()
.coordinates(40.7, -74.0)
.uncertainty_meters(1000.0)
.name("Approximate NYC")
.build()
.unwrap();§Coordinate System
Locations use WGS84 (EPSG:4326):
- Latitude: -90° to +90° (negative = South)
- Longitude: -180° to +180° (negative = West)
- Elevation: meters above sea level (optional)
Fields§
§lat: f64Latitude in decimal degrees (-90 to 90).
lon: f64Longitude in decimal degrees (-180 to 180).
elevation: Option<f64>Elevation in meters above sea level.
uncertainty_meters: Option<f64>Uncertainty radius in meters.
name: Option<String>Human-readable place name.
Implementations§
Source§impl Location
impl Location
Sourcepub fn with_elevation(lat: f64, lon: f64, elevation: f64) -> Self
pub fn with_elevation(lat: f64, lon: f64, elevation: f64) -> Self
Creates a new location with elevation.
§Arguments
lat- Latitude in decimal degreeslon- Longitude in decimal degreeselevation- Elevation in meters above sea level
Sourcepub fn builder() -> LocationBuilder
pub fn builder() -> LocationBuilder
Creates a new builder for constructing a Location.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks if the coordinates are valid WGS84 values.
Returns true if latitude is between -90 and 90,
and longitude is between -180 and 180.
Sourcepub fn to_geo_point(&self) -> Point<f64>
pub fn to_geo_point(&self) -> Point<f64>
Returns the coordinates as a geo-types Point.
Sourcepub fn from_geo_point(point: Point<f64>) -> Self
pub fn from_geo_point(point: Point<f64>) -> Self
Creates a Location from a geo-types Point.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Location
impl<'de> Deserialize<'de> for Location
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
impl StructuralPartialEq for Location
Auto Trait Implementations§
impl Freeze for Location
impl RefUnwindSafe for Location
impl Send for Location
impl Sync for Location
impl Unpin for Location
impl UnwindSafe for Location
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