Struct elastic::types::prelude::GeoPoint [] [src]

pub struct GeoPoint<TMapping> where
    TMapping: GeoPointMapping
{ /* fields omitted */ }

An Elasticsearch geo_point type with a format.

The format is provided as a generic parameter. This struct wraps up a geo::Point struct, which have an x and y floating point value.

Examples

Defining a geo point using the default format:

let point: GeoPoint<DefaultGeoPointMapping> = GeoPoint::build(1.0, 1.0);

Defining a geo point using a named format:

let point: GeoPoint<DefaultGeoPointMapping<GeoPointString>> = GeoPoint::build(1.0, 1.0);

Accessing the values of a geo point:

let point: GeoPoint<DefaultGeoPointMapping> = GeoPoint::build(1.0, 1.0);

//eg: (1.0,1.0)
println!("({},{})",
    point.x(),
    point.y()
);

Links

Methods

impl<TMapping> GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

[src]

Creates a new GeoPoint from the given coordinate.

This function will consume the provided Coordinate.

Examples

use geo::{ Point, Coordinate };
use elastic_types::prelude::*;
    
//Create a geo Coordinate struct
let coord = Coordinate { x: 1.0, y: 1.0 };
    
//Give it to the GeoPoint struct
let point: GeoPoint<DefaultGeoPointMapping> = GeoPoint::new(Point(coord));

[src]

Creates an GeoPoint from the given x and y primitives:

let point: GeoPoint<DefaultGeoPointMapping> = GeoPoint::build(1.0, 1.0);

[src]

Change the format/mapping of this geo point.

Examples

//Get a point formatted as a string
let point: GeoPoint<DefaultGeoPointMapping<GeoPointString>> = GeoPoint::build(1.0, 1.0);
    
//Change the format to an object
let otherpoint: GeoPoint<DefaultGeoPointMapping<GeoPointObject>> = GeoPoint::remap(point);

Methods from Deref<Target = Point<f64>>

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

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

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

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

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<TMapping> PartialEq<GeoPoint<TMapping>> for GeoPoint<TMapping> where
    TMapping: PartialEq<TMapping> + GeoPointMapping
[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<M> PartialEq<GeoPoint<M>> for Point<f64> where
    M: GeoPointMapping
[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<M> PartialEq<Point<f64>> for GeoPoint<M> where
    M: GeoPointMapping
[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<TMapping> Clone for GeoPoint<TMapping> where
    TMapping: Clone + GeoPointMapping
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'de, TMapping> Deserialize<'de> for GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

[src]

Deserialize this value from the given Serde deserializer. Read more

impl<TMapping> ToGeo<f64> for GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

[src]

impl<M> Deref for GeoPoint<M> where
    M: GeoPointMapping
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<TMapping> GeoPointFieldType<TMapping> for GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

impl<M> Borrow<Point<f64>> for GeoPoint<M> where
    M: GeoPointMapping
[src]

[src]

Immutably borrows from an owned value. Read more

impl<TMapping> Serialize for GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl<TMapping> From<Coordinate<f64>> for GeoPoint<TMapping> where
    TMapping: GeoPointMapping
[src]

[src]

Performs the conversion.

impl<M> From<Point<f64>> for GeoPoint<M> where
    M: GeoPointMapping
[src]

[src]

Performs the conversion.

impl<TMapping> Debug for GeoPoint<TMapping> where
    TMapping: Debug + GeoPointMapping
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<TMapping> Send for GeoPoint<TMapping> where
    TMapping: Send

impl<TMapping> Sync for GeoPoint<TMapping> where
    TMapping: Sync