Use static_database instead of test data

This commit is contained in:
Maximilian Ammann 2021-12-18 11:44:17 +01:00
parent 99ba556110
commit 1315cb3dca
5 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,4 @@
use std::env;
use std::{env, fs};
use std::path::{Path, PathBuf};
use mapr_utils::mbtiles::extract;
@ -11,9 +11,13 @@ fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let out = PathBuf::from(Path::new(&out_dir).join("munich-tiles"));
fs::remove_dir_all(&out);
//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,
);
).unwrap();
}

View File

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

View File

@ -9,6 +9,10 @@ pub fn get_tile_count() -> usize {
TILES.files().count()
}
pub fn get_source_path() -> &'static str {
concat!(env!("OUT_DIR"), "/munich-tiles")
}
pub fn get_tile(x: u32, y: u32, z: u32) -> Option<&'static File<'static>> {
TILES.get_file(format!("{}/{}/{}.{}", z, x, y, "pbf"))
}
@ -18,6 +22,7 @@ mod tests {
#[test]
fn test_tiles_available() {
assert_eq!(get_tile_count(), 1); // World overview
assert!(get_tile(0,0,0).is_some()); // World overview
assert!(get_tile(2179, 1421,12).is_some()); // Maxvorstadt Munich
}

View File

@ -10,6 +10,7 @@ use winit::event::{DeviceEvent, ElementState, KeyboardInput, MouseButton, Window
use winit::window::Window;
use crate::fps_meter::FPSMeter;
use crate::io::static_database;
use crate::render::camera;
use crate::render::camera::CameraController;
use crate::render::tesselation::TileMask;
@ -81,8 +82,6 @@ pub struct State {
scene: SceneParams,
}
const TEST_TILES: &[u8] = include_bytes!("../../test-data/12-2176-1425.pbf");
impl SceneParams {
pub fn new() -> Self {
let mut cpu_primitives = Vec::with_capacity(PRIM_BUFFER_LEN);
@ -120,7 +119,9 @@ impl State {
let mut geometry: VertexBuffers<GpuVertexUniform, u16> = VertexBuffers::new();
//let tile = parse_tile("test-data/12-2176-1425.pbf").expect("failed loading tile");
let tile = parse_tile_reader(&mut Cursor::new(TEST_TILES)).expect("failed to load tile");
println!("Using static database from {}", static_database::get_source_path());
let tile = parse_tile_reader(&mut Cursor::new(static_database::get_tile(2179, 1421,12).unwrap().contents())).expect("failed to load tile");
let (tile_stroke_range, tile_fill_range) = (
tile.tesselate_stroke(&mut geometry, STROKE_PRIM_ID),
tile.tesselate_fill(&mut geometry, FILL_PRIM_ID),

Binary file not shown.