mapcomplete/Models/ThemeConfig/LayerConfig.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

658 lines
26 KiB
TypeScript
Raw Normal View History

2021-07-23 15:56:22 +02:00
import { Translation } from "../../UI/i18n/Translation"
import SourceConfig from "./SourceConfig"
import TagRenderingConfig from "./TagRenderingConfig"
import PresetConfig, { PreciseInput } from "./PresetConfig"
import { LayerConfigJson } from "./Json/LayerConfigJson"
import Translations from "../../UI/i18n/Translations"
import { TagUtils } from "../../Logic/Tags/TagUtils"
2021-07-22 11:29:09 +02:00
import FilterConfig from "./FilterConfig"
import { Unit } from "../Unit"
import DeleteConfig from "./DeleteConfig"
import MoveConfig from "./MoveConfig"
import PointRenderingConfig from "./PointRenderingConfig"
import WithContextLoader from "./WithContextLoader"
import LineRenderingConfig from "./LineRenderingConfig"
import PointRenderingConfigJson from "./Json/PointRenderingConfigJson"
import LineRenderingConfigJson from "./Json/LineRenderingConfigJson"
2021-10-22 18:53:07 +02:00
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
import BaseUIElement from "../../UI/BaseUIElement"
2021-11-08 02:36:01 +01:00
import Combine from "../../UI/Base/Combine"
import Title from "../../UI/Base/Title"
import List from "../../UI/Base/List"
import Link from "../../UI/Base/Link"
2021-11-08 03:00:58 +01:00
import { Utils } from "../../Utils"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import Table from "../../UI/Base/Table"
import FilterConfigJson from "./Json/FilterConfigJson"
import { And } from "../../Logic/Tags/And"
import { Overpass } from "../../Logic/Osm/Overpass"
2022-04-30 00:28:51 +02:00
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import Svg from "../../Svg"
2023-03-24 19:21:15 +01:00
import { ImmutableStore } from "../../Logic/UIEventSource"
import { OsmTags } from "../OsmFeature"
import Constants from "../Constants"
2021-04-10 23:53:13 +02:00
2021-10-22 18:53:07 +02:00
export default class LayerConfig extends WithContextLoader {
2022-07-06 17:11:17 +02:00
public static readonly syncSelectionAllowed = ["no", "local", "theme-only", "global"] as const
public readonly id: string
public readonly name: Translation
public readonly description: Translation
2023-03-24 19:21:15 +01:00
/**
* Only 'null' for special, privileged layers
*/
public readonly source: SourceConfig | null
public readonly calculatedTags: [string, string, boolean][]
public readonly doNotDownload: boolean
public readonly passAllFeatures: boolean
2022-07-18 02:00:32 +02:00
public readonly isShown: TagsFilter
public minzoom: number
public minzoomVisible: number
public readonly maxzoom: number
public readonly title?: TagRenderingConfig
public readonly titleIcons: TagRenderingConfig[]
public readonly mapRendering: PointRenderingConfig[]
public readonly lineRendering: LineRenderingConfig[]
2021-07-23 15:56:22 +02:00
public readonly units: Unit[]
public readonly deletion: DeleteConfig | null
public readonly allowMove: MoveConfig | null
public readonly allowSplit: boolean
public readonly shownByDefault: boolean
/**
* In seconds
*/
public readonly maxAgeOfCache: number
public readonly presets: PresetConfig[]
public readonly tagRenderings: TagRenderingConfig[]
public readonly filters: FilterConfig[]
public readonly filterIsSameAs: string
public readonly forceLoad: boolean
2023-06-14 20:44:01 +02:00
public readonly syncSelection: (typeof LayerConfig.syncSelectionAllowed)[number] // this is a trick to conver a constant array of strings into a type union of these values
2022-09-08 21:40:48 +02:00
2023-06-01 02:52:21 +02:00
public readonly _needsFullNodeDatabase: boolean
public readonly popupInFloatover
2021-07-23 15:56:22 +02:00
constructor(json: LayerConfigJson, context?: string, official: boolean = true) {
context = context + "." + json.id
2022-07-06 17:11:17 +02:00
const translationContext = "layers:" + json.id
super(json, context)
2021-07-23 15:56:22 +02:00
this.id = json.id
2022-01-26 21:40:38 +01:00
2022-07-06 17:11:17 +02:00
if (typeof json === "string") {
throw `Not a valid layer: the layerConfig is a string. 'npm run generate:layeroverview' might be needed (at ${context})`
}
2022-01-26 21:40:38 +01:00
if (json.id === undefined) {
2022-07-06 17:11:17 +02:00
throw `Not a valid layer: id is undefined: ${JSON.stringify(json)} (At ${context})`
}
if (json.source === undefined) {
throw "Layer " + this.id + " does not define a source section (" + context + ")"
}
2023-03-25 02:48:24 +01:00
if (json.source === "special" || json.source === "special:library") {
2023-03-24 19:21:15 +01:00
this.source = null
} else if (json.source["osmTags"] === undefined) {
throw (
"Layer " +
this.id +
" does not define a osmTags in the source section - these should always be present, even for geojson layers (" +
context +
")"
2022-09-08 21:40:48 +02:00
)
}
2021-07-23 15:56:22 +02:00
if (json.id.toLowerCase() !== json.id) {
throw `${context}: The id of a layer should be lowercase: ${json.id}`
}
if (json.id.match(/[a-z0-9-_]/) == null) {
throw `${context}: The id of a layer should match [a-z0-9-_]*: ${json.id}`
}
2021-07-23 15:56:22 +02:00
2022-07-06 17:11:17 +02:00
if (
json.syncSelection !== undefined &&
LayerConfig.syncSelectionAllowed.indexOf(json.syncSelection) < 0
) {
throw (
context +
" Invalid sync-selection: must be one of " +
LayerConfig.syncSelectionAllowed.map((v) => `'${v}'`).join(", ") +
" but got '" +
json.syncSelection +
"'"
2022-09-08 21:40:48 +02:00
)
}
this.syncSelection = json.syncSelection ?? "no"
2023-03-25 02:48:24 +01:00
if (typeof json.source !== "string") {
this.maxAgeOfCache = json.source["maxCacheAge"] ?? 24 * 60 * 60 * 30
const osmTags = TagUtils.Tag(json.source["osmTags"], context + "source.osmTags")
2023-03-25 02:48:24 +01:00
if (osmTags.isNegative()) {
throw (
context +
"The source states tags which give a very wide selection: it only uses negative expressions, which will result in too much and unexpected data. Add at least one required tag. The tags are:\n\t" +
osmTags.asHumanString(false, false, {})
)
}
2023-03-25 02:48:24 +01:00
this.source = new SourceConfig(
{
osmTags: osmTags,
geojsonSource: json.source["geoJson"],
geojsonSourceLevel: json.source["geoJsonZoomLevel"],
overpassScript: json.source["overpassScript"],
isOsmCache: json.source["isOsmCache"],
mercatorCrs: json.source["mercatorCrs"],
idKey: json.source["idKey"],
},
json.id
2022-09-08 21:40:48 +02:00
)
}
2022-07-06 17:11:17 +02:00
if (json.source["geoJsonSource"] !== undefined) {
throw context + "Use 'geoJson' instead of 'geoJsonSource'"
}
if (json.source["geojson"] !== undefined) {
throw context + "Use 'geoJson' instead of 'geojson' (the J is a capital letter)"
}
2022-07-06 17:11:17 +02:00
this.allowSplit = json.allowSplit ?? false
2022-04-01 12:51:55 +02:00
this.name = Translations.T(json.name, translationContext + ".name")
2022-07-06 17:11:17 +02:00
if (json.units !== undefined && !Array.isArray(json.units)) {
throw (
"At " +
context +
".units: the 'units'-section should be a list; you probably have an object there"
2022-09-08 21:40:48 +02:00
)
2022-04-22 03:17:40 +02:00
}
this.units = (json.units ?? []).map((unitJson, i) =>
Unit.fromJson(unitJson, `${context}.unit[${i}]`)
2022-09-08 21:40:48 +02:00
)
if (json.description !== undefined) {
if (Object.keys(json.description).length === 0) {
json.description = undefined
}
}
2022-04-01 12:51:55 +02:00
this.description = Translations.T(json.description, translationContext + ".description")
2021-07-23 15:56:22 +02:00
this.calculatedTags = undefined
if (json.calculatedTags !== undefined) {
if (!official) {
console.warn(
`Unofficial theme ${this.id} with custom javascript! This is a security risk`
)
}
2021-07-23 15:56:22 +02:00
this.calculatedTags = []
for (const kv of json.calculatedTags) {
const index = kv.indexOf("=")
2022-04-23 15:20:54 +02:00
let key = kv.substring(0, index).trim()
const r = "[a-z_][a-z0-9:]*"
2022-07-06 17:11:17 +02:00
if (key.match(r) === null) {
throw (
"At " +
context +
" invalid key for calculated tag: " +
key +
"; it should match " +
r
2022-09-08 21:40:48 +02:00
)
2022-04-23 15:20:54 +02:00
}
const isStrict = key.endsWith(":")
if (isStrict) {
key = key.substr(0, key.length - 1)
}
2021-07-23 15:56:22 +02:00
const code = kv.substring(index + 1)
try {
new Function("feat", "return " + code + ";")
} catch (e) {
2022-04-30 22:58:36 +02:00
throw `Invalid function definition: the custom javascript is invalid:${e} (at ${context}). The offending javascript code is:\n ${code}`
}
this.calculatedTags.push([key, code, isStrict])
2020-10-27 01:01:34 +01:00
}
2021-07-23 15:56:22 +02:00
}
2021-07-23 15:56:22 +02:00
this.doNotDownload = json.doNotDownload ?? false
this.passAllFeatures = json.passAllFeatures ?? false
this.minzoom = json.minzoom ?? 0
2023-06-01 02:52:21 +02:00
this._needsFullNodeDatabase = json.fullNodeDatabase ?? false
if (json["minZoom"] !== undefined) {
throw "At " + context + ": minzoom is written all lowercase"
2022-07-12 10:23:45 +02:00
}
2021-07-27 19:39:57 +02:00
this.minzoomVisible = json.minzoomVisible ?? this.minzoom
this.shownByDefault = json.shownByDefault ?? true
this.forceLoad = json.forceLoad ?? false
if (json.presets === null) json.presets = undefined
if (json.presets !== undefined && json.presets?.map === undefined) {
throw "Presets should be a list of items (at " + context + ")"
2021-09-22 20:44:53 +02:00
}
this.presets = (json.presets ?? []).map((pr, i) => {
let preciseInput: PreciseInput = {
2021-10-16 00:43:53 +02:00
preferredBackground: ["photo"],
snapToLayers: undefined,
maxSnapDistance: undefined,
}
if (pr["preciseInput"] !== undefined) {
throw "Layer " + this.id + " still uses the old 'preciseInput'-field"
}
if (pr.snapToLayer !== undefined) {
let snapToLayers: string[]
if (typeof pr.snapToLayer === "string") {
snapToLayers = [pr.snapToLayer]
} else {
snapToLayers = pr.snapToLayer
}
preciseInput = {
snapToLayers,
maxSnapDistance: pr.maxSnapDistance ?? 10,
}
} else if (pr.maxSnapDistance !== undefined) {
throw (
"Layer " +
this.id +
" defines a maxSnapDistance, but does not include a `snapToLayer`"
)
}
const config: PresetConfig = {
2022-04-01 12:51:55 +02:00
title: Translations.T(pr.title, `${translationContext}.presets.${i}.title`),
tags: pr.tags.map((t) => TagUtils.SimpleTag(t)),
2022-04-01 12:51:55 +02:00
description: Translations.T(
pr.description,
`${translationContext}.presets.${i}.description`
),
preciseInput: preciseInput,
exampleImages: pr.exampleImages,
2021-07-24 02:32:33 +02:00
}
return config
2021-07-24 02:32:33 +02:00
})
2021-07-23 15:56:22 +02:00
2021-10-22 18:53:07 +02:00
if (json.mapRendering === undefined) {
throw "MapRendering is undefined in " + context
2021-10-21 01:26:20 +02:00
}
2021-11-09 18:22:05 +01:00
if (json.mapRendering === null) {
this.mapRendering = []
this.lineRendering = []
} else {
2021-11-09 19:45:26 +01:00
this.mapRendering = Utils.NoNull(json.mapRendering)
2021-11-09 18:22:05 +01:00
.filter((r) => r["location"] !== undefined)
.map(
(r, i) =>
new PointRenderingConfig(
<PointRenderingConfigJson>r,
context + ".mapRendering[" + i + "]"
)
2022-09-08 21:40:48 +02:00
)
2021-11-09 19:45:26 +01:00
this.lineRendering = Utils.NoNull(json.mapRendering)
2021-11-09 18:22:05 +01:00
.filter((r) => r["location"] === undefined)
.map(
(r, i) =>
new LineRenderingConfig(
<LineRenderingConfigJson>r,
context + ".mapRendering[" + i + "]"
)
2022-09-08 21:40:48 +02:00
)
2021-11-09 18:22:05 +01:00
const hasCenterRendering = this.mapRendering.some(
(r) =>
2022-12-16 13:45:07 +01:00
r.location.has("centroid") ||
r.location.has("projected_centerpoint") ||
r.location.has("start") ||
r.location.has("end")
2022-09-08 21:40:48 +02:00
)
2021-11-09 18:22:05 +01:00
if (this.lineRendering.length === 0 && this.mapRendering.length === 0) {
throw (
"The layer " +
this.id +
" does not have any maprenderings defined and will thus not show up on the map at all. If this is intentional, set maprenderings to 'null' instead of '[]'"
)
2022-01-21 03:57:49 +01:00
} else if (
!hasCenterRendering &&
this.lineRendering.length === 0 &&
Constants.priviliged_layers.indexOf(<any>this.id) < 0 &&
!this.source?.geojsonSource?.startsWith(
2022-01-21 03:57:49 +01:00
"https://api.openstreetmap.org/api/0.6/notes.json"
2022-09-08 21:40:48 +02:00
)
2022-01-21 03:57:49 +01:00
) {
throw (
"The layer " +
this.id +
" might not render ways. This might result in dropped information (at " +
context +
")"
2022-09-08 21:40:48 +02:00
)
2021-11-09 18:22:05 +01:00
}
}
const missingIds =
Utils.NoNull(json.tagRenderings)?.filter(
(tr) =>
typeof tr !== "string" &&
tr["builtin"] === undefined &&
tr["id"] === undefined &&
tr["rewrite"] === undefined
) ?? []
2021-11-08 03:00:58 +01:00
if (missingIds?.length > 0 && official) {
console.error("Some tagRenderings of", this.id, "are missing an id:", missingIds)
throw "Missing ids in tagrenderings"
}
this.tagRenderings = (Utils.NoNull(json.tagRenderings) ?? []).map(
(tr, i) =>
new TagRenderingConfig(
<TagRenderingConfigJson>tr,
this.id + ".tagRenderings[" + i + "]"
)
2022-09-08 21:40:48 +02:00
)
2021-11-08 03:00:58 +01:00
if (
json.filter !== undefined &&
json.filter !== null &&
json.filter["sameAs"] !== undefined
) {
this.filterIsSameAs = json.filter["sameAs"]
this.filters = []
} else {
this.filters = (<FilterConfigJson[]>json.filter ?? []).map((option, i) => {
2022-04-01 12:51:55 +02:00
return new FilterConfig(option, `layers:${this.id}.filter.${i}`)
})
}
2021-11-08 03:00:58 +01:00
{
2021-12-21 18:35:31 +01:00
const duplicateIds = Utils.Dupiclates(this.filters.map((f) => f.id))
2021-11-08 03:00:58 +01:00
if (duplicateIds.length > 0) {
throw `Some filters have a duplicate id: ${duplicateIds} (at ${context}.filters)`
}
}
if (json["filters"] !== undefined) {
throw "Error in " + context + ": use 'filter' instead of 'filters'"
}
2021-07-23 15:56:22 +02:00
this.titleIcons = this.ParseTagRenderings(<TagRenderingConfigJson[]>json.titleIcons ?? [], {
readOnlyMode: true,
2022-09-08 21:40:48 +02:00
})
2020-11-16 01:59:30 +01:00
this.title = this.tr("title", undefined, translationContext)
2022-07-18 02:00:32 +02:00
this.isShown = TagUtils.TagD(json.isShown, context + ".isShown")
2021-10-22 18:53:07 +02:00
2021-07-23 15:56:22 +02:00
this.deletion = null
if (json.deletion === true) {
json.deletion = {}
}
if (json.deletion !== undefined && json.deletion !== false) {
this.deletion = new DeleteConfig(json.deletion, `${context}.deletion`)
}
this.allowMove = null
if (json.allowMove === false) {
this.allowMove = null
} else if (json.allowMove === true) {
this.allowMove = new MoveConfig({}, context + ".allowMove")
2022-12-23 16:39:01 +01:00
} else if (json.allowMove !== undefined) {
this.allowMove = new MoveConfig(json.allowMove, context + ".allowMove")
}
2021-07-23 15:56:22 +02:00
if (json["showIf"] !== undefined) {
throw (
"Invalid key on layerconfig " +
this.id +
": showIf. Did you mean 'isShown' instead?"
)
}
this.popupInFloatover = json.popupInFloatover ?? false
}
2021-11-07 16:34:51 +01:00
public defaultIcon(): BaseUIElement | undefined {
if (this.mapRendering === undefined || this.mapRendering === null) {
2021-11-09 19:45:26 +01:00
return undefined
}
const mapRendering = this.mapRendering.filter((r) => r.location.has("point"))[0]
if (mapRendering === undefined) {
return undefined
}
return mapRendering.GetBaseIcon(this.GetBaseTags(), { noFullWidth: true })
}
public GetBaseTags(): Record<string, string> {
return TagUtils.changeAsProperties(
this.source?.osmTags?.asChange({ id: "node/-1" }) ?? [{ k: "id", v: "node/-1" }]
)
}
2022-04-28 00:32:43 +02:00
public GenerateDocumentation(
usedInThemes: string[],
layerIsNeededBy?: Map<string, string[]>,
dependencies: {
2022-07-06 17:11:17 +02:00
context?: string
reason: string
neededLayer: string
}[] = [],
addedByDefault = false,
canBeIncluded = true
): BaseUIElement {
const extraProps: (string | BaseUIElement)[] = []
2022-07-06 17:11:17 +02:00
extraProps.push("This layer is shown at zoomlevel **" + this.minzoom + "** and higher")
2021-11-08 02:36:01 +01:00
if (canBeIncluded) {
2021-11-09 18:22:05 +01:00
if (addedByDefault) {
extraProps.push(
"**This layer is included automatically in every theme. This layer might contain no points**"
)
2021-11-08 14:18:45 +01:00
}
if (this.shownByDefault === false) {
extraProps.push(
"This layer is not visible by default and must be enabled in the filter by the user. "
)
}
2021-11-08 02:36:01 +01:00
if (this.title === undefined) {
2022-07-20 14:39:19 +02:00
extraProps.push(
"Elements don't have a title set and cannot be toggled nor will they show up in the dashboard. If you import this layer in your theme, override `title` to make this toggleable."
)
}
2022-07-20 14:39:19 +02:00
if (this.name === undefined && this.shownByDefault === false) {
extraProps.push(
"This layer is not visible by default and the visibility cannot be toggled, effectively resulting in a fully hidden layer. This can be useful, e.g. to calculate some metatags. If you want to render this layer (e.g. for debugging), enable it by setting the URL-parameter layer-<id>=true"
)
2021-11-08 02:36:01 +01:00
}
if (this.name === undefined) {
extraProps.push(
"Not visible in the layer selection by default. If you want to make this layer toggable, override `name`"
)
}
if (this.mapRendering.length === 0) {
extraProps.push(
"Not rendered on the map by default. If you want to rendering this on the map, override `mapRenderings`"
)
}
if (this.source?.geojsonSource !== undefined) {
extraProps.push(
new Combine([
Utils.runningFromConsole
? "<img src='../warning.svg' height='1rem'/>"
: undefined,
"This layer is loaded from an external source, namely ",
new FixedUiElement(this.source.geojsonSource).SetClass("code"),
])
2022-09-08 21:40:48 +02:00
)
}
2021-11-08 02:36:01 +01:00
} else {
extraProps.push(
"This layer can **not** be included in a theme. It is solely used by [special renderings](SpecialRenderings.md) showing a minimap with custom data."
)
}
let usingLayer: BaseUIElement[] = []
if (usedInThemes?.length > 0 && !addedByDefault) {
usingLayer = [
new Title("Themes using this layer", 4),
new List(
(usedInThemes ?? []).map(
(id) => new Link(id, "https://mapcomplete.osm.be/" + id)
2022-09-08 21:40:48 +02:00
)
),
2021-11-08 02:36:01 +01:00
]
}
for (const dep of dependencies) {
extraProps.push(
new Combine([
"This layer will automatically load ",
new Link(dep.neededLayer, "./" + dep.neededLayer + ".md"),
" into the layout as it depends on it: ",
dep.reason,
"(" + dep.context + ")",
])
2022-09-08 21:40:48 +02:00
)
}
for (const revDep of Utils.Dedup(layerIsNeededBy?.get(this.id) ?? [])) {
extraProps.push(
new Combine([
"This layer is needed as dependency for layer",
new Link(revDep, "#" + revDep),
])
2022-09-08 21:40:48 +02:00
)
}
let neededTags: TagsFilter[] = Utils.NoNull([this.source?.osmTags])
if (this.source?.osmTags["and"] !== undefined) {
neededTags = this.source.osmTags["and"]
}
let tableRows = Utils.NoNull(
this.tagRenderings
.map((tr) => tr.FreeformValues())
.map((values) => {
if (values == undefined) {
return undefined
}
const embedded: (Link | string)[] = values.values?.map((v) =>
Link.OsmWiki(values.key, v, true).SetClass("mr-2")
) ?? ["_no preset options defined, or no values in them_"]
return [
new Combine([
new Link(
Utils.runningFromConsole
? "<img src='https://mapcomplete.osm.be/assets/svg/statistics.svg' height='18px'>"
: Svg.statistics_svg().SetClass("w-4 h-4 mr-2"),
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values",
true
2022-01-26 21:40:38 +01:00
),
Link.OsmWiki(values.key),
]).SetClass("flex"),
values.type === undefined
? "Multiple choice"
: new Link(values.type, "../SpecialInputElements.md#" + values.type),
new Combine(embedded).SetClass("flex"),
]
})
2022-09-08 21:40:48 +02:00
)
let quickOverview: BaseUIElement = undefined
if (tableRows.length > 0) {
quickOverview = new Combine([
2022-04-30 00:28:51 +02:00
new FixedUiElement("Warning: ").SetClass("bold"),
"this quick overview is incomplete",
new Table(
["attribute", "type", "values which are supported by this layer"],
tableRows
).SetClass("zebra-table"),
]).SetClass("flex-col flex")
}
let iconImg: BaseUIElement = new FixedUiElement("")
if (Utils.runningFromConsole) {
const icon = this.mapRendering
.filter((mr) => mr.location.has("point"))
.map((mr) => mr.icon?.render?.txt)
.find((i) => i !== undefined)
// This is for the documentation in a markdown-file, so we have to use raw HTML
if (icon !== undefined) {
iconImg = new FixedUiElement(
`<img src='https://mapcomplete.osm.be/${icon}' height="100px"> `
)
}
} else {
iconImg = this.mapRendering
.filter((mr) => mr.location.has("point"))
.map(
(mr) =>
2023-03-24 19:21:15 +01:00
mr.RenderIcon(new ImmutableStore<OsmTags>({ id: "node/-1" }), false, {
includeBadges: false,
}).html
2022-09-08 21:40:48 +02:00
)
.find((i) => i !== undefined)
}
2022-09-08 21:40:48 +02:00
let overpassLink: BaseUIElement = undefined
2023-03-25 02:48:24 +01:00
if (this.source !== undefined) {
try {
2022-07-06 17:11:17 +02:00
overpassLink = new Link(
"Execute on overpass",
Overpass.AsOverpassTurboLink(<TagsFilter>new And(neededTags).optimize())
2022-09-08 21:40:48 +02:00
)
} catch (e) {
console.error("Could not generate overpasslink for " + this.id)
}
}
2022-12-16 13:45:07 +01:00
const filterDocs: (string | BaseUIElement)[] = []
if (this.filters.length > 0) {
filterDocs.push(new Title("Filters", 4))
2022-12-16 13:45:07 +01:00
filterDocs.push(...this.filters.map((filter) => filter.GenerateDocs()))
}
2023-04-20 18:58:31 +02:00
const tagsDescription = []
if (this.source === null) {
tagsDescription.push(
new Title("Basic tags for this layer", 2),
"Elements must have the all of following tags to be shown on this layer:",
new List(neededTags.map((t) => t.asHumanString(true, false, {}))),
overpassLink
)
} else {
tagsDescription.push("This is a special layer - data is not sourced from OpenStreetMap")
}
2021-11-08 02:36:01 +01:00
return new Combine([
new Combine([new Title(this.id, 1), iconImg, this.description, "\n"]).SetClass(
"flex flex-col"
),
new List(extraProps),
...usingLayer,
2023-04-20 18:58:31 +02:00
...tagsDescription,
new Title("Supported attributes", 2),
quickOverview,
...this.tagRenderings.map((tr) => tr.GenerateDocumentation()),
2022-12-16 13:45:07 +01:00
...filterDocs,
])
.SetClass("flex-col")
.SetClass("link-underline")
2021-11-08 02:36:01 +01:00
}
2021-07-23 15:56:22 +02:00
public CustomCodeSnippets(): string[] {
if (this.calculatedTags === undefined) {
return []
}
return this.calculatedTags.map((code) => code[1])
2021-07-22 11:29:09 +02:00
}
AllTagRenderings(): TagRenderingConfig[] {
2022-07-18 02:00:32 +02:00
return Utils.NoNull([...this.tagRenderings, ...this.titleIcons, this.title])
}
2021-10-22 18:53:07 +02:00
public isLeftRightSensitive(): boolean {
return this.lineRendering.some((lr) => lr.leftRightSensitive)
}
}