overpass_lib/query/
bbox.rs1use std::fmt::Write;
2use crate::{OverpassQL, OverpassQLError};
3
4#[derive(Debug, Clone, Copy)]
7pub struct Bbox {
8 pub south: f64,
10 pub west: f64,
12 pub north: f64,
14 pub east: f64,
16}
17
18impl Bbox {
19 pub fn new(south: f64, west: f64, north: f64, east: f64) -> Self {
20 Self { south, west, north, east }
21 }
22}
23
24impl OverpassQL for Bbox {
25 fn fmt_oql(&self, f: &mut impl Write) -> Result<(), OverpassQLError> {
26 let Self { south, west, north, east } = self;
27 write!(f, "{south},{west},{north},{east}")?;
28 Ok(())
29 }
30}
31
32#[cfg(test)]
33mod test {
34 use super::*;
35
36 #[test]
37 fn fmt() {
38 let b = Bbox::new(1f64, 2f64, 3f64, 4f64);
39 assert_eq!(b.to_oql().as_str(), "1,2,3,4");
40 }
41
42 }