1use serde_json::json;
2
3#[derive(Debug, Clone, PartialEq)]
5pub struct BoundingBox {
6 pub left: f64,
8 pub bottom: f64,
10 pub right: f64,
12 pub top: f64,
14}
15
16impl BoundingBox {
17 pub fn new(left: f64, bottom: f64, right: f64, top: f64) -> Self {
19 Self {
20 left,
21 bottom,
22 right,
23 top,
24 }
25 }
26}
27
28#[derive(Debug, Clone, PartialEq)]
30pub struct Coords {
31 pub x: f64,
33 pub y: f64,
35}
36
37impl Coords {
38 pub fn new(x: f64, y: f64) -> Self {
40 Self { x, y }
41 }
42}
43
44#[derive(Debug, Clone, PartialEq)]
46pub struct Xyz {
47 pub x: u64,
49 pub y: u64,
51 pub z: u8,
53}
54
55impl Xyz {
56 pub fn new(x: u64, y: u64, z: u8) -> Self {
58 Self { x, y, z }
59 }
60}
61
62pub fn bbox_to_feature(west: f64, south: f64, east: f64, north: f64) -> serde_json::Value {
64 json!({
65 "type": "Polygon",
66 "coordinates": [
67 [[west, south], [west, north], [east, north], [east, south], [west, south]]
68 ],
69 })
70}