diff --git a/maplibre/src/coords.rs b/maplibre/src/coords.rs index c80182295..e0249b492 100644 --- a/maplibre/src/coords.rs +++ b/maplibre/src/coords.rs @@ -59,7 +59,8 @@ impl fmt::Debug for Quadkey { } } -/// Zoom is an exponential scale that defines the zoom level for camera and tiles. +/// `Zoom` is an exponential scale that defines of the camera and tiles. +/// We can derive the `ZoomLevel` from `Zoom` by using the `[crate::coords::ZOOM_BOUNDS]`. #[derive(Copy, Clone, Debug)] pub struct Zoom(f64); @@ -444,7 +445,7 @@ impl From> for WorldCoords { } } -/// Defines a bounding box on a tiled map with a zoom level and a padding. +/// Defines a bounding box on a tiled map with a [`ZoomLevel`] and a padding. #[derive(Debug)] pub struct ViewRegion { min_tile: WorldTileCoords, diff --git a/maplibre/src/error.rs b/maplibre/src/error.rs index 13962508c..1f0a662b1 100644 --- a/maplibre/src/error.rs +++ b/maplibre/src/error.rs @@ -3,7 +3,7 @@ use lyon::tessellation::TessellationError; use std::sync::mpsc::SendError; -/// Multiple types of map rendering errors +/// Enumeration of errors which can happen during the operation of the library. #[derive(Debug)] pub enum Error { Schedule, diff --git a/maplibre/src/input/pan_handler.rs b/maplibre/src/input/pan_handler.rs index 5f69b0480..c230eedb5 100644 --- a/maplibre/src/input/pan_handler.rs +++ b/maplibre/src/input/pan_handler.rs @@ -97,11 +97,6 @@ impl PanHandler { return false; } - if !self.is_panning { - // starting to pan - // FIXME: This `if` statement is not used - } - if *state == ElementState::Pressed { // currently panning or starting to pan self.is_panning = true; diff --git a/maplibre/src/io/geometry_index.rs b/maplibre/src/io/geometry_index.rs index 684c46187..6febc93a6 100644 --- a/maplibre/src/io/geometry_index.rs +++ b/maplibre/src/io/geometry_index.rs @@ -14,7 +14,7 @@ use rstar::{Envelope, PointDistance, RTree, RTreeObject, AABB}; use crate::coords::{InnerCoords, Quadkey, WorldCoords, WorldTileCoords, Zoom, EXTENT, TILE_SIZE}; use crate::util::math::bounds_from_points; -/// A quad tree storing the current tiles being rendered. +/// A quad tree storing the currently loaded tiles. pub struct GeometryIndex { index: BTreeMap, } @@ -62,7 +62,7 @@ impl GeometryIndex { /// Spatial tiles are stored in a multi-dimentional tree which represents their position in the tile. /// Linear tiles are simply stored in a vector. /// -/// A spatial tile index can improve query performance on tiles. +/// A spatial tile index can theoretically improve query performance on tiles. Practically it could be slower though. The `Spatial` index is experimental and currently unused. pub enum TileIndex { Spatial { tree: RTree> }, Linear { list: Vec> }, diff --git a/maplibre/src/io/static_tile_fetcher.rs b/maplibre/src/io/static_tile_fetcher.rs index b003588c9..b95c09d93 100644 --- a/maplibre/src/io/static_tile_fetcher.rs +++ b/maplibre/src/io/static_tile_fetcher.rs @@ -15,7 +15,7 @@ static TILES: Dir = include_dir!("$OUT_DIR/extracted-tiles"); #[cfg(not(static_tiles))] static TILES: Dir = Dir::new("/path", &[]); -/// Load PBF files from the local direction `extracted-tiles`. +/// Load PBF files which were statically embedded in the `build.rs` #[derive(Default)] pub struct StaticTileFetcher; diff --git a/maplibre/src/lib.rs b/maplibre/src/lib.rs index 71f484088..66e48bf37 100644 --- a/maplibre/src/lib.rs +++ b/maplibre/src/lib.rs @@ -1,6 +1,20 @@ //! # Maplibre-rs //! //! A multi-platform library for rendering vector tile maps with WebGPU. +//! +//! Maplibre-rs is a map renderer that can run natively on MacOS, Linux, Windows, Android, iOS and the web. +//! It takes advantage of Lyon to tessellate vector tiles and WebGPU to display them efficiently. +//! Maplibre-rs also has an headless mode (*work in progress*) that can generate rasters. +//! +//! The official guide book can be found here #![doc = include_str!("description.md")] +//! +//! ### Example +//! +//! To import maplibre-rs in your `Cargo.toml`: +//! +//! ```toml +//! maplibre = "0.0.2" +//! ``` use crate::io::scheduler::{ScheduleMethod, Scheduler}; use crate::io::source_client::HTTPClient; @@ -95,10 +109,6 @@ where { /// Initializes the whole rendering pipeline for the given configuration. /// Returns the initialized map, ready to be run. - /// - /// # Panics - /// - /// * Panics if Winit is unable to retrieve the target window size. pub async fn initialize(self) -> Map { #[cfg(target_os = "android")] // On android we can not get the dimensions of the window initially. Therefore, we use a @@ -135,10 +145,6 @@ where HC: HTTPClient, { /// Runs the map application without a maximum number of frames per second defined. - /// - /// # Panics - /// - /// * Panics if the operating system is unable to starts the worker threads. pub fn run_sync(self) { self.run_sync_with_optionally_max_frames(None); } @@ -148,10 +154,6 @@ where /// # Arguments /// /// * `max_frames` - The maxiumum number of frame per seconds. - /// - /// # Panics - /// - /// * Panics if the operating system is unable to starts the worker threads. pub fn run_sync_with_max_frames(self, max_frames: u64) { self.run_sync_with_optionally_max_frames(Some(max_frames)) } @@ -225,11 +227,6 @@ where } /// Builds the UninitializedMap with the given configuration. - /// - /// # Panics - /// - /// * Panics if no schedule method has been configured. - /// * Panics if no http client has been configured. pub fn build(self) -> UninitializedMap { let (window, event_loop) = (self.window_factory)(); diff --git a/maplibre/src/map_state.rs b/maplibre/src/map_state.rs index 7652f1db0..0ac272ce0 100644 --- a/maplibre/src/map_state.rs +++ b/maplibre/src/map_state.rs @@ -1,4 +1,4 @@ -//! Stores the state of the map such as zoom level, camera, styles, etc. +//! Stores the state of the map such as `[crate::coords::Zoom]`, `[crate::camera::Camera]`, `[crate::style::Style]`, `[crate::io::tile_cache::TileCache]` and more. use crate::coords::{ViewRegion, WorldTileCoords, Zoom, TILE_SIZE}; use crate::error::Error; diff --git a/maplibre/src/platform/noweb/http_client.rs b/maplibre/src/platform/noweb/http_client.rs index 435f4a629..aa2d43c6e 100644 --- a/maplibre/src/platform/noweb/http_client.rs +++ b/maplibre/src/platform/noweb/http_client.rs @@ -6,7 +6,6 @@ use reqwest_middleware::ClientWithMiddleware; use reqwest_middleware_cache::managers::CACacheManager; use reqwest_middleware_cache::{Cache, CacheMode}; -/// Reqwest http client #[derive(Clone)] pub struct ReqwestHttpClient { client: ClientWithMiddleware, diff --git a/maplibre/src/style/layer.rs b/maplibre/src/style/layer.rs index 6b5dbfa94..39454bbf0 100644 --- a/maplibre/src/style/layer.rs +++ b/maplibre/src/style/layer.rs @@ -5,7 +5,6 @@ use csscolorparser::Color; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -/// Background styling. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct BackgroundPaint { #[serde(rename = "background-color")] @@ -14,7 +13,6 @@ pub struct BackgroundPaint { // TODO a lot } -/// Fill styling. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct FillPaint { #[serde(rename = "fill-color")] @@ -23,7 +21,6 @@ pub struct FillPaint { // TODO a lot } -/// Line styling. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct LinePaint { #[serde(rename = "line-color")] diff --git a/maplibre/src/winit.rs b/maplibre/src/winit.rs index b0ee52873..ecb690b8a 100644 --- a/maplibre/src/winit.rs +++ b/maplibre/src/winit.rs @@ -89,10 +89,6 @@ where let dt = now - last_render_time; last_render_time = now; - // FIXME: Inputs are updated in RedrawRequested which - // 1. Adds a strain on the main thread, maybe we need another thread for that. - // 2. Delta time is correlated to the frame rate, and a low frame rate will cause - // a lag with inputs. e.g. a button is held for a certain amount of time. input_controller.update_state(self.view_state_mut(), dt); match self.update_and_redraw() {