Include munichs tiles in final binary

This commit is contained in:
Maximilian Ammann 2021-12-18 11:13:27 +01:00
parent 0345072108
commit 74b62791d1
5 changed files with 51 additions and 8 deletions

View File

@ -18,8 +18,8 @@ build = "build.rs"
[lib]
crate-type = ["cdylib", "rlib"]
#[package.metadata.wasm-pack.profile.release]
#wasm-opt = false
[package.metadata.wasm-pack.profile.release]
wasm-opt = true
[profile.release]
lto = true
@ -45,7 +45,6 @@ instant = { version = "0.1", features = ["stdweb"] }
futures = "0.3.5"
pollster = "0.2"
env_logger = "0.9"
winit = { version = "0.25", default-features = true, features = ["x11", "wayland"] }
[dependencies]
@ -53,17 +52,20 @@ winit = { version = "0.25", default-features = true, features = ["x11", "wayland
# Vector riles
vector-tile = { path = "./libs/vector_tile" }
style-spec = { path = "./libs/style_spec" }
# Math and geo
# https://docs.rs/euclid/0.22.6/euclid/index.html
#geo = "0.18.0"
#geo-types = "0.7"
# proj = "0.24" FIXME: Incompatible with wasm
# mbutiles = "0.1.1" FIXME: Incompatible with wasm
cgmath = "0.18"
# Rendering
wgpu = { version = "0.11" }
lyon = { version = "0.17", features = ["extra"] } # extra for rust logo
lyon_path = "0.17"
# https://docs.rs/euclid/0.22.6/euclid/index.html
# Logging
log = "0.4"
@ -73,9 +75,8 @@ log = "0.4"
bytemuck = "1.2.0"
bytemuck_derive = "1.0"
# Serialization
#serde = { version = "1.0", features = ["derive"] }
#serde_json = "1.0"
include_dir = "0.7.2"
[dev-dependencies]
criterion = "0.3"
@ -84,6 +85,7 @@ test-env-log = "0.2"
[build-dependencies]
wgsl-validate = { path = "./libs/wgsl_validate" }
mapr-utils = { path = "./libs/mapr_utils" }
[[bin]]
name = "mapr"

View File

@ -1,5 +1,19 @@
use std::env;
use std::path::{Path, PathBuf};
use mapr_utils::mbtiles::extract;
use wgsl_validate::validate_project_wgsl;
fn main() {
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,
);
}

View File

@ -0,0 +1,2 @@
mod static_database;

24
src/io/static_database.rs Normal file
View 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
View File

@ -0,0 +1 @@
*.mbtiles