Filter out http sources, add types
This commit is contained in:
parent
86a797a75f
commit
18cc3d7748
3 changed files with 258 additions and 82 deletions
|
@ -1,6 +1,6 @@
|
|||
import Script from "./Script"
|
||||
import { Utils } from "../src/Utils"
|
||||
import { FeatureCollection } from "geojson"
|
||||
import { Eli, EliEntry } from "./@types/eli"
|
||||
import fs from "fs"
|
||||
|
||||
class DownloadEli extends Script {
|
||||
|
@ -12,8 +12,8 @@ class DownloadEli extends Script {
|
|||
// Target should use '.json' instead of '.geojson', as the latter cannot be imported by the build systems
|
||||
const target = args[0] ?? "src/assets/editor-layer-index.json"
|
||||
|
||||
const eli = <FeatureCollection>await Utils.downloadJson(url)
|
||||
const keptLayers = []
|
||||
const eli: Eli = await Utils.downloadJson(url)
|
||||
const keptLayers: EliEntry[] = []
|
||||
console.log("Got", eli.features.length, "ELI-entries")
|
||||
for (let layer of eli.features) {
|
||||
const props = layer.properties
|
||||
|
@ -45,11 +45,11 @@ class DownloadEli extends Script {
|
|||
continue
|
||||
}
|
||||
|
||||
if (props.permission_url === "no") {
|
||||
if (props.permission_osm === "no") {
|
||||
continue
|
||||
}
|
||||
|
||||
if (props.max_zoom < 19) {
|
||||
if (props.max_zoom && props.max_zoom < 19) {
|
||||
// We want users to zoom to level 19 when adding a point
|
||||
// If they are on a layer which hasn't enough precision, they can not zoom far enough. This is confusing, so we don't use this layer
|
||||
continue
|
||||
|
@ -60,24 +60,24 @@ class DownloadEli extends Script {
|
|||
continue
|
||||
}
|
||||
|
||||
const keptKeys = [
|
||||
"name",
|
||||
"id",
|
||||
"url",
|
||||
"attribution",
|
||||
"type",
|
||||
"category",
|
||||
"min_zoom",
|
||||
"max_zoom",
|
||||
"best",
|
||||
"default",
|
||||
"tile-size",
|
||||
]
|
||||
layer.properties = {}
|
||||
for (const keptKey of keptKeys) {
|
||||
if (props[keptKey]) {
|
||||
layer.properties[keptKey] = props[keptKey]
|
||||
}
|
||||
if (props.url.startsWith("http://")) {
|
||||
// Mixed content will not work properly, so we don't use this layer
|
||||
continue
|
||||
}
|
||||
|
||||
// Override the layer, so it contains only the properties we need
|
||||
layer.properties = {
|
||||
name: props.name,
|
||||
id: props.id,
|
||||
url: props.url,
|
||||
attribution: props.attribution,
|
||||
type: props.type,
|
||||
category: props.category,
|
||||
min_zoom: props.min_zoom,
|
||||
max_zoom: props.max_zoom,
|
||||
best: props.best ? true : undefined,
|
||||
default: props.default ? true : undefined,
|
||||
"tile-size": props["tile-size"],
|
||||
}
|
||||
|
||||
layer = { properties: layer.properties, type: layer.type, geometry: layer.geometry }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue