Struct geo::Point
[−]
[src]
pub struct Point<T>(pub Coordinate<T>)
where
T: Float;
Methods
impl<T> Point<T> where
T: Float + ToPrimitive,
[src]
T: Float + ToPrimitive,
fn new(x: T, y: T) -> Point<T>
Creates a new point.
use geo::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.x(), 1.234); assert_eq!(p.y(), 2.345);
fn x(&self) -> T
Returns the x/horizontal component of the point.
use geo::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.x(), 1.234);
fn set_x(&mut self, x: T) -> &mut Point<T>
Sets the x/horizontal component of the point.
use geo::Point; let mut p = Point::new(1.234, 2.345); p.set_x(9.876); assert_eq!(p.x(), 9.876);
fn y(&self) -> T
Returns the y/vertical component of the point.
use geo::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.y(), 2.345);
fn set_y(&mut self, y: T) -> &mut Point<T>
Sets the y/vertical component of the point.
use geo::Point; let mut p = Point::new(1.234, 2.345); p.set_y(9.876); assert_eq!(p.y(), 9.876);
fn lng(&self) -> T
Returns the longitude/horizontal component of the point.
use geo::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.lng(), 1.234);
fn set_lng(&mut self, lng: T) -> &mut Point<T>
Sets the longitude/horizontal component of the point.
use geo::Point; let mut p = Point::new(1.234, 2.345); p.set_lng(9.876); assert_eq!(p.lng(), 9.876);
fn lat(&self) -> T
Returns the latitude/vertical component of the point.
use geo::Point; let p = Point::new(1.234, 2.345); assert_eq!(p.lat(), 2.345);
fn set_lat(&mut self, lat: T) -> &mut Point<T>
Sets the latitude/vertical component of the point.
use geo::Point; let mut p = Point::new(1.234, 2.345); p.set_lat(9.876); assert_eq!(p.lat(), 9.876);
fn dot(&self, point: &Point<T>) -> T
Returns the dot product of the two points:
dot = x1 * x2 + y1 * y2
use geo::Point; let p = Point::new(1.5, 0.5); let dot = p.dot(&Point::new(2.0, 4.5)); assert_eq!(dot, 5.25);
Trait Implementations
impl<T: PartialEq> PartialEq for Point<T> where
T: Float,
[src]
T: Float,
fn eq(&self, __arg_0: &Point<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Point<T>) -> bool
This method tests for !=
.
impl<T: Clone> Clone for Point<T> where
T: Float,
[src]
T: Float,
fn clone(&self) -> Point<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Copy> Copy for Point<T> where
T: Float,
[src]
T: Float,
impl<T: Debug> Debug for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Neg for Point<T> where
T: Float + Neg<Output = T> + ToPrimitive,
[src]
T: Float + Neg<Output = T> + ToPrimitive,
type Output = Point<T>
The resulting type after applying the -
operator
fn neg(self) -> Point<T>
Returns a point with the x and y components negated.
use geo::Point; let p = -Point::new(-1.25, 2.5); assert_eq!(p.x(), 1.25); assert_eq!(p.y(), -2.5);
impl<T> Add for Point<T> where
T: Float + ToPrimitive,
[src]
T: Float + ToPrimitive,
type Output = Point<T>
The resulting type after applying the +
operator
fn add(self, rhs: Point<T>) -> Point<T>
Add a point to the given point.
use geo::Point; let p = Point::new(1.25, 2.5) + Point::new(1.5, 2.5); assert_eq!(p.x(), 2.75); assert_eq!(p.y(), 5.0);
impl<T> Sub for Point<T> where
T: Float + ToPrimitive,
[src]
T: Float + ToPrimitive,
type Output = Point<T>
The resulting type after applying the -
operator
fn sub(self, rhs: Point<T>) -> Point<T>
Subtract a point from the given point.
use geo::Point; let p = Point::new(1.25, 3.0) - Point::new(1.5, 2.5); assert_eq!(p.x(), -0.25); assert_eq!(p.y(), 0.5);
impl<T> Centroid<T> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Contains<Point<T>> for Point<T> where
T: Float + ToPrimitive,
[src]
T: Float + ToPrimitive,
fn contains(&self, p: &Point<T>) -> bool
Checks if the geometry A is completely inside the B geometry. Read more
impl<T> Distance<T, Point<T>> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Distance<T, MultiPoint<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn distance(&self, points: &MultiPoint<T>) -> T
Minimum distance from a Point to a MultiPoint
impl<T> Distance<T, Polygon<T>> for Point<T> where
T: Float,
[src]
T: Float,
impl<T> Distance<T, MultiPolygon<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn distance(&self, mpolygon: &MultiPolygon<T>) -> T
Minimum distance from a Point to a MultiPolygon
impl<T> Distance<T, MultiLineString<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn distance(&self, mls: &MultiLineString<T>) -> T
Minimum distance from a Point to a MultiLineString
impl<T> Distance<T, LineString<T>> for Point<T> where
T: Float,
[src]
T: Float,
fn distance(&self, linestring: &LineString<T>) -> T
Minimum distance from a Point to a LineString
impl<T> HaversineDistance<T, Point<T>> for Point<T> where
T: Float + FromPrimitive,
[src]
T: Float + FromPrimitive,
fn haversine_distance(&self, rhs: &Point<T>) -> T
Returns the Haversine distance between two points: Read more
impl<T> Rotate<T> for Point<T> where
T: Float,
[src]
T: Float,
fn rotate(&self, angle: T) -> Self
Rotate the Point about itself by the given number of degrees This operation leaves the point coordinates unchanged
impl<T> RotatePoint<T> for Point<T> where
T: Float,
[src]
T: Float,
fn rotate_around_point(&self, angle: T, point: &Point<T>) -> Self
Rotate the Point about another point by the given number of degrees