mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Include munichs tiles in final binary
This commit is contained in:
parent
0345072108
commit
74b62791d1
18
Cargo.toml
18
Cargo.toml
@ -18,8 +18,8 @@ build = "build.rs"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
#[package.metadata.wasm-pack.profile.release]
|
[package.metadata.wasm-pack.profile.release]
|
||||||
#wasm-opt = false
|
wasm-opt = true
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
@ -45,7 +45,6 @@ instant = { version = "0.1", features = ["stdweb"] }
|
|||||||
futures = "0.3.5"
|
futures = "0.3.5"
|
||||||
pollster = "0.2"
|
pollster = "0.2"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
|
|
||||||
winit = { version = "0.25", default-features = true, features = ["x11", "wayland"] }
|
winit = { version = "0.25", default-features = true, features = ["x11", "wayland"] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@ -53,17 +52,20 @@ winit = { version = "0.25", default-features = true, features = ["x11", "wayland
|
|||||||
# Vector riles
|
# Vector riles
|
||||||
vector-tile = { path = "./libs/vector_tile" }
|
vector-tile = { path = "./libs/vector_tile" }
|
||||||
style-spec = { path = "./libs/style_spec" }
|
style-spec = { path = "./libs/style_spec" }
|
||||||
|
|
||||||
|
# Math and geo
|
||||||
|
# https://docs.rs/euclid/0.22.6/euclid/index.html
|
||||||
#geo = "0.18.0"
|
#geo = "0.18.0"
|
||||||
#geo-types = "0.7"
|
#geo-types = "0.7"
|
||||||
# proj = "0.24" FIXME: Incompatible with wasm
|
# proj = "0.24" FIXME: Incompatible with wasm
|
||||||
# mbutiles = "0.1.1" FIXME: Incompatible with wasm
|
|
||||||
cgmath = "0.18"
|
cgmath = "0.18"
|
||||||
|
|
||||||
# Rendering
|
# Rendering
|
||||||
wgpu = { version = "0.11" }
|
wgpu = { version = "0.11" }
|
||||||
lyon = { version = "0.17", features = ["extra"] } # extra for rust logo
|
lyon = { version = "0.17", features = ["extra"] } # extra for rust logo
|
||||||
lyon_path = "0.17"
|
lyon_path = "0.17"
|
||||||
# https://docs.rs/euclid/0.22.6/euclid/index.html
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
@ -73,9 +75,8 @@ log = "0.4"
|
|||||||
bytemuck = "1.2.0"
|
bytemuck = "1.2.0"
|
||||||
bytemuck_derive = "1.0"
|
bytemuck_derive = "1.0"
|
||||||
|
|
||||||
# Serialization
|
include_dir = "0.7.2"
|
||||||
#serde = { version = "1.0", features = ["derive"] }
|
|
||||||
#serde_json = "1.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
@ -84,6 +85,7 @@ test-env-log = "0.2"
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
wgsl-validate = { path = "./libs/wgsl_validate" }
|
wgsl-validate = { path = "./libs/wgsl_validate" }
|
||||||
|
mapr-utils = { path = "./libs/mapr_utils" }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "mapr"
|
name = "mapr"
|
||||||
|
|||||||
14
build.rs
14
build.rs
@ -1,5 +1,19 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use mapr_utils::mbtiles::extract;
|
||||||
use wgsl_validate::validate_project_wgsl;
|
use wgsl_validate::validate_project_wgsl;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
validate_project_wgsl();
|
validate_project_wgsl();
|
||||||
|
|
||||||
|
let root_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
|
let out_dir = env::var("OUT_DIR").unwrap();
|
||||||
|
|
||||||
|
let out = PathBuf::from(Path::new(&out_dir).join("munich-tiles"));
|
||||||
|
//let out = PathBuf::from(Path::new(&root_dir).join("test-data/munich-tiles"));
|
||||||
|
let source = Path::new(&root_dir).join("test-data/maptiler-osm-2017-07-03-v3.6.1-germany_munich.mbtiles");
|
||||||
|
extract(source,
|
||||||
|
out,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
mod static_database;
|
||||||
|
|
||||||
24
src/io/static_database.rs
Normal file
24
src/io/static_database.rs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use std::concat;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use include_dir::{Dir, File, include_dir};
|
||||||
|
|
||||||
|
static TILES: Dir = include_dir!("$OUT_DIR/munich-tiles");
|
||||||
|
|
||||||
|
pub fn get_tile_count() -> usize {
|
||||||
|
TILES.files().count()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_tile(x: u32, y: u32, z: u32) -> Option<&'static File<'static>> {
|
||||||
|
TILES.get_file(format!("{}/{}/{}.{}", z, x, y, "pbf"))
|
||||||
|
}
|
||||||
|
|
||||||
|
mod tests {
|
||||||
|
use crate::io::static_database::{get_tile, get_tile_count};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_tiles_available() {
|
||||||
|
assert!(get_tile(0,0,0).is_some()); // World overview
|
||||||
|
assert!(get_tile(2179, 1421,12).is_some()); // Maxvorstadt Munich
|
||||||
|
}
|
||||||
|
}
|
||||||
1
test-data/.gitignore
vendored
Normal file
1
test-data/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.mbtiles
|
||||||
Loading…
x
Reference in New Issue
Block a user