forked from MapComplete/MapComplete
Fix tile generation, don't generate files from 100GB anymore
This commit is contained in:
parent
ce435765f2
commit
7d420b0765
5 changed files with 20 additions and 7 deletions
2
android
2
android
|
@ -1 +1 @@
|
|||
Subproject commit dc3f3f5ac3d4d42bed7aeb58ff5386a063dbac06
|
||||
Subproject commit 472b6da88e038d34e2915ebd36350376acf0c58c
|
|
@ -46,12 +46,17 @@ export class PmTilesExtractGenerator {
|
|||
return `${this._targetDir}/${z}/${x}/${y}.pmtiles`
|
||||
}
|
||||
|
||||
async generateArchive(z: number, x: number, y: number, maxzoom?: number): Promise<string> {
|
||||
async generateArchive(z: number, x: number, y: number, maxzoom: number): Promise<string> {
|
||||
const [[max_lat, min_lon], [min_lat, max_lon]] = Tiles.tile_bounds(z, x, y)
|
||||
let maxzoomflag = ""
|
||||
if (maxzoom !== undefined) {
|
||||
maxzoomflag = " --maxzoom=" + maxzoom
|
||||
}
|
||||
|
||||
if(!maxzoom && z < 15){
|
||||
throw "No maxzoom for a pretty low zoom detected. This will result in a big archive"
|
||||
}
|
||||
|
||||
const outputFileName = this.getFilename(z, x, y)
|
||||
await this.startProcess(
|
||||
`extract ${
|
||||
|
|
|
@ -66,7 +66,8 @@ class ServerPmTileExtracts extends Script {
|
|||
ScriptUtils.createParentDir(targetFile)
|
||||
console.log("Creating", targetFile)
|
||||
const start = new Date()
|
||||
await generator.generateArchive(z, x, y)
|
||||
const maxzoom = OfflineBasemapManager.zoomelevels[z]
|
||||
await generator.generateArchive(z, x, y, maxzoom)
|
||||
const stop = new Date()
|
||||
console.log(
|
||||
"Creating ",
|
||||
|
@ -82,7 +83,11 @@ class ServerPmTileExtracts extends Script {
|
|||
if (req.destroyed) {
|
||||
return null
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": "application/octet-stream" })
|
||||
const stats = statSync(targetFile)
|
||||
|
||||
res.writeHead(200, { "Content-Type": "application/octet-stream" ,
|
||||
"Content-Length": stats.size
|
||||
})
|
||||
Server.sendFile(targetFile, res)
|
||||
|
||||
return null
|
||||
|
|
|
@ -73,7 +73,6 @@ export class OfflineForegroundDataManager {
|
|||
}
|
||||
this._bboxesForOffline.data.push(data)
|
||||
this._bboxesForOffline.update(offl => OfflineForegroundDataManager.clean(offl))
|
||||
// this._bboxesForOffline.update(data => OfflineForegroundDataManager.clean(data))
|
||||
this._isUpdating.set(true)
|
||||
await this.updateSingleBbox(data)
|
||||
this._isUpdating.set(false)
|
||||
|
@ -100,7 +99,6 @@ export class OfflineForegroundDataManager {
|
|||
// As 'offlBbox' is included in the _bboxForOffline, pinging it will update downstream UI elements
|
||||
console.log(">>> Updating bbox preping", offlBbox, this._bboxesForOffline.data.indexOf(offlBbox))
|
||||
this._bboxesForOffline.ping()
|
||||
console.log(">>> Updating bbox", offlBbox, this._bboxesForOffline.data.indexOf(offlBbox))
|
||||
try {
|
||||
await OfflineBasemapManager.singleton.installBbox(bbox)
|
||||
console.log(">>> BBox update started")
|
||||
|
@ -117,6 +115,11 @@ export class OfflineForegroundDataManager {
|
|||
console.log(">>> bboxes for offline are now:", this._bboxesForOffline.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges fully contained bboxes into the bigger bbox
|
||||
* @param bboxes
|
||||
* @private
|
||||
*/
|
||||
private static clean(bboxes: OfflineBbox[]): OfflineBbox[] {
|
||||
const validated = bboxes.filter(bbox => {
|
||||
try {
|
||||
|
|
|
@ -145,7 +145,7 @@ export default class OverpassFeatureSource<T extends OsmFeature = OsmFeature>
|
|||
} catch (e) {
|
||||
this.retries.update(i => i + 1)
|
||||
console.error(`QUERY FAILED (attempt ${this.retries.data}, will retry: ${this._isActive.data}) due to`, e)
|
||||
if(options.noRetries){
|
||||
if(options?.noRetries){
|
||||
throw e
|
||||
}
|
||||
await Utils.waitFor(1000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue