Feature(offline): prioritize generating europe

This commit is contained in:
Pieter Vander Vennet 2025-07-31 13:43:21 +02:00
parent 55ef862027
commit b6f21a795f

View file

@ -38,15 +38,13 @@ class GeneratePmTilesExtracts extends Script {
return this.startProcess(`extract planet-latest.pmtiles --download-threads=1 --minzoom=${z}${maxzoomflag} --bbox=${[min_lon, min_lat + 0.0001, max_lon, max_lat].join(",")} ${this.getFilename(z, x, y)}`) return this.startProcess(`extract planet-latest.pmtiles --download-threads=1 --minzoom=${z}${maxzoomflag} --bbox=${[min_lon, min_lat + 0.0001, max_lon, max_lat].join(",")} ${this.getFilename(z, x, y)}`)
} }
private* generateField(z: number, maxzoom?: number): Generator<Promise<void>> { private* generateColumnIfNeeded(z: number, x: number, boundary: number, maxzoom?: number): Generator<Promise<void>> {
const boundary = 2 << (z - 1)
for (let x = 0; x < boundary; x++) {
const lastFileForColumn = this.getFilename(z, x, boundary - 1) const lastFileForColumn = this.getFilename(z, x, boundary - 1)
if (existsSync(this.targetDir + "/" + lastFileForColumn)) { if (existsSync(this.targetDir + "/" + lastFileForColumn)) {
// Skip this column, already exists // Skip this column, already exists
console.log("Skipping column ", x, "at zoom", z) console.log("Skipping column ", x, "at zoom", z)
this.skipped += boundary this.skipped += boundary
continue return
} }
console.log("Starting column", x, "at zoom", z, "as", this.targetDir + "/" + lastFileForColumn, "does not exist") console.log("Starting column", x, "at zoom", z, "as", this.targetDir + "/" + lastFileForColumn, "does not exist")
@ -54,6 +52,16 @@ class GeneratePmTilesExtracts extends Script {
yield this.generateArchive(z, x, y, maxzoom) yield this.generateArchive(z, x, y, maxzoom)
} }
} }
private* generateField(z: number, maxzoom?: number): Generator<Promise<void>> {
const boundary = 2 << (z - 1)
for (let x = 0; x < boundary / 2; x++) {
// We first generate starting from the meridian, as this will prioritize Europe, where the dev is based
this.generateColumnIfNeeded(z, x, boundary, maxzoom)
}
for (let x = 0; x < boundary; x++) {
this.generateColumnIfNeeded(z, x, boundary, maxzoom)
}
} }
private getFilename(z: number, x: number, y: number) { private getFilename(z: number, x: number, y: number) {