geometry_proj/lib.rs
1//! Coordinate-reference-system reprojection for the geometry kernel.
2//!
3//! Boost.Geometry defers projections to its unsupported
4//! `extensions/gis/projections/`; this crate fills the gap with the
5//! pure-Rust [`proj4rs`] engine (no C dependency). Build a [`Crs`] from
6//! a proj4 string, an EPSG code, or a WKT definition, then
7//! [`reproject`](reproject()) a geometry from one CRS to another in
8//! place.
9//!
10//! ```
11//! use geometry_cs::Cartesian;
12//! use geometry_model::Point2D;
13//! use geometry_proj::{reproject, Crs};
14//! use geometry_trait::Point as _;
15//!
16//! let wgs84 = Crs::from_epsg(4326).unwrap(); // lon/lat, radians
17//! let mercator = Crs::from_epsg(3857).unwrap(); // metres
18//! let mut p = Point2D::<f64, Cartesian>::new(0.0, 0.0);
19//! reproject(&mut p, &wgs84, &mercator).unwrap();
20//! assert!(p.get::<0>().abs() < 1e-6);
21//! ```
22//!
23//! # Units
24//!
25//! `proj4rs` carries geographic coordinates in **radians**; convert with
26//! [`f64::to_radians`] / [`f64::to_degrees`] at the boundary. See
27//! [`reproject`](reproject()) for detail.
28//!
29//! Module layout:
30//!
31//! * [`crs`] — the [`Crs`] type and its constructors.
32//! * [`reproject`](mod@reproject) — the [`ReprojectPoints`] hook and the
33//! [`reproject`](reproject()) function.
34
35#![forbid(unsafe_code)]
36
37extern crate alloc;
38
39pub mod crs;
40pub mod reproject;
41
42pub use crs::{Crs, CrsError};
43// feature-group: Reprojection
44// feature-desc: CRS-to-CRS point reprojection (standalone crate)
45pub use reproject::{ReprojectPoints, reproject};