pub struct Point3d {
pub point: Point,
pub z: f64,
}Expand description
A 3D geographic point with x, y (longitude/latitude) and z (altitude/elevation).
This type represents a point in 3D space, typically used for altitude-aware geospatial applications like drone tracking, aviation, or multi-floor buildings.
§Examples
use spatio_types::point::Point3d;
use spatio_types::geo::Point;
// Create a 3D point for a drone at 100 meters altitude
let drone_position = Point3d::new(-74.0060, 40.7128, 100.0);
assert_eq!(drone_position.altitude(), 100.0);
// Calculate 3D distance to another point
let other = Point3d::new(-74.0070, 40.7138, 150.0);
let distance = drone_position.distance_3d(&other);Fields§
§point: PointThe 2D geographic point (longitude/latitude or x/y)
z: f64The altitude/elevation/z-coordinate (in meters typically)
Implementations§
Source§impl Point3d
impl Point3d
Sourcepub fn from_point_and_altitude(point: Point, z: f64) -> Self
pub fn from_point_and_altitude(point: Point, z: f64) -> Self
Create a 3D point from a 2D point and altitude.
Sourcepub fn distance_3d(&self, other: &Point3d) -> f64
pub fn distance_3d(&self, other: &Point3d) -> f64
Calculate the 3D Euclidean distance to another 3D point.
This calculates the straight-line distance in 3D space using the Pythagorean theorem.
§Examples
use spatio_types::point::Point3d;
let p1 = Point3d::new(0.0, 0.0, 0.0);
let p2 = Point3d::new(3.0, 4.0, 12.0);
let distance = p1.distance_3d(&p2);
assert_eq!(distance, 13.0); // 3-4-5 triangle extended to 3DSourcepub fn haversine_distances(&self, other: &Point3d) -> (f64, f64, f64)
pub fn haversine_distances(&self, other: &Point3d) -> (f64, f64, f64)
Calculate all distance components at once (horizontal, altitude, 3D).
This is more efficient than calling haversine_2d and haversine_3d separately as it calculates the haversine formula only once.
§Returns
Tuple of (horizontal_distance, altitude_difference, distance_3d) in meters.
§Examples
use spatio_types::point::Point3d;
let p1 = Point3d::new(-74.0060, 40.7128, 0.0);
let p2 = Point3d::new(-74.0070, 40.7138, 100.0);
let (h_dist, alt_diff, dist_3d) = p1.haversine_distances(&p2);Sourcepub fn haversine_3d(&self, other: &Point3d) -> f64
pub fn haversine_3d(&self, other: &Point3d) -> f64
Calculate the haversine distance combined with altitude difference.
This uses the haversine formula for the horizontal distance (considering Earth’s curvature) and combines it with the altitude difference using the Pythagorean theorem.
§Returns
Distance in meters.
§Examples
use spatio_types::point::Point3d;
let p1 = Point3d::new(-74.0060, 40.7128, 0.0); // NYC sea level
let p2 = Point3d::new(-74.0070, 40.7138, 100.0); // Nearby, 100m up
let distance = p1.haversine_3d(&p2);Sourcepub fn haversine_2d(&self, other: &Point3d) -> f64
pub fn haversine_2d(&self, other: &Point3d) -> f64
Sourcepub fn altitude_difference(&self, other: &Point3d) -> f64
pub fn altitude_difference(&self, other: &Point3d) -> f64
Get the altitude difference to another point.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Point3d
impl<'de> Deserialize<'de> for Point3d
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>,
impl StructuralPartialEq for Point3d
Auto Trait Implementations§
impl Freeze for Point3d
impl RefUnwindSafe for Point3d
impl Send for Point3d
impl Sync for Point3d
impl Unpin for Point3d
impl UnwindSafe for Point3d
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more