diff --git a/scripts/generatePmTilesExtracts.ts b/scripts/generatePmTilesExtracts.ts index ce1f39c1a..44fe11bf9 100644 --- a/scripts/generatePmTilesExtracts.ts +++ b/scripts/generatePmTilesExtracts.ts @@ -38,21 +38,29 @@ 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)}`) } + private* generateColumnIfNeeded(z: number, x: number, boundary: number, maxzoom?: number): Generator> { + const lastFileForColumn = this.getFilename(z, x, boundary - 1) + if (existsSync(this.targetDir + "/" + lastFileForColumn)) { + // Skip this column, already exists + console.log("Skipping column ", x, "at zoom", z) + this.skipped += boundary + return + } + console.log("Starting column", x, "at zoom", z, "as", this.targetDir + "/" + lastFileForColumn, "does not exist") + + for (let y = 0; y < boundary; y++) { + yield this.generateArchive(z, x, y, maxzoom) + } + } + private* generateField(z: number, maxzoom?: number): Generator> { 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++) { - const lastFileForColumn = this.getFilename(z, x, boundary - 1) - if (existsSync(this.targetDir + "/" + lastFileForColumn)) { - // Skip this column, already exists - console.log("Skipping column ", x, "at zoom", z) - this.skipped += boundary - continue - } - console.log("Starting column", x, "at zoom", z, "as", this.targetDir + "/" + lastFileForColumn, "does not exist") - - for (let y = 0; y < boundary; y++) { - yield this.generateArchive(z, x, y, maxzoom) - } + this.generateColumnIfNeeded(z, x, boundary, maxzoom) } }