pub struct Transform { /* private fields */ }Expand description
A reusable coordinate transformation between two CRS.
Create once with Transform::new, then call convert
for each coordinate. All input/output coordinates use the CRS’s native units:
degrees (lon/lat) for geographic CRS, meters for projected CRS.
§Example
use proj_core::Transform;
let t = Transform::new("EPSG:4326", "EPSG:3857").unwrap();
let (x, y) = t.convert((-74.006, 40.7128)).unwrap();
assert!((x - (-8238310.0)).abs() < 1.0);Implementations§
Source§impl Transform
impl Transform
Sourcepub fn new(from_crs: &str, to_crs: &str) -> Result<Self>
pub fn new(from_crs: &str, to_crs: &str) -> Result<Self>
Create a transform from authority code strings (e.g., "EPSG:4326").
This is the primary constructor, matching the API pattern from C PROJ’s
Proj::new_known_crs().
Sourcepub fn from_epsg(from: u32, to: u32) -> Result<Self>
pub fn from_epsg(from: u32, to: u32) -> Result<Self>
Create a transform from EPSG codes directly.
Sourcepub fn from_crs_defs(from: &CrsDef, to: &CrsDef) -> Result<Self>
pub fn from_crs_defs(from: &CrsDef, to: &CrsDef) -> Result<Self>
Create a transform from explicit CRS definitions.
Use this for custom CRS not in the built-in registry.
Sourcepub fn convert<T: Transformable>(&self, coord: T) -> Result<T>
pub fn convert<T: Transformable>(&self, coord: T) -> Result<T>
Transform a single coordinate.
Input and output units are the native units of the respective CRS: degrees for geographic CRS, meters for projected CRS.
The return type matches the input type:
(f64, f64)in →(f64, f64)outCoordin →Coordoutgeo_types::Coord<f64>in →geo_types::Coord<f64>out (withgeo-typesfeature)
Sourcepub fn convert_batch<T: Transformable + Clone>(
&self,
coords: &[T],
) -> Result<Vec<T>>
pub fn convert_batch<T: Transformable + Clone>( &self, coords: &[T], ) -> Result<Vec<T>>
Batch transform (sequential).
Sourcepub fn convert_batch_parallel<T: Transformable + Send + Sync + Clone>(
&self,
coords: &[T],
) -> Result<Vec<T>>
pub fn convert_batch_parallel<T: Transformable + Send + Sync + Clone>( &self, coords: &[T], ) -> Result<Vec<T>>
Batch transform with Rayon parallelism.
Auto Trait Implementations§
impl Freeze for Transform
impl !RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnsafeUnpin for Transform
impl !UnwindSafe for Transform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more