Crates.io | miniproj |
lib.rs | miniproj |
version | 0.10.3 |
source | src |
created_at | 2023-04-03 13:41:40.49781 |
updated_at | 2024-02-29 13:34:21.895086 |
description | This crate implements general and specific geodetic operations like geographic projections. |
homepage | |
repository | https://git.geomar.de/flemming-staebler/miniproj/ |
max_upload_size | |
id | 829099 |
size | 25,332 |
This crate implements geographic coordinate projections between projected coordinate systems and their underlying geographic coordinate systems, for projected coordinate reference systems defined by the European Petroleum Survey Group Geodesy. It was originally developped at the GEOMAR Helmholtz Centre for Ocean Research as part of the Digital Earth Project, and continues to provide reprojection functionality to the Digital Earth Viewer.
The projections are implemented according to the
Guidance Notes, with all "dynamically
uniform" local variables calculated at compile time. The projections are then
stored in a static PHFMap
for quick access at
runtime. Code generation is split out into the miniproj-epsg-registry
crate,
while the operations themselves are implemented in miniproj-ops
.
Miniproj is not related to or derived from Proj.
EPSG Code | Operation Method Name | # of Projected CRS covered |
---|---|---|
9807 | Transverse Mercator | 3591 |
9802 | Lambert Conic Conformal (2SP) | 949 |
9801 | Lambert Conic Conformal (1SP) | 215 |
9822 | Albers Equal Area | 36 |
9809 | Oblique Stereographic | 20 |
9820 | Lambert Azimuthal Equal Area | 14 |
9810 | Polar Stereographic (Variant A) | 10 |
1024 | Popular Visualisation Pseudo-Mercator | 1 |
EPSG Code | Operation Method Name |
---|---|
9602 | Geographic/Geocentric Conversions |
EPSG Code | Operation Method Name |
---|---|
None | Under Development |
// Get the WGS84 UTM zone 32N projection
use miniproj::{
get_projection,
Projection,
get_ellipsoid_code,
get_ellipsoid,
Ellipsoid
};
let projection = get_projection(32632)
.expect("Projection not implemented.");
// Coordinates of the office where this crate was written in UTM:
let (easting, northing) = (576935.86f64, 6020593.46f64);
// To get the latitude and longitude, use the Projection::to_deg
// method. Note that the order of the returned tuple is not
// alphabetical, but instead follows the axis order (X for
// Longitude, Y for Latitude).
let (lon, lat) = projection.projected_to_deg(easting, northing);
assert!((lon - 10.183034).abs() < 0.000001);
assert!((lat - 54.327389).abs() < 0.000001);
// To convert this geographic position to a geocentric position
// (a position in euclidian space), get the underlying ellipsoid:
let ellipsoid = get_ellipsoid_code(32632)
.and_then(|c| get_ellipsoid(c))
.expect("No associated ellipsoid.");
// Do the actual conversion. Axis order applies as explained above.
// Height as per GPS altitude.
let (x, y, z) = ellipsoid.deg_to_geocentric(lon, lat, 53.7);
assert!((x - 3668985.10).abs() < 0.1);
assert!((y - 659033.08).abs() < 0.1);
assert!((z - 5158122.64).abs() < 0.1);
Miniproj is still under development and missing some important functionality. If you are looking for a refined, proven library, check out PROJ.
rusqlite
miniproj
can now be built with stable rustc
(1.71.0)Ellipsoid
s by EPSG codeno-std
geo
As many of the other components of the Digital Earth Viewer, Miniproj is licensed under EUPL v1.2, which is a copyleft license similar and compatible to GPLv2 and available in 23 languages. This license does not apply to the projections themselves. The database files are extracts from the EPSG Geodetic Parameter Registry and redistributed under their own Terms of Use.