chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-07-10 18:26:31 +02:00
parent a190597905
commit 087e639020
382 changed files with 29496 additions and 2675 deletions

View file

@ -1,4 +1,8 @@
import { SpecialVisualization, SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization"
import {
SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import { HistogramViz } from "./HistogramViz"
import { Store, UIEventSource } from "../../Logic/UIEventSource"
import { Feature } from "geojson"
@ -29,14 +33,15 @@ class DirectionIndicatorVis extends SpecialVisualization {
funcName = "direction_indicator"
args = []
docs = "Gives a distance indicator and a compass pointing towards the location from your GPS-location. If clicked, centers the map on the object"
docs =
"Gives a distance indicator and a compass pointing towards the location from your GPS-location. If clicked, centers the map on the object"
group = "data"
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
feature: Feature
): BaseUIElement {
return new SvelteUIElement(DirectionIndicator, { state, feature })
}
@ -44,7 +49,8 @@ class DirectionIndicatorVis extends SpecialVisualization {
class DirectionAbsolute extends SpecialVisualization {
funcName = "direction_absolute"
docs = "Converts compass degrees (with 0° being north, 90° being east, ...) into a human readable, translated direction such as 'north', 'northeast'"
docs =
"Converts compass degrees (with 0° being north, 90° being east, ...) into a human readable, translated direction such as 'north', 'northeast'"
args = [
{
name: "key",
@ -63,7 +69,7 @@ class DirectionAbsolute extends SpecialVisualization {
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
args: string[]
): BaseUIElement {
const key = args[0] === "" ? "_direction:centerpoint" : args[0]
const offset = args[1] === "" ? 0 : Number(args[1])
@ -76,19 +82,19 @@ class DirectionAbsolute extends SpecialVisualization {
})
.mapD((value) => {
const dir = GeoOperations.bearingToHuman(
GeoOperations.parseBearing(value) + offset,
GeoOperations.parseBearing(value) + offset
)
console.log("Human dir", dir)
return Translations.t.general.visualFeedback.directionsAbsolute[dir]
}),
})
)
}
}
class OpeningHoursTableVis extends SpecialVisualizationSvelte {
funcName = "opening_hours_table"
docs = "Creates an opening-hours table. Usage: {opening_hours_table(opening_hours)} to create a table of the tag 'opening_hours'."
docs =
"Creates an opening-hours table. Usage: {opening_hours_table(opening_hours)} to create a table of the tag 'opening_hours'."
args = [
{
name: "key",
@ -150,7 +156,7 @@ class OpeningHoursState extends SpecialVisualizationSvelte {
constr(
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[],
args: string[]
): SvelteUIElement {
const keyToUse = args[0]
const prefix = args[1]
@ -169,7 +175,8 @@ class Canonical extends SpecialVisualization {
group = "data"
funcName = "canonical"
docs = "Converts a short, canonical value into the long, translated text including the unit. This only works if a `unit` is defined for the corresponding value. The unit specification will be included in the text. "
docs =
"Converts a short, canonical value into the long, translated text including the unit. This only works if a `unit` is defined for the corresponding value. The unit specification will be included in the text. "
example =
"If the object has `length=42`, then `{canonical(length)}` will be shown as **42 meter** (in english), **42 metre** (in french), ..."
args = [
@ -191,17 +198,15 @@ class Canonical extends SpecialVisualization {
return undefined
}
const allUnits: Unit[] = [].concat(
...(state?.theme?.layers?.map((lyr) => lyr.units) ?? []),
...(state?.theme?.layers?.map((lyr) => lyr.units) ?? [])
)
const unit = allUnits.filter((unit) =>
unit.isApplicableToKey(key),
)[0]
const unit = allUnits.filter((unit) => unit.isApplicableToKey(key))[0]
if (unit === undefined) {
return value
}
const getCountry = () => tagSource.data._country
return unit.asHumanLongValue(value, getCountry)
}),
})
)
}
}
@ -209,23 +214,24 @@ class Canonical extends SpecialVisualization {
class StatisticsVis extends SpecialVisualizationSvelte {
funcName = "statistics"
group = "data"
docs = "Show general statistics about all the elements currently in view. Intended to use on the `current_view`-layer. They will be split per layer"
docs =
"Show general statistics about all the elements currently in view. Intended to use on the `current_view`-layer. They will be split per layer"
args = []
constr(state) {
return new SvelteUIElement(AllFeaturesStatistics, { state })
}
}
class PresetDescription extends SpecialVisualization {
funcName = "preset_description"
docs = "Shows the extra description from the presets of the layer, if one matches. It will pick the most specific one (e.g. if preset `A` implies `B`, but `B` does not imply `A`, it'll pick B) or the first one if no ordering can be made. Might be empty"
docs =
"Shows the extra description from the presets of the layer, if one matches. It will pick the most specific one (e.g. if preset `A` implies `B`, but `B` does not imply `A`, it'll pick B) or the first one if no ordering can be made. Might be empty"
args = []
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
tagSource: UIEventSource<Record<string, string>>
): BaseUIElement {
const translation = tagSource.map((tags) => {
const layer = state.theme.getMatchingLayer(tags)
@ -245,12 +251,12 @@ class PresetTypeSelect extends SpecialVisualizationSvelte {
tags: UIEventSource<Record<string, string>>,
argument: string[],
selectedElement: Feature,
layer: LayerConfig,
layer: LayerConfig
): SvelteUIElement {
const t = Translations.t.preset_type
if(layer._basedOn !== layer.id){
if (layer._basedOn !== layer.id) {
console.warn("Trying to use the _original_ layer")
layer = state.theme.layers.find(l => l.id === layer._basedOn) ?? layer
layer = state.theme.layers.find((l) => l.id === layer._basedOn) ?? layer
}
const question: QuestionableTagRenderingConfigJson = {
id: layer.id + "-type",
@ -264,7 +270,7 @@ class PresetTypeSelect extends SpecialVisualizationSvelte {
}).translations,
})),
}
if(question.mappings.length === 0){
if (question.mappings.length === 0) {
console.error("No mappings for preset_type_select, something went wrong")
return undefined
}
@ -285,13 +291,7 @@ class AllTagsVis extends SpecialVisualizationSvelte {
args = []
group = "data"
constr(
state,
tags: UIEventSource<Record<string, string>>,
_,
__,
layer: LayerConfig,
) {
constr(state, tags: UIEventSource<Record<string, string>>, _, __, layer: LayerConfig) {
return new SvelteUIElement(AllTagsPanel, { tags, layer })
}
}
@ -312,7 +312,7 @@ class TagsVis extends SpecialVisualization {
constr(
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
argument: string[]
): BaseUIElement {
const key = argument[0] ?? "value"
return new VariableUiElement(
@ -329,13 +329,10 @@ class TagsVis extends SpecialVisualization {
return parsed.asHumanString(true, false, {})
} catch (e) {
return new FixedUiElement(
"Could not parse this tag: " +
JSON.stringify(value) +
" due to " +
e,
"Could not parse this tag: " + JSON.stringify(value) + " due to " + e
).SetClass("alert")
}
}),
})
)
}
}