forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
ebc48f6b53
commit
e7de94576f
232 changed files with 11430 additions and 3365 deletions
|
@ -97,7 +97,6 @@ WHERE
|
|||
"User-Agent": "MapComplete script",
|
||||
})
|
||||
return <LanguageSpecResult[]>result.results.bindings
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,15 +191,17 @@ async function getOfficialLanguagesPerCountryCached(
|
|||
return officialLanguages
|
||||
}
|
||||
|
||||
async function generateSignLanguageOverview(){
|
||||
async function generateSignLanguageOverview() {
|
||||
const signLanguages = await fetchSignLanguages()
|
||||
const signPerId = WikidataUtils.extractLanguageData(signLanguages, WikidataUtils.languageRemapping)
|
||||
const asRecord : Record<string, Record<string, string>> = {}
|
||||
const signPerId = WikidataUtils.extractLanguageData(
|
||||
signLanguages,
|
||||
WikidataUtils.languageRemapping
|
||||
)
|
||||
const asRecord: Record<string, Record<string, string>> = {}
|
||||
for (const lng of signPerId.keys()) {
|
||||
asRecord[lng.toLowerCase()] = Utils.MapToObj(signPerId.get(lng).translations)
|
||||
}
|
||||
return asRecord
|
||||
|
||||
}
|
||||
|
||||
async function main(wipeCache = false) {
|
||||
|
@ -217,7 +218,10 @@ async function main(wipeCache = false) {
|
|||
const data = JSON.parse(readFileSync(cacheFile, { encoding: "utf8" }))
|
||||
const perId = WikidataUtils.extractLanguageData(data, WikidataUtils.languageRemapping)
|
||||
const nativeList = getNativeList(perId)
|
||||
writeFileSync("./src/assets/language_native.json", JSON.stringify({ ...nativeList, ...signLanguages }, null, " "))
|
||||
writeFileSync(
|
||||
"./src/assets/language_native.json",
|
||||
JSON.stringify({ ...nativeList, ...signLanguages }, null, " ")
|
||||
)
|
||||
|
||||
const languagesPerCountry = Utils.TransposeMap(
|
||||
await getOfficialLanguagesPerCountryCached(wipeCache)
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
DoesImageExist,
|
||||
PrevalidateTheme,
|
||||
ValidateLayer,
|
||||
ValidateThemeEnsemble
|
||||
ValidateThemeEnsemble,
|
||||
} from "../src/Models/ThemeConfig/Conversion/Validation"
|
||||
import { Translation } from "../src/UI/i18n/Translation"
|
||||
import { OrderLayer, PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer"
|
||||
|
@ -19,7 +19,7 @@ import {
|
|||
DesugaringStep,
|
||||
Each,
|
||||
Fuse,
|
||||
On
|
||||
On,
|
||||
} from "../src/Models/ThemeConfig/Conversion/Conversion"
|
||||
import { Utils } from "../src/Utils"
|
||||
import Script from "./Script"
|
||||
|
@ -201,14 +201,15 @@ class LayerBuilder extends Conversion<object, Map<string, LayerConfigJson>> {
|
|||
mkdirSync(LayerOverviewUtils.layerPath)
|
||||
}
|
||||
|
||||
const usedImages = Lists.dedup(new ExtractImages(true, new Set(this._desugaringState.tagRenderings.keys()))
|
||||
.convertStrict({ layers: [layer], id: "dummy", icon: undefined, title: undefined })
|
||||
.map((x) => x.path))
|
||||
const usedImages = Lists.dedup(
|
||||
new ExtractImages(true, new Set(this._desugaringState.tagRenderings.keys()))
|
||||
.convertStrict({ layers: [layer], id: "dummy", icon: undefined, title: undefined })
|
||||
.map((x) => x.path)
|
||||
)
|
||||
usedImages.sort()
|
||||
|
||||
layer["_usedImages"] = usedImages
|
||||
|
||||
|
||||
writeFileSync(LayerBuilder.targetPath(layer.id), JSON.stringify(layer, null, " "), {
|
||||
encoding: "utf8",
|
||||
})
|
||||
|
|
|
@ -14,20 +14,24 @@ import { GenerateLicenseInfo } from "./generateLicenseInfo"
|
|||
|
||||
class ImportCustomTheme extends Script {
|
||||
constructor() {
|
||||
super(["Given the path of a custom layer, will load the layer into mapcomplete as official","",
|
||||
"Usage:",
|
||||
"vite-node scripts/importCustomTheme.ts <path-of-layer-or-theme>"].join("\n"))
|
||||
super(
|
||||
[
|
||||
"Given the path of a custom layer, will load the layer into mapcomplete as official",
|
||||
"",
|
||||
"Usage:",
|
||||
"vite-node scripts/importCustomTheme.ts <path-of-layer-or-theme>",
|
||||
].join("\n")
|
||||
)
|
||||
}
|
||||
|
||||
async main(args: string[]) {
|
||||
if(args.length === 0){
|
||||
if (args.length === 0) {
|
||||
this.printHelp()
|
||||
return
|
||||
}
|
||||
const path = args[0]
|
||||
|
||||
const layerconfig = <LayerConfigJson>JSON.parse(
|
||||
readFileSync(path, "utf-8"))
|
||||
const layerconfig = <LayerConfigJson>JSON.parse(readFileSync(path, "utf-8"))
|
||||
const id = layerconfig.id
|
||||
const dirPath = "./assets/layers/" + id
|
||||
if (!existsSync(dirPath)) {
|
||||
|
|
|
@ -13,12 +13,12 @@ import { And } from "../../src/Logic/Tags/And"
|
|||
import { Lists } from "../../src/Utils/Lists"
|
||||
|
||||
export class FixWikimediaInImageTag extends Script {
|
||||
|
||||
constructor() {
|
||||
super("For the given bbox, queries all `image=http(s)://commons.wikimedia.org` tags and replaces it with `commons`-tagging")
|
||||
super(
|
||||
"For the given bbox, queries all `image=http(s)://commons.wikimedia.org` tags and replaces it with `commons`-tagging"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
private handleFeature(f: Feature): ChangeTagAction {
|
||||
const p = f.properties
|
||||
const existingCommons = p["wikimedia_commons"]
|
||||
|
@ -28,19 +28,25 @@ export class FixWikimediaInImageTag extends Script {
|
|||
return undefined
|
||||
}
|
||||
|
||||
const extractedCommons: string = img.match(/^https?:\/\/commons.wikimedia.org\/wiki\/(.*)$/)[1]
|
||||
console.log("Feature " + p.id + ": " + img + ", extr " + extractedCommons + ", old: " + existingCommons)
|
||||
|
||||
const extractedCommons: string = img.match(
|
||||
/^https?:\/\/commons.wikimedia.org\/wiki\/(.*)$/
|
||||
)[1]
|
||||
console.log(
|
||||
"Feature " +
|
||||
p.id +
|
||||
": " +
|
||||
img +
|
||||
", extr " +
|
||||
extractedCommons +
|
||||
", old: " +
|
||||
existingCommons
|
||||
)
|
||||
|
||||
if (existingCommons === extractedCommons) {
|
||||
return new ChangeTagAction(id,
|
||||
new Tag("image", ""),
|
||||
p,
|
||||
{
|
||||
changeType: "cleanup",
|
||||
theme: "/"
|
||||
}
|
||||
)
|
||||
return new ChangeTagAction(id, new Tag("image", ""), p, {
|
||||
changeType: "cleanup",
|
||||
theme: "/",
|
||||
})
|
||||
}
|
||||
if (existingCommons) {
|
||||
return undefined
|
||||
|
@ -48,12 +54,16 @@ export class FixWikimediaInImageTag extends Script {
|
|||
if (!extractedCommons.startsWith("File:")) {
|
||||
return undefined
|
||||
}
|
||||
return new ChangeTagAction(id,
|
||||
new And([new Tag("image", ""), new Tag("wikimedia_commons", decodeURIComponent(extractedCommons))]),
|
||||
return new ChangeTagAction(
|
||||
id,
|
||||
new And([
|
||||
new Tag("image", ""),
|
||||
new Tag("wikimedia_commons", decodeURIComponent(extractedCommons)),
|
||||
]),
|
||||
p,
|
||||
{
|
||||
changeType: "cleanup",
|
||||
theme: "/"
|
||||
theme: "/",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -63,7 +73,8 @@ export class FixWikimediaInImageTag extends Script {
|
|||
if (existsSync(pth)) {
|
||||
return JSON.parse(readFileSync(pth, "utf-8"))
|
||||
}
|
||||
const overpass = new Overpass(Constants.defaultOverpassUrls[0],
|
||||
const overpass = new Overpass(
|
||||
Constants.defaultOverpassUrls[0],
|
||||
new RegexTag("image", /https?:\/\/commons.wikimedia.org/)
|
||||
)
|
||||
const [feats] = await overpass.queryGeoJson(bbox)
|
||||
|
@ -77,18 +88,17 @@ export class FixWikimediaInImageTag extends Script {
|
|||
//return
|
||||
}
|
||||
|
||||
const bbox = new BBox([3.632100582083325,
|
||||
51.11343904784337, 3.8584183481742116,
|
||||
50.99383861993195])
|
||||
const bbox = new BBox([
|
||||
3.632100582083325, 51.11343904784337, 3.8584183481742116, 50.99383861993195,
|
||||
])
|
||||
const feats = await this.fetchData(bbox)
|
||||
|
||||
const actions = Lists.noNull(feats.features.map(f => this.handleFeature(f)))
|
||||
const actions = Lists.noNull(feats.features.map((f) => this.handleFeature(f)))
|
||||
|
||||
const xml = await Changes.createChangesetXMLForJosm(actions)
|
||||
const pth = "move_image_to_wikimedia_commons_" + bbox.toLngLatFlat().join("_") + ".osc"
|
||||
writeFileSync(pth, xml, "utf-8")
|
||||
console.log("Written xml to file://" + pth)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue