pub struct Transform { /* private fields */ }Expand description
A reusable coordinate transformation between two CRS.
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").
Sourcepub fn with_selection_options(
from_crs: &str,
to_crs: &str,
options: SelectionOptions,
) -> Result<Self>
pub fn with_selection_options( from_crs: &str, to_crs: &str, options: SelectionOptions, ) -> Result<Self>
Create a transform with explicit selection options.
Sourcepub fn from_operation(
operation_id: CoordinateOperationId,
from_crs: &str,
to_crs: &str,
) -> Result<Self>
pub fn from_operation( operation_id: CoordinateOperationId, from_crs: &str, to_crs: &str, ) -> Result<Self>
Create a transform from an explicit registry operation id.
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.
Sourcepub fn from_horizontal_components(from: &CrsDef, to: &CrsDef) -> Result<Self>
pub fn from_horizontal_components(from: &CrsDef, to: &CrsDef) -> Result<Self>
Create a horizontal-only transform from explicit CRS definitions.
Compound CRS inputs are reduced to their horizontal component before operation selection. This is intended for XY-only workflows where vertical transformation is deliberately out of scope.
Sourcepub fn from_horizontal_components_with_selection_options(
from: &CrsDef,
to: &CrsDef,
options: SelectionOptions,
) -> Result<Self>
pub fn from_horizontal_components_with_selection_options( from: &CrsDef, to: &CrsDef, options: SelectionOptions, ) -> Result<Self>
Create a horizontal-only transform from explicit CRS definitions with operation-selection options.
Sourcepub fn from_crs_defs_with_selection_options(
from: &CrsDef,
to: &CrsDef,
options: SelectionOptions,
) -> Result<Self>
pub fn from_crs_defs_with_selection_options( from: &CrsDef, to: &CrsDef, options: SelectionOptions, ) -> Result<Self>
Create a transform from explicit CRS definitions with operation-selection options.
Use this when a custom CRS references grid resources and the transform
needs an application-supplied crate::grid::GridProvider.
Sourcepub fn convert<T: Transformable>(&self, coord: T) -> Result<T>
pub fn convert<T: Transformable>(&self, coord: T) -> Result<T>
Transform a single coordinate.
Sourcepub fn convert_geometry<T: TransformableGeometry>(
&self,
geometry: T,
) -> Result<T>
pub fn convert_geometry<T: TransformableGeometry>( &self, geometry: T, ) -> Result<T>
Transform a whole geo-types geometry.
This method is available only with the geo-types feature. It
transforms coordinates in geometry storage order and returns the first
coordinate error without producing a partial result.
geo_types::Rect is treated as a source bounds envelope and converted
to sampled axis-aligned target bounds with 21 intermediate points per
edge. This is an approximation for nonlinear projections: extrema can
occur between samples. Use Self::convert_rect when the rect sampling
density should be chosen by the caller.
Sourcepub fn convert_rect(
&self,
rect: Rect<f64>,
densify_points: usize,
) -> Result<Rect<f64>>
pub fn convert_rect( &self, rect: Rect<f64>, densify_points: usize, ) -> Result<Rect<f64>>
Transform a geo_types::Rect to sampled axis-aligned target bounds.
This method is available only with the geo-types feature. A rect
represents an envelope, not a true geometry, so nonlinear projections can
have edge extrema between samples. Increase densify_points to sample
edges more finely for higher-fidelity bounds, or use
Self::transform_bounds directly when working with Bounds.
densify_points is the number of intermediate samples added per edge
and must be no larger than MAX_BOUNDS_DENSIFY_POINTS.
Sourcepub fn convert_3d<T: Transformable3D>(&self, coord: T) -> Result<T>
pub fn convert_3d<T: Transformable3D>(&self, coord: T) -> Result<T>
Transform a single 3D coordinate.
Sourcepub fn convert_with_diagnostics<T: Transformable>(
&self,
coord: T,
) -> Result<TransformOutcome<T>>
pub fn convert_with_diagnostics<T: Transformable>( &self, coord: T, ) -> Result<TransformOutcome<T>>
Transform a single coordinate and report the operation actually used.
This 2D API is XY-only: it does not apply or sample configured vertical transforms.
When the selected grid-backed operation misses grid coverage, this reports the coverage misses and the lower-ranked fallback operation that produced the result.
Sourcepub fn convert_3d_with_diagnostics<T: Transformable3D>(
&self,
coord: T,
) -> Result<TransformOutcome<T>>
pub fn convert_3d_with_diagnostics<T: Transformable3D>( &self, coord: T, ) -> Result<TransformOutcome<T>>
Transform a single 3D coordinate and report the operation actually used.
When the selected grid-backed operation misses grid coverage, this reports the coverage misses and the lower-ranked fallback operation that produced the result.
Sourcepub fn source_crs(&self) -> &CrsDef
pub fn source_crs(&self) -> &CrsDef
Return the source CRS definition for this transform.
Sourcepub fn target_crs(&self) -> &CrsDef
pub fn target_crs(&self) -> &CrsDef
Return the target CRS definition for this transform.
Sourcepub fn selected_operation(&self) -> &CoordinateOperationMetadata
pub fn selected_operation(&self) -> &CoordinateOperationMetadata
Return metadata for the selected coordinate operation.
Sourcepub fn selection_diagnostics(&self) -> &OperationSelectionDiagnostics
pub fn selection_diagnostics(&self) -> &OperationSelectionDiagnostics
Return selection diagnostics for this transform.
Sourcepub fn vertical_diagnostics(&self) -> &VerticalTransformDiagnostics
pub fn vertical_diagnostics(&self) -> &VerticalTransformDiagnostics
Return diagnostics for the vertical component of this transform.
Sourcepub fn inverse(&self) -> Result<Self>
pub fn inverse(&self) -> Result<Self>
Build the inverse transform by swapping the source and target CRS.
Sourcepub fn transform_bounds(
&self,
bounds: Bounds,
densify_points: usize,
) -> Result<Bounds>
pub fn transform_bounds( &self, bounds: Bounds, densify_points: usize, ) -> Result<Bounds>
Reproject a 2D bounding box by sampling its perimeter.
densify_points is the number of intermediate samples added per edge
and must be no larger than MAX_BOUNDS_DENSIFY_POINTS.
Sourcepub fn transform_geographic_wrapped_bounds(
&self,
bounds: Bounds,
densify_points: usize,
) -> Result<Bounds>
pub fn transform_geographic_wrapped_bounds( &self, bounds: Bounds, densify_points: usize, ) -> Result<Bounds>
Reproject a geographic bounding box that crosses the antimeridian.
bounds is interpreted as west/south/east/north in source geographic
degrees and must satisfy west > east. Projected and normal
non-wrapped bounds should use Self::transform_bounds.
densify_points is the number of intermediate samples added per edge
and must be no larger than MAX_BOUNDS_DENSIFY_POINTS.
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_3d<T: Transformable3D + Clone>(
&self,
coords: &[T],
) -> Result<Vec<T>>
pub fn convert_batch_3d<T: Transformable3D + Clone>( &self, coords: &[T], ) -> Result<Vec<T>>
Batch transform of 3D coordinates (sequential).
Sourcepub fn convert_coords_in_place(&self, coords: &mut [Coord]) -> Result<()>
pub fn convert_coords_in_place(&self, coords: &mut [Coord]) -> Result<()>
Transform 2D coordinates in place without allocating.
Coordinates before a failing coordinate are left converted; the failing coordinate and subsequent coordinates are left unchanged.
Sourcepub fn convert_coords_3d_in_place(&self, coords: &mut [Coord3D]) -> Result<()>
pub fn convert_coords_3d_in_place(&self, coords: &mut [Coord3D]) -> Result<()>
Transform 3D coordinates in place without allocating.
Coordinates before a failing coordinate are left converted; the failing coordinate and subsequent coordinates are left unchanged.
Sourcepub fn convert_coords_into(
&self,
input: &[Coord],
output: &mut [Coord],
) -> Result<()>
pub fn convert_coords_into( &self, input: &[Coord], output: &mut [Coord], ) -> Result<()>
Transform 2D coordinates from input into an existing output slice.
output must have exactly the same length as input. This API performs
no allocation and does not require cloning input coordinates.
Sourcepub fn convert_coords_3d_into(
&self,
input: &[Coord3D],
output: &mut [Coord3D],
) -> Result<()>
pub fn convert_coords_3d_into( &self, input: &[Coord3D], output: &mut [Coord3D], ) -> Result<()>
Transform 3D coordinates from input into an existing output slice.
output must have exactly the same length as input. This API performs
no allocation and does not require cloning input coordinates.
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.
Sourcepub fn convert_batch_parallel_3d<T: Transformable3D + Send + Sync + Clone>(
&self,
coords: &[T],
) -> Result<Vec<T>>
pub fn convert_batch_parallel_3d<T: Transformable3D + Send + Sync + Clone>( &self, coords: &[T], ) -> Result<Vec<T>>
Batch transform of 3D coordinates with adaptive Rayon parallelism.
Auto Trait Implementations§
impl !RefUnwindSafe for Transform
impl !UnwindSafe for Transform
impl Freeze for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnsafeUnpin 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