mod roads;
pub use roads::{GroundMeasure, PaperMeasure, RoadClassObject, RoadClassSpec, RoadMeasure, RoadOptions, RoadWidthMode, Roads};
use crate::geom::Lines;
use crate::osm::Feature;
use crate::output::Output;
use geo::MultiPolygon;
#[derive(Debug, Clone)]
pub struct LayerParts {
pub outlines: Lines,
pub details: Lines,
pub trails: Lines,
pub filling: Lines,
pub mask: MultiPolygon<f64>,
}
impl Default for LayerParts {
fn default() -> Self {
LayerParts { outlines: vec![], details: vec![], trails: vec![], filling: vec![], mask: MultiPolygon::new(vec![]) }
}
}
impl LayerParts {
pub fn is_empty(&self) -> bool {
self.outlines.is_empty() && self.details.is_empty() && self.trails.is_empty() && self.filling.is_empty() && self.mask.0.is_empty()
}
}
pub struct Context<'a> {
pub output: &'a Output,
pub features: &'a [Feature],
}
pub fn roads_render(ctx: &Context, opts: &RoadOptions) -> Roads {
roads::build(ctx, opts)
}
pub fn osm_keys(module: &str) -> &'static [&'static str] {
match module {
"roads" => &["highway"],
_ => &[],
}
}
fn numeric(value: &str) -> Option<f64> {
value.parse::<f64>().ok()
}
pub fn is_underground(f: &Feature) -> bool {
below_ground(f, &[])
}
fn below_ground(f: &Feature, skip: &[&str]) -> bool {
f.tags.iter().any(|(k, v)| {
let key = k.to_ascii_lowercase();
let levelish = key.contains("layer") || key.contains("level");
levelish && !skip.contains(&k.as_str()) && numeric(v).is_some_and(|n| n < 0.0)
}) || f.tag("location").is_some_and(|l| l.eq_ignore_ascii_case("underground"))
}