WIP: more features in inspector

This commit is contained in:
Pieter Vander Vennet 2024-11-25 23:44:26 +01:00
parent c34300fae1
commit 552ea22275
19 changed files with 526 additions and 65 deletions

View file

@ -26,7 +26,10 @@ export class Overpass {
) {
this._timeout = timeout ?? new ImmutableStore<number>(90)
this._interpreterUrl = interpreterUrl
const optimized = filter.optimize()
if (filter === undefined && !extraScripts) {
throw "Filter is undefined. This is probably a bug. Alternatively, pass an 'extraScript'"
}
const optimized = filter?.optimize()
if (optimized === true || optimized === false) {
throw "Invalid filter: optimizes to true of false"
}
@ -85,7 +88,7 @@ export class Overpass {
* new Overpass(new Tag("key","value"), [], "").buildScript("{{bbox}}") // => `[out:json][timeout:90]{{bbox}};(nwr["key"="value"];);out body;out meta;>;out skel qt;`
*/
public buildScript(bbox: string, postCall: string = "", pretty = false): string {
const filters = this._filter.asOverpass()
const filters = this._filter?.asOverpass() ?? []
let filter = ""
for (const filterOr of filters) {
if (pretty) {
@ -97,12 +100,13 @@ export class Overpass {
}
}
for (const extraScript of this._extraScripts) {
filter += "(" + extraScript + ");"
filter += extraScript
}
return `[out:json][timeout:${this._timeout.data}]${bbox};(${filter});out body;${
this._includeMeta ? "out meta;" : ""
}>;out skel qt;`
}
/**
* Constructs the actual script to execute on Overpass with geocoding
* 'PostCall' can be used to set an extra range, see 'AsOverpassTurboLink'