Scripts: add script that moves wikimedia-files from image to Wikimedia

This commit is contained in:
Pieter Vander Vennet 2025-09-06 23:28:15 +02:00
parent 0d24f23177
commit 8d678008b7
2 changed files with 101 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import { Utils } from "../../Utils"
import { ImmutableStore, Store } from "../UIEventSource"
import { BBox } from "../BBox"
import osmtogeojson from "osmtogeojson"
import { Feature } from "geojson"
import { Feature, FeatureCollection } from "geojson"
("use strict")
/**
@ -37,7 +37,7 @@ export class Overpass {
this._includeMeta = includeMeta
}
public async queryGeoJson<T extends Feature>(bounds: BBox): Promise<[{features: T[]}, Date]> {
public async queryGeoJson<T extends Feature>(bounds: BBox): Promise<[{ features: T[] } & FeatureCollection, Date]> {
const bbox =
"[bbox:" +
bounds.getSouth() +
@ -49,16 +49,16 @@ export class Overpass {
bounds.getEast() +
"]"
const query = this.buildScript(bbox)
return await this.ExecuteQuery<T>(query)
return await this.executeQuery<T>(query)
}
public buildUrl(query: string) {
return `${this._interpreterUrl}?data=${encodeURIComponent(query)}`
}
private async ExecuteQuery<T extends Feature>(
private async executeQuery<T extends Feature>(
query: string
): Promise<[{features: T[]}, Date]> {
): Promise<[{ features: T[] } & FeatureCollection, Date]> {
const json = await Utils.downloadJson<{
elements: []
remark
@ -73,7 +73,7 @@ export class Overpass {
console.warn("No features for", this.buildUrl(query))
}
const geojson = <{features: T[]}> <any> osmtogeojson(json)
const geojson = <{ features: T[] } & FeatureCollection><any>osmtogeojson(json)
const osmTime = new Date(json.osm3s.timestamp_osm_base)
return [geojson, osmTime]
}