forked from MapComplete/MapComplete
Feature: offline basemaps: first working version (without ability to install basemaps from the UI)
This commit is contained in:
parent
4c858fbe7e
commit
2cd0b11448
13 changed files with 494 additions and 178 deletions
39
scripts/generatePmTilesExtractionScript.ts
Normal file
39
scripts/generatePmTilesExtractionScript.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import Script from "./Script"
|
||||
import { Tiles } from "../src/Models/TileRange"
|
||||
|
||||
class GeneratePmTilesExtractionScript extends Script {
|
||||
|
||||
constructor() {
|
||||
super("Generates a bash script to extract all subpyramids of maxzoom=8 from planet-latest.pmtiles")
|
||||
}
|
||||
|
||||
private emitRange(z: number, x: number, y: number, maxzoom?: number): string {
|
||||
const [[max_lat, min_lon], [min_lat, max_lon]] = Tiles.tile_bounds(z, x, y)
|
||||
let maxzoomflag = ""
|
||||
if(maxzoom !== undefined){
|
||||
maxzoomflag = " --maxzoom="+maxzoom
|
||||
}
|
||||
return (`./pmtiles extract planet-latest.pmtiles --minzoom=${z}${maxzoomflag} --bbox=${[min_lon, min_lat + 0.0001, max_lon, max_lat].join(",")} ${z}-${x}-${y}.pmtiles`)
|
||||
}
|
||||
|
||||
private generateField(z: number, maxzoom?:number){
|
||||
const boundary = 2 << z
|
||||
for (let x = 0; x < boundary; x++) {
|
||||
const xCommands = []
|
||||
for (let y = 0; y < boundary; y++) {
|
||||
xCommands.push(this.emitRange(z, x, y,maxzoom))
|
||||
}
|
||||
console.log(xCommands.join(" && ") + " && echo 'All pyramids for x = " + x + " are generated' & ")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async main(): Promise<void> {
|
||||
this.generateField(0, 4)
|
||||
this.generateField(5, 8)
|
||||
this.generateField(9)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new GeneratePmTilesExtractionScript().run()
|
Loading…
Add table
Add a link
Reference in a new issue