36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { writeFileSync } from "fs"
|
|
import Script from "./Script"
|
|
import sunny from "../public/assets/sunny.json"
|
|
|
|
export class GenerateSunnyUnlabeled extends Script {
|
|
constructor() {
|
|
super("Generates 'sunny-unlabeled.json' based on sunny.json")
|
|
}
|
|
|
|
generateUnlabeled() {
|
|
const unlabeled = { "#": "AUTOMATICALLY GENERATED! Do not edit.", ...sunny }
|
|
unlabeled.name = unlabeled.name + "-unlabeled"
|
|
unlabeled.layers = sunny.layers.filter(
|
|
(l) => l.type !== "symbol" || !l.layout["text-field"]
|
|
)
|
|
writeFileSync("public/assets/sunny-unlabeled.json", JSON.stringify(unlabeled, null, " "))
|
|
}
|
|
|
|
/**
|
|
* Generates a variation hosted by api.protomaps
|
|
*/
|
|
generateHosted() {
|
|
const tilesource = "https://api.protomaps.com/tiles/v4/{z}/{x}/{y}.mvt?key=2af8b969a9e8b692"
|
|
const hosted = { "#": "AUTOMATICALLY GENERATED! Do not edit.", ...sunny }
|
|
delete hosted.sources.protomaps.url
|
|
hosted.sources.protomaps["tiles"] = [tilesource]
|
|
writeFileSync("public/assets/sunny-hosted.json", JSON.stringify(hosted, null, " "))
|
|
}
|
|
|
|
async main(args: string[]): Promise<void> {
|
|
this.generateUnlabeled()
|
|
this.generateHosted()
|
|
}
|
|
}
|
|
|
|
new GenerateSunnyUnlabeled().run()
|