Expand description
§geoconvert
geoconvert is a lightweight library for converting between different
geographic coordinate systems. Currently, there are three coordinate systems implemented:
The implementation of this library is a translation of a subset of
GeographicLib from C++ to Rust. Specifically, geoconvert
implements some of the functionality of the GeoConvert
command line tool.
§Usage
You can create coordinates manually using a struct’s create() function, then convert to other
types using the to_*/from_* methods.
use geoconvert::{LatLon, Mgrs, UtmUps};
// This returns a result. When calling `create()`, the arguments are validated to ensure only a valid
// coordinate gets created.
let coord = LatLon::create(40.748333, -73.985278).unwrap();
// Convert to a UTM/UPS coordinate
let coord_utm = coord.to_utmups();
let coord_utm = UtmUps::from_latlon(&coord);
// Convert to an MGRS coordinate
// Note that for MGRS you must specify the precision
let coord_mgrs = coord.to_mgrs(6);
let coord_mgrs = Mgrs::from_latlon(&coord, 6);§Features
If you want serde compatibility with Serialize/Deserialize, activate the serde feature.
Modules§
Structs§
- LatLon
- Representation of a WGS84 Latitude/Longitude point. Can be converted
to/from
UtmUpsandMgrs. - Mgrs
- Representation of a WGS84
Military Grid Reference System
point. Stored internally as a
UtmUpspoint with a precision. - UtmUps
- Representation of a WGS84
UTM
/
UPS
point. If converted to from lat/lon, it will
automatically determine whether it should be UTM/UPS. It becomes a UPS coordinate
if the latitude is outside the range
[-84,84]. A zone value of0designates UPS.