Skip to main content

Crs

Struct Crs 

Source
pub struct Crs { /* private fields */ }
Expand description

A coordinate reference system the reprojection functions transform between.

Thin newtype over proj4rs::Proj; construct it from a proj4 string (Crs::from_proj_string), an EPSG code (Crs::from_epsg), or a WKT definition (Crs::from_wkt).

Implementations§

Source§

impl Crs

Source

pub fn from_proj_string(s: &str) -> Result<Self, CrsError>

Build a CRS from a proj4 definition string, e.g. "+proj=utm +zone=32 +datum=WGS84".

§Errors

CrsError::Proj if proj4rs rejects the string.

§Examples
use geometry_proj::Crs;
let wgs84 = Crs::from_proj_string("+proj=longlat +datum=WGS84 +no_defs").unwrap();
Source

pub fn from_epsg(code: u16) -> Result<Self, CrsError>

Build a CRS from an EPSG code, e.g. 4326 (WGS84 lon/lat) or 3857 (Web Mercator).

§Errors

CrsError::Proj if the code is unknown to proj4rs.

§Examples
use geometry_proj::Crs;
let web_mercator = Crs::from_epsg(3857).unwrap();
Source

pub fn from_wkt(wkt: &str) -> Result<Self, CrsError>

Build a CRS from a WKT definition, parsed to a proj string by proj4wkt.

§Errors

CrsError::Wkt if the WKT cannot be parsed, or CrsError::Proj if the resulting proj string is invalid.

Source

pub fn is_geographic(&self) -> bool

Whether this CRS is geographic (lon/lat), whose coordinates are carried in radians by proj4rs.

Auto Trait Implementations§

§

impl Freeze for Crs

§

impl RefUnwindSafe for Crs

§

impl Send for Crs

§

impl Sync for Crs

§

impl Unpin for Crs

§

impl UnsafeUnpin for Crs

§

impl UnwindSafe for Crs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SameAs<T> for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.