forked from MapComplete/MapComplete
Merge master
This commit is contained in:
commit
890816d2dd
424 changed files with 40595 additions and 3354 deletions
|
@ -7,6 +7,10 @@ export type EliCategory =
|
|||
| "qa"
|
||||
| "elevation"
|
||||
| "other"
|
||||
|
||||
/**
|
||||
* This class has grown beyond the point of only containing Raster Layers
|
||||
*/
|
||||
export interface RasterLayerProperties {
|
||||
/**
|
||||
* The name of the imagery source
|
||||
|
@ -19,7 +23,8 @@ export interface RasterLayerProperties {
|
|||
|
||||
readonly url: string
|
||||
readonly category?: string | EliCategory
|
||||
readonly type?: "vector" | string
|
||||
readonly type?: "vector" | "raster" | string
|
||||
readonly style?: string,
|
||||
|
||||
readonly attribution?: {
|
||||
readonly url?: string
|
||||
|
|
|
@ -48,23 +48,12 @@ export class AvailableRasterLayers {
|
|||
geometry: BBox.global.asGeometry(),
|
||||
}
|
||||
|
||||
public static readonly maptilerDefaultLayer: RasterLayerPolygon = {
|
||||
type: "Feature",
|
||||
properties: {
|
||||
name: "MapTiler",
|
||||
url:
|
||||
"https://api.maptiler.com/maps/15cc8f61-0353-4be6-b8da-13daea5f7432/style.json?key=" +
|
||||
Constants.maptilerApiKey,
|
||||
category: "osmbasedmap",
|
||||
id: "maptiler",
|
||||
type: "vector",
|
||||
attribution: {
|
||||
text: "Maptiler",
|
||||
url: "https://www.maptiler.com/copyright/",
|
||||
},
|
||||
},
|
||||
geometry: BBox.global.asGeometry(),
|
||||
}
|
||||
/**
|
||||
* The default background layer that any theme uses which does not explicitly define a background
|
||||
*/
|
||||
public static readonly defaultBackgroundLayer: RasterLayerPolygon = AvailableRasterLayers.globalLayers.find(l => {
|
||||
return l.properties.id === "protomaps.sunny"
|
||||
})
|
||||
|
||||
public static layersAvailableAt(
|
||||
location: Store<{ lon: number; lat: number }>,
|
||||
|
@ -90,7 +79,7 @@ export class AvailableRasterLayers {
|
|||
return GeoOperations.inside(lonlat, eliPolygon)
|
||||
})
|
||||
matching.unshift(AvailableRasterLayers.osmCarto)
|
||||
matching.push(AvailableRasterLayers.maptilerDefaultLayer)
|
||||
matching.push(AvailableRasterLayers.defaultBackgroundLayer)
|
||||
if (enableBing?.data) {
|
||||
matching.push(AvailableRasterLayers.bing)
|
||||
}
|
||||
|
@ -107,7 +96,7 @@ export class AvailableRasterLayers {
|
|||
all.push(...AvailableRasterLayers.globalLayers.map((l) => l.properties.id))
|
||||
all.push(...AvailableRasterLayers.EditorLayerIndex.map((l) => l.properties.id))
|
||||
all.push(this.osmCarto.properties.id)
|
||||
all.push(this.maptilerDefaultLayer.properties.id)
|
||||
all.push(this.defaultBackgroundLayer.properties.id)
|
||||
return new Set<string>(all)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,9 +277,11 @@ export class ValidateTheme extends DesugaringStep<LayoutConfigJson> {
|
|||
backgroundId === "photo" || backgroundId === "map" || backgroundId === "osmbasedmap"
|
||||
|
||||
if (!isCategory && !ValidateTheme._availableLayers.has(backgroundId)) {
|
||||
const options = Array.from(ValidateTheme._availableLayers)
|
||||
const nearby = Utils.sortedByLevenshteinDistance(backgroundId, options, t => t)
|
||||
context
|
||||
.enter("defaultBackgroundId")
|
||||
.err("This layer ID is not known: " + backgroundId)
|
||||
.err(`This layer ID is not known: ${backgroundId}. Perhaps you meant one of ${nearby.slice(0,5).join(", ")}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -850,7 +852,7 @@ class CheckTranslation extends DesugaringStep<Translatable> {
|
|||
for (const key of keys) {
|
||||
const lng = json[key]
|
||||
if (lng === "") {
|
||||
context.enter(lng).err("Got an empty string in translation for language " + lng)
|
||||
context.enter(lng).err("Got an empty string in translation for language " + key)
|
||||
}
|
||||
|
||||
// TODO validate that all subparts are here
|
||||
|
@ -1012,6 +1014,13 @@ class MiscTagRenderingChecks extends DesugaringStep<TagRenderingConfigJson> {
|
|||
) {
|
||||
continue
|
||||
}
|
||||
if(json.freeform.key.indexOf("wikidata")>=0){
|
||||
context
|
||||
.enter("render")
|
||||
.err(
|
||||
`The rendering for language ${ln} does not contain \`{${json.freeform.key}}\`. Did you perhaps forget to set "freeform.type: 'wikidata'"?`
|
||||
)
|
||||
}
|
||||
context
|
||||
.enter("render")
|
||||
.err(
|
||||
|
@ -1264,7 +1273,7 @@ export class PrevalidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
// It is tempting to add an index to this warning; however, due to labels the indices here might be different from the index in the tagRendering list
|
||||
context
|
||||
.enter("tagRenderings")
|
||||
.err("Some tagrenderings have a duplicate id: " + duplicates.join(", "))
|
||||
.err("Some tagrenderings have a duplicate id: " + duplicates.join(", ")+"\n"+JSON.stringify(json.tagRenderings.filter(tr=> duplicates.indexOf(tr["id"])>=0)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1837,6 +1846,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
{
|
||||
tags: TagsFilter
|
||||
foundInTheme: string[]
|
||||
isCounted: boolean
|
||||
}
|
||||
>
|
||||
> {
|
||||
|
@ -1855,10 +1865,11 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
string,
|
||||
{
|
||||
tags: TagsFilter
|
||||
foundInTheme: string[]
|
||||
foundInTheme: string[],
|
||||
isCounted: boolean
|
||||
}
|
||||
> {
|
||||
const idToSource = new Map<string, { tags: TagsFilter; foundInTheme: string[] }>()
|
||||
const idToSource = new Map<string, { tags: TagsFilter; foundInTheme: string[], isCounted: boolean }>()
|
||||
|
||||
for (const theme of json) {
|
||||
for (const layer of theme.layers) {
|
||||
|
@ -1879,7 +1890,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
const id = layer.id
|
||||
const tags = layer.source.osmTags
|
||||
if (!idToSource.has(id)) {
|
||||
idToSource.set(id, { tags, foundInTheme: [theme.id] })
|
||||
idToSource.set(id, { tags, foundInTheme: [theme.id], isCounted: layer.doCount })
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1888,6 +1899,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
|||
if (oldTags.shadows(tags) && tags.shadows(oldTags)) {
|
||||
// All is good, all is well
|
||||
oldTheme.push(theme.id)
|
||||
idToSource.get(id).isCounted ||= layer.doCount
|
||||
continue
|
||||
}
|
||||
context.err(
|
||||
|
|
|
@ -38,7 +38,7 @@ export default interface LineRenderingConfigJson {
|
|||
/**
|
||||
* question: Should a dasharray be used to render the lines?
|
||||
* The dasharray defines 'pixels of line, pixels of gap, pixels of line, pixels of gap, ...'. For example, `5 6` will be 5 pixels of line followed by a 6 pixel gap.
|
||||
* Cannot be a dynamic property due to a mapbox limitation
|
||||
* Cannot be a dynamic property due to a MapLibre limitation (see https://github.com/maplibre/maplibre-gl-js/issues/1235)
|
||||
* ifunset: Ways are rendered with a full line
|
||||
*/
|
||||
dashArray?: string
|
||||
|
|
|
@ -91,7 +91,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
mercatorCrs: json.source["mercatorCrs"],
|
||||
idKey: json.source["idKey"],
|
||||
},
|
||||
json.id
|
||||
json.id,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ export default class LayerConfig extends WithContextLoader {
|
|||
}
|
||||
this.units = [].concat(
|
||||
...(json.units ?? []).map((unitJson, i) =>
|
||||
Unit.fromJson(unitJson, `${context}.unit[${i}]`)
|
||||
)
|
||||
Unit.fromJson(unitJson, `${context}.unit[${i}]`),
|
||||
),
|
||||
)
|
||||
|
||||
if (json.description !== undefined) {
|
||||
|
@ -122,7 +122,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
if (json.calculatedTags !== undefined) {
|
||||
if (!official) {
|
||||
console.warn(
|
||||
`Unofficial theme ${this.id} with custom javascript! This is a security risk`
|
||||
`Unofficial theme ${this.id} with custom javascript! This is a security risk`,
|
||||
)
|
||||
}
|
||||
this.calculatedTags = []
|
||||
|
@ -159,7 +159,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
}
|
||||
this.minzoomVisible = json.minzoomVisible ?? this.minzoom
|
||||
this.shownByDefault = json.shownByDefault ?? true
|
||||
this.doCount = json.isCounted ?? true
|
||||
this.doCount = json.isCounted ?? this.shownByDefault ?? true
|
||||
this.forceLoad = json.forceLoad ?? false
|
||||
if (json.presets === null) json.presets = undefined
|
||||
if (json.presets !== undefined && json.presets?.map === undefined) {
|
||||
|
@ -191,7 +191,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
tags: pr.tags.map((t) => TagUtils.SimpleTag(t)),
|
||||
description: Translations.T(
|
||||
pr.description,
|
||||
`${translationContext}.presets.${i}.description`
|
||||
`${translationContext}.presets.${i}.description`,
|
||||
),
|
||||
preciseInput: preciseInput,
|
||||
exampleImages: pr.exampleImages,
|
||||
|
@ -205,7 +205,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
if (json.lineRendering) {
|
||||
this.lineRendering = Utils.NoNull(json.lineRendering).map(
|
||||
(r, i) => new LineRenderingConfig(r, `${context}[${i}]`)
|
||||
(r, i) => new LineRenderingConfig(r, `${context}[${i}]`),
|
||||
)
|
||||
} else {
|
||||
this.lineRendering = []
|
||||
|
@ -213,7 +213,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
if (json.pointRendering) {
|
||||
this.mapRendering = Utils.NoNull(json.pointRendering).map(
|
||||
(r, i) => new PointRenderingConfig(r, `${context}[${i}](${this.id})`)
|
||||
(r, i) => new PointRenderingConfig(r, `${context}[${i}](${this.id})`),
|
||||
)
|
||||
} else {
|
||||
this.mapRendering = []
|
||||
|
@ -225,7 +225,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
r.location.has("centroid") ||
|
||||
r.location.has("projected_centerpoint") ||
|
||||
r.location.has("start") ||
|
||||
r.location.has("end")
|
||||
r.location.has("end"),
|
||||
)
|
||||
|
||||
if (
|
||||
|
@ -247,7 +247,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
Constants.priviliged_layers.indexOf(<any>this.id) < 0 &&
|
||||
this.source !== null /*library layer*/ &&
|
||||
!this.source?.geojsonSource?.startsWith(
|
||||
"https://api.openstreetmap.org/api/0.6/notes.json"
|
||||
"https://api.openstreetmap.org/api/0.6/notes.json",
|
||||
)
|
||||
) {
|
||||
throw (
|
||||
|
@ -266,7 +266,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
typeof tr !== "string" &&
|
||||
tr["builtin"] === undefined &&
|
||||
tr["id"] === undefined &&
|
||||
tr["rewrite"] === undefined
|
||||
tr["rewrite"] === undefined,
|
||||
) ?? []
|
||||
if (missingIds?.length > 0 && official) {
|
||||
console.error("Some tagRenderings of", this.id, "are missing an id:", missingIds)
|
||||
|
@ -277,8 +277,8 @@ export default class LayerConfig extends WithContextLoader {
|
|||
(tr, i) =>
|
||||
new TagRenderingConfig(
|
||||
<QuestionableTagRenderingConfigJson>tr,
|
||||
this.id + ".tagRenderings[" + i + "]"
|
||||
)
|
||||
this.id + ".tagRenderings[" + i + "]",
|
||||
),
|
||||
)
|
||||
|
||||
if (
|
||||
|
@ -352,7 +352,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
public GetBaseTags(): Record<string, string> {
|
||||
return TagUtils.changeAsProperties(
|
||||
this.source?.osmTags?.asChange({ id: "node/-1" }) ?? [{ k: "id", v: "node/-1" }]
|
||||
this.source?.osmTags?.asChange({ id: "node/-1" }) ?? [{ k: "id", v: "node/-1" }],
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
neededLayer: string
|
||||
}[] = [],
|
||||
addedByDefault = false,
|
||||
canBeIncluded = true
|
||||
canBeIncluded = true,
|
||||
): BaseUIElement {
|
||||
const extraProps: (string | BaseUIElement)[] = []
|
||||
|
||||
|
@ -374,32 +374,32 @@ export default class LayerConfig extends WithContextLoader {
|
|||
if (canBeIncluded) {
|
||||
if (addedByDefault) {
|
||||
extraProps.push(
|
||||
"**This layer is included automatically in every theme. This layer might contain no points**"
|
||||
"**This layer is included automatically in every theme. This layer might contain no points**",
|
||||
)
|
||||
}
|
||||
if (this.shownByDefault === false) {
|
||||
extraProps.push(
|
||||
"This layer is not visible by default and must be enabled in the filter by the user. "
|
||||
"This layer is not visible by default and must be enabled in the filter by the user. ",
|
||||
)
|
||||
}
|
||||
if (this.title === undefined) {
|
||||
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."
|
||||
"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.",
|
||||
)
|
||||
}
|
||||
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"
|
||||
"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",
|
||||
)
|
||||
}
|
||||
if (this.name === undefined) {
|
||||
extraProps.push(
|
||||
"Not visible in the layer selection by default. If you want to make this layer toggable, override `name`"
|
||||
"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`"
|
||||
"Not rendered on the map by default. If you want to rendering this on the map, override `mapRenderings`",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -411,23 +411,28 @@ export default class LayerConfig extends WithContextLoader {
|
|||
: undefined,
|
||||
"This layer is loaded from an external source, namely ",
|
||||
new FixedUiElement(this.source.geojsonSource).SetClass("code"),
|
||||
])
|
||||
]),
|
||||
)
|
||||
}
|
||||
} 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."
|
||||
"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.org/" + id))
|
||||
),
|
||||
]
|
||||
if (!addedByDefault) {
|
||||
|
||||
if (usedInThemes?.length > 0) {
|
||||
usingLayer = [
|
||||
new Title("Themes using this layer", 4),
|
||||
new List(
|
||||
(usedInThemes ?? []).map((id) => new Link(id, "https://mapcomplete.org/" + id)),
|
||||
),
|
||||
]
|
||||
} else if(this.source !== null) {
|
||||
usingLayer = [new FixedUiElement("No themes use this layer")]
|
||||
}
|
||||
}
|
||||
|
||||
for (const dep of dependencies) {
|
||||
|
@ -438,7 +443,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
" into the layout as it depends on it: ",
|
||||
dep.reason,
|
||||
"(" + dep.context + ")",
|
||||
])
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -447,7 +452,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
new Combine([
|
||||
"This layer is needed as dependency for layer",
|
||||
new Link(revDep, "#" + revDep),
|
||||
])
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -459,14 +464,14 @@ export default class LayerConfig extends WithContextLoader {
|
|||
return undefined
|
||||
}
|
||||
const embedded: (Link | string)[] = values.values?.map((v) =>
|
||||
Link.OsmWiki(values.key, v, true).SetClass("mr-2")
|
||||
Link.OsmWiki(values.key, v, true).SetClass("mr-2"),
|
||||
) ?? ["_no preset options defined, or no values in them_"]
|
||||
return [
|
||||
new Combine([
|
||||
new Link(
|
||||
"<img src='https://mapcomplete.org/assets/svg/statistics.svg' height='18px'>",
|
||||
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values",
|
||||
true
|
||||
true,
|
||||
),
|
||||
Link.OsmWiki(values.key),
|
||||
]).SetClass("flex"),
|
||||
|
@ -475,7 +480,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
: new Link(values.type, "../SpecialInputElements.md#" + values.type),
|
||||
new Combine(embedded).SetClass("flex"),
|
||||
]
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
let quickOverview: BaseUIElement = undefined
|
||||
|
@ -485,7 +490,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
"this quick overview is incomplete",
|
||||
new Table(
|
||||
["attribute", "type", "values which are supported by this layer"],
|
||||
tableRows
|
||||
tableRows,
|
||||
).SetClass("zebra-table"),
|
||||
]).SetClass("flex-col flex")
|
||||
}
|
||||
|
@ -499,7 +504,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
(mr) =>
|
||||
mr.RenderIcon(new ImmutableStore<OsmTags>({ id: "node/-1" }), {
|
||||
includeBadges: false,
|
||||
}).html
|
||||
}).html,
|
||||
)
|
||||
.find((i) => i !== undefined)
|
||||
}
|
||||
|
@ -511,7 +516,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
"Execute on overpass",
|
||||
Overpass.AsOverpassTurboLink(<TagsFilter>this.source.osmTags.optimize())
|
||||
.replaceAll("(", "%28")
|
||||
.replaceAll(")", "%29")
|
||||
.replaceAll(")", "%29"),
|
||||
)
|
||||
} catch (e) {
|
||||
console.error("Could not generate overpasslink for " + this.id)
|
||||
|
@ -533,19 +538,19 @@ export default class LayerConfig extends WithContextLoader {
|
|||
const parts = neededTags["and"]
|
||||
tagsDescription.push(
|
||||
"Elements must match **all** of the following expressions:",
|
||||
parts.map((p, i) => i + ". " + p.asHumanString(true, false, {})).join("\n")
|
||||
parts.map((p, i) => i + ". " + p.asHumanString(true, false, {})).join("\n"),
|
||||
)
|
||||
} else if (neededTags["or"]) {
|
||||
const parts = neededTags["or"]
|
||||
tagsDescription.push(
|
||||
"Elements must match **any** of the following expressions:",
|
||||
parts.map((p) => " - " + p.asHumanString(true, false, {})).join("\n")
|
||||
parts.map((p) => " - " + p.asHumanString(true, false, {})).join("\n"),
|
||||
)
|
||||
} else {
|
||||
tagsDescription.push(
|
||||
"Elements must match the expression **" +
|
||||
neededTags.asHumanString(true, false, {}) +
|
||||
"**"
|
||||
neededTags.asHumanString(true, false, {}) +
|
||||
"**",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -556,7 +561,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
return new Combine([
|
||||
new Combine([new Title(this.id, 1), iconImg, this.description, "\n"]).SetClass(
|
||||
"flex flex-col"
|
||||
"flex flex-col",
|
||||
),
|
||||
new List(extraProps),
|
||||
...usingLayer,
|
||||
|
|
|
@ -313,6 +313,9 @@ export default class LayoutConfig implements LayoutInformation {
|
|||
if (tags === undefined) {
|
||||
return undefined
|
||||
}
|
||||
if(tags.id.startsWith("current_view")){
|
||||
return this.getLayer("current_view")
|
||||
}
|
||||
for (const layer of this.layers) {
|
||||
if (!layer.source) {
|
||||
if (layer.isShown?.matchesProperties(tags)) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { TagsFilter } from "../../Logic/Tags/TagsFilter"
|
|||
export default class LineRenderingConfig extends WithContextLoader {
|
||||
public readonly color: TagRenderingConfig
|
||||
public readonly width: TagRenderingConfig
|
||||
public readonly dashArray: TagRenderingConfig
|
||||
public readonly dashArray: string
|
||||
public readonly lineCap: TagRenderingConfig
|
||||
public readonly offset: TagRenderingConfig
|
||||
public readonly fill: TagRenderingConfig
|
||||
|
@ -19,7 +19,7 @@ export default class LineRenderingConfig extends WithContextLoader {
|
|||
super(json, context)
|
||||
this.color = this.tr("color", "#0000ff")
|
||||
this.width = this.tr("width", "7")
|
||||
this.dashArray = this.tr("dashArray", "")
|
||||
this.dashArray = json.dashArray
|
||||
this.lineCap = this.tr("lineCap", "round")
|
||||
this.fill = this.tr("fill", undefined)
|
||||
this.fillColor = this.tr("fillColor", undefined)
|
||||
|
|
|
@ -628,6 +628,22 @@ export default class TagRenderingConfig {
|
|||
* config.constructChangeSpecification("", undefined, undefined, {}) // => undefined
|
||||
* config.constructChangeSpecification("5", undefined, undefined, {}).optimize() // => new Tag("capacity", "5")
|
||||
*
|
||||
* // Should pick a mapping, even if freeform is used
|
||||
* const config = new TagRenderingConfig({"id": "shop-types", render: "Shop type is {shop}", freeform: {key: "shop", addExtraTags:["fixme=freeform shop type used"]}, mappings:[{if: "shop=second_hand", then: "Second hand shop"}]})
|
||||
* config.constructChangeSpecification("freeform", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used"
|
||||
* config.constructChangeSpecification("freeform", undefined, undefined, {}).asHumanString(false, false, {}) // => "shop=freeform & fixme=freeform shop type used"
|
||||
* config.constructChangeSpecification("second_hand", 1, undefined, {}).asHumanString(false, false, {}) // => "shop=second_hand"
|
||||
*
|
||||
*
|
||||
* const config = new TagRenderingConfig({id: "oh", render: "{opening_hours}", question: {"en":"When open?"}, freeform: {key: "opening_hours"},
|
||||
* mappings: [{ "if": "opening_hours=closed",
|
||||
* "then": {
|
||||
* "en": "Marked as closed for an unspecified time",
|
||||
* },
|
||||
* "hideInAnswer": true}] }
|
||||
* const tags = config.constructChangeSpecification("Tu-Fr 05:30-09:30", undefined, undefined, { }}
|
||||
* tags // =>new And([ new Tag("opening_hours", "Tu-Fr 05:30-09:30")])
|
||||
*
|
||||
* @param freeformValue The freeform value which will be applied as 'freeform.key'. Ignored if 'freeform.key' is not set
|
||||
*
|
||||
* @param singleSelectedMapping (Only used if multiAnswer == false): the single mapping to apply. Use (mappings.length) for the freeform
|
||||
|
@ -640,6 +656,12 @@ export default class TagRenderingConfig {
|
|||
multiSelectedMapping: boolean[] | undefined,
|
||||
currentProperties: Record<string, string>
|
||||
): UploadableTag {
|
||||
console.log("constructChangeSpecification:", {
|
||||
freeformValue,
|
||||
singleSelectedMapping,
|
||||
multiSelectedMapping,
|
||||
currentProperties,
|
||||
})
|
||||
if (typeof freeformValue === "string") {
|
||||
freeformValue = freeformValue?.trim()
|
||||
}
|
||||
|
@ -667,11 +689,22 @@ export default class TagRenderingConfig {
|
|||
this.mappings.length == 0 ||
|
||||
(singleSelectedMapping === this.mappings.length && !this.multiAnswer))
|
||||
) {
|
||||
const freeformOnly = { [this.freeform.key]: freeformValue }
|
||||
const matchingMapping = this.mappings?.find((m) => m.if.matchesProperties(freeformOnly))
|
||||
if (matchingMapping) {
|
||||
return new And([matchingMapping.if, ...(matchingMapping.addExtraTags ?? [])])
|
||||
}
|
||||
// Either no mappings, or this is a radio-button selected freeform value
|
||||
return new And([
|
||||
const tag = new And([
|
||||
new Tag(this.freeform.key, freeformValue),
|
||||
...(this.freeform.addExtraTags ?? []),
|
||||
])
|
||||
const newProperties = tag.applyOn(currentProperties)
|
||||
if (this.invalidValues?.matchesProperties(newProperties)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return tag
|
||||
}
|
||||
|
||||
if (this.multiAnswer) {
|
||||
|
|
|
@ -450,6 +450,19 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
this.selectedElement.setData(feature)
|
||||
}
|
||||
|
||||
public showCurrentLocationOn(map: Store<MlMap>): ShowDataLayer {
|
||||
const id = "gps_location"
|
||||
const flayerGps = this.layerState.filteredLayers.get(id)
|
||||
const features = this.geolocation.currentUserLocation
|
||||
return new ShowDataLayer(map, {
|
||||
features,
|
||||
doShowLayer: flayerGps.isDisplayed,
|
||||
layer: flayerGps.layerDef,
|
||||
metaTags: this.userRelatedState.preferencesAsTags,
|
||||
selectedElement: this.selectedElement,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Various small methods that need to be called
|
||||
*/
|
||||
|
@ -674,7 +687,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
const summaryTileSource = new SummaryTileSource(
|
||||
url.protocol + "//" + url.host + "/summary",
|
||||
layers.map((l) => l.id),
|
||||
this.mapProperties.zoom.map((z) => Math.max(Math.ceil(z), 0)),
|
||||
this.mapProperties.zoom.map((z) => Math.max(Math.floor(z), 0)),
|
||||
this.mapProperties,
|
||||
{
|
||||
isActive: this.mapProperties.zoom.map((z) => z <= maxzoom),
|
||||
|
@ -682,6 +695,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
)
|
||||
return new SummaryTileSourceRewriter(summaryTileSource, this.layerState.filteredLayers)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the special layers to the map
|
||||
*/
|
||||
|
@ -796,7 +810,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
new MetaTagging(this)
|
||||
new TitleHandler(this.selectedElement, this.featureProperties, this)
|
||||
new ChangeToElementsActor(this.changes, this.featureProperties)
|
||||
new PendingChangesUploader(this.changes, this.selectedElement)
|
||||
new PendingChangesUploader(this.changes, this.selectedElement, this.imageUploadManager)
|
||||
new SelectedElementTagsUpdater(this)
|
||||
new BackgroundLayerResetter(this.mapProperties.rasterLayer, this.availableLayers)
|
||||
new PreferredRasterLayerSelector(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue