gridish

Crates.iogridish
lib.rsgridish
version1.0.1
sourcesrc
created_at2024-03-27 15:24:17.720942
updated_at2024-08-28 10:02:09.585549
descriptionLibrary for working with British and Irish national grid strings.
homepage
repositoryhttps://github.com/BIS-Brecon/gridish
max_upload_size
id1188117
size75,716
(BezBIS)

documentation

README

gridish

CI Pipeline Status

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 gridish::{OSGB, Precision};
use geo_types::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(Precision::_10Km);
assert_eq!("SO84".to_string(), gridref_10k.to_string());

// Get the eastings / northings at the gridref's south west corner
assert_eq!(gridref.sw(), coord! {x: 389_200.0, y: 243_700.0 }.into());

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.
use gridish::{OSGB, Precision};
use geo_types::coord;

// Parse grid reference from a DINTY (2km) string.
let gridref_2k: OSGB = "SN24R".parse().unwrap();

// Get the eastings / northings at the gridref's south west corner
assert_eq!(gridref_2k.sw(), coord! {x: 226_000.0, y: 242_000.0 }.into());

License

Licensed under either of

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.

Commit count: 14

cargo fmt