gridish
A rust library for working with British and Irish national grids (OSGB, and OSI). Provides a simple interface for converting valid grid references into eastings / northings and vice versa, as well as functionality to recalculate a grid reference to a new precision. This crate intentionally does not provide functionality to convert between different coordinate systems, as there are already several libraries available to do this; it exists solely to fill the gap between numerical coordinates in eastings / northings and their textual representations.
Examples
use ;
use coord;
// Parse grid reference from a 6 figure (100m) string.
let gridref_100m: OSGB = "SO892437".parse.unwrap;
// Recalculate grid reference to 2 figures (10km)
let gridref_10k = gridref_100m.recalculate;
assert_eq!;
// Get the eastings / northings at the gridref's south west corner
assert_eq!;
assert_eq!;
Features
serde: Provides support for (de)serialization using serde.tetrads: Provides support for tetrad grid references in the DINTY format, as commonly used in biological surveys.quadrants: Provides support for quadrants at the end of grid references.
Tetrads
use OSGB;
use coord;
// Parse grid reference from a 2 figure with tetrad (2km) string.
let gridref_2k: OSGB = "SN24R".parse.unwrap;
// Get the eastings / northings at the gridref's south west corner
assert_eq!;
Quadrants
use OSGB;
use coord;
// Parse grid reference from a 2 figure with quadrant (5km) string.
let gridref_5k: OSGB = "SN24NW".parse.unwrap;
// Get the eastings / northings at the gridref's south west corner
assert_eq!;
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
All contributions from humans and other sentient organisms are welcome. Any contributions made with the aid of Generative AI, or where you as an individual are not the author, are not.
Please open an issue for discussion before adding any new features.