forked from MapComplete/MapComplete
Chore: housekeeping
This commit is contained in:
parent
cd9e03dd6f
commit
b300fffdc5
156 changed files with 4436 additions and 1318 deletions
|
@ -8,7 +8,6 @@ import { Tiles } from "../src/Models/TileRange"
|
|||
import ScriptUtils from "./ScriptUtils"
|
||||
|
||||
class DownloadCommunityIndex extends Script {
|
||||
|
||||
constructor() {
|
||||
super("Updates the community index")
|
||||
}
|
||||
|
@ -18,7 +17,8 @@ class DownloadCommunityIndex extends Script {
|
|||
}
|
||||
|
||||
private static targetZoomlevel: number = 6
|
||||
private static upstreamUrl: string = "https://raw.githubusercontent.com/osmlab/osm-community-index/main/dist/"
|
||||
private static upstreamUrl: string =
|
||||
"https://raw.githubusercontent.com/osmlab/osm-community-index/main/dist/"
|
||||
|
||||
/**
|
||||
* Prunes away unnecessary fields from a CommunityResource
|
||||
|
@ -33,12 +33,14 @@ class DownloadCommunityIndex extends Script {
|
|||
resolved: {
|
||||
name: r.resolved.name,
|
||||
description: r.resolved.description,
|
||||
url: r.resolved.url
|
||||
}
|
||||
url: r.resolved.url,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
private static stripResourcesObj(resources: Readonly<Record<string, Readonly<CommunityResource>>>) {
|
||||
private static stripResourcesObj(
|
||||
resources: Readonly<Record<string, Readonly<CommunityResource>>>
|
||||
) {
|
||||
const stripped: Record<string, CommunityResource> = {}
|
||||
for (const k in resources) {
|
||||
const type = resources[k].type
|
||||
|
@ -52,20 +54,24 @@ class DownloadCommunityIndex extends Script {
|
|||
}
|
||||
|
||||
public static async update(targetDirectory: string) {
|
||||
const data = await Utils.downloadJson<FeatureCollection<Polygon | MultiPolygon, {
|
||||
resources: Record<string, CommunityResource>,
|
||||
nameEn: string,
|
||||
id: string
|
||||
}>>(DownloadCommunityIndex.upstreamUrl + "completeFeatureCollection.json"
|
||||
)
|
||||
const data = await Utils.downloadJson<
|
||||
FeatureCollection<
|
||||
Polygon | MultiPolygon,
|
||||
{
|
||||
resources: Record<string, CommunityResource>
|
||||
nameEn: string
|
||||
id: string
|
||||
}
|
||||
>
|
||||
>(DownloadCommunityIndex.upstreamUrl + "completeFeatureCollection.json")
|
||||
if (!existsSync(targetDirectory)) {
|
||||
mkdirSync(targetDirectory)
|
||||
}
|
||||
const features = data.features
|
||||
const global = features.find(
|
||||
f => f.id === "Q2"
|
||||
const global = features.find((f) => f.id === "Q2")
|
||||
const globalProperties = DownloadCommunityIndex.stripResourcesObj(
|
||||
global.properties.resources
|
||||
)
|
||||
const globalProperties = DownloadCommunityIndex.stripResourcesObj(global.properties.resources)
|
||||
writeFileSync(targetDirectory + "/global.json", JSON.stringify(globalProperties), "utf8")
|
||||
console.log("Written global properties")
|
||||
|
||||
|
@ -80,12 +86,15 @@ class DownloadCommunityIndex extends Script {
|
|||
const url = `${DownloadCommunityIndex.upstreamUrl}img/${type}.svg`
|
||||
await ScriptUtils.DownloadFileTo(url, `${targetDirectory}/${type}.svg`)
|
||||
}
|
||||
const local = features.filter(f => f.id !== "Q2")
|
||||
const local = features.filter((f) => f.id !== "Q2")
|
||||
const spread = GeoOperations.spreadIntoBboxes(local, DownloadCommunityIndex.targetZoomlevel)
|
||||
let written = 0
|
||||
let skipped = 0
|
||||
const writtenTilesOverview: Record<number, number[]> = {}
|
||||
writeFileSync(targetDirectory + "local.geojson", JSON.stringify({ type: "FeatureCollection", features: local }))
|
||||
writeFileSync(
|
||||
targetDirectory + "local.geojson",
|
||||
JSON.stringify({ type: "FeatureCollection", features: local })
|
||||
)
|
||||
for (const tileIndex of spread.keys()) {
|
||||
const features = spread.get(tileIndex)
|
||||
const clipped = GeoOperations.clipAllInBox(features, tileIndex)
|
||||
|
@ -94,7 +103,9 @@ class DownloadCommunityIndex extends Script {
|
|||
continue
|
||||
}
|
||||
for (const f of clipped) {
|
||||
f.properties.resources = DownloadCommunityIndex.stripResourcesObj(f.properties.resources)
|
||||
f.properties.resources = DownloadCommunityIndex.stripResourcesObj(
|
||||
f.properties.resources
|
||||
)
|
||||
}
|
||||
|
||||
const [z, x, y] = Tiles.tile_from_index(tileIndex)
|
||||
|
@ -102,7 +113,11 @@ class DownloadCommunityIndex extends Script {
|
|||
clipped.forEach((f) => {
|
||||
delete f.bbox
|
||||
})
|
||||
writeFileSync(path, JSON.stringify({ type: "FeatureCollection", features: clipped }), "utf8")
|
||||
writeFileSync(
|
||||
path,
|
||||
JSON.stringify({ type: "FeatureCollection", features: clipped }),
|
||||
"utf8"
|
||||
)
|
||||
written++
|
||||
let yList = writtenTilesOverview[x]
|
||||
if (!yList) {
|
||||
|
@ -113,11 +128,14 @@ class DownloadCommunityIndex extends Script {
|
|||
console.log(`Written tile ${path}`)
|
||||
}
|
||||
console.log(`Created ${written} tiles, skipped ${skipped}`)
|
||||
writeFileSync(targetDirectory + "/tile_6_overview.json", JSON.stringify(writtenTilesOverview), "utf8")
|
||||
writeFileSync(
|
||||
targetDirectory + "/tile_6_overview.json",
|
||||
JSON.stringify(writtenTilesOverview),
|
||||
"utf8"
|
||||
)
|
||||
console.log("Created overview file")
|
||||
}
|
||||
|
||||
|
||||
async main(args: string[]): Promise<void> {
|
||||
const path = args[0]
|
||||
if (!path) {
|
||||
|
@ -126,7 +144,6 @@ class DownloadCommunityIndex extends Script {
|
|||
}
|
||||
|
||||
await DownloadCommunityIndex.update(path)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ export class GenerateDocs extends Script {
|
|||
ScriptUtils.fixUtils()
|
||||
|
||||
this.WriteMarkdownFile("./Docs/SpecialRenderings.md", SpecialVisualizations.HelpMessage(), [
|
||||
"src/UI/SpecialVisualizations.ts"
|
||||
"src/UI/SpecialVisualizations.ts",
|
||||
])
|
||||
|
||||
if (!existsSync("./Docs/Themes")) {
|
||||
|
@ -171,7 +171,6 @@ export class GenerateDocs extends Script {
|
|||
ScriptUtils.erasableLog("Written docs for theme", theme.id)
|
||||
})
|
||||
|
||||
|
||||
this.WriteMarkdownFile(
|
||||
"./Docs/CalculatedTags.md",
|
||||
["# Metatags", SimpleMetaTaggers.HelpText(), ExtraFunctions.HelpText()].join("\n"),
|
||||
|
|
|
@ -9,12 +9,16 @@ import {
|
|||
DoesImageExist,
|
||||
PrevalidateTheme,
|
||||
ValidateLayer,
|
||||
ValidateThemeEnsemble
|
||||
ValidateThemeEnsemble,
|
||||
} from "../src/Models/ThemeConfig/Conversion/Validation"
|
||||
import { Translation } from "../src/UI/i18n/Translation"
|
||||
import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer"
|
||||
import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme"
|
||||
import { Conversion, DesugaringContext, DesugaringStep } from "../src/Models/ThemeConfig/Conversion/Conversion"
|
||||
import {
|
||||
Conversion,
|
||||
DesugaringContext,
|
||||
DesugaringStep,
|
||||
} from "../src/Models/ThemeConfig/Conversion/Conversion"
|
||||
import { Utils } from "../src/Utils"
|
||||
import Script from "./Script"
|
||||
import { AllSharedLayers } from "../src/Customizations/AllSharedLayers"
|
||||
|
@ -620,10 +624,7 @@ class LayerOverviewUtils extends Script {
|
|||
for (const sharedLayerPath of ScriptUtils.getLayerPaths()) {
|
||||
if (whitelist.size > 0) {
|
||||
const idByPath = sharedLayerPath.split("/").at(-1).split(".")[0]
|
||||
if (
|
||||
!Constants.isPriviliged(idByPath) &&
|
||||
!whitelist.has(idByPath)
|
||||
) {
|
||||
if (!Constants.isPriviliged(idByPath) && !whitelist.has(idByPath)) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ class GenerateLayouts extends Script {
|
|||
"https://api.panoramax.xyz",
|
||||
"https://panoramax.mapcomplete.org",
|
||||
"https://data.velopark.be",
|
||||
"https://data.mapcomplete.org"
|
||||
"https://data.mapcomplete.org",
|
||||
].concat(...(await this.eliUrls()))
|
||||
|
||||
SpecialVisualizations.specialVisualizations.forEach((sv) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue