use serde_json::json;
#[derive(Debug, Clone, PartialEq)]
pub struct BoundingBox {
pub left: f64,
pub bottom: f64,
pub right: f64,
pub top: f64,
}
impl BoundingBox {
pub fn new(left: f64, bottom: f64, right: f64, top: f64) -> Self {
Self {
left,
bottom,
right,
top,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Coords {
pub x: f64,
pub y: f64,
}
impl Coords {
pub fn new(x: f64, y: f64) -> Self {
Self { x, y }
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Xyz {
pub x: u64,
pub y: u64,
pub z: u8,
}
impl Xyz {
pub fn new(x: u64, y: u64, z: u8) -> Self {
Self { x, y, z }
}
}
pub fn bbox_to_feature(west: f64, south: f64, east: f64, north: f64) -> serde_json::Value {
json!({
"type": "Polygon",
"coordinates": [
[[west, south], [west, north], [east, north], [east, south], [west, south]]
],
})
}