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
impl Crs
Sourcepub fn from_proj_string(s: &str) -> Result<Self, CrsError>
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();Sourcepub fn from_epsg(code: u16) -> Result<Self, CrsError>
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();Sourcepub fn from_wkt(wkt: &str) -> Result<Self, CrsError>
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.
Sourcepub fn is_geographic(&self) -> bool
pub fn is_geographic(&self) -> bool
Whether this CRS is geographic (lon/lat), whose coordinates are
carried in radians by proj4rs.