Struct geocoding::Point [] [src]

pub struct Point<T>(pub Coordinate<T>)
where
    T: CoordinateType
;

A single Point in 2D space.

Points can be created using the new(x, y) constructor, or from a Coordinate or pair of points.

use geo::{Point, Coordinate};
let p1: Point<f64> = (0., 1.).into();
let c = Coordinate{ x: 10., y: 20.};
let p2: Point<f64> = c.into();

Methods

impl<T> Point<T> where
    T: CoordinateType + ToPrimitive
[src]

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

Returns the cross product of 3 points. A positive value implies selfpoint_bpoint_c is counter-clockwise, negative implies clockwise.

Examples

use geo::Point;
 
let p_a = Point::new(1.0, 2.0);
let p_b = Point::new(3.0,5.0);
let p_c = Point::new(7.0,12.0);
 
let cross = p_a.cross_prod(&p_b, &p_c);
 
assert_eq!(cross, 2.0)

Trait Implementations

impl<T> PointN for Point<T> where
    T: Float + SpadeNum + Debug
[src]

The points's internal scalar type.

[src]

The (fixed) number of dimensions of this point type.

[src]

Creates a new point with all components set to a certain value.

[src]

Returns the nth element of this point.

[src]

Returns a mutable reference to the nth element of this point.

impl<T> Neg for Point<T> where
    T: CoordinateType + Neg<Output = T> + ToPrimitive
[src]

The resulting type after applying the - operator.

[src]

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> Centroid<T> for Point<T> where
    T: Float
[src]

[src]

See: https://en.wikipedia.org/wiki/Centroid Read more

impl<T> Serialize for Point<T> where
    T: CoordinateType + Serialize
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl<T> Sub<Point<T>> for Point<T> where
    T: CoordinateType + ToPrimitive
[src]

The resulting type after applying the - operator.

[src]

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> Rotate<T> for Point<T> where
    T: Float
[src]

[src]

Rotate the Point about itself by the given number of degrees This operation leaves the point coordinates unchanged

impl<T> TwoDimensional for Point<T> where
    T: Float + SpadeNum + Debug
[src]

impl<T> Copy for Point<T> where
    T: Copy + CoordinateType
[src]

impl<T> MapCoordsInplace<T> for Point<T> where
    T: CoordinateType
[src]

[src]

Apply a function to all the coordinates in a geometric object, in place Read more

impl<T, NT> MapCoords<T, NT> for Point<T> where
    NT: CoordinateType,
    T: CoordinateType
[src]

[src]

Apply a function to all the coordinates in a geometric object, returning a new object. Read more

impl<T> PartialEq<Point<T>> for Point<T> where
    T: PartialEq<T> + CoordinateType
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T> Clone for Point<T> where
    T: Clone + CoordinateType
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T> Add<Point<T>> for Point<T> where
    T: CoordinateType + ToPrimitive
[src]

The resulting type after applying the + operator.

[src]

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<'de, T> Deserialize<'de> for Point<T> where
    T: CoordinateType + Deserialize<'de>, 
[src]

[src]

Deserialize this value from the given Serde deserializer. Read more

impl<T> Distance<T, Point<T>> for MultiPolygon<T> where
    T: Float
[src]

[src]

Minimum distance from a MultiPolygon to a Point

impl<T> Distance<T, MultiPolygon<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Point to a MultiPolygon

impl<T> Distance<T, MultiLineString<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Point to a MultiLineString

impl<T> Distance<T, Polygon<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Point to a Polygon

impl<T> Distance<T, Point<T>> for LineString<T> where
    T: Float
[src]

[src]

Minimum distance from a LineString to a Point

impl<T> Distance<T, Point<T>> for Line<T> where
    T: Float
[src]

[src]

Minimum distance from a Line to a Point

impl<T> Distance<T, Line<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Line to a Point

impl<T> Distance<T, LineString<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Point to a LineString

impl<T> Distance<T, Point<T>> for MultiLineString<T> where
    T: Float
[src]

[src]

Minimum distance from a MultiLineString to a Point

impl<T> Distance<T, Point<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance between two Points

impl<T> Distance<T, Point<T>> for Polygon<T> where
    T: Float
[src]

[src]

Minimum distance from a Polygon to a Point

impl<T> Distance<T, MultiPoint<T>> for Point<T> where
    T: Float
[src]

[src]

Minimum distance from a Point to a MultiPoint

impl<T> Distance<T, Point<T>> for MultiPoint<T> where
    T: Float
[src]

[src]

Minimum distance from a MultiPoint to a Point

impl<T> Bearing<T> for Point<T> where
    T: Float + FromPrimitive
[src]

[src]

Returns the bearing to another Point in degrees, where North is 0° and East is 45°. Read more

impl<F> ClosestPoint<F, Point<F>> for Polygon<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for MultiPolygon<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<'a, F, C> ClosestPoint<F, Point<F>> for &'a C where
    C: ClosestPoint<F, Point<F>>,
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for Line<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for MultiLineString<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for Point<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for LineString<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<F> ClosestPoint<F, Point<F>> for MultiPoint<F> where
    F: Float
[src]

[src]

Find the closest point between self and p.

impl<T> Intersects<Line<T>> for Point<T> where
    T: Float
[src]

[src]

Checks if the geometry A intersects the geometry B. Read more

impl<T> Intersects<Point<T>> for Line<T> where
    T: Float
[src]

[src]

Checks if the geometry A intersects the geometry B. Read more

impl<T> HaversineDistance<T, Point<T>> for Point<T> where
    T: Float + FromPrimitive
[src]

[src]

Returns the Haversine distance between two points: Read more

impl<T> From<Point<T>> for Geometry<T> where
    T: CoordinateType
[src]

[src]

Performs the conversion.

impl<T> From<(T, T)> for Point<T> where
    T: CoordinateType
[src]

[src]

Performs the conversion.

impl<T> From<Coordinate<T>> for Point<T> where
    T: CoordinateType
[src]

[src]

Performs the conversion.

impl<T> Contains<Point<T>> for Point<T> where
    T: Float + ToPrimitive
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Contains<Point<T>> for Bbox<T> where
    T: CoordinateType
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Contains<Point<T>> for LineString<T> where
    T: Float
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Contains<Point<T>> for MultiPolygon<T> where
    T: Float
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Contains<Point<T>> for Line<T> where
    T: Float
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Contains<Point<T>> for Polygon<T> where
    T: Float
[src]

[src]

Checks if the geometry A is completely inside the B geometry. Read more

impl<T> Debug for Point<T> where
    T: Debug + CoordinateType
[src]

[src]

Formats the value using the given formatter. Read more

impl<T> HaversineDestination<T> for Point<T> where
    T: Float + FromPrimitive
[src]

[src]

Returns a new Point using distance to the existing Point and a bearing for the direction Read more

Auto Trait Implementations

impl<T> Send for Point<T> where
    T: Send

impl<T> Sync for Point<T> where
    T: Sync