Trait proj::Coord

source ·
pub trait Coord<T>where
    T: CoordinateType,{
    // Required methods
    fn x(&self) -> T;
    fn y(&self) -> T;
    fn from_xy(x: T, y: T) -> Self;
}
Expand description

A point in two dimensional space. The primary unit of input/output for proj.

By default, any numeric (x, y) tuple implements Coord, but you can conform your type to Coord to pass it directly into proj.

See the geo-types feature for interop with the geo-types crate

Required Methods§

source

fn x(&self) -> T

source

fn y(&self) -> T

source

fn from_xy(x: T, y: T) -> Self

Implementations on Foreign Types§

source§

impl<T: CoordinateType> Coord<T> for Point<T>

 extern crate proj;
 use proj::Proj;
 use geo_types::Point;

 let from = "EPSG:2230";
 let to = "EPSG:26946";
 let nad_ft_to_m = Proj::new_known_crs(&from, &to, None).unwrap();
 let result = nad_ft_to_m
     .convert(Point::new(4760096.421921f64, 3744293.729449f64))
     .unwrap();
 assert_relative_eq!(result.x(), 1450880.29f64, epsilon=1.0e-2);
 assert_relative_eq!(result.y(), 1141263.01f64, epsilon=1.0e-2);
source§

fn x(&self) -> T

source§

fn y(&self) -> T

source§

fn from_xy(x: T, y: T) -> Self

source§

impl<T: CoordinateType> Coord<T> for (T, T)

source§

fn x(&self) -> T

source§

fn y(&self) -> T

source§

fn from_xy(x: T, y: T) -> Self

source§

impl<T: CoordinateType> Coord<T> for Coord<T>

 extern crate proj;
 use proj::Proj;
 use geo_types::coord;

 let from = "EPSG:2230";
 let to = "EPSG:26946";
 let nad_ft_to_m = Proj::new_known_crs(&from, &to, None).unwrap();
 let result = nad_ft_to_m
     .convert(coord! { x: 4760096.421921f64, y: 3744293.729449f64 })
     .unwrap();
 assert_relative_eq!(result.x, 1450880.29f64, epsilon=1.0e-2);
 assert_relative_eq!(result.y, 1141263.01f64, epsilon=1.0e-2);
source§

fn x(&self) -> T

source§

fn y(&self) -> T

source§

fn from_xy(x: T, y: T) -> Self

Implementors§