pub struct GeoBounds {
pub min_lat: f64,
pub min_lon: f64,
pub max_lat: f64,
pub max_lon: f64,
}Expand description
Geographic bounding box.
Represents a rectangular region defined by minimum and maximum latitude and longitude values.
§Examples
use spatial_narrative::core::{GeoBounds, Location};
// Create bounds for the San Francisco Bay Area
let bay_area = GeoBounds::new(37.0, -123.0, 38.5, -121.5);
// Check if a location is within bounds
let sf = Location::new(37.7749, -122.4194);
assert!(bay_area.contains(&sf));Fields§
§min_lat: f64Minimum latitude (south).
min_lon: f64Minimum longitude (west).
max_lat: f64Maximum latitude (north).
max_lon: f64Maximum longitude (east).
Implementations§
Source§impl GeoBounds
impl GeoBounds
Sourcepub fn new(min_lat: f64, min_lon: f64, max_lat: f64, max_lon: f64) -> Self
pub fn new(min_lat: f64, min_lon: f64, max_lat: f64, max_lon: f64) -> Self
Creates a new bounding box.
§Arguments
min_lat- Southern boundarymin_lon- Western boundarymax_lat- Northern boundarymax_lon- Eastern boundary
Sourcepub fn from_corners(sw: &Location, ne: &Location) -> Self
pub fn from_corners(sw: &Location, ne: &Location) -> Self
Creates bounds from two corner locations.
Sourcepub fn from_locations<'a>(
locations: impl IntoIterator<Item = &'a Location>,
) -> Option<Self>
pub fn from_locations<'a>( locations: impl IntoIterator<Item = &'a Location>, ) -> Option<Self>
Creates bounds that contain all given locations.
Sourcepub fn from_center_degrees(
center: &Location,
lat_radius: f64,
lon_radius: f64,
) -> Self
pub fn from_center_degrees( center: &Location, lat_radius: f64, lon_radius: f64, ) -> Self
Creates bounds centered on a point with given radius in degrees.
Sourcepub fn contains(&self, location: &Location) -> bool
pub fn contains(&self, location: &Location) -> bool
Checks if a location is within these bounds.
Sourcepub fn intersects(&self, other: &GeoBounds) -> bool
pub fn intersects(&self, other: &GeoBounds) -> bool
Checks if these bounds intersect with other bounds.
Sourcepub fn intersection(&self, other: &GeoBounds) -> Option<GeoBounds>
pub fn intersection(&self, other: &GeoBounds) -> Option<GeoBounds>
Returns the intersection of two bounds, if any.
Sourcepub fn union(&self, other: &GeoBounds) -> GeoBounds
pub fn union(&self, other: &GeoBounds) -> GeoBounds
Returns bounds that contain both this and other bounds.
Sourcepub fn expand_to_include(&mut self, location: &Location)
pub fn expand_to_include(&mut self, location: &Location)
Expands bounds to include the given location.
Sourcepub fn to_geo_rect(&self) -> Rect<f64>
pub fn to_geo_rect(&self) -> Rect<f64>
Converts to a geo-types Rect.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GeoBounds
impl<'de> Deserialize<'de> for GeoBounds
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 Copy for GeoBounds
impl StructuralPartialEq for GeoBounds
Auto Trait Implementations§
impl Freeze for GeoBounds
impl RefUnwindSafe for GeoBounds
impl Send for GeoBounds
impl Sync for GeoBounds
impl Unpin for GeoBounds
impl UnwindSafe for GeoBounds
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