#[cfg(all(feature = "rendering", target_os = "linux"))]
use maplibre_native::{Color as MlnColor, LineCap as MlnLineCap, LineJoin as MlnLineJoin};
#[derive(Debug, Default, Clone)]
pub struct OverlaySpec {
pub features: Vec<OverlayFeature>,
}
impl OverlaySpec {
#[must_use]
pub fn is_empty(&self) -> bool {
self.features.is_empty()
}
}
#[derive(Debug, Clone)]
pub struct OverlayFeature {
pub geometry: Option<geojson::Geometry>,
pub properties: Option<OverlayProperties>,
}
#[derive(Debug, Default, Clone)]
pub struct OverlayProperties {
pub circle_color: Option<Color>,
pub circle_opacity: Option<f32>,
pub circle_radius: Option<f32>,
pub circle_stroke_color: Option<Color>,
pub circle_stroke_opacity: Option<f32>,
pub circle_stroke_width: Option<f32>,
pub line_color: Option<Color>,
pub line_opacity: Option<f32>,
pub line_width: Option<f32>,
pub line_cap: Option<LineCap>,
pub line_join: Option<LineJoin>,
pub fill_color: Option<Color>,
pub fill_opacity: Option<f32>,
pub fill_outline_color: Option<Color>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineCap {
Butt,
Round,
Square,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LineJoin {
Miter,
Bevel,
Round,
}
#[cfg(all(feature = "rendering", target_os = "linux"))]
impl From<Color> for MlnColor {
fn from(c: Color) -> Self {
Self::rgba(c.r, c.g, c.b, c.a)
}
}
#[cfg(all(feature = "rendering", target_os = "linux"))]
impl From<LineCap> for MlnLineCap {
fn from(cap: LineCap) -> Self {
match cap {
LineCap::Butt => Self::Butt,
LineCap::Round => Self::Round,
LineCap::Square => Self::Square,
}
}
}
#[cfg(all(feature = "rendering", target_os = "linux"))]
impl From<LineJoin> for MlnLineJoin {
fn from(join: LineJoin) -> Self {
match join {
LineJoin::Miter => Self::Miter,
LineJoin::Bevel => Self::Bevel,
LineJoin::Round => Self::Round,
}
}
}