[−][src]Struct elastic_types::geo::point::GeoPoint
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]
TMapping: GeoPointMapping,
pub fn new<I>(point: I) -> Self where
I: Into<P<f64>>,
[src]
I: Into<P<f64>>,
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));
pub fn build(x: f64, y: f64) -> Self
[src]
Creates an GeoPoint
from the given x
and y
primitives:
let point: GeoPoint<DefaultGeoPointMapping> = GeoPoint::build(1.0, 1.0);
pub fn remap<TNewMapping>(point: GeoPoint<TMapping>) -> GeoPoint<TNewMapping> where
TNewMapping: GeoPointMapping,
[src]
TNewMapping: GeoPointMapping,
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 = P<f64>>
pub fn x(&self) -> T
[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);
pub fn y(&self) -> T
[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);
pub fn lng(&self) -> T
[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);
pub fn lat(&self) -> T
[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);
pub fn dot(&self, point: &Point<T>) -> T
[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);
Trait Implementations
impl<TMapping> GeoPointFieldType<TMapping> for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
impl<TMapping: PartialEq> PartialEq<GeoPoint<TMapping>> for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
fn eq(&self, other: &GeoPoint<TMapping>) -> bool
[src]
fn ne(&self, other: &GeoPoint<TMapping>) -> bool
[src]
impl<M> PartialEq<Point<f64>> for GeoPoint<M> where
M: GeoPointMapping,
[src]
M: GeoPointMapping,
impl<M> PartialEq<GeoPoint<M>> for P<f64> where
M: GeoPointMapping,
[src]
M: GeoPointMapping,
impl<M> From<Point<f64>> for GeoPoint<M> where
M: GeoPointMapping,
[src]
M: GeoPointMapping,
impl<TMapping> From<Coordinate<f64>> for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
impl<TMapping: Clone> Clone for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
fn clone(&self) -> GeoPoint<TMapping>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<M> Deref for GeoPoint<M> where
M: GeoPointMapping,
[src]
M: GeoPointMapping,
impl<TMapping: Debug> Debug for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
impl<M> Borrow<Point<f64>> for GeoPoint<M> where
M: GeoPointMapping,
[src]
M: GeoPointMapping,
impl<TMapping> ToGeo<f64> for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
impl<TMapping> Serialize for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
impl<'de, TMapping> Deserialize<'de> for GeoPoint<TMapping> where
TMapping: GeoPointMapping,
[src]
TMapping: GeoPointMapping,
fn deserialize<D>(deserializer: D) -> Result<GeoPoint<TMapping>, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl<TMapping> Send for GeoPoint<TMapping> where
TMapping: Send,
TMapping: Send,
impl<TMapping> Sync for GeoPoint<TMapping> where
TMapping: Sync,
TMapping: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,