mod bng_transformations;
pub(crate) use bng_transformations::{
convert_line_to_bng, convert_multipolygon_to_bng, convert_polygon_to_bng, convert_to_bng,
};
use geo_types::Point;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Crs {
#[default]
Wgs84,
Bng,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ConversionMethod {
#[default]
Ostn15,
Proj,
}
pub trait Coordinate {
fn x(&self) -> f64;
fn y(&self) -> f64;
}
impl Coordinate for (f64, f64) {
fn x(&self) -> f64 {
self.0
}
fn y(&self) -> f64 {
self.1
}
}
impl Coordinate for Point<f64> {
fn x(&self) -> f64 {
Point::x(*self)
}
fn y(&self) -> f64 {
Point::y(*self)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_coordinate_trait_tuple() {
let tuple = (100.0, 200.0);
assert_eq!(tuple.x(), 100.0);
assert_eq!(tuple.y(), 200.0);
}
#[test]
fn test_coordinate_trait_point() {
let point = Point::new(100.0, 200.0);
assert_eq!(point.x(), 100.0);
assert_eq!(point.y(), 200.0);
}
#[test]
fn test_crs_enum_default() {
assert_eq!(Crs::default(), Crs::Wgs84);
}
}