rustial 0.0.1

A geospatial map library for Rust
#![warn(missing_docs)]
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
// ---------------------------------------------------------------------------
//! # Rustial
//!
//! Scientific-grade 2.5D geospatial map library for Rust.
//!
//! This crate is the **public API surface** of the rustial project.
//! It re-exports the types you need from the lower-level workspace
//! crates so that downstream users only ever need a single dependency:
//!
//! ```toml
//! [dependencies]
//! rustial = "1"
//! ```
//!
//! ## Workspace architecture
//!
//! ```text
//! rustial                          <-- you are here (facade)
//!   |
//!   +-- rustial-engine             framework-agnostic engine (math, camera, layers,
//!   |                              tiles, terrain, vectors, models, I/O abstractions)
//!   +-- rustial-renderer-wgpu      pure WGPU renderer (behind `wgpu-renderer` feature)
//!   +-- rustial-renderer-bevy      Bevy engine renderer (behind `bevy-renderer` feature)
//! ```
//!
//! ## Feature flags
//!
//! | Flag | Default | Description |
//! |------|---------|-------------|
//! | `wgpu-renderer` | **yes** | Enables [`WgpuMapRenderer`] and [`RenderParams`]. |
//! | `bevy-renderer` | no | Enables [`RustialBevyPlugin`], [`RustialBevyConfig`], and Bevy ECS components. |
//! | `terrain-rgb` | no | Enables [`AwsTerrainSource`] and [`MapboxTerrainSource`] (reqwest + image). |
//! | `geojson` | no | Enables the GeoJSON parser ([`parse_geojson`]). |
//! | `disk-cache` | no | Enables [`DiskCache`] for flat-file on-disk tile persistence. |
//!
//! ## Quick start (pure WGPU)
//!
//! ```rust,ignore
//! use rustial::{MapBuilder, MapState, WgpuMapRenderer};
//!
//! let mut state = MapBuilder::new()
//!     .center(51.1, 17.0)
//!     .zoom(10)
//!     .viewport(1280, 720)
//!     .build();
//! state.update();
//!
//! // Feed `state` and a wgpu::Device/Queue to WgpuMapRenderer::render().
//! ```
//!
//! ## Quick start (Bevy)
//!
//! ```rust,ignore
//! use bevy::prelude::*;
//! use rustial::{RustialBevyPlugin, RustialBevyConfig, default_plugins};
//!
//! App::new()
//!     .add_plugins(default_plugins("my map", (1280, 720)))
//!     .insert_resource(RustialBevyConfig {
//!         center: (51.1, 17.0),
//!         zoom: 10,
//!         ..default()
//!     })
//!     .add_plugins(RustialBevyPlugin)
//!     .run();
//! ```
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// Facade-owned modules
// ---------------------------------------------------------------------------

mod builder;
mod error;
mod handle;

#[cfg(feature = "terrain-rgb")]
mod terrain_sources;

pub use builder::MapBuilder;
pub use error::RustialError;
pub use handle::MapHandle;

#[cfg(feature = "terrain-rgb")]
pub use terrain_sources::{AwsTerrainSource, MapboxTerrainSource};

// ---------------------------------------------------------------------------
// Re-exports -- Math primitives (rustial-engine)
//
// Coordinates, projections, ellipsoid, tile math, frustum culling,
// geodesic calculations, and elevation grids.
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    geo_to_tile,
    geo_to_tile_checked,
    geodesic_destination,
    geodesic_destination_on,
    geodesic_distance,
    geodesic_distance_on,
    tile_bounds_world,
    tile_to_geo,
    visible_tiles,
    visible_tiles_checked,
    visible_tiles_flat_view,
    visible_tiles_flat_view_capped,
    visible_tiles_flat_view_capped_with_config,
    visible_tiles_flat_view_refined_capped,
    visible_tiles_flat_view_with_config,
    visible_tiles_lod,
    // Elevation
    ElevationGrid,
    // Ellipsoid & geodesics
    Ellipsoid,
    Equirectangular,
    FlatTileSelectionConfig,
    FlatTileView,
    // Frustum culling
    Frustum,
    // Bounds
    GeoBounds,
    // Coordinate types
    GeoCoord,
    GeodesicResult,
    Globe,
    Plane,
    // Projections
    Projection,
    TileCoord,
    // Tile math
    TileId,
    VerticalPerspective,
    VincentyConvergenceError,
    WebMercator,
    WorldBounds,
    WorldCoord,
    MAX_ZOOM,
    PLANE_BOTTOM,
    PLANE_FAR,
    PLANE_LEFT,
    PLANE_NEAR,
    PLANE_RIGHT,
    PLANE_TOP,
};

// ---------------------------------------------------------------------------
// Re-exports -- Camera & input (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    Camera, CameraAnimator, CameraConstraints, CameraController, CameraMode, CameraProjection,
    EaseToOptions, FlyToOptions, InputEvent,
};

// ---------------------------------------------------------------------------
// Re-exports -- Layer system (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    BackgroundLayer,
    // Dynamic frame provider system (video/canvas sources).
    CallbackFrameProvider,
    DynamicImageOverlayLayer,
    FrameData,
    FrameProvider,
    FrameProviderFactory,
    HillshadeLayer,
    HillshadeParams,
    ImageOverlayLayer,
    Layer,
    LayerId,
    LayerStack,
    ModelLayer,
    TileLayer,
    VectorLayer,
    VectorMeshData,
    VectorRenderMode,
    VectorStyle,
};

// ---------------------------------------------------------------------------
// Re-exports -- Style/runtime breadth (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    // Feature-state-driven style resolution helpers.
    circle_style_with_state,
    fill_extrusion_style_with_state,
    fill_style_with_state,
    heatmap_style_with_state,
    line_style_with_state,
    symbol_style_with_state,
    vector_style_with_state,
    AmbientLight,
    BackgroundStyleLayer,
    CanvasSource,
    CircleStyleLayer,
    // Clustering.
    ClusterOptions,
    ComputedLighting,
    ComputedShadow,
    ComputedSky,
    DirectionalLight,
    FillExtrusionStyleLayer,
    FillStyleLayer,
    FromFeatureStateProperty,
    GeoJsonSource,
    HeatmapStyleLayer,
    HillshadeStyleLayer,
    ImageSource,
    LayerTransitionState,
    // Lighting configuration.
    LightConfig,
    LightingMode,
    LineStyleLayer,
    MapStyle,
    ModelSource,
    ModelStyleLayer,
    PointCluster,
    RasterSource,
    RasterStyleLayer,
    ResolvedTransitions,
    // Shadow map configuration.
    ShadowConfig,
    // Sky / atmosphere configuration.
    SkyConfig,
    SkyType,
    StyleDocument,
    StyleError,
    StyleEvalContext,
    StyleEvalContextFull,
    StyleLayer,
    StyleLayerId,
    StyleLayerMeta,
    StyleProjection,
    StyleSource,
    StyleSourceId,
    StyleSourceKind,
    StyleValue,
    SymbolStyleLayer,
    TerrainSource,
    // Style transition types.
    TransitionSpec,
    Transitioning,
    VectorStyleLayer,
    VectorTileSource,
    VideoSource,
};

// ---------------------------------------------------------------------------
// Re-exports -- Expression engine (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    BoolExpression, ExprEvalContext, Expression, NumericExpression, StringExpression,
};

// ---------------------------------------------------------------------------
// Re-exports -- Map state & frame output (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{FitBoundsOptions, FitBoundsPadding, FrameOutput, MapState};

// ---------------------------------------------------------------------------
// Re-exports -- Geometry & vector data (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    bearing, geometry_bbox, geometry_centroid, initial_bearing, interpolate_great_circle,
    linestring_length, polygon_area, ring_area, simplify_douglas_peucker, simplify_polygon_ring,
    stroke_line, triangulate_polygon, triangulate_polygon_with_holes, Feature, FeatureCollection,
    Geometry, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, PropertyValue,
};

#[cfg(feature = "geojson")]
pub use rustial_engine::{parse_geojson, GeoJsonError};

#[cfg(feature = "shapefile")]
pub use rustial_engine::{parse_shapefile, ShapefileError};

// ---------------------------------------------------------------------------
// Re-exports -- Tile engine (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    DecodedImage, HttpTileSource, HttpVectorTileSource, PooledTileSource, RasterMipChain,
    RasterMipLevel, TileCache, TileCacheEntry, TileData, TileDecoder, TileError, TileFreshness,
    TileManager, TileManagerCounters, TilePixelRect, TileResponse, TileSelectionConfig,
    TileSelectionStats, TileSource, TileTextureRegion, VectorTileData, VisibleTile, VisibleTileSet,
};

// ---------------------------------------------------------------------------
// Re-exports -- I/O abstractions (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{FetchPool, HttpClient, HttpRequest, HttpResponse};

#[cfg(all(feature = "disk-cache", not(target_arch = "wasm32")))]
pub use rustial_engine::{DiskCache, DiskCacheError};

// ---------------------------------------------------------------------------
// Re-exports -- TileJSON metadata (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{TileJson, TileJsonError, TileScheme, VectorLayerMeta};

#[cfg(feature = "style-json")]
pub use rustial_engine::{parse_tilejson, parse_tilejson_value};

// ---------------------------------------------------------------------------
// Re-exports -- MVT decoder (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{decode_mvt, DecodedVectorTile, MvtDecodeOptions, MvtError};

// ---------------------------------------------------------------------------
// Re-exports -- Terrain & elevation (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    build_terrain_mesh, prepare_hillshade_raster, ElevationSource, FlatElevationSource,
    HttpElevationSource, PreparedHillshadeRaster, QuantizedMeshSource, TerrainConfig, TerrainError,
    TerrainManager, TerrainMeshData, TerrainRgbEncoding,
};

// ---------------------------------------------------------------------------
// Re-exports -- 3D models (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{AltitudeMode, ModelInstance, ModelLoadError, ModelMesh};

// ---------------------------------------------------------------------------
// Re-exports -- WGPU renderer (behind `wgpu-renderer` feature)
// ---------------------------------------------------------------------------

#[cfg(feature = "wgpu-renderer")]
pub use rustial_renderer_wgpu::{RenderParams, TerrainInteractionBuffers, WgpuMapRenderer};

// ---------------------------------------------------------------------------
// Re-exports -- Bevy renderer (behind `bevy-renderer` feature)
// ---------------------------------------------------------------------------

#[cfg(feature = "bevy-renderer")]
pub use rustial_renderer_bevy::{
    backends_from_env, default_plugins, geo_to_vec3, MapStateResource, RustialBevyConfig,
    RustialBevyPlugin, TerrainInteractionBuffersResource,
};

#[cfg(feature = "bevy-renderer")]
pub use rustial_renderer_bevy::components::{GeoAltitudeMode, GeoTransform, MapEntity};

pub use rustial_engine::{
    GlyphAtlas, GlyphAtlasEntry, GlyphKey, GlyphProvider, GlyphRaster, ImageManager, PlacedSymbol,
    ProceduralGlyphProvider, SpriteImage, SpriteSheet, SymbolAnchor, SymbolAssetDependencies,
    SymbolAssetRegistry, SymbolCandidate, SymbolCollisionBox, SymbolPlacementConfig,
    SymbolPlacementEngine, SymbolWritingMode,
};

pub use rustial_engine::{
    geometry_intersects_bbox, FeatureState, FeatureStateId, GeoBBox, QueriedFeature, QueryOptions,
};

pub use rustial_engine::{
    HitCategory, HitProvenance, NonPickableLayerKind, PickHit, PickOptions, PickQuery, PickResult,
    PickableLayerKind,
};

pub use rustial_engine::{
    InteractionButton, InteractionEvent, InteractionEventKind, InteractionModifiers,
    InteractionTarget, InteractionTargetKind, PointerKind, ScreenPoint,
};

pub use rustial_engine::{InteractionConfig, InteractionManager};

pub use rustial_engine::{EventEmitter, ListenerId};

// ---------------------------------------------------------------------------
// Re-exports -- Visualization primitives (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    ColorRamp, ColorStop, ColumnInstance, ColumnInstanceSet, ExtrusionParams, GeoGrid,
    GridExtrusionLayer, GridScalarLayer, InstancedColumnLayer, LabeledStop, LegendSpec,
    NormalizationMode, PointCloudLayer, PointInstance, PointInstanceSet, ScalarField2D,
    VisualizationOverlay,
};

// ---------------------------------------------------------------------------
// Re-exports -- Async data pipeline (rustial-engine)
// ---------------------------------------------------------------------------

pub use rustial_engine::{
    partition_features_by_tile, AsyncVisualizationPipeline, DataTaskPool, DataTaskResultReceiver,
    TerrainCacheKey, TerrainTaskInput, TerrainTaskOutput, ThreadDataTaskPool, VectorBucketKey,
    VectorCacheKey, VectorTaskInput, VectorTaskOutput, VisualizationTaskOutput,
};