mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Use u8 for z and change example region
This commit is contained in:
parent
e8474a84b6
commit
90bdfd3505
14
build.rs
14
build.rs
@ -4,6 +4,10 @@ use std::{env, fs};
|
||||
use mapr_utils::mbtiles::extract;
|
||||
use wgsl_validate::validate_project_wgsl;
|
||||
|
||||
pub const MUNICH_X: u32 = 17421;
|
||||
pub const MUNICH_Y: u32 = 11360;
|
||||
pub const MUNICH_Z: u8 = 15;
|
||||
|
||||
fn main() {
|
||||
validate_project_wgsl();
|
||||
|
||||
@ -14,15 +18,15 @@ fn main() {
|
||||
if out.exists() && out.is_dir() {
|
||||
fs::remove_dir_all(&out).unwrap()
|
||||
}
|
||||
let source = Path::new(&root_dir).join("test-data/munich-12.mbtiles");
|
||||
let source = Path::new(&root_dir).join(format!("test-data/munich-{}.mbtiles", MUNICH_Z));
|
||||
|
||||
// Pack tiles around Maxvorstadt (100 tiles in each direction)
|
||||
// Pack tiles around Munich HBF (100 tiles in each direction)
|
||||
extract(
|
||||
source,
|
||||
out,
|
||||
12,
|
||||
(2179 - 100)..(2179 + 100),
|
||||
(1421 - 100)..(1421 + 100),
|
||||
MUNICH_Z,
|
||||
(MUNICH_X - 100)..(MUNICH_X + 100),
|
||||
(MUNICH_Y - 100)..(MUNICH_Y + 100),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ impl From<rusqlite::Error> for Error {
|
||||
pub fn extract<P: AsRef<Path>, R: AsRef<Path>>(
|
||||
input_mbtiles: P,
|
||||
output_dir: R,
|
||||
z: u32,
|
||||
z: u8,
|
||||
x_range: Range<u32>,
|
||||
y_range: Range<u32>,
|
||||
) -> Result<(), Error> {
|
||||
@ -83,13 +83,13 @@ pub fn extract<P: AsRef<Path>, R: AsRef<Path>>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn flip_vertical_axis(zoom: u32, value: u32) -> u32 {
|
||||
2u32.pow(zoom) - 1 - value
|
||||
fn flip_vertical_axis(zoom: u8, value: u32) -> u32 {
|
||||
2u32.pow(zoom as u32) - 1 - value
|
||||
}
|
||||
|
||||
fn extract_tile(tile: &Row, output_path: &Path) -> Result<(), Error> {
|
||||
let (z, x, mut y): (u32, u32, u32) = (
|
||||
tile.get::<_, u32>(0)?,
|
||||
let (z, x, mut y): (u8, u32, u32) = (
|
||||
tile.get::<_, u8>(0)?,
|
||||
tile.get::<_, u32>(1)?,
|
||||
tile.get::<_, u32>(2)?,
|
||||
);
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
use crate::io::cache::Cache;
|
||||
|
||||
pub const MUNICH_OFFSET_X: u32 = 2178;
|
||||
pub const MUNICH_OFFSET_Y: u32 = 1421;
|
||||
pub const MUNICH_X: u32 = 17421;
|
||||
pub const MUNICH_Y: u32 = 11360;
|
||||
pub const MUNICH_Z: u8 = 15;
|
||||
|
||||
pub fn fetch_munich_tiles(cache: &Cache) {
|
||||
for x in 0..6 {
|
||||
for y in 0..6 {
|
||||
cache.fetch((MUNICH_OFFSET_X + x, MUNICH_OFFSET_Y + y, 12).into())
|
||||
for x in 0..10 {
|
||||
for y in 0..10 {
|
||||
cache.fetch((MUNICH_X + x, MUNICH_Y + y, MUNICH_Z).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ use std::default::Default;
|
||||
use std::io::Cursor;
|
||||
use std::ops::Range;
|
||||
|
||||
use crate::example::{MUNICH_OFFSET_X, MUNICH_OFFSET_Y};
|
||||
use crate::example::{MUNICH_X, MUNICH_Y};
|
||||
use log::{trace, warn};
|
||||
use lyon::tessellation::VertexBuffers;
|
||||
use wgpu::util::DeviceExt;
|
||||
@ -371,8 +371,8 @@ impl State {
|
||||
|
||||
for tile in upload.iter() {
|
||||
let new_coords = TileCoords {
|
||||
x: tile.coords.x - MUNICH_OFFSET_X,
|
||||
y: tile.coords.y - MUNICH_OFFSET_Y,
|
||||
x: tile.coords.x - MUNICH_X,
|
||||
y: tile.coords.y - MUNICH_Y,
|
||||
z: tile.coords.z,
|
||||
};
|
||||
|
||||
@ -468,8 +468,8 @@ impl State {
|
||||
let TileCoords { x, y, .. } = entry.coords;
|
||||
|
||||
// FIXME: Improve conversion
|
||||
let world_x = x as i32 - MUNICH_OFFSET_X as i32;
|
||||
let world_y = y as i32 - MUNICH_OFFSET_Y as i32 * -1;
|
||||
let world_x = x as i32 - MUNICH_X as i32;
|
||||
let world_y = y as i32 - MUNICH_Y as i32 * -1;
|
||||
|
||||
pass.set_pipeline(&self.render_pipeline);
|
||||
let reference = match (world_x, world_y) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Bounds copied from https://boundingbox.klokantech.com/
|
||||
|
||||
|
||||
if ! command -v tilelive-copy &> /dev/null
|
||||
then
|
||||
@ -8,9 +8,13 @@ then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Bounds copied from https://boundingbox.klokantech.com/
|
||||
tilelive-copy \
|
||||
--minzoom=12 --maxzoom=12 \
|
||||
--bounds="11.417441,48.036758,11.77999,48.217795" \
|
||||
--bounds="11.395769,48.083436,11.618242,48.220866" \
|
||||
test-data/europe_germany-2020-02-13-openmaptiles-v3.12.1.mbtiles test-data/munich-12.mbtiles
|
||||
|
||||
tilelive-copy \
|
||||
--minzoom=15 --maxzoom=15 \
|
||||
--bounds="11.395769,48.083436,11.618242,48.220866" \
|
||||
test-data/europe_germany-2020-02-13-openmaptiles-v3.12.1.mbtiles test-data/munich-15.mbtiles
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user