mirror of
https://github.com/Findus23/RainbowRoad.git
synced 2024-09-19 16:03:52 +02:00
add data export
This commit is contained in:
parent
5c6338544c
commit
a6741fb5a1
2 changed files with 35 additions and 0 deletions
30
commands/export.ts
Normal file
30
commands/export.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
const files = ["Wien", "Burgenland", "Kärnten", "Niederösterreich", "Oberösterreich", "Salzburg", "Steiermark", "Tirol", "Vorarlberg"]
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
let count = 0
|
||||||
|
const data = {}
|
||||||
|
files.forEach(f => {
|
||||||
|
// @ts-ignore
|
||||||
|
data[f] = JSON.parse(fs.readFileSync(`../data/${f}.json`, 'utf8'))
|
||||||
|
// @ts-ignore
|
||||||
|
count += data[f].length
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const exportData = {}
|
||||||
|
// @ts-ignore
|
||||||
|
exportData["meta"] = {
|
||||||
|
"exported_at": now.toISOString(),
|
||||||
|
"license": "CC BY-SA 4.0",
|
||||||
|
"source": "https://github.com/Findus23/RainbowRoad/tree/main/data",
|
||||||
|
"num_crossings": count
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
exportData["data"] = data
|
||||||
|
|
||||||
|
|
||||||
|
fs.writeFileSync("../dist/data.json", JSON.stringify(exportData, null, 2).concat('\n'))
|
||||||
|
|
|
@ -56,6 +56,11 @@ export function setOverlay(): void {
|
||||||
"github.com/Findus23/RainbowRoad",
|
"github.com/Findus23/RainbowRoad",
|
||||||
"https://github.com/Findus23/RainbowRoad"
|
"https://github.com/Findus23/RainbowRoad"
|
||||||
))
|
))
|
||||||
|
content.appendChild(dlSet(
|
||||||
|
"Daten-Export:",
|
||||||
|
"/data.json",
|
||||||
|
"/data.json"
|
||||||
|
))
|
||||||
const dl = createElement("dl")
|
const dl = createElement("dl")
|
||||||
dl.appendChild(createElementWithContent("dt", "Lizenz:"))
|
dl.appendChild(createElementWithContent("dt", "Lizenz:"))
|
||||||
const dd = createElementWithContent("dd", "GPL-3 (Code), CC BY-SA 4.0 (Daten)")
|
const dd = createElementWithContent("dd", "GPL-3 (Code), CC BY-SA 4.0 (Daten)")
|
||||||
|
|
Loading…
Reference in a new issue