mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Remove core crate
This commit is contained in:
parent
24bd16c112
commit
a6519785cb
2
.idea/maplibre-rs.iml
generated
2
.idea/maplibre-rs.iml
generated
@ -6,10 +6,10 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/libs/mbtiles/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/libs/mbtiles/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/maplibre-build-tools/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/maplibre-build-tools/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/maplibre-core/src" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/maplibre-style/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/maplibre-style/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/maplibre-tilejson/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/maplibre-tilejson/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/maplibre/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/maplibre/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/maplibre/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/android/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/android/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/apple/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/apple/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/benchmarks/benches" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/benchmarks/benches" isTestSource="true" />
|
||||||
|
|||||||
@ -4,7 +4,6 @@ resolver = "2"
|
|||||||
|
|
||||||
members = [
|
members = [
|
||||||
"maplibre",
|
"maplibre",
|
||||||
"maplibre-core",
|
|
||||||
"maplibre-build-tools",
|
"maplibre-build-tools",
|
||||||
"maplibre-demo",
|
"maplibre-demo",
|
||||||
|
|
||||||
|
|||||||
@ -1,85 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "maplibre-core"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Maximilian Ammann <max@maxammann.org>"]
|
|
||||||
edition = "2021"
|
|
||||||
build = "build.rs"
|
|
||||||
license = "MIT OR Apache-2.0"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
web-webgl = ["wgpu/webgl"]
|
|
||||||
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
|
||||||
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
|
|
||||||
default = []
|
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
|
||||||
console_error_panic_hook = "0.1"
|
|
||||||
web-sys = { version = "0.3", features = [
|
|
||||||
"Window",
|
|
||||||
"Headers",
|
|
||||||
"WorkerGlobalScope", "Request", "RequestInit", "RequestMode", "Response",
|
|
||||||
"ErrorEvent", "DedicatedWorkerGlobalScope"
|
|
||||||
] }
|
|
||||||
js-sys = "0.3"
|
|
||||||
wasm-bindgen = "0.2"
|
|
||||||
wasm-bindgen-futures = "0.4"
|
|
||||||
console_log = { version = "0.2", features = ["color"] }
|
|
||||||
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
|
|
||||||
instant = { version = "0.1", features = ["wasm-bindgen"] } # FIXME: Untrusted dependency
|
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android"))'.dependencies]
|
|
||||||
tokio = { version = "1.17", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
|
|
||||||
env_logger = "0.9"
|
|
||||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
|
||||||
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
|
|
||||||
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency
|
|
||||||
tracing-tracy = { version = "0.8", optional = true }
|
|
||||||
tracy-client = { version = "0.12.7", optional = true }
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
|
||||||
winit = { version = "0.26", default-features = false }
|
|
||||||
# Use rusttls on android because cross compiling is difficult
|
|
||||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
|
||||||
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
winit = { version = "0.26", default-features = false }
|
|
||||||
|
|
||||||
raw-window-handle = "0.4"
|
|
||||||
|
|
||||||
tracing = { version = "0.1" }
|
|
||||||
tracing-subscriber = { version = "0.3", optional = true }
|
|
||||||
|
|
||||||
cgmath = "0.18"
|
|
||||||
|
|
||||||
geo = { version = "0.19" }
|
|
||||||
geo-types = { version = "0.7", features = ["use-rstar_0_9"] }
|
|
||||||
rstar = { version = "0.9" }
|
|
||||||
prost = "0.9"
|
|
||||||
geozero = { git = "https://github.com/georust/geozero", rev = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
|
|
||||||
|
|
||||||
tile-grid = "0.3"
|
|
||||||
|
|
||||||
# Rendering
|
|
||||||
wgpu = { version = "0.12" }
|
|
||||||
lyon = { version = "0.17", features = [] }
|
|
||||||
|
|
||||||
# cached = "0.32"
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
log = "0.4"
|
|
||||||
|
|
||||||
# Utils
|
|
||||||
bytemuck = "1.2.0"
|
|
||||||
bytemuck_derive = "1.0"
|
|
||||||
|
|
||||||
include_dir = "0.7.2"
|
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
csscolorparser = { version = "0.5", features = ["serde", "cint"]}
|
|
||||||
cint = "0.2"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
maplibre-build-tools = { path = "../maplibre-build-tools" }
|
|
||||||
@ -1,162 +0,0 @@
|
|||||||
use crate::io::scheduler::Scheduler;
|
|
||||||
|
|
||||||
mod input;
|
|
||||||
|
|
||||||
pub(crate) mod coords;
|
|
||||||
pub(crate) mod error;
|
|
||||||
pub(crate) mod io;
|
|
||||||
pub(crate) mod map_state;
|
|
||||||
pub(crate) mod platform;
|
|
||||||
pub(crate) mod render;
|
|
||||||
pub(crate) mod tessellation;
|
|
||||||
pub(crate) mod util;
|
|
||||||
pub(crate) mod winit;
|
|
||||||
pub(crate) mod style;
|
|
||||||
pub(crate) mod tilejson;
|
|
||||||
|
|
||||||
// Used for benchmarking
|
|
||||||
pub mod benchmarking;
|
|
||||||
pub mod window;
|
|
||||||
|
|
||||||
use crate::map_state::{MapState, Runnable};
|
|
||||||
use crate::render::render_state::RenderState;
|
|
||||||
use crate::window::{WindowFactory, WindowSize};
|
|
||||||
pub use io::scheduler::ScheduleMethod;
|
|
||||||
use crate::style::Style;
|
|
||||||
pub use platform::schedule_method::*;
|
|
||||||
|
|
||||||
pub struct Map<W, E> {
|
|
||||||
map_state: MapState<W>,
|
|
||||||
event_loop: E,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<W, E> Map<W, E>
|
|
||||||
where
|
|
||||||
MapState<W>: Runnable<E>,
|
|
||||||
{
|
|
||||||
pub fn run(self) {
|
|
||||||
self.run_with_optionally_max_frames(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run_with_max_frames(self, max_frames: u64) {
|
|
||||||
self.run_with_optionally_max_frames(Some(max_frames));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
|
||||||
self.map_state.run(self.event_loop, max_frames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UninitializedMap<W, E> {
|
|
||||||
window: W,
|
|
||||||
window_size: WindowSize,
|
|
||||||
event_loop: E,
|
|
||||||
scheduler: Scheduler,
|
|
||||||
style: Style,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<W, E> UninitializedMap<W, E>
|
|
||||||
where
|
|
||||||
W: raw_window_handle::HasRawWindowHandle,
|
|
||||||
{
|
|
||||||
pub async fn initialize(self) -> Map<W, E> {
|
|
||||||
let render_state = RenderState::initialize(&self.window, self.window_size).await;
|
|
||||||
Map {
|
|
||||||
map_state: MapState::new(
|
|
||||||
self.window,
|
|
||||||
self.window_size,
|
|
||||||
render_state,
|
|
||||||
self.scheduler,
|
|
||||||
self.style,
|
|
||||||
),
|
|
||||||
event_loop: self.event_loop,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
impl<W, E> UninitializedMap<W, E>
|
|
||||||
where
|
|
||||||
W: raw_window_handle::HasRawWindowHandle,
|
|
||||||
MapState<W>: Runnable<E>,
|
|
||||||
{
|
|
||||||
pub fn run_sync(self) {
|
|
||||||
self.run_sync_with_optionally_max_frames(None);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run_sync_with_max_frames(self, max_frames: u64) {
|
|
||||||
self.run_sync_with_optionally_max_frames(Some(max_frames))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_sync_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
|
||||||
tokio::runtime::Builder::new_multi_thread()
|
|
||||||
.worker_threads(4)
|
|
||||||
.enable_io()
|
|
||||||
.enable_time()
|
|
||||||
.on_thread_start(|| {
|
|
||||||
#[cfg(feature = "enable-tracing")]
|
|
||||||
tracy_client::set_thread_name("tokio-runtime-worker");
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
self.initialize()
|
|
||||||
.await
|
|
||||||
.run_with_optionally_max_frames(max_frames);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MapBuilder<W, E> {
|
|
||||||
window_factory: Box<WindowFactory<W, E>>,
|
|
||||||
schedule_method: Option<ScheduleMethod>,
|
|
||||||
scheduler: Option<Scheduler>,
|
|
||||||
style: Option<Style>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<W, E> MapBuilder<W, E>
|
|
||||||
where
|
|
||||||
MapState<W>: Runnable<E>,
|
|
||||||
W: raw_window_handle::HasRawWindowHandle,
|
|
||||||
{
|
|
||||||
pub(crate) fn new(create_window: Box<WindowFactory<W, E>>) -> Self {
|
|
||||||
Self {
|
|
||||||
window_factory: create_window,
|
|
||||||
schedule_method: None,
|
|
||||||
scheduler: None,
|
|
||||||
style: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_schedule_method(mut self, schedule_method: ScheduleMethod) -> Self {
|
|
||||||
self.schedule_method = Some(schedule_method);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_existing_scheduler(mut self, scheduler: Scheduler) -> Self {
|
|
||||||
self.scheduler = Some(scheduler);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_style(mut self, style: Style) -> Self {
|
|
||||||
self.style = Some(style);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build(self) -> UninitializedMap<W, E> {
|
|
||||||
let (window, window_size, event_loop) = (self.window_factory)();
|
|
||||||
|
|
||||||
let scheduler = self
|
|
||||||
.scheduler
|
|
||||||
.unwrap_or_else(|| Scheduler::new(self.schedule_method.unwrap_or_default()));
|
|
||||||
let style = self.style.unwrap_or_default();
|
|
||||||
|
|
||||||
UninitializedMap {
|
|
||||||
window,
|
|
||||||
window_size,
|
|
||||||
event_loop,
|
|
||||||
scheduler,
|
|
||||||
style,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +1,85 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "maplibre"
|
name = "maplibre"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = ""
|
authors = ["Maximilian Ammann <max@maxammann.org>"]
|
||||||
categories = []
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
build = "build.rs"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
web-webgl = ["maplibre-core/web-webgl"]
|
web-webgl = ["wgpu/webgl"]
|
||||||
enable-tracing = ["maplibre-core/enable-tracing"]
|
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
||||||
|
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
|
||||||
|
default = []
|
||||||
|
|
||||||
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
console_error_panic_hook = "0.1"
|
||||||
|
web-sys = { version = "0.3", features = [
|
||||||
|
"Window",
|
||||||
|
"Headers",
|
||||||
|
"WorkerGlobalScope", "Request", "RequestInit", "RequestMode", "Response",
|
||||||
|
"ErrorEvent", "DedicatedWorkerGlobalScope"
|
||||||
|
] }
|
||||||
|
js-sys = "0.3"
|
||||||
|
wasm-bindgen = "0.2"
|
||||||
|
wasm-bindgen-futures = "0.4"
|
||||||
|
console_log = { version = "0.2", features = ["color"] }
|
||||||
|
tracing-wasm = { version = "0.2", optional = true } # FIXME: Low quality dependency
|
||||||
|
instant = { version = "0.1", features = ["wasm-bindgen"] } # FIXME: Untrusted dependency
|
||||||
|
|
||||||
|
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", target_os = "android"))'.dependencies]
|
||||||
|
tokio = { version = "1.17", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
|
||||||
|
env_logger = "0.9"
|
||||||
|
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||||
|
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
|
||||||
|
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency
|
||||||
|
tracing-tracy = { version = "0.8", optional = true }
|
||||||
|
tracy-client = { version = "0.12.7", optional = true }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
|
winit = { version = "0.26", default-features = false }
|
||||||
|
# Use rusttls on android because cross compiling is difficult
|
||||||
|
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
winit = { version = "0.26", default-features = false, features = ["x11", "wayland"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
maplibre-core = { path = "../maplibre-core" }
|
winit = { version = "0.26", default-features = false }
|
||||||
|
|
||||||
|
raw-window-handle = "0.4"
|
||||||
|
|
||||||
|
tracing = { version = "0.1" }
|
||||||
|
tracing-subscriber = { version = "0.3", optional = true }
|
||||||
|
|
||||||
|
cgmath = "0.18"
|
||||||
|
|
||||||
|
geo = { version = "0.19" }
|
||||||
|
geo-types = { version = "0.7", features = ["use-rstar_0_9"] }
|
||||||
|
rstar = { version = "0.9" }
|
||||||
|
prost = "0.9"
|
||||||
|
geozero = { git = "https://github.com/georust/geozero", rev = "373b731", default-features = false, features = ["with-mvt", "with-geo"]}
|
||||||
|
|
||||||
|
tile-grid = "0.3"
|
||||||
|
|
||||||
|
# Rendering
|
||||||
|
wgpu = { version = "0.12" }
|
||||||
|
lyon = { version = "0.17", features = [] }
|
||||||
|
|
||||||
|
# cached = "0.32"
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log = "0.4"
|
||||||
|
|
||||||
|
# Utils
|
||||||
|
bytemuck = "1.2.0"
|
||||||
|
bytemuck_derive = "1.0"
|
||||||
|
|
||||||
|
include_dir = "0.7.2"
|
||||||
|
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
csscolorparser = { version = "0.5", features = ["serde", "cint"]}
|
||||||
|
cint = "0.2"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
maplibre-build-tools = { path = "../maplibre-build-tools" }
|
||||||
|
|||||||
@ -1 +1,162 @@
|
|||||||
pub use maplibre_core::*;
|
use crate::io::scheduler::Scheduler;
|
||||||
|
|
||||||
|
mod input;
|
||||||
|
|
||||||
|
pub(crate) mod coords;
|
||||||
|
pub(crate) mod error;
|
||||||
|
pub(crate) mod io;
|
||||||
|
pub(crate) mod map_state;
|
||||||
|
pub(crate) mod platform;
|
||||||
|
pub(crate) mod render;
|
||||||
|
pub(crate) mod tessellation;
|
||||||
|
pub(crate) mod util;
|
||||||
|
pub(crate) mod winit;
|
||||||
|
pub(crate) mod style;
|
||||||
|
pub(crate) mod tilejson;
|
||||||
|
|
||||||
|
// Used for benchmarking
|
||||||
|
pub mod benchmarking;
|
||||||
|
pub mod window;
|
||||||
|
|
||||||
|
use crate::map_state::{MapState, Runnable};
|
||||||
|
use crate::render::render_state::RenderState;
|
||||||
|
use crate::window::{WindowFactory, WindowSize};
|
||||||
|
pub use io::scheduler::ScheduleMethod;
|
||||||
|
use crate::style::Style;
|
||||||
|
pub use platform::schedule_method::*;
|
||||||
|
|
||||||
|
pub struct Map<W, E> {
|
||||||
|
map_state: MapState<W>,
|
||||||
|
event_loop: E,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W, E> Map<W, E>
|
||||||
|
where
|
||||||
|
MapState<W>: Runnable<E>,
|
||||||
|
{
|
||||||
|
pub fn run(self) {
|
||||||
|
self.run_with_optionally_max_frames(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_with_max_frames(self, max_frames: u64) {
|
||||||
|
self.run_with_optionally_max_frames(Some(max_frames));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||||
|
self.map_state.run(self.event_loop, max_frames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct UninitializedMap<W, E> {
|
||||||
|
window: W,
|
||||||
|
window_size: WindowSize,
|
||||||
|
event_loop: E,
|
||||||
|
scheduler: Scheduler,
|
||||||
|
style: Style,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W, E> UninitializedMap<W, E>
|
||||||
|
where
|
||||||
|
W: raw_window_handle::HasRawWindowHandle,
|
||||||
|
{
|
||||||
|
pub async fn initialize(self) -> Map<W, E> {
|
||||||
|
let render_state = RenderState::initialize(&self.window, self.window_size).await;
|
||||||
|
Map {
|
||||||
|
map_state: MapState::new(
|
||||||
|
self.window,
|
||||||
|
self.window_size,
|
||||||
|
render_state,
|
||||||
|
self.scheduler,
|
||||||
|
self.style,
|
||||||
|
),
|
||||||
|
event_loop: self.event_loop,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
impl<W, E> UninitializedMap<W, E>
|
||||||
|
where
|
||||||
|
W: raw_window_handle::HasRawWindowHandle,
|
||||||
|
MapState<W>: Runnable<E>,
|
||||||
|
{
|
||||||
|
pub fn run_sync(self) {
|
||||||
|
self.run_sync_with_optionally_max_frames(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run_sync_with_max_frames(self, max_frames: u64) {
|
||||||
|
self.run_sync_with_optionally_max_frames(Some(max_frames))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_sync_with_optionally_max_frames(self, max_frames: Option<u64>) {
|
||||||
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
.worker_threads(4)
|
||||||
|
.enable_io()
|
||||||
|
.enable_time()
|
||||||
|
.on_thread_start(|| {
|
||||||
|
#[cfg(feature = "enable-tracing")]
|
||||||
|
tracy_client::set_thread_name("tokio-runtime-worker");
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
self.initialize()
|
||||||
|
.await
|
||||||
|
.run_with_optionally_max_frames(max_frames);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MapBuilder<W, E> {
|
||||||
|
window_factory: Box<WindowFactory<W, E>>,
|
||||||
|
schedule_method: Option<ScheduleMethod>,
|
||||||
|
scheduler: Option<Scheduler>,
|
||||||
|
style: Option<Style>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W, E> MapBuilder<W, E>
|
||||||
|
where
|
||||||
|
MapState<W>: Runnable<E>,
|
||||||
|
W: raw_window_handle::HasRawWindowHandle,
|
||||||
|
{
|
||||||
|
pub(crate) fn new(create_window: Box<WindowFactory<W, E>>) -> Self {
|
||||||
|
Self {
|
||||||
|
window_factory: create_window,
|
||||||
|
schedule_method: None,
|
||||||
|
scheduler: None,
|
||||||
|
style: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_schedule_method(mut self, schedule_method: ScheduleMethod) -> Self {
|
||||||
|
self.schedule_method = Some(schedule_method);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_existing_scheduler(mut self, scheduler: Scheduler) -> Self {
|
||||||
|
self.scheduler = Some(scheduler);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_style(mut self, style: Style) -> Self {
|
||||||
|
self.style = Some(style);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(self) -> UninitializedMap<W, E> {
|
||||||
|
let (window, window_size, event_loop) = (self.window_factory)();
|
||||||
|
|
||||||
|
let scheduler = self
|
||||||
|
.scheduler
|
||||||
|
.unwrap_or_else(|| Scheduler::new(self.schedule_method.unwrap_or_default()));
|
||||||
|
let style = self.style.unwrap_or_default();
|
||||||
|
|
||||||
|
UninitializedMap {
|
||||||
|
window,
|
||||||
|
window_size,
|
||||||
|
event_loop,
|
||||||
|
scheduler,
|
||||||
|
style,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -7,8 +7,8 @@ edition = "2021"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
web-webgl = ["maplibre-core/web-webgl"]
|
web-webgl = ["maplibre/web-webgl"]
|
||||||
enable-tracing = ["maplibre-core/enable-tracing"]
|
enable-tracing = ["maplibre/enable-tracing"]
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.release]
|
[package.metadata.wasm-pack.profile.release]
|
||||||
wasm-opt = true
|
wasm-opt = true
|
||||||
@ -18,4 +18,4 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
maplibre-core = { path = "../maplibre-core" }
|
maplibre = { path = "../maplibre" }
|
||||||
Loading…
x
Reference in New Issue
Block a user