use std::borrow::Cow;
use geolith::error::Result;
use crate::terrain::dem::Dem;
pub type Bounds = (f64, f64, f64, f64);
pub trait ElevationSource: Sync {
fn wgs84_bounds(&self) -> Bounds;
fn elevation_range(&self) -> Option<(f32, f32)>;
fn source_epsg(&self) -> u32;
fn patches(&self, bounds: Bounds, metres_per_pixel: f64) -> Result<Vec<Cow<'_, Dem>>>;
}
impl ElevationSource for Dem {
fn wgs84_bounds(&self) -> Bounds {
Dem::wgs84_bounds(self)
}
fn elevation_range(&self) -> Option<(f32, f32)> {
Dem::elevation_range(self)
}
fn source_epsg(&self) -> u32 {
self.crs.epsg()
}
fn patches(&self, _bounds: Bounds, _metres_per_pixel: f64) -> Result<Vec<Cow<'_, Dem>>> {
Ok(vec![Cow::Borrowed(self)])
}
}