Struct elastic::types::prelude::GeoPoint
[−]
[src]
pub struct GeoPoint<F, M = DefaultGeoPointMapping<F>> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>, { /* 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<DefaultGeoPointFormat> = GeoPoint::build(1.0, 1.0);
Defining a geo point using a named format:
let point: GeoPoint<GeoPointString> = GeoPoint::build(1.0, 1.0);
Defining a geo point using a custom mapping:
let point: GeoPoint<GeoPointString, DefaultGeoPointMapping<_>> = GeoPoint::build(1.0, 1.0);
Accessing the values of a geo point:
let point: GeoPoint<DefaultGeoPointFormat> = GeoPoint::build(1.0, 1.0); //eg: (1.0,1.0) println!("({},{})", point.x(), point.y() );
Links
Methods
impl<F, M> GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
fn new<I>(point: I) -> GeoPoint<F, M> where
I: Into<Point<f64>>,
I: Into<Point<f64>>,
Creates a new GeoPoint
from the given coordinate.
This function will consume the provided Coordinate
.
Examples
use geo::{ Point, Coordinate }; use elastic_types::geo::point::{ GeoPoint, DefaultGeoPointFormat }; //Create a geo Coordinate struct let coord = Coordinate { x: 1.0, y: 1.0 }; //Give it to the GeoPoint struct let point: GeoPoint<DefaultGeoPointFormat> = GeoPoint::new(Point(coord));
fn build(x: f64, y: f64) -> GeoPoint<F, M>
Creates an GeoPoint
from the given x
and y
primitives:
let point: GeoPoint<DefaultGeoPointFormat> = GeoPoint::build(1.0, 1.0);
fn remap<FInto, MInto>(self) -> GeoPoint<FInto, MInto> where
FInto: GeoPointFormat,
MInto: GeoPointMapping<Format = FInto>,
FInto: GeoPointFormat,
MInto: GeoPointMapping<Format = FInto>,
Change the format/mapping of this geo point.
Examples
//Get a point formatted as a string let point: GeoPoint<GeoPointString> = GeoPoint::build(1.0, 1.0); //Change the format to an object let otherpoint: GeoPoint<GeoPointObject> = point.remap();
Methods from Deref<Target = Point<f64>>
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 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 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 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 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<M, F> AsRef<Point<f64>> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<F, M> ToGeo<f64> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<'de, F, M> Deserialize<'de> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
fn deserialize<D>(
deserializer: D
) -> Result<GeoPoint<F, M>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
deserializer: D
) -> Result<GeoPoint<F, M>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl<F, M> Debug for GeoPoint<F, M> where
F: Debug + GeoPointFormat,
M: Debug + GeoPointMapping<Format = F>,
[src]
F: Debug + GeoPointFormat,
M: Debug + GeoPointMapping<Format = F>,
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.
impl<F, M> Serialize for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<M, F> From<Point<f64>> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<F, M> From<Coordinate<f64>> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<M, F> PartialEq<Point<f64>> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<F, M> PartialEq<GeoPoint<F, M>> for GeoPoint<F, M> where
F: PartialEq<F> + GeoPointFormat,
M: PartialEq<M> + GeoPointMapping<Format = F>,
[src]
F: PartialEq<F> + GeoPointFormat,
M: PartialEq<M> + GeoPointMapping<Format = F>,
impl<F, M> GeoPointFieldType<M, F> for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
impl<M, F> Deref for GeoPoint<F, M> where
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
[src]
F: GeoPointFormat,
M: GeoPointMapping<Format = F>,
type Target = Point<f64>
The resulting type after dereferencing
fn deref(&self) -> &Point<f64>
The method called to dereference a value
impl<F, M> Clone for GeoPoint<F, M> where
F: Clone + GeoPointFormat,
M: Clone + GeoPointMapping<Format = F>,
[src]
F: Clone + GeoPointFormat,
M: Clone + GeoPointMapping<Format = F>,