#![doc = include_str!("../README.MD")]
#![warn(missing_docs)]
#[cfg(feature = "egui")]
pub mod egui;
#[cfg(feature = "geojson")]
pub mod geojson;
mod geometry;
mod image;
mod layer;
mod map;
#[cfg(feature = "osm")]
pub mod osm;
mod projection;
mod renderer;
#[cfg(feature = "style-yaml")]
pub mod style_yaml;
mod styling;
#[cfg(feature = "tiles")]
mod tiles;
#[cfg(feature = "vello")]
pub mod vello;
#[cfg(feature = "xilem")]
pub mod xilem;
mod zoom_split;
pub use geo;
pub use anyhow::Result;
pub use ccutils::containers::RefOrValue;
#[cfg(feature = "tiles")]
pub use tiles_client::ClientBuilder as TilesClientBuilder;
pub(crate) use layer::BoxedLayer;
pub(crate) use projection::YAxisDirection;
pub use geometry::GeometryType;
pub use image::{BoxedImageDataRef, ImageData, ImageFeature, VecLayer as ImagesVecLayer};
pub use layer::{FeaturesVecLayer, IntoLayer, Layer};
pub use map::{Feature, GeometryRef, Map, MapBuilder};
pub use projection::{Projection, Unit as ProjectionUnit, transform};
pub use renderer::{MapRenderer, ViewController};
pub use styling::{
IconAnchor, IconConfig, LabelConfig, RenderingState, Rgba, Style, StyleBuilder, Symbol,
SymbolColor, rgb, rgba,
};
#[cfg(feature = "tiles")]
pub use tiles::{Tile, TilesLayer};
pub use zoom_split::{ZoomSplitLayer, ZoomSplitLayerBuilder};
#[cfg(feature = "image")]
pub use image::{GeoImage, load_image_from_memory, open_image};
pub mod utils
{
#[macro_export]
macro_rules! try_from_feature {
($child: tt, $feature: tt) => {
impl<'a> TryFrom<&'a $feature> for &'a $child
{
type Error = &'static str;
fn try_from(feature: &'a $feature) -> Result<Self, Self::Error>
{
match feature
{
$feature::$child(v) => Ok(v),
_ => Err("Invalid feature type."),
}
}
}
};
}
pub use try_from_feature;
#[macro_export]
macro_rules! composite_feature {
(enum $feature: ident { $($children: ident($children_ty: ty)),* $(,)? }) => {
enum $feature
{
$(
$children($children_ty),
)*
}
$(
impl From<$children_ty> for $feature
{
fn from(value: $children_ty) -> Self
{
Self::$children(value)
}
}
impl<'a> TryFrom<&'a $feature> for &'a $children_ty
{
type Error = &'static str;
fn try_from(feature: &'a $feature) -> Result<Self, Self::Error>
{
match feature
{
$feature::$children(v) => Ok(v),
_ => Err("Invalid feature type."),
}
}
}
)*
impl $crate::Feature for $feature
{
fn element_geometry_type(&self) -> cartography::GeometryType
{
match self
{
$(
$feature::$children(feat) => feat.element_geometry_type(),
)*
}
}
fn geometry(&self) -> Option<cartography::geo::Geometry>
{
match self
{
$(
$feature::$children(feat) => feat.geometry(),
)*
}
}
fn geometry_type(&self) -> cartography::GeometryType
{
match self
{
$(
$feature::$children(feat) => feat.geometry_type(),
)*
}
}
fn image<'a>(&'a self) -> Option<cartography::ImageFeature<cartography::BoxedImageDataRef<'a>>>
{
match self
{
$(
$feature::$children(feat) => feat.image(),
)*
}
}
fn intersects(&self, rect: cartography::geo::Rect) -> bool
{
match self
{
$(
$feature::$children(feat) => feat.intersects(rect),
)*
}
}
}
};
}
pub use composite_feature;
}