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//!
16//! # Example
17//!
18//! ```
19//! use proj_core::Transform;
20//!
21//! // Create a transform from WGS84 geographic to Web Mercator
22//! let t = Transform::new("EPSG:4326", "EPSG:3857").unwrap();
23//!
24//! // Transform NYC coordinates (lon, lat in degrees) → (x, y in meters)
25//! let (x, y) = t.convert((-74.006, 40.7128)).unwrap();
26//! assert!((x - (-8238310.0)).abs() < 100.0);
27//!
28//! // Inverse: Web Mercator → WGS84
29//! let inv = Transform::new("EPSG:3857", "EPSG:4326").unwrap();
30//! let (lon, lat) = inv.convert((x, y)).unwrap();
31//! assert!((lon - (-74.006)).abs() < 1e-6);
32//! ```
33
34pub mod coord;
35pub mod crs;
36pub mod datum;
37pub mod ellipsoid;
38mod epsg_db;
39pub mod error;
40mod geocentric;
41pub mod grid;
42mod helmert;
43pub mod operation;
44mod projection;
45pub mod registry;
46mod selector;
47pub mod transform;
48
49pub use coord::{Bounds, Coord, Coord3D, Transformable, Transformable3D};
50pub use crs::{CrsDef, GeographicCrsDef, LinearUnit, ProjectedCrsDef, ProjectionMethod};
51pub use datum::{Datum, DatumToWgs84, HelmertParams};
52pub use ellipsoid::Ellipsoid;
53pub use error::{Error, Result};
54pub use grid::{
55    EmbeddedGridProvider, FilesystemGridProvider, GridDefinition, GridError, GridFormat,
56    GridHandle, GridProvider, GridSample,
57};
58pub use operation::{
59    AreaOfInterest, AreaOfInterestCrs, AreaOfUse, CoordinateOperation, CoordinateOperationId,
60    CoordinateOperationMetadata, GridId, GridInterpolation, GridShiftDirection, OperationAccuracy,
61    OperationMatchKind, OperationMethod, OperationSelectionDiagnostics, OperationStep,
62    OperationStepDirection, SelectionOptions, SelectionPolicy, SelectionReason, SkippedOperation,
63    SkippedOperationReason,
64};
65pub use registry::{
66    lookup_authority_code, lookup_datum_epsg, lookup_epsg, lookup_operation, operations_between,
67};
68pub use transform::Transform;