Experiment: experimenting with PMTiles

This commit is contained in:
Pieter Vander Vennet 2025-07-25 19:39:27 +02:00
parent 517540face
commit 4c858fbe7e
6 changed files with 71 additions and 8 deletions

View file

@ -1,3 +1,63 @@
<script lang="ts"></script>
<script lang="ts">
import { PMTiles } from "pmtiles"
// What piece of the map to download and cache locally for the current map view?
const gentBBox = {
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
3.6911333519349228,
51.069673467969096
],
[
3.6911333519349228,
51.02886180987505
],
[
3.773873676856965,
51.02886180987505
],
[
3.773873676856965,
51.069673467969096
],
[
3.6911333519349228,
51.069673467969096
]
]
],
"type": "Polygon"
}
}
// URL or fetch source of the PMTiles archive
let source = new PMTiles("https://cache.mapcomplete.org/planet-latest.pmtiles")
async function test(z: number, x: number, y: number) {
const meta = await source.getMetadata()
console.log(meta)
const minzoom = meta["minzoom"]
const maxzoom = meta["maxzoom"]
console.log("Range is", minzoom, maxzoom)
for (const l of meta["vector_layers"]) {
// console.log(l)
}
// const header = await source.getHeader()
// console.log(header)
let resp = await source.getZxy(z, x, y)
console.log(resp)
// let tileData = resp?.data
// do something with tileData
}
test(14, 8338, 5469) // Elf-julistraat Brugge
test(15, 12233, 10534)
</script>
Nothing to test