Skip to main content

proj_core/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Pure-Rust coordinate transformation library.
4//!
5//! No C dependencies, no unsafe, WASM-compatible.
6//!
7//! The primary type is [`Transform`], which provides CRS-to-CRS coordinate
8//! transformation using authority codes (e.g., `"EPSG:4326"`).
9//! For area-aware or policy-constrained selection, use
10//! [`Transform::with_selection_options`] and inspect
11//! [`Transform::selected_operation`] /
12//! [`Transform::selection_diagnostics`].
13//! The [`registry`], [`operation`], and [`grid`] modules expose the embedded
14//! operation catalog, selection metadata, and NTv2 grid-provider interfaces.
15//! `convert_3d` preserves `z` when no explicit vertical CRS is present or when
16//! source and target compound CRS definitions have identical vertical
17//! components. It converts `z` units when both vertical components use the same
18//! vertical reference frame with different linear units. Grid/geoid height
19//! transformations require explicit vertical grid operations and caller-supplied
20//! grid resources; otherwise they are rejected.
21//!
22//! # Example
23//!
24//! ```
25//! use proj_core::Transform;
26//!
27//! // Create a transform from WGS84 geographic to Web Mercator
28//! let t = Transform::new("EPSG:4326", "EPSG:3857").unwrap();
29//!
30//! // Transform NYC coordinates (lon, lat in degrees) → (x, y in meters)
31//! let (x, y) = t.convert((-74.006, 40.7128)).unwrap();
32//! assert!((x - (-8238310.0)).abs() < 100.0);
33//!
34//! // Inverse: Web Mercator → WGS84
35//! let inv = Transform::new("EPSG:3857", "EPSG:4326").unwrap();
36//! let (lon, lat) = inv.convert((x, y)).unwrap();
37//! assert!((lon - (-74.006)).abs() < 1e-6);
38//! ```
39
40pub mod coord;
41pub mod crs;
42pub mod datum;
43pub mod ellipsoid;
44mod epsg_db;
45pub mod error;
46mod geocentric;
47pub mod grid;
48mod helmert;
49pub mod operation;
50mod projection;
51pub mod registry;
52mod selector;
53pub mod transform;
54
55pub use coord::{Bounds, Coord, Coord3D, Transformable, Transformable3D};
56pub use crs::{
57    CompoundCrsDef, CrsDef, GeographicCrsDef, HorizontalCrsDef, LinearUnit, ProjectedCrsDef,
58    ProjectionMethod, VerticalCrsDef, VerticalCrsKind,
59};
60pub use datum::{Datum, DatumGridShift, DatumGridShiftEntry, DatumToWgs84, HelmertParams};
61pub use ellipsoid::Ellipsoid;
62pub use error::{Error, Result};
63pub use grid::{
64    EmbeddedGridProvider, FilesystemGridProvider, GridDefinition, GridError, GridFormat,
65    GridHandle, GridProvider, GridSample, VerticalGridSample,
66};
67pub use operation::{
68    AreaOfInterest, AreaOfInterestCrs, AreaOfUse, CoordinateOperation, CoordinateOperationId,
69    CoordinateOperationMetadata, GridCoverageMiss, GridId, GridInterpolation, GridShiftDirection,
70    OperationAccuracy, OperationMatchKind, OperationMethod, OperationSelectionDiagnostics,
71    OperationStep, OperationStepDirection, SelectionOptions, SelectionPolicy, SelectionReason,
72    SkippedOperation, SkippedOperationReason, TransformOutcome, VerticalGridOffsetConvention,
73    VerticalGridOperation, VerticalGridProvenance, VerticalTransformAction,
74    VerticalTransformDiagnostics,
75};
76pub use registry::{
77    lookup_authority_code, lookup_datum_epsg, lookup_epsg, lookup_operation, lookup_vertical_epsg,
78    operation_candidates_between, operation_candidates_between_with_selection_options,
79    operations_between,
80};
81pub use transform::Transform;