Refactoring: switch specialVis constructor to an object

This commit is contained in:
Pieter Vander Vennet 2025-08-15 02:32:04 +02:00
parent 6bb33771b4
commit be5bcd99d7
37 changed files with 302 additions and 559 deletions

View file

@ -430,10 +430,10 @@
} }
}, },
{ {
"id": "favourite_icon", "condition": "_favourite=yes",
"description": "Only for rendering", "description": "Only for rendering",
"icon": "circle:white;heart:red", "icon": "circle:white;heart:red",
"condition": "_favourite=yes", "id": "favourite_icon",
"metacondition": "__showTimeSensitiveIcons!=no" "metacondition": "__showTimeSensitiveIcons!=no"
}, },
{ {

View file

@ -217,8 +217,8 @@
}, },
{ {
"id": "debug", "id": "debug",
"render": "{all_tags()}", "metacondition": "__featureSwitchIsDebugging=true",
"metacondition": "__featureSwitchIsDebugging=true" "render": "{all_tags()}"
} }
], ],
"filter": [ "filter": [

View file

@ -114,9 +114,9 @@
"lineRendering": [], "lineRendering": [],
"tagRenderings": [ "tagRenderings": [
{ {
"classes": "p-0",
"id": "conversation", "id": "conversation",
"render": "{visualize_note_comments()}", "render": "{visualize_note_comments()}"
"classes": "p-0"
}, },
{ {
"id": "add_image", "id": "add_image",

View file

@ -66,16 +66,16 @@
], ],
"tagRenderings": [ "tagRenderings": [
{ {
"id": "country_name", "condition": "level=country",
"description": "The name of the country", "description": "The name of the country",
"render": "{nameEn} {emojiFlag}", "id": "country_name",
"condition": "level=country" "render": "{nameEn} {emojiFlag}"
}, },
{ {
"id": "community_links", "condition": "_community_links~*",
"description": "Community Links (Discord, meetups, Slack groups, IRC channels, mailing lists etc...)", "description": "Community Links (Discord, meetups, Slack groups, IRC channels, mailing lists etc...)",
"render": "{_community_links}", "id": "community_links",
"condition": "_community_links~*" "render": "{_community_links}"
} }
], ],
"filter": [ "filter": [

View file

@ -21,6 +21,7 @@ import SelectedElementTagsUpdater from "../../Logic/Actors/SelectedElementTagsUp
import NoElementsInViewDetector, { import NoElementsInViewDetector, {
FeatureViewState, FeatureViewState,
} from "../../Logic/Actors/NoElementsInViewDetector" } from "../../Logic/Actors/NoElementsInViewDetector"
import { features } from "monaco-editor/esm/metadata"
export class WithChangesState extends WithLayoutSourceState { export class WithChangesState extends WithLayoutSourceState {
readonly changes: Changes readonly changes: Changes
@ -226,15 +227,10 @@ export class WithChangesState extends WithLayoutSourceState {
metaTags: this.userRelatedState.preferencesAsTags, metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement, selectedElement: this.selectedElement,
fetchStore: (id) => this.featureProperties.getStore(id), fetchStore: (id) => this.featureProperties.getStore(id),
onClick: feature => {
this.setSelectedElement(feature)
}
}) })
/*new ShowDataLayer(map, {
layer: fs.layer.layerDef,
features: filtered,
doShowLayer,
metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement,
fetchStore: (id) => this.featureProperties.getStore(id),
})*/
}) })
return filteringFeatureSource return filteringFeatureSource
} }

View file

@ -130,7 +130,8 @@ export class WithLayoutSourceState extends WithSelectedElementState {
} }
protected setSelectedElement(feature: Feature) { protected setSelectedElement(feature: Feature) {
// The given feature might be a partial one from the cache // The given feature might be a partial one from the cache or might be a centroid point instead of the way
// We lookup a version by IDP
if (feature !== undefined) { if (feature !== undefined) {
feature = feature =
this.indexedFeatures.featuresById.data?.get(feature?.properties?.id) ?? feature this.indexedFeatures.featuresById.data?.get(feature?.properties?.id) ?? feature

View file

@ -4,7 +4,7 @@ import FavouritesFeatureSource from "../../Logic/FeatureSource/Sources/Favourite
import Constants from "../Constants" import Constants from "../Constants"
import { FeatureSource } from "../../Logic/FeatureSource/FeatureSource" import { FeatureSource } from "../../Logic/FeatureSource/FeatureSource"
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource" import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource"
import { Feature } from "geojson" import { Feature, Geometry } from "geojson"
import { BBox } from "../../Logic/BBox" import { BBox } from "../../Logic/BBox"
import ShowDataLayer from "../../UI/Map/ShowDataLayer" import ShowDataLayer from "../../UI/Map/ShowDataLayer"
import MetaTagging from "../../Logic/MetaTagging" import MetaTagging from "../../Logic/MetaTagging"
@ -22,6 +22,7 @@ import {
} from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource" } from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions" import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
import { ClusterGrouping } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource" import { ClusterGrouping } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource"
import { OsmTags } from "../OsmFeature"
export class WithSpecialLayers extends WithChangesState { export class WithSpecialLayers extends WithChangesState {
readonly favourites: FavouritesFeatureSource readonly favourites: FavouritesFeatureSource
@ -180,7 +181,7 @@ export class WithSpecialLayers extends WithChangesState {
}) })
) )
// show last click = new point/note marker // show last click = new point/note marker
const features = new StaticFeatureSource(lastClickFiltered) const features: StaticFeatureSource<Feature<Geometry, Record<string, string> & {id: string}>> = new StaticFeatureSource(lastClickFiltered)
this.featureProperties.trackFeatureSource(features) this.featureProperties.trackFeatureSource(features)
new ShowDataLayer(this.map, { new ShowDataLayer(this.map, {
features, features,

View file

@ -459,11 +459,6 @@ export default class ShowDataLayer {
preprocessPoints, preprocessPoints,
} = this._options } = this._options
let onClick = this._options.onClick let onClick = this._options.onClick
if (!onClick && selectedElement && layer.title !== undefined) {
onClick = (feature: Feature) => {
selectedElement?.setData(feature)
}
}
if (drawLines !== false) { if (drawLines !== false) {
for (let i = 0; i < layer.lineRendering.length; i++) { for (let i = 0; i < layer.lineRendering.length; i++) {
const lineRenderingConfig = layer.lineRendering[i] const lineRenderingConfig = layer.lineRendering[i]

View file

@ -3,8 +3,8 @@ import ThemeConfig from "../../Models/ThemeConfig/ThemeConfig"
import { Changes } from "../../Logic/Osm/Changes" import { Changes } from "../../Logic/Osm/Changes"
import { import {
SpecialVisualisationArg, SpecialVisualisationArg,
SpecialVisualisationParams,
SpecialVisualization, SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte, SpecialVisualizationSvelte,
} from "../SpecialVisualization" } from "../SpecialVisualization"
import { IndexedFeatureSource } from "../../Logic/FeatureSource/FeatureSource" import { IndexedFeatureSource } from "../../Logic/FeatureSource/FeatureSource"
@ -83,15 +83,11 @@ export default class AutoApplyButtonVis extends SpecialVisualizationSvelte {
4. At last, add this component` 4. At last, add this component`
} }
constr( constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const target_layer_id = args[0]
tagSource: UIEventSource<Record<string, string>>, const targetTagRendering = args[2]
argument: string[] const text = args[3]
): SvelteUIElement { const icon = args[4]
const target_layer_id = argument[0]
const targetTagRendering = argument[2]
const text = argument[3]
const icon = argument[4]
const options = { const options = {
target_layer_id, target_layer_id,
targetTagRendering, targetTagRendering,
@ -102,7 +98,7 @@ export default class AutoApplyButtonVis extends SpecialVisualizationSvelte {
const to_parse: UIEventSource<string[]> = new UIEventSource<string[]>(undefined) const to_parse: UIEventSource<string[]> = new UIEventSource<string[]>(undefined)
Stores.chronic(500, () => to_parse.data === undefined) Stores.chronic(500, () => to_parse.data === undefined)
.map(() => { .map(() => {
const applicable = <string | string[]>tagSource.data[argument[1]] const applicable = <string | string[]>tags.data[args[1]]
if (typeof applicable === "string") { if (typeof applicable === "string") {
return <string[]>JSON.parse(applicable) return <string[]>JSON.parse(applicable)
} else { } else {

View file

@ -1,11 +1,5 @@
import { import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import { UIEventSource } from "../../Logic/UIEventSource"
import { Feature, LineString } from "geojson" import { Feature, LineString } from "geojson"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import ExportFeatureButton from "./ExportFeatureButton.svelte" import ExportFeatureButton from "./ExportFeatureButton.svelte"
@ -17,13 +11,7 @@ class ExportAsGpxVis extends SpecialVisualizationSvelte {
args = [] args = []
needsUrls = [] needsUrls = []
constr( constr({ tags, feature, layer }: SpecialVisualisationParams) {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
) {
if (feature.geometry.type !== "LineString") { if (feature.geometry.type !== "LineString") {
return undefined return undefined
} }
@ -48,7 +36,7 @@ class ExportAsGeojsonVis extends SpecialVisualizationSvelte {
docs = "Exports the selected feature as GeoJson-file" docs = "Exports the selected feature as GeoJson-file"
args = [] args = []
constr(state, tags, args, feature, layer) { constr({ tags, feature, layer }: SpecialVisualisationParams) {
const t = Translations.t.general.download const t = Translations.t.general.download
return new SvelteUIElement(ExportFeatureButton, { return new SvelteUIElement(ExportFeatureButton, {
tags, tags,
@ -64,7 +52,7 @@ class ExportAsGeojsonVis extends SpecialVisualizationSvelte {
} }
export class DataExportVisualisations { export class DataExportVisualisations {
public static initList(): SpecialVisualization[] { public static initList(): SpecialVisualizationSvelte[] {
return [new ExportAsGpxVis(), new ExportAsGeojsonVis()] return [new ExportAsGpxVis(), new ExportAsGeojsonVis()]
} }
} }

View file

@ -1,11 +1,6 @@
import { import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import { HistogramViz } from "./HistogramViz" import { HistogramViz } from "./HistogramViz"
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store } from "../../Logic/UIEventSource"
import { Feature } from "geojson"
import BaseUIElement from "../BaseUIElement" import BaseUIElement from "../BaseUIElement"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import DirectionIndicator from "../Base/DirectionIndicator.svelte" import DirectionIndicator from "../Base/DirectionIndicator.svelte"
@ -20,15 +15,15 @@ import NextChangeViz from "../OpeningHours/NextChangeViz.svelte"
import { Unit } from "../../Models/Unit" import { Unit } from "../../Models/Unit"
import AllFeaturesStatistics from "../Statistics/AllFeaturesStatistics.svelte" import AllFeaturesStatistics from "../Statistics/AllFeaturesStatistics.svelte"
import { LanguageElement } from "./LanguageElement/LanguageElement" import { LanguageElement } from "./LanguageElement/LanguageElement"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson" import { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import { And } from "../../Logic/Tags/And" import { And } from "../../Logic/Tags/And"
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig" import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import TagRenderingEditable from "./TagRendering/TagRenderingEditable.svelte" import TagRenderingEditable from "./TagRendering/TagRenderingEditable.svelte"
import AllTagsPanel from "./AllTagsPanel/AllTagsPanel.svelte" import AllTagsPanel from "./AllTagsPanel/AllTagsPanel.svelte"
import CollectionTimes from "../CollectionTimes/CollectionTimes.svelte" import CollectionTimes from "../CollectionTimes/CollectionTimes.svelte"
import Tr from "../Base/Tr.svelte"
class DirectionIndicatorVis extends SpecialVisualization { class DirectionIndicatorVis extends SpecialVisualizationSvelte {
funcName = "direction_indicator" funcName = "direction_indicator"
args = [] args = []
@ -36,13 +31,8 @@ class DirectionIndicatorVis extends SpecialVisualization {
"Gives a distance indicator and a compass pointing towards the location from your GPS-location. If clicked, centers the map on the object" "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" group = "data"
constr( constr(params: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, return new SvelteUIElement(DirectionIndicator, params)
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature
): BaseUIElement {
return new SvelteUIElement(DirectionIndicator, { state, feature })
} }
} }
@ -65,17 +55,15 @@ class DirectionAbsolute extends SpecialVisualization {
] ]
group = "data" group = "data"
constr( constr({
state: SpecialVisualizationState, tags,
tagSource: UIEventSource<Record<string, string>>, args,
args: string[] }: SpecialVisualisationParams): BaseUIElement {
): BaseUIElement {
const key = args[0] === "" ? "_direction:centerpoint" : args[0] const key = args[0] === "" ? "_direction:centerpoint" : args[0]
const offset = args[1] === "" ? 0 : Number(args[1]) const offset = args[1] === "" ? 0 : Number(args[1])
return new VariableUiElement( return new VariableUiElement(
tagSource tags.map((tags) => {
.map((tags) => {
console.log("Direction value", tags[key], key) console.log("Direction value", tags[key], key)
return tags[key] return tags[key]
}) })
@ -117,14 +105,12 @@ class OpeningHoursTableVis extends SpecialVisualizationSvelte {
example = example =
"A normal opening hours table can be invoked with `{opening_hours_table()}`. A table for e.g. conditional access with opening hours can be `{opening_hours_table(access:conditional, no @ &LPARENS, &RPARENS)}`" "A normal opening hours table can be invoked with `{opening_hours_table()}`. A table for e.g. conditional access with opening hours can be `{opening_hours_table(access:conditional, no @ &LPARENS, &RPARENS)}`"
constr(state, tagSource: UIEventSource<any>, args) { constr({ tags, args }: SpecialVisualisationParams): SvelteUIElement {
const [key, prefix, postfix] = args const [key, prefix, postfix] = args
const openingHoursStore: Store<opening_hours | "error" | undefined> = const openingHoursStore: Store<opening_hours | "error" | undefined> =
OH.CreateOhObjectStore(tagSource, key, prefix, postfix) OH.CreateOhObjectStore(tags, key, prefix, postfix)
return new SvelteUIElement(OpeningHoursWithError, { return new SvelteUIElement(OpeningHoursWithError, {
tags: tagSource, tags, key, opening_hours_obj: openingHoursStore,
key,
opening_hours_obj: openingHoursStore,
}) })
} }
} }
@ -152,11 +138,7 @@ class OpeningHoursState extends SpecialVisualizationSvelte {
}, },
] ]
constr( constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[]
): SvelteUIElement {
const keyToUse = args[0] const keyToUse = args[0]
const prefix = args[1] const prefix = args[1]
const postfix = args[2] const postfix = args[2]
@ -187,10 +169,10 @@ class Canonical extends SpecialVisualization {
}, },
] ]
constr(state, tagSource, args) { constr({ state, tags, args }: SpecialVisualisationParams) {
const key = args[0] const key = args[0]
return new VariableUiElement( return new VariableUiElement(
tagSource tags
.map((tags) => tags[key]) .map((tags) => tags[key])
.map((value) => { .map((value) => {
if (value === undefined) { if (value === undefined) {
@ -203,7 +185,7 @@ class Canonical extends SpecialVisualization {
if (unit === undefined) { if (unit === undefined) {
return value return value
} }
const getCountry = () => tagSource.data._country const getCountry = () => tags.data._country
return unit.asHumanLongValue(value, getCountry) return unit.asHumanLongValue(value, getCountry)
}) })
) )
@ -217,26 +199,23 @@ class StatisticsVis extends SpecialVisualizationSvelte {
"Show general statistics about all the elements currently in view. Intended to use on the `current_view`-layer. They will be split per layer" "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 = [] args = []
constr(state) { constr(params: SpecialVisualisationParams) {
return new SvelteUIElement(AllFeaturesStatistics, { state }) return new SvelteUIElement(AllFeaturesStatistics, params)
} }
} }
class PresetDescription extends SpecialVisualization { class PresetDescription extends SpecialVisualizationSvelte {
funcName = "preset_description" funcName = "preset_description"
docs = 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" "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 = [] args = []
constr( constr({ state, tags }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const translation = tags.map((tags) => {
tagSource: UIEventSource<Record<string, string>>
): BaseUIElement {
const translation = tagSource.map((tags) => {
const layer = state.theme.getMatchingLayer(tags) const layer = state.theme.getMatchingLayer(tags)
return layer?.getMostMatchingPreset(tags)?.description return layer?.getMostMatchingPreset(tags)?.description
}) })
return new VariableUiElement(translation) return new SvelteUIElement(Tr, { t: translation })
} }
} }
@ -245,13 +224,7 @@ class PresetTypeSelect extends SpecialVisualizationSvelte {
docs = "An editable tag rendering which allows to change the type" docs = "An editable tag rendering which allows to change the type"
args = [] args = []
constr( constr({ state, tags, feature, layer }: SpecialVisualisationParams,): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
argument: string[],
selectedElement: Feature,
layer: LayerConfig
): SvelteUIElement {
const t = Translations.t.preset_type const t = Translations.t.preset_type
if (layer._basedOn !== layer.id) { if (layer._basedOn !== layer.id) {
console.warn("Trying to use the _original_ layer") console.warn("Trying to use the _original_ layer")
@ -277,7 +250,7 @@ class PresetTypeSelect extends SpecialVisualizationSvelte {
return new SvelteUIElement(TagRenderingEditable, { return new SvelteUIElement(TagRenderingEditable, {
config, config,
tags, tags,
selectedElement, selectedElement: feature,
state, state,
layer, layer,
}) })
@ -290,8 +263,8 @@ class AllTagsVis extends SpecialVisualizationSvelte {
args = [] args = []
group = "data" group = "data"
constr(state, tags: UIEventSource<Record<string, string>>, _, __, layer: LayerConfig) { constr(params: SpecialVisualisationParams) {
return new SvelteUIElement(AllTagsPanel, { tags, layer }) return new SvelteUIElement(AllTagsPanel, params)
} }
} }
@ -308,18 +281,12 @@ class PointsInTimeVis extends SpecialVisualization {
}, },
] ]
constr( constr( {tags, args}: SpecialVisualisationParams): BaseUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement {
const key = args[0] const key = args[0]
const points_in_time = tagSource.map((tags) => tags[key]) const points_in_time = tags.map((tags) => tags[key])
const times = points_in_time.map( const times = points_in_time.map(
(times) => OH.createOhObject(<any>tagSource.data, times, tagSource.data["_country"], 1), (times) => OH.createOhObject(<any>tags.data, times, tags.data["_country"], 1),
[tagSource] [tags]
) )
return new VariableUiElement( return new VariableUiElement(
times.map((times) => new SvelteUIElement(CollectionTimes, { times })) times.map((times) => new SvelteUIElement(CollectionTimes, { times }))

View file

@ -1,5 +1,5 @@
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store, UIEventSource } from "../../Logic/UIEventSource"
import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization"
import { Feature } from "geojson" import { Feature } from "geojson"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import Histogram from "../BigComponents/Histogram.svelte" import Histogram from "../BigComponents/Histogram.svelte"
@ -36,12 +36,8 @@ export class HistogramViz extends SpecialVisualization {
] ]
} }
constr( constr( {tags, args}: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const values: Store<string[]> = tags.map((tags) => {
tagSource: UIEventSource<Record<string, string>>,
args: string[]
) {
const values: Store<string[]> = tagSource.map((tags) => {
const value = tags[args[0]] const value = tags[args[0]]
try { try {
if (value === "" || value === undefined) { if (value === "" || value === undefined) {

View file

@ -1,7 +1,11 @@
import { SpecialVisualisationArg, SpecialVisualization, SpecialVisualizationState } from "../../SpecialVisualization" import {
SpecialVisualisationArg,
SpecialVisualisationParams,
SpecialVisualizationSvelte,
SpecialVisualizationUtils,
} from "../../SpecialVisualization"
import { UIEventSource } from "../../../Logic/UIEventSource" import { UIEventSource } from "../../../Logic/UIEventSource"
import { Feature, Geometry, LineString, Polygon } from "geojson" import { Feature, Geometry, LineString, Polygon } from "geojson"
import BaseUIElement from "../../BaseUIElement"
import { ImportFlowArguments, ImportFlowUtils } from "./ImportFlow" import { ImportFlowArguments, ImportFlowUtils } from "./ImportFlow"
import Translations from "../../i18n/Translations" import Translations from "../../i18n/Translations"
import { Utils } from "../../../Utils" import { Utils } from "../../../Utils"
@ -14,6 +18,7 @@ import { Changes } from "../../../Logic/Osm/Changes"
import ThemeConfig from "../../../Models/ThemeConfig/ThemeConfig" import ThemeConfig from "../../../Models/ThemeConfig/ThemeConfig"
import { OsmConnection } from "../../../Logic/Osm/OsmConnection" import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
import { OsmTags } from "../../../Models/OsmFeature" import { OsmTags } from "../../../Models/OsmFeature"
import Tr from "../../Base/Tr.svelte"
export interface ConflateFlowArguments extends ImportFlowArguments { export interface ConflateFlowArguments extends ImportFlowArguments {
way_to_conflate: string way_to_conflate: string
@ -22,7 +27,7 @@ export interface ConflateFlowArguments extends ImportFlowArguments {
snap_onto_layers?: string snap_onto_layers?: string
} }
export default class ConflateImportButtonViz extends SpecialVisualization implements AutoAction { export default class ConflateImportButtonViz extends SpecialVisualizationSvelte implements AutoAction {
supportsAutoAction: boolean = true supportsAutoAction: boolean = true
needsUrls = [] needsUrls = []
group = "data_import" group = "data_import"
@ -80,32 +85,25 @@ export default class ConflateImportButtonViz extends SpecialVisualization implem
await state.changes.applyAction(action) await state.changes.applyAction(action)
} }
constr( constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<OsmTags>,
argument: string[],
feature: Feature
): BaseUIElement {
const canBeImported = const canBeImported =
feature.geometry.type === "LineString" || feature.geometry.type === "LineString" ||
(feature.geometry.type === "Polygon" && feature.geometry.coordinates.length === 1) (feature.geometry.type === "Polygon" && feature.geometry.coordinates.length === 1)
if (!canBeImported) { if (!canBeImported) {
return Translations.t.general.add.import.wrongTypeToConflate.SetClass("alert") return new SvelteUIElement(Tr, { t: Translations.t.general.add.import.wrongTypeToConflate, cls: "alert" })
} }
const args: ConflateFlowArguments = <any>Utils.ParseVisArgs(this.args, argument) const argsParsed: ConflateFlowArguments = <any>SpecialVisualizationUtils.parseArgs(this.args, args)
const tagsToApply = ImportFlowUtils.getTagsToApply(tagSource, args) const tagsToApply = ImportFlowUtils.getTagsToApply(<UIEventSource<OsmTags>>tags, argsParsed)
const idOfWayToReplaceGeometry = tagSource.data[args.way_to_conflate] const idOfWayToReplaceGeometry = tags.data[argsParsed.way_to_conflate]
const importFlow = new ConflateImportFlowState( const importFlow = new ConflateImportFlowState(
state, state,
<Feature<LineString | Polygon>>feature, <Feature<LineString | Polygon>>feature,
args, argsParsed,
tagsToApply, tagsToApply,
tagSource, tags,
idOfWayToReplaceGeometry idOfWayToReplaceGeometry
) )
return new SvelteUIElement(WayImportFlow, { return new SvelteUIElement(WayImportFlow, { importFlow })
importFlow,
})
} }
getLayerDependencies = (args: string[]) => getLayerDependencies = (args: string[]) =>

View file

@ -66,13 +66,14 @@ ${Utils.special_visualizations_importRequirementDocs}
* Given the tagsstore of the point which represents the challenge, creates a new store with tags that should be applied onto the newly created point, * Given the tagsstore of the point which represents the challenge, creates a new store with tags that should be applied onto the newly created point,
*/ */
public static getTagsToApply( public static getTagsToApply(
originalFeatureTags: UIEventSource<OsmTags>, originalFeatureTags: Store<OsmTags>,
args: { tags: string } args: { tags: string }
): Store<Tag[]> { ): Store<Tag[]> {
if (originalFeatureTags === undefined) { if (originalFeatureTags === undefined) {
return undefined return undefined
} }
let newTags: Store<Tag[]> let newTags: Store<Tag[]>
// Listing of the keys that should be transferred
const tags = args.tags const tags = args.tags
if ( if (
tags.indexOf(" ") < 0 && tags.indexOf(" ") < 0 &&
@ -81,12 +82,6 @@ ${Utils.special_visualizations_importRequirementDocs}
) { ) {
// This is a property to expand... // This is a property to expand...
const items: string = originalFeatureTags.data[tags] const items: string = originalFeatureTags.data[tags]
console.debug(
"The import button is using tags from properties[" +
tags +
"] of this object, namely ",
items
)
if (items.startsWith("{")) { if (items.startsWith("{")) {
// This is probably a JSON // This is probably a JSON

View file

@ -1,7 +1,5 @@
import { Feature, Point } from "geojson" import { Feature, Point } from "geojson"
import { UIEventSource } from "../../../Logic/UIEventSource" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../../SpecialVisualization"
import { SpecialVisualization, SpecialVisualizationState } from "../../SpecialVisualization"
import BaseUIElement from "../../BaseUIElement"
import SvelteUIElement from "../../Base/SvelteUIElement" import SvelteUIElement from "../../Base/SvelteUIElement"
import PointImportFlow from "./PointImportFlow.svelte" import PointImportFlow from "./PointImportFlow.svelte"
import { PointImportFlowArguments, PointImportFlowState } from "./PointImportFlowState" import { PointImportFlowArguments, PointImportFlowState } from "./PointImportFlowState"
@ -9,12 +7,14 @@ import { Utils } from "../../../Utils"
import { ImportFlowUtils } from "./ImportFlow" import { ImportFlowUtils } from "./ImportFlow"
import Translations from "../../i18n/Translations" import Translations from "../../i18n/Translations"
import { GeoOperations } from "../../../Logic/GeoOperations" import { GeoOperations } from "../../../Logic/GeoOperations"
import Tr from "../../Base/Tr.svelte"
import { UIEventSource } from "../../../Logic/UIEventSource"
import { OsmTags } from "../../../Models/OsmFeature" import { OsmTags } from "../../../Models/OsmFeature"
/** /**
* The wrapper to make the special visualisation for the PointImportFlow * The wrapper to make the special visualisation for the PointImportFlow
*/ */
export class PointImportButtonViz extends SpecialVisualization { export class PointImportButtonViz extends SpecialVisualizationSvelte {
public readonly funcName = "import_button" public readonly funcName = "import_button"
public readonly docs: string = public readonly docs: string =
"This button will copy the point from an external dataset into OpenStreetMap" + "This button will copy the point from an external dataset into OpenStreetMap" +
@ -47,29 +47,24 @@ export class PointImportButtonViz extends SpecialVisualization {
public needsUrls = [] public needsUrls = []
group = "data_import" group = "data_import"
constr( constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<OsmTags>,
argument: string[],
feature: Feature
): BaseUIElement {
const to_point_index = this.args.findIndex((arg) => arg.name === "to_point") const to_point_index = this.args.findIndex((arg) => arg.name === "to_point")
const summarizePointArg = argument[to_point_index].toLowerCase() const summarizePointArg = args[to_point_index].toLowerCase()
if (feature.geometry.type !== "Point") { if (feature.geometry.type !== "Point") {
if (summarizePointArg !== "no" && summarizePointArg !== "false") { if (summarizePointArg !== "no" && summarizePointArg !== "false") {
feature = GeoOperations.centerpoint(feature) feature = GeoOperations.centerpoint(feature)
} else { } else {
return Translations.t.general.add.import.wrongType.SetClass("alert") return new SvelteUIElement(Tr, { t: Translations.t.general.add.import.wrongType.SetClass("alert") })
} }
} }
const baseArgs: PointImportFlowArguments = <any>Utils.ParseVisArgs(this.args, argument) const baseArgs: PointImportFlowArguments = <any>Utils.ParseVisArgs(this.args, args)
const tagsToApply = ImportFlowUtils.getTagsToApply(tagSource, baseArgs) const tagsToApply = ImportFlowUtils.getTagsToApply(<UIEventSource<OsmTags>>tags, baseArgs)
const importFlow = new PointImportFlowState( const importFlow = new PointImportFlowState(
state, state,
<Feature<Point>>feature, <Feature<Point>>feature,
baseArgs, baseArgs,
tagsToApply, tagsToApply,
tagSource tags
) )
return new SvelteUIElement(PointImportFlow, { return new SvelteUIElement(PointImportFlow, {

View file

@ -1,10 +1,12 @@
import { SpecialVisualization, SpecialVisualizationState } from "../../SpecialVisualization" import {
SpecialVisualisationParams,
SpecialVisualizationSvelte,
SpecialVisualizationUtils,
} from "../../SpecialVisualization"
import { AutoAction } from "../AutoApplyButtonVis" import { AutoAction } from "../AutoApplyButtonVis"
import { Feature, LineString, Polygon } from "geojson" import { Feature, LineString, Polygon } from "geojson"
import { UIEventSource } from "../../../Logic/UIEventSource" import { UIEventSource } from "../../../Logic/UIEventSource"
import BaseUIElement from "../../BaseUIElement"
import { ImportFlowUtils } from "./ImportFlow" import { ImportFlowUtils } from "./ImportFlow"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import SvelteUIElement from "../../Base/SvelteUIElement" import SvelteUIElement from "../../Base/SvelteUIElement"
import WayImportFlow from "./WayImportFlow.svelte" import WayImportFlow from "./WayImportFlow.svelte"
import WayImportFlowState, { WayImportFlowArguments } from "./WayImportFlowState" import WayImportFlowState, { WayImportFlowArguments } from "./WayImportFlowState"
@ -13,12 +15,11 @@ import ThemeConfig from "../../../Models/ThemeConfig/ThemeConfig"
import { Changes } from "../../../Logic/Osm/Changes" import { Changes } from "../../../Logic/Osm/Changes"
import { IndexedFeatureSource } from "../../../Logic/FeatureSource/FeatureSource" import { IndexedFeatureSource } from "../../../Logic/FeatureSource/FeatureSource"
import FullNodeDatabaseSource from "../../../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" import FullNodeDatabaseSource from "../../../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
import { OsmTags } from "../../../Models/OsmFeature"
/** /**
* Wrapper around 'WayImportFlow' to make it a special visualisation * Wrapper around 'WayImportFlow' to make it a special visualisation
*/ */
export default class WayImportButtonViz extends SpecialVisualization implements AutoAction { export default class WayImportButtonViz extends SpecialVisualizationSvelte implements AutoAction {
public readonly funcName: string = "import_way_button" public readonly funcName: string = "import_way_button"
needsUrls = [] needsUrls = []
group = "data_import" group = "data_import"
@ -60,25 +61,20 @@ export default class WayImportButtonViz extends SpecialVisualization implements
public readonly supportsAutoAction = true public readonly supportsAutoAction = true
public readonly needsNodeDatabase = true public readonly needsNodeDatabase = true
constr( constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<OsmTags>,
argument: string[],
feature: Feature,
_: LayerConfig
): BaseUIElement {
const geometry = feature.geometry const geometry = feature.geometry
if (!(geometry.type == "LineString" || geometry.type === "Polygon")) { if (!(geometry.type == "LineString" || geometry.type === "Polygon")) {
throw "Invalid type to import " + geometry.type throw "Invalid type to import, expected linestring of polygon but got " + geometry.type
} }
const args: WayImportFlowArguments = <any>Utils.ParseVisArgs(this.args, argument) const parsedArgs: WayImportFlowArguments = <any>SpecialVisualizationUtils.parseArgs(this.args, args)
const tagsToApply = ImportFlowUtils.getTagsToApply(tagSource, args) console.log("Parsed args are", parsedArgs)
const tagsToApply = ImportFlowUtils.getTagsToApply(tags, parsedArgs)
const importFlow = new WayImportFlowState( const importFlow = new WayImportFlowState(
state, state,
<Feature<LineString | Polygon>>feature, <Feature<LineString | Polygon>>feature,
args, parsedArgs,
tagsToApply, tagsToApply,
tagSource tags,
) )
return new SvelteUIElement(WayImportFlow, { return new SvelteUIElement(WayImportFlow, {
importFlow, importFlow,

View file

@ -1,12 +1,8 @@
import { SpecialVisualization, SpecialVisualizationState } from "../../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../../SpecialVisualization"
import BaseUIElement from "../../BaseUIElement"
import { UIEventSource } from "../../../Logic/UIEventSource"
import SvelteUIElement from "../../Base/SvelteUIElement" import SvelteUIElement from "../../Base/SvelteUIElement"
import { Feature } from "geojson"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import { default as LanguageElementSvelte } from "./LanguageElement.svelte" import { default as LanguageElementSvelte } from "./LanguageElement.svelte"
export class LanguageElement extends SpecialVisualization { export class LanguageElement extends SpecialVisualizationSvelte {
funcName: string = "language_chooser" funcName: string = "language_chooser"
needsUrls = [] needsUrls = []
@ -66,14 +62,16 @@ export class LanguageElement extends SpecialVisualization {
` `
constr( constr(
state: SpecialVisualizationState, {
tagSource: UIEventSource<Record<string, string>>, state,
argument: string[], tags,
feature: Feature, args,
layer: LayerConfig feature,
): BaseUIElement { layer,
}: SpecialVisualisationParams,
): SvelteUIElement {
let [key, question, item_render, single_render, all_render, on_no_known_languages] = let [key, question, item_render, single_render, all_render, on_no_known_languages] =
argument args
if (item_render === undefined || item_render.trim() === "") { if (item_render === undefined || item_render.trim() === "") {
item_render = "{language()}" item_render = "{language()}"
} }
@ -101,7 +99,7 @@ export class LanguageElement extends SpecialVisualization {
return new SvelteUIElement(LanguageElementSvelte, { return new SvelteUIElement(LanguageElementSvelte, {
key, key,
tags: tagSource, tags,
state, state,
feature, feature,
layer, layer,

View file

@ -1,7 +1,6 @@
import { GeoOperations } from "../../Logic/GeoOperations" import { GeoOperations } from "../../Logic/GeoOperations"
import { ImmutableStore, UIEventSource } from "../../Logic/UIEventSource" import { ImmutableStore } from "../../Logic/UIEventSource"
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import { Feature } from "geojson"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import MapillaryLink from "../BigComponents/MapillaryLink.svelte" import MapillaryLink from "../BigComponents/MapillaryLink.svelte"
@ -20,12 +19,7 @@ export class MapillaryLinkVis extends SpecialVisualizationSvelte {
}, },
] ]
public constr( public constr({ args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagsSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature
): SvelteUIElement {
const [lon, lat] = GeoOperations.centerpointCoordinates(feature) const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
let zoom = Number(args[0]) let zoom = Number(args[0])
if (isNaN(zoom)) { if (isNaN(zoom)) {

View file

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store, UIEventSource } from "../../Logic/UIEventSource"
import type { Feature } from "geojson" import type { Feature, Geometry } from "geojson"
import { GeoOperations } from "../../Logic/GeoOperations" import { GeoOperations } from "../../Logic/GeoOperations"
import { MapLibreAdaptor } from "../Map/MapLibreAdaptor" import { MapLibreAdaptor } from "../Map/MapLibreAdaptor"
import type { SpecialVisualizationState } from "../SpecialVisualization" import type { SpecialVisualizationState } from "../SpecialVisualization"
@ -8,22 +8,23 @@
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource" import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource"
import MaplibreMap from "../Map/MaplibreMap.svelte" import MaplibreMap from "../Map/MaplibreMap.svelte"
import DelayedComponent from "../Base/DelayedComponent.svelte" import DelayedComponent from "../Base/DelayedComponent.svelte"
import type { OsmTags } from "../../Models/OsmFeature"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
export let state: SpecialVisualizationState export let state: SpecialVisualizationState
export let tagSource: UIEventSource<Record<string, string>> export let tags: UIEventSource<Record<string, string>>
export let defaultzoom: number export let defaultzoom: number
export let idkeys: string[] export let idkeys: string[]
export let feature: Feature export let feature: Feature
export let clss: string = "h-40 rounded" export let clss: string = "h-40 rounded"
const keys = idkeys const keys = idkeys
let featuresToShow: Store<Feature[]> = state.indexedFeatures.featuresById.map( let featuresToShow: Store<Feature<Geometry, OsmTags>[]> = state.indexedFeatures.featuresById.map(
(featuresById) => { (featuresById) => {
if (featuresById === undefined) { if (featuresById === undefined) {
return [] return []
} }
const properties = tagSource.data const properties = tags.data
const features: Feature[] = [] const features: Feature<Geometry, OsmTags>[] = []
for (const key of keys) { for (const key of keys) {
const value = properties[key] const value = properties[key]
if (value === undefined || value === null) { if (value === undefined || value === null) {
@ -44,13 +45,13 @@
console.warn("No feature found for id ", id) console.warn("No feature found for id ", id)
continue continue
} }
features.push(feature) features.push(<Feature<Geometry, OsmTags>> feature)
} }
} }
return features return features
}, },
[tagSource], [tags],
onDestroy onDestroy,
) )
let mlmap = new UIEventSource(undefined) let mlmap = new UIEventSource(undefined)
@ -70,7 +71,7 @@
mlmap, mlmap,
new StaticFeatureSource(featuresToShow), new StaticFeatureSource(featuresToShow),
state.theme.layers, state.theme.layers,
{ zoomToFeatures: true } { zoomToFeatures: true },
) )
</script> </script>

View file

@ -1,6 +1,6 @@
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store } from "../../Logic/UIEventSource"
import { MultiApplyParams } from "./MultiApply" import { MultiApplyParams } from "./MultiApply"
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import MultiApplyButton from "./MultiApplyButton.svelte" import MultiApplyButton from "./MultiApplyButton.svelte"
@ -36,17 +36,13 @@ export class MultiApplyViz extends SpecialVisualizationSvelte {
example = example =
"{multi_apply(_features_with_the_same_name_within_100m, name:etymology:wikidata;name:etymology, Apply etymology information on all nearby objects with the same name)}" "{multi_apply(_features_with_the_same_name_within_100m, name:etymology:wikidata;name:etymology, Apply etymology information on all nearby objects with the same name)}"
constr( constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagsSource: UIEventSource<Record<string, string>>,
args: string[]
): SvelteUIElement {
const featureIdsKey = args[0] const featureIdsKey = args[0]
const keysToApply = args[1].split(";") const keysToApply = args[1].split(";")
const text = args[2] const text = args[2]
const autoapply = args[3]?.toLowerCase() === "true" const autoapply = args[3]?.toLowerCase() === "true"
const overwrite = args[4]?.toLowerCase() === "true" const overwrite = args[4]?.toLowerCase() === "true"
const featureIds: Store<string[]> = tagsSource.map((tags) => { const featureIds: Store<string[]> = tags.map((tags) => {
const ids = tags[featureIdsKey] const ids = tags[featureIdsKey]
try { try {
if (ids === undefined) { if (ids === undefined) {
@ -71,7 +67,7 @@ export class MultiApplyViz extends SpecialVisualizationSvelte {
text, text,
autoapply, autoapply,
overwrite, overwrite,
tagsSource, tagsSource: tags,
state, state,
} }
return new SvelteUIElement(MultiApplyButton, { params }) return new SvelteUIElement(MultiApplyButton, { params })

View file

@ -1,11 +1,11 @@
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store } from "../../Logic/UIEventSource"
import { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider" import { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
import Wikidata from "../../Logic/Web/Wikidata" import Wikidata from "../../Logic/Web/Wikidata"
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction" import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
import { And } from "../../Logic/Tags/And" import { And } from "../../Logic/Tags/And"
import { Tag } from "../../Logic/Tags/Tag" import { Tag } from "../../Logic/Tags/Tag"
import AllImageProviders from "../../Logic/ImageProviders/AllImageProviders" import AllImageProviders from "../../Logic/ImageProviders/AllImageProviders"
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import PlantNet from "../PlantNet/PlantNet.svelte" import PlantNet from "../PlantNet/PlantNet.svelte"
import { default as PlantNetCode } from "../../Logic/Web/PlantNet" import { default as PlantNetCode } from "../../Logic/Web/PlantNet"
@ -37,11 +37,7 @@ export class PlantNetDetectionViz extends SpecialVisualizationSvelte {
}, },
] ]
public constr( public constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[]
): SvelteUIElement {
let imagePrefixes: string[] = undefined let imagePrefixes: string[] = undefined
if (args.length > 0) { if (args.length > 0) {
imagePrefixes = [].concat(...args.map((a) => a.split(","))) imagePrefixes = [].concat(...args.map((a) => a.split(",")))

View file

@ -1,6 +1,5 @@
import { UIEventSource } from "../../Logic/UIEventSource"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import ShareButton from "../Base/ShareButton.svelte" import ShareButton from "../Base/ShareButton.svelte"
@ -23,20 +22,19 @@ export class ShareLinkViz extends SpecialVisualizationSvelte {
] ]
needsUrls = [] needsUrls = []
public constr( public constr({
state: SpecialVisualizationState, state,
tagSource: UIEventSource<Record<string, string>>, tags,
args: string[] args}:SpecialVisualisationParams
) { ) {
const text = args[1] const text = args[1]
const generateShareData = () => { const generateShareData = () => {
const title = state?.theme?.title?.txt ?? "MapComplete" const title = state?.theme?.title?.txt ?? "MapComplete"
const matchingLayer: LayerConfig = state?.theme?.getMatchingLayer(tags?.data)
const matchingLayer: LayerConfig = state?.theme?.getMatchingLayer(tagSource?.data)
let name = let name =
matchingLayer?.title?.GetRenderValue(tagSource.data)?.Subs(tagSource.data)?.txt ?? matchingLayer?.title?.GetRenderValue(tags.data)?.Subs(tags.data)?.txt ??
tagSource.data?.name ?? tags.data?.name ??
"POI" "POI"
if (name) { if (name) {
name = `${name} (${title})` name = `${name} (${title})`

View file

@ -51,7 +51,7 @@
{ {
try { try {
return specpart.func return specpart.func
.constr(state, tags, specpart.args, feature, layer) .constr({state, tags, args : specpart.args, feature, layer})
?.SetClass(specpart.style) ?.SetClass(specpart.style)
} catch (e) { } catch (e) {
console.error( console.error(

View file

@ -1,4 +1,9 @@
import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization" import {
SpecialVisualisationParams,
SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import { UIEventSource } from "../../Logic/UIEventSource" import { UIEventSource } from "../../Logic/UIEventSource"
import { GeoOperations } from "../../Logic/GeoOperations" import { GeoOperations } from "../../Logic/GeoOperations"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
@ -9,18 +14,14 @@ import { ServerSourceInfo } from "../../Models/SourceOverview"
/** /**
* Wrapper around 'UploadTraceToOsmUI' * Wrapper around 'UploadTraceToOsmUI'
*/ */
export class UploadToOsmViz extends SpecialVisualization { export class UploadToOsmViz extends SpecialVisualizationSvelte {
funcName = "upload_to_osm" funcName = "upload_to_osm"
docs = docs =
"Uploads the GPS-history as GPX to OpenStreetMap.org; clears the history afterwards. The actual feature is ignored." "Uploads the GPS-history as GPX to OpenStreetMap.org; clears the history afterwards. The actual feature is ignored."
args = [] args = []
needsUrls: ServerSourceInfo[] = [Constants.osmAuthConfig] needsUrls: ServerSourceInfo[] = [Constants.osmAuthConfig]
constr( constr({ state }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
_: UIEventSource<Record<string, string>>,
__: string[]
) {
const locations = state.historicalUserLocations.features.data const locations = state.historicalUserLocations.features.data
return new SvelteUIElement(UploadTraceToOsmUI, { return new SvelteUIElement(UploadTraceToOsmUI, {
state, state,

View file

@ -1,4 +1,5 @@
import { import {
SpecialVisualisationParams,
SpecialVisualization, SpecialVisualization,
SpecialVisualizationState, SpecialVisualizationState,
SpecialVisualizationSvelte, SpecialVisualizationSvelte,
@ -79,7 +80,7 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
}, },
] ]
constr(state, tagsSource, args) { constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
let [message, image, message_closed, statusToSet, maproulette_id_key, askFeedback] = args let [message, image, message_closed, statusToSet, maproulette_id_key, askFeedback] = args
if (image === "") { if (image === "") {
image = "confirm" image = "confirm"
@ -90,7 +91,7 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
statusToSet = statusToSet ?? "1" statusToSet = statusToSet ?? "1"
return new SvelteUIElement(MaprouletteSetStatus, { return new SvelteUIElement(MaprouletteSetStatus, {
state, state,
tags: tagsSource, tags,
message, message,
image, image,
message_closed, message_closed,
@ -149,21 +150,15 @@ class LinkedDataFromWebsite extends SpecialVisualization {
}, },
] ]
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
if (state.theme.enableMorePrivacy) { if (state.theme.enableMorePrivacy) {
return undefined return undefined
} }
const key = argument[0] ?? "website" const key = args[0] ?? "website"
const useProxy = argument[1] !== "no" const useProxy = args[1] !== "no"
const readonly = argument[3] === "readonly" const readonly = args[3] === "readonly"
const isClosed = (argument[4] ?? "yes") === "yes" const isClosed = (args[4] ?? "yes") === "yes"
const downloadInformation = new UIEventSource(false) const downloadInformation = new UIEventSource(false)
const countryStore: Store<string | undefined> = tags.mapD((tags) => tags._country) const countryStore: Store<string | undefined> = tags.mapD((tags) => tags._country)
const sourceUrl: Store<string | undefined> = tags.mapD((tags) => { const sourceUrl: Store<string | undefined> = tags.mapD((tags) => {
@ -245,7 +240,7 @@ class LinkedDataFromWebsite extends SpecialVisualization {
} }
} }
class CompareData extends SpecialVisualization { class CompareData extends SpecialVisualizationSvelte {
funcName = "compare_data" funcName = "compare_data"
group = "data_import" group = "data_import"
needsUrls = (args) => args[1].split(";") needsUrls = (args) => args[1].split(";")
@ -270,20 +265,14 @@ class CompareData extends SpecialVisualization {
docs = docs =
"Gives an interactive element which shows a tag comparison between the OSM-object and the upstream object. This allows to copy some or all tags into OSM" "Gives an interactive element which shows a tag comparison between the OSM-object and the upstream object. This allows to copy some or all tags into OSM"
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement {
const url = args[0] const url = args[0]
const readonly = args[3] === "yes" const readonly = args[3] === "yes"
const externalData = UIEventSource.fromPromiseWithErr(Utils.downloadJson(url)) const externalData = UIEventSource.fromPromiseWithErr(Utils.downloadJson(url))
return new SvelteUIElement(ComparisonTool, { return new SvelteUIElement(ComparisonTool, {
url, url,
state, state,
tags: tagSource, tags,
layer, layer,
feature, feature,
readonly, readonly,
@ -292,7 +281,7 @@ class CompareData extends SpecialVisualization {
} }
} }
export class DataImportSpecialVisualisations { export class DataImportSpecialVisualisations {
public static initList(): (SpecialVisualization & { group })[] { public static initList(): SpecialVisualizationSvelte[] {
return [ return [
new TagApplyViz(), new TagApplyViz(),
new PointImportButtonViz(), new PointImportButtonViz(),

View file

@ -1,7 +1,4 @@
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import { UIEventSource } from "../../Logic/UIEventSource"
import { Feature } from "geojson"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import MarkAsFavourite from "../Popup/MarkAsFavourite.svelte" import MarkAsFavourite from "../Popup/MarkAsFavourite.svelte"
import MarkAsFavouriteMini from "../Popup/MarkAsFavouriteMini.svelte" import MarkAsFavouriteMini from "../Popup/MarkAsFavouriteMini.svelte"
@ -14,19 +11,8 @@ class FavouriteStatus extends SpecialVisualizationSvelte {
args = [] args = []
group = "favourites" group = "favourites"
constr( constr(params: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, return new SvelteUIElement(MarkAsFavourite, params)
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
return new SvelteUIElement(MarkAsFavourite, {
tags: tagSource,
state,
layer,
feature,
})
} }
} }
@ -37,19 +23,8 @@ class FavouriteIcon extends SpecialVisualizationSvelte {
"A small button that allows a (logged in) contributor to mark a location as a favourite location, sized to fit a title-icon" "A small button that allows a (logged in) contributor to mark a location as a favourite location, sized to fit a title-icon"
args = [] args = []
constr( constr(params: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, return new SvelteUIElement(MarkAsFavouriteMini, params)
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
return new SvelteUIElement(MarkAsFavouriteMini, {
tags: tagSource,
state,
layer,
feature,
})
} }
} }

View file

@ -1,12 +1,9 @@
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualizationSvelte } from "../SpecialVisualization"
import AllImageProviders from "../../Logic/ImageProviders/AllImageProviders" import AllImageProviders from "../../Logic/ImageProviders/AllImageProviders"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import ImageCarousel from "../Image/ImageCarousel.svelte" import ImageCarousel from "../Image/ImageCarousel.svelte"
import UploadImage from "../Image/UploadImage.svelte" import UploadImage from "../Image/UploadImage.svelte"
import { CombinedFetcher } from "../../Logic/Web/NearbyImagesSearch" import { CombinedFetcher } from "../../Logic/Web/NearbyImagesSearch"
import { UIEventSource } from "../../Logic/UIEventSource"
import { Feature } from "geojson"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import { GeoOperations } from "../../Logic/GeoOperations" import { GeoOperations } from "../../Logic/GeoOperations"
import NearbyImages from "../Image/NearbyImages.svelte" import NearbyImages from "../Image/NearbyImages.svelte"
import NearbyImagesCollapsed from "../Image/NearbyImagesCollapsed.svelte" import NearbyImagesCollapsed from "../Image/NearbyImagesCollapsed.svelte"
@ -32,13 +29,7 @@ class NearbyImageVis extends SpecialVisualizationSvelte {
funcName = "nearby_images" funcName = "nearby_images"
needsUrls = CombinedFetcher.apiUrls needsUrls = CombinedFetcher.apiUrls
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
const isOpen = args[0] === "open" const isOpen = args[0] === "open"
const readonly = args[1] === "readonly" || args[1] === "yes" const readonly = args[1] === "readonly" || args[1] === "yes"
const [lon, lat] = GeoOperations.centerpointCoordinates(feature) const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
@ -69,7 +60,7 @@ class ImageCarouselVis extends SpecialVisualizationSvelte {
] ]
needsUrls = AllImageProviders.apiUrls needsUrls = AllImageProviders.apiUrls
constr(state, tags, args, feature) { constr({state, tags, args, feature}: SpecialVisualisationParams) {
let imagePrefixes: string[] = undefined let imagePrefixes: string[] = undefined
if (args.length > 0) { if (args.length > 0) {
imagePrefixes = [].concat(...args.map((a) => a.split(";"))) imagePrefixes = [].concat(...args.map((a) => a.split(";")))
@ -114,7 +105,7 @@ class ImageUpload extends SpecialVisualizationSvelte {
}, },
] ]
constr(state, tags, args, feature) { constr({state, tags, args, feature}: SpecialVisualisationParams) {
const targetKey = args[0] === "" ? undefined : args[0] const targetKey = args[0] === "" ? undefined : args[0]
const noBlur = args[3]?.toLowerCase()?.trim() const noBlur = args[3]?.toLowerCase()?.trim()
return new SvelteUIElement(UploadImage, { return new SvelteUIElement(UploadImage, {

View file

@ -1,8 +1,4 @@
import { import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
SpecialVisualization,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
import { UIEventSource } from "../../Logic/UIEventSource" import { UIEventSource } from "../../Logic/UIEventSource"
import { Feature } from "geojson" import { Feature } from "geojson"
@ -57,11 +53,7 @@ class CloseNoteViz extends SpecialVisualizationSvelte {
] ]
public readonly group = "notes" public readonly group = "notes"
public constr( public constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[]
): SvelteUIElement {
const { text, icon, idkey, comment, minZoom, zoomButton } = Utils.ParseVisArgs( const { text, icon, idkey, comment, minZoom, zoomButton } = Utils.ParseVisArgs(
this.args, this.args,
args args
@ -94,10 +86,7 @@ class AddNoteCommentViz extends SpecialVisualizationSvelte {
] ]
public readonly group = "notes" public readonly group = "notes"
public constr( public constr({ state, tags }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>
): SvelteUIElement {
return new SvelteUIElement(AddNoteComment, { state, tags }) return new SvelteUIElement(AddNoteComment, { state, tags })
} }
} }
@ -110,13 +99,8 @@ class OpenNote extends SpecialVisualizationSvelte {
docs = docs =
"Creates a new map note on the given location. This options is placed in the 'last_click'-popup automatically if the 'notes'-layer is enabled" "Creates a new map note on the given location. This options is placed in the 'last_click'-popup automatically if the 'notes'-layer is enabled"
constr( constr({ state, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const [lon, lat] = GeoOperations.centerpointCoordinates(<Feature>feature)
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature
): SvelteUIElement {
const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
return new SvelteUIElement(CreateNewNote, { return new SvelteUIElement(CreateNewNote, {
state, state,
coordinate: new UIEventSource({ lon, lat }), coordinate: new UIEventSource({ lon, lat }),
@ -138,7 +122,7 @@ class AddImageToNote extends SpecialVisualizationSvelte {
group = "notes" group = "notes"
needsUrls = [] needsUrls = []
constr(state, tags, args, feature) { constr({ state, tags, args, feature }: SpecialVisualisationParams) {
const id = tags.data[args[0] ?? "id"] const id = tags.data[args[0] ?? "id"]
tags = state.featureProperties.getStore(id) tags = state.featureProperties.getStore(id)
return new SvelteUIElement(UploadImage, { state, tags, feature }) return new SvelteUIElement(UploadImage, { state, tags, feature })
@ -164,7 +148,7 @@ class VisualiseNoteComment extends SpecialVisualization {
] ]
needsUrls = [Constants.osmAuthConfig] needsUrls = [Constants.osmAuthConfig]
constr(state, tags, args) { constr({ state, tags, args }: SpecialVisualisationParams) {
return new VariableUiElement( return new VariableUiElement(
tags tags
.map((tags) => tags[args[0]]) .map((tags) => tags[args[0]])
@ -191,7 +175,7 @@ class VisualiseNoteComment extends SpecialVisualization {
} }
export class NoteVisualisations { export class NoteVisualisations {
public static initList(): (SpecialVisualization & { group })[] { public static initList(): SpecialVisualization[] {
return [ return [
new AddNoteCommentViz(), new AddNoteCommentViz(),
new CloseNoteViz(), new CloseNoteViz(),

View file

@ -1,4 +1,5 @@
import { import {
SpecialVisualisationParams,
SpecialVisualization, SpecialVisualization,
SpecialVisualizationState, SpecialVisualizationState,
SpecialVisualizationSvelte, SpecialVisualizationSvelte,
@ -16,6 +17,7 @@ import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import BaseUIElement from "../BaseUIElement" import BaseUIElement from "../BaseUIElement"
import Combine from "../Base/Combine" import Combine from "../Base/Combine"
import { ServerSourceInfo } from "../../Models/SourceOverview" import { ServerSourceInfo } from "../../Models/SourceOverview"
import { WithUserRelatedState } from "../../Models/ThemeViewState/WithUserRelatedState"
class CreateReview extends SpecialVisualizationSvelte { class CreateReview extends SpecialVisualizationSvelte {
public static MangroveReviewInfo: ServerSourceInfo = { public static MangroveReviewInfo: ServerSourceInfo = {
@ -58,7 +60,7 @@ class CreateReview extends SpecialVisualizationSvelte {
}, },
] ]
constr(state, tags, args, feature, layer) { constr({ state, tags, args, feature, layer }: SpecialVisualisationParams) {
const nameKey = args[0] ?? "name" const nameKey = args[0] ?? "name"
const fallbackName = args[1] const fallbackName = args[1]
const question = args[2] const question = args[2]
@ -70,7 +72,7 @@ class CreateReview extends SpecialVisualizationSvelte {
nameKey: nameKey, nameKey: nameKey,
fallbackName, fallbackName,
}, },
state <SpecialVisualizationState & WithUserRelatedState>state,
) )
return new SvelteUIElement(ReviewForm, { return new SvelteUIElement(ReviewForm, {
reviews, reviews,
@ -103,7 +105,7 @@ class ListReview extends SpecialVisualizationSvelte {
}, },
] ]
constr(state, tags, args, feature) { constr({ state, tags, args, feature }: SpecialVisualisationParams) {
const nameKey = args[0] ?? "name" const nameKey = args[0] ?? "name"
const fallbackName = args[1] const fallbackName = args[1]
const reviews = FeatureReviews.construct( const reviews = FeatureReviews.construct(
@ -138,7 +140,7 @@ class Rating extends SpecialVisualizationSvelte {
}, },
] ]
constr(state, tags, args, feature) { constr({ state, tags, args, feature }: SpecialVisualisationParams) {
const nameKey = args[0] ?? "name" const nameKey = args[0] ?? "name"
const fallbackName = args[1] const fallbackName = args[1]
const reviews = FeatureReviews.construct( const reviews = FeatureReviews.construct(
@ -171,12 +173,8 @@ class ImportMangroveKey extends SpecialVisualizationSvelte {
}, },
] ]
constr( constr({ state, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const [text] = args
_: UIEventSource<Record<string, string>>,
argument: string[]
): SvelteUIElement {
const [text] = argument
return new SvelteUIElement(ImportReviewIdentity, { state, text }) return new SvelteUIElement(ImportReviewIdentity, { state, text })
} }
} }
@ -207,22 +205,16 @@ class Reviews extends SpecialVisualization {
] ]
needsUrls = [CreateReview.MangroveReviewInfo] needsUrls = [CreateReview.MangroveReviewInfo]
constr( constr(params: SpecialVisualisationParams): BaseUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement {
return new Combine([ return new Combine([
new CreateReview().constr(state, tagSource, args, feature, layer), new CreateReview().constr(params),
new ListReview().constr(state, tagSource, args, feature), new ListReview().constr(params),
]) ])
} }
} }
export class ReviewSpecialVisualisations { export class ReviewSpecialVisualisations {
public static initList(): (SpecialVisualization & { group })[] { public static initList(): SpecialVisualization[] {
return [ return [
new Rating(), new Rating(),
new CreateReview(), new CreateReview(),

View file

@ -1,4 +1,8 @@
import { SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization" import {
SpecialVisualisationParams,
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import Constants from "../../Models/Constants" import Constants from "../../Models/Constants"
import LogoutButton from "../Base/LogoutButton.svelte" import LogoutButton from "../Base/LogoutButton.svelte"
@ -25,7 +29,7 @@ class LanguagePickerVis extends SpecialVisualizationSvelte {
group = "settings" group = "settings"
docs = "A component to set the language of the user interface" docs = "A component to set the language of the user interface"
constr(state: SpecialVisualizationState): SvelteUIElement { constr({ state }: SpecialVisualisationParams): SvelteUIElement {
const availableLanguages = Locale.showLinkToWeblate.map((showTranslations) => const availableLanguages = Locale.showLinkToWeblate.map((showTranslations) =>
showTranslations showTranslations
? LanguageUtils.usedLanguagesSorted ? LanguageUtils.usedLanguagesSorted
@ -68,7 +72,7 @@ class GpsAllTags extends SpecialVisualizationSvelte {
docs = "Shows the current tags of the GPS-representing object, used for debugging" docs = "Shows the current tags of the GPS-representing object, used for debugging"
args = [] args = []
constr(state: SpecialVisualizationState): SvelteUIElement { constr({ state }: SpecialVisualisationParams): SvelteUIElement {
const tags = (<ThemeViewState>state).geolocation.currentUserLocation.features.map( const tags = (<ThemeViewState>state).geolocation.currentUserLocation.features.map(
(features) => features[0]?.properties (features) => features[0]?.properties
) )
@ -85,7 +89,7 @@ class StorageAllTags extends SpecialVisualizationSvelte {
docs = "Shows the current state of storage" docs = "Shows the current state of storage"
args = [] args = []
constr(state: SpecialVisualizationState): SvelteUIElement { constr({ state }: SpecialVisualisationParams): SvelteUIElement {
const data = {} const data = {}
for (const key in localStorage) { for (const key in localStorage) {
data[key] = localStorage[key] data[key] = localStorage[key]
@ -117,13 +121,9 @@ export class ClearCachesVis extends SpecialVisualizationSvelte {
] ]
group = "settings" group = "settings"
constr( constr({ args }: SpecialVisualisationParams): SvelteUIElement {
_: SpecialVisualizationState,
__: UIEventSource<Record<string, string>>,
argument: string[]
): SvelteUIElement {
return new SvelteUIElement(ClearCaches, { return new SvelteUIElement(ClearCaches, {
msg: argument[0] ?? "Clear local caches", msg: args[0] ?? "Clear local caches",
}) })
} }
} }
@ -144,7 +144,7 @@ class LoginButtonVis extends SpecialVisualizationSvelte {
docs = "Show a login button" docs = "Show a login button"
group = "settings" group = "settings"
constr(state: SpecialVisualizationState, _, args): SvelteUIElement { constr({ state, args }: SpecialVisualisationParams): SvelteUIElement {
const force = args[0].toLowerCase() const force = args[0].toLowerCase()
let msg = args[1] let msg = args[1]
if (msg === "") { if (msg === "") {
@ -175,16 +175,10 @@ class QrLogin extends SpecialVisualizationSvelte {
"A QR-code which shares the current URL and adds the login token. Anyone with this login token will have the same permissions as you currently have. Logging out from this session will also log them out" "A QR-code which shares the current URL and adds the login token. Anyone with this login token will have the same permissions as you currently have. Logging out from this session will also log them out"
group = "settings" group = "settings"
constr( constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
const shared_oauth_cookie = state.osmConnection.getToken() const shared_oauth_cookie = state.osmConnection.getToken()
const sideText = argument[0] const sideText = args[0]
const sideTextClass = argument[1] ?? "" const sideTextClass = args[1] ?? ""
return new SvelteUIElement(QrCode, { return new SvelteUIElement(QrCode, {
state, state,
tags, tags,
@ -202,8 +196,8 @@ class Logout extends SpecialVisualizationSvelte {
docs = "Shows a button where the user can log out" docs = "Shows a button where the user can log out"
group = "settings" group = "settings"
constr(state: SpecialVisualizationState): SvelteUIElement { constr({ state }: SpecialVisualisationParams): SvelteUIElement {
return new SvelteUIElement(LogoutButton, { osmConnection: state.osmConnection }) return new SvelteUIElement(LogoutButton,state)
} }
} }
@ -213,7 +207,7 @@ class PendingChanges extends SpecialVisualizationSvelte {
group = "settings" group = "settings"
args = [] args = []
constr(state: SpecialVisualizationState): SvelteUIElement { constr({ state }: SpecialVisualisationParams): SvelteUIElement {
return new SvelteUIElement(PendingChangesIndicator, { state, compact: false }) return new SvelteUIElement(PendingChangesIndicator, { state, compact: false })
} }
} }
@ -224,8 +218,8 @@ class ClearLocationHistoryVis extends SpecialVisualizationSvelte {
docs = "A button to remove the travelled track information from the device" docs = "A button to remove the travelled track information from the device"
args = [] args = []
constr(state) { constr(params: SpecialVisualisationParams) {
return new SvelteUIElement(ClearGPSHistory, { state }) return new SvelteUIElement(ClearGPSHistory, params)
} }
} }
@ -233,7 +227,6 @@ export class SettingsVisualisations {
public static initList(): SpecialVisualizationSvelte[] { public static initList(): SpecialVisualizationSvelte[] {
return [ return [
new LanguagePickerVis(), new LanguagePickerVis(),
new DisabledQuestionsVis(), new DisabledQuestionsVis(),
new GyroscopeAllTags(), new GyroscopeAllTags(),
new GpsAllTags(), new GpsAllTags(),

View file

@ -1,5 +1,5 @@
import { AutoAction } from "../Popup/AutoApplyButtonVis" import { AutoAction } from "../Popup/AutoApplyButtonVis"
import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization" import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization"
import { Utils } from "../../Utils" import { Utils } from "../../Utils"
import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Store, UIEventSource } from "../../Logic/UIEventSource"
import { Tag } from "../../Logic/Tags/Tag" import { Tag } from "../../Logic/Tags/Tag"
@ -174,12 +174,7 @@ export default class TagApplyViz extends SpecialVisualization implements AutoAct
} }
} }
public constr( public constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature
): SvelteUIElement {
const tagsToApply: Store<Tag[]> = TagApplyViz.generateTagsToApply(args[0], tags) const tagsToApply: Store<Tag[]> = TagApplyViz.generateTagsToApply(args[0], tags)
const msg = args[1] const msg = args[1]
let image = args[2]?.trim() let image = args[2]?.trim()

View file

@ -1,4 +1,5 @@
import { import {
SpecialVisualisationParams,
SpecialVisualization, SpecialVisualization,
SpecialVisualizationState, SpecialVisualizationState,
SpecialVisualizationSvelte, SpecialVisualizationSvelte,
@ -39,7 +40,7 @@ class StealViz extends SpecialVisualization {
] ]
needsUrls = [] needsUrls = []
constr(state: SpecialVisualizationState, featureTags, args) { constr({ state, tags, args }: SpecialVisualisationParams) {
const [featureIdKey, layerAndtagRenderingIds] = args const [featureIdKey, layerAndtagRenderingIds] = args
const tagRenderings: [LayerConfig, TagRenderingConfig][] = [] const tagRenderings: [LayerConfig, TagRenderingConfig][] = []
for (const layerAndTagRenderingId of layerAndtagRenderingIds.split(";")) { for (const layerAndTagRenderingId of layerAndtagRenderingIds.split(";")) {
@ -52,7 +53,7 @@ class StealViz extends SpecialVisualization {
throw "Could not create stolen tagrenddering: tagRenderings not found" throw "Could not create stolen tagrenddering: tagRenderings not found"
} }
return new VariableUiElement( return new VariableUiElement(
featureTags.map( tags.map(
(tags) => { (tags) => {
const featureId = tags[featureIdKey] const featureId = tags[featureIdKey]
if (featureId === undefined) { if (featureId === undefined) {
@ -133,18 +134,12 @@ class Multi extends SpecialVisualization {
}, },
] ]
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams) {
state: SpecialVisualizationState,
featureTags: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
) {
const [key, tr, classesRaw] = args const [key, tr, classesRaw] = args
const classes = classesRaw ?? "" const classes = classesRaw ?? ""
const translation = new Translation({ "*": tr }) const translation = new Translation({ "*": tr })
return new VariableUiElement( return new VariableUiElement(
featureTags.map((tags) => { tags.map((tags) => {
let properties: object[] let properties: object[]
if (typeof tags[key] === "string") { if (typeof tags[key] === "string") {
properties = JSON.parse(tags[key]) properties = JSON.parse(tags[key])
@ -198,20 +193,14 @@ class Group extends SpecialVisualizationSvelte {
}, },
] ]
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const [header, labelsStr, blacklistStr] = args
tags: UIEventSource<Record<string, string>>,
argument: string[],
selectedElement: Feature,
layer: LayerConfig
): SvelteUIElement {
const [header, labelsStr, blacklistStr] = argument
const labels = labelsStr.split(";").map((x) => x.trim()) const labels = labelsStr.split(";").map((x) => x.trim())
const blacklist = blacklistStr?.split(";")?.map((x) => x.trim()) ?? [] const blacklist = blacklistStr?.split(";")?.map((x) => x.trim()) ?? []
return new SvelteUIElement(GroupedView, { return new SvelteUIElement(GroupedView, {
state, state,
tags, tags,
selectedElement, selectedElement: feature,
layer, layer,
header, header,
labels, labels,
@ -226,10 +215,10 @@ class OpenInId extends SpecialVisualizationSvelte {
args = [] args = []
group = "tagrendering_manipulation" group = "tagrendering_manipulation"
constr(state, feature): SvelteUIElement { constr({state, feature}: SpecialVisualisationParams): SvelteUIElement {
return new SvelteUIElement(OpenIdEditor, { return new SvelteUIElement(OpenIdEditor, {
mapProperties: state.mapProperties, mapProperties: state.mapProperties,
objectId: feature.data.id, objectId: feature.properties.id,
}) })
} }
} }
@ -254,12 +243,12 @@ class OpenInJosm extends SpecialVisualizationSvelte {
}, },
] ]
constr(state): SvelteUIElement { constr(params: SpecialVisualisationParams): SvelteUIElement {
return new SvelteUIElement(OpenJosm, { state }) return new SvelteUIElement(OpenJosm, params)
} }
} }
export default class TagrenderingManipulationSpecialVisualisations { export default class TagrenderingManipulationSpecialVisualisations {
public static initList(): (SpecialVisualization & { group })[] { public static initList(): SpecialVisualization[] {
return [new StealViz(), new Multi(), new Group(), new OpenInId(), new OpenInJosm()] return [new StealViz(), new Multi(), new Group(), new OpenInId(), new OpenInJosm()]
} }
} }

View file

@ -1,4 +1,5 @@
import { import {
SpecialVisualisationParams,
SpecialVisualization, SpecialVisualization,
SpecialVisualizationState, SpecialVisualizationState,
SpecialVisualizationSvelte, SpecialVisualizationSvelte,
@ -49,13 +50,7 @@ class QuestionViz extends SpecialVisualizationSvelte {
] ]
group = "default" group = "default"
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tags: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
const labels = args[0] const labels = args[0]
?.split(";") ?.split(";")
?.map((s) => s.trim()) ?.map((s) => s.trim())
@ -110,12 +105,7 @@ class Minimap extends SpecialVisualizationSvelte {
example = example =
"`{minimap()}`, `{minimap(17, id, _list_of_embedded_feature_ids_calculated_by_calculated_tag):height:10rem; border: 2px solid black}`" "`{minimap()}`, `{minimap(17, id, _list_of_embedded_feature_ids_calculated_by_calculated_tag):height:10rem; border: 2px solid black}`"
constr( constr({ state, tags, args, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature
): SvelteUIElement {
const minzoom = Number(args[0] ?? 18) const minzoom = Number(args[0] ?? 18)
const ids = args[1]?.split(";")?.map((s) => s.trim()) ?? ["id"] const ids = args[1]?.split(";")?.map((s) => s.trim()) ?? ["id"]
const clss = args[2] const clss = args[2]
@ -125,7 +115,7 @@ class Minimap extends SpecialVisualizationSvelte {
idkeys: ids, idkeys: ids,
clss, clss,
feature, feature,
tagSource, tags,
}) })
} }
} }
@ -136,12 +126,9 @@ class SplitButton extends SpecialVisualizationSvelte {
args = [] args = []
group = "default" group = "default"
constr( constr({ state, tags }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>
): SvelteUIElement {
return new SvelteUIElement(SplitRoadWizard, { return new SvelteUIElement(SplitRoadWizard, {
id: tagSource.map((pr) => pr.id), id: tags.map((pr) => pr.id),
state, state,
}) })
} }
@ -154,13 +141,7 @@ class MoveButton extends SpecialVisualizationSvelte {
args = [] args = []
group = "default" group = "default"
constr( constr({ state, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
if (feature.geometry.type !== "Point") { if (feature.geometry.type !== "Point") {
return undefined return undefined
} }
@ -180,18 +161,12 @@ class DeleteButton extends SpecialVisualizationSvelte {
args = [] args = []
group = "default" group = "default"
constr( constr({ state, tags, feature, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
if (!layer.deletion) { if (!layer.deletion) {
return undefined return undefined
} }
return new SvelteUIElement(DeleteWizard, { return new SvelteUIElement(DeleteWizard, {
tags: tagSource, tags,
deleteConfig: layer.deletion, deleteConfig: layer.deletion,
state, state,
feature, feature,
@ -215,14 +190,9 @@ class QrCodeVis extends SpecialVisualizationSvelte {
group = "default" group = "default"
docs = "Generates a QR-code to share the selected object" docs = "Generates a QR-code to share the selected object"
constr( constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const sideText = args[0]
tags: UIEventSource<Record<string, string>>, const sideTextClass = args[1] ?? ""
argument: string[],
feature: Feature
): SvelteUIElement {
const sideText = argument[0]
const sideTextClass = argument[1] ?? ""
return new SvelteUIElement(QrCode, { return new SvelteUIElement(QrCode, {
state, state,
tags, tags,
@ -248,18 +218,12 @@ class IfNothingKnown extends SpecialVisualizationSvelte {
docs = docs =
"Shows a 'nothing is currently known-message if there is at least one unanswered question and no known (answerable) question" "Shows a 'nothing is currently known-message if there is at least one unanswered question and no known (answerable) question"
constr( constr({ state, tags, args, layer }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const text = args[0]
tagSource: UIEventSource<Record<string, string>>, const cssClasses = args[1]
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
const text = argument[0]
const cssClasses = argument[1]
return new SvelteUIElement(NothingKnown, { return new SvelteUIElement(NothingKnown, {
state, state,
tags: tagSource, tags,
layer, layer,
text, text,
cssClasses, cssClasses,
@ -274,7 +238,7 @@ class AddNewPointVis extends SpecialVisualizationSvelte {
args = [] args = []
group = "default" group = "default"
constr(state: SpecialVisualizationState, _, __, feature: GeoJSON): SvelteUIElement { constr({ state, feature }: SpecialVisualisationParams): SvelteUIElement {
const [lon, lat] = GeoOperations.centerpointCoordinates(feature) const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
return new SvelteUIElement(AddNewPoint, { return new SvelteUIElement(AddNewPoint, {
state, state,
@ -297,14 +261,10 @@ class Translated extends SpecialVisualization {
}, },
] ]
constr( constr({ tags, args }: SpecialVisualisationParams): BaseUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[]
): BaseUIElement {
return new VariableUiElement( return new VariableUiElement(
tagSource.map((tags) => { tags.map((tags) => {
const v = tags[argument[0] ?? "value"] const v = tags[args[0] ?? "value"]
try { try {
const tr = typeof v === "string" ? JSON.parse(v) : v const tr = typeof v === "string" ? JSON.parse(v) : v
return new Translation(tr).SetClass("font-bold") return new Translation(tr).SetClass("font-bold")
@ -327,14 +287,8 @@ class TitleVis extends SpecialVisualizationSvelte {
example = example =
"`What is the phone number of {title()}`, which might automatically become `What is the phone number of XYZ`." "`What is the phone number of {title()}`, which might automatically become `What is the phone number of XYZ`."
constr( constr(params: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, return new SvelteUIElement(FeatureTitle, params)
tags: UIEventSource<Record<string, string>>,
_: string[],
feature: Feature,
layer: LayerConfig
) {
return new SvelteUIElement(FeatureTitle, { state, tags, feature, layer })
} }
} }
@ -352,13 +306,7 @@ class BracedVis extends SpecialVisualization {
}, },
] ]
constr( constr({ args }: SpecialVisualisationParams): BaseUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement {
return new FixedUiElement("{" + args[0] + "}") return new FixedUiElement("{" + args[0] + "}")
} }
} }
@ -368,18 +316,9 @@ class CreateCopyVis extends SpecialVisualizationSvelte {
funcName = "create_copy" funcName = "create_copy"
docs = "Allow to create a copy of the current element" docs = "Allow to create a copy of the current element"
args = [] args = []
constr(
state: SpecialVisualizationState, constr(params: SpecialVisualisationParams): SvelteUIElement {
tags: UIEventSource<Record<string, string>>, return new SvelteUIElement(CreateCopy, params)
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement {
try {
return new SvelteUIElement(CreateCopy, { state, tags, argument, feature, layer })
} catch (e) {
console.error(">>> failed", e)
}
} }
} }

View file

@ -1,10 +1,5 @@
import { import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
SpecialVisualization, import { ImmutableStore, Store } from "../../Logic/UIEventSource"
SpecialVisualizationState,
SpecialVisualizationSvelte,
} from "../SpecialVisualization"
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
import BaseUIElement from "../BaseUIElement"
import SvelteUIElement from "../Base/SvelteUIElement" import SvelteUIElement from "../Base/SvelteUIElement"
import FediverseLink from "../Popup/FediverseLink.svelte" import FediverseLink from "../Popup/FediverseLink.svelte"
import Wikidata, { WikidataResponse } from "../../Logic/Web/Wikidata" import Wikidata, { WikidataResponse } from "../../Logic/Web/Wikidata"
@ -18,7 +13,7 @@ import SendEmail from "../Popup/SendEmail.svelte"
import DynLink from "../Base/DynLink.svelte" import DynLink from "../Base/DynLink.svelte"
import { Lists } from "../../Utils/Lists" import { Lists } from "../../Utils/Lists"
class FediverseLinkVis extends SpecialVisualization { class FediverseLinkVis extends SpecialVisualizationSvelte {
funcName = "fediverse_link" funcName = "fediverse_link"
group = "web_and_communication" group = "web_and_communication"
docs = "Converts a fediverse username or link into a clickable link" docs = "Converts a fediverse username or link into a clickable link"
@ -31,17 +26,13 @@ class FediverseLinkVis extends SpecialVisualization {
}, },
] ]
constr( constr({ state, tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState, const key = args[0]
tags: UIEventSource<Record<string, string>>,
argument: string[]
): BaseUIElement {
const key = argument[0]
return new SvelteUIElement(FediverseLink, { key, tags, state }) return new SvelteUIElement(FediverseLink, { key, tags, state })
} }
} }
class WikipediaVis extends SpecialVisualization { class WikipediaVis extends SpecialVisualizationSvelte {
funcName = "wikipedia" funcName = "wikipedia"
group = "web_and_communication" group = "web_and_communication"
docs = "A box showing the corresponding wikipedia article(s) - based on the **wikidata** tag." docs = "A box showing the corresponding wikipedia article(s) - based on the **wikidata** tag."
@ -58,9 +49,9 @@ class WikipediaVis extends SpecialVisualization {
example = example =
"`{wikipedia()}` is a basic example, `{wikipedia(name:etymology:wikidata)}` to show the wikipedia page of whom the feature was named after. Also remember that these can be styled, e.g. `{wikipedia():max-height: 10rem}` to limit the height" "`{wikipedia()}` is a basic example, `{wikipedia(name:etymology:wikidata)}` to show the wikipedia page of whom the feature was named after. Also remember that these can be styled, e.g. `{wikipedia():max-height: 10rem}` to limit the height"
constr(_, tagsSource, args) { constr({ tags, args }: SpecialVisualisationParams) {
const keys = args[0].split(";").map((k) => k.trim()) const keys = args[0].split(";").map((k) => k.trim())
const wikiIds: Store<string[]> = tagsSource.map((tags) => { const wikiIds: Store<string[]> = tags.map((tags) => {
const key = keys.find((k) => tags[k] !== undefined && tags[k] !== "") const key = keys.find((k) => tags[k] !== undefined && tags[k] !== "")
return tags[key]?.split(";")?.map((id) => id.trim()) ?? [] return tags[key]?.split(";")?.map((id) => id.trim()) ?? []
}) })
@ -88,8 +79,8 @@ class WikidatalabelVis extends SpecialVisualization {
example = example =
"`{wikidata_label()}` is a basic example, `{wikipedia(name:etymology:wikidata)}` to show the label itself" "`{wikidata_label()}` is a basic example, `{wikipedia(name:etymology:wikidata)}` to show the label itself"
constr(_, tagsSource, args) { constr({ tags, args }: SpecialVisualisationParams) {
const id = tagsSource const id = tags
.map((tags) => tags[args[0]]) .map((tags) => tags[args[0]])
.map((wikidata) => { .map((wikidata) => {
const wikidataIds = Lists.noEmpty( const wikidataIds = Lists.noEmpty(
@ -144,8 +135,8 @@ class SendEmailVis extends SpecialVisualizationSvelte {
}, },
] ]
constr(__, tags, args) { constr(params: SpecialVisualisationParams) {
return new SvelteUIElement(SendEmail, { args, tags }) return new SvelteUIElement(SendEmail, params)
} }
} }
@ -184,31 +175,27 @@ class LinkVis extends SpecialVisualizationSvelte {
}, },
] ]
constr( constr({ tags, args }: SpecialVisualisationParams): SvelteUIElement {
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
args: string[]
): SvelteUIElement {
let [text, href, classnames, download, ariaLabel, icon] = args let [text, href, classnames, download, ariaLabel, icon] = args
if (download === "") { if (download === "") {
download = undefined download = undefined
} }
const newTab = download === undefined && !href.startsWith("#") const newTab = download === undefined && !href.startsWith("#")
const textStore = tagSource.map((tags) => Utils.SubstituteKeys(text, tags)) const textStore = tags.map((tags) => Utils.SubstituteKeys(text, tags))
const hrefStore = tagSource.map((tags) => Utils.SubstituteKeys(href, tags)) const hrefStore = tags.map((tags) => Utils.SubstituteKeys(href, tags))
return new SvelteUIElement(DynLink, { return new SvelteUIElement(DynLink, {
text: textStore, text: textStore,
href: hrefStore, href: hrefStore,
classnames: new ImmutableStore(classnames), classnames: new ImmutableStore(classnames),
download: tagSource.map((tags) => Utils.SubstituteKeys(download, tags)), download: tags.map((tags) => Utils.SubstituteKeys(download, tags)),
ariaLabel: tagSource.map((tags) => Utils.SubstituteKeys(ariaLabel, tags)), ariaLabel: tags.map((tags) => Utils.SubstituteKeys(ariaLabel, tags)),
newTab: new ImmutableStore(newTab), newTab: new ImmutableStore(newTab),
icon: tagSource.map((tags) => Utils.SubstituteKeys(icon, tags)), icon: tags.map((tags) => Utils.SubstituteKeys(icon, tags)),
}) })
} }
} }
export class WebAndCommunicationSpecialVisualisations { export class WebAndCommunicationSpecialVisualisations {
public static initList(): (SpecialVisualization & { group })[] { public static initList(): SpecialVisualization[] {
return [ return [
new FediverseLinkVis(), new FediverseLinkVis(),
new WikipediaVis(), new WikipediaVis(),

View file

@ -98,10 +98,20 @@ export interface SpecialVisualisationArg {
export class SpecialVisualizationUtils { export class SpecialVisualizationUtils {
static parseArgs(specs: { name: string; defaultValue?: string }[], args: string[]){
return Utils.ParseVisArgs(specs, args)
}
} }
export interface SpecialVisualisationParams {
state: SpecialVisualizationState
tags: UIEventSource<Record<string, string>>
args: string[]
feature: Feature
layer: LayerConfig
}
export abstract class SpecialVisualization { export abstract class SpecialVisualization {
readonly funcName: string readonly funcName: string
@ -128,23 +138,11 @@ export abstract class SpecialVisualization {
structuredExamples?(): { feature: Feature<Geometry, Record<string, string>>; args: string[] }[] structuredExamples?(): { feature: Feature<Geometry, Record<string, string>>; args: string[] }[]
abstract constr( abstract constr(options: SpecialVisualisationParams): BaseUIElement
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): BaseUIElement
} }
export abstract class SpecialVisualizationSvelte extends SpecialVisualization { export abstract class SpecialVisualizationSvelte extends SpecialVisualization {
abstract constr( abstract constr(options: SpecialVisualisationParams): SvelteUIElement
state: SpecialVisualizationState,
tagSource: UIEventSource<Record<string, string>>,
argument: string[],
feature: Feature,
layer: LayerConfig
): SvelteUIElement
} }
export type RenderingSpecification = export type RenderingSpecification =

View file

@ -1,4 +1,4 @@
import { RenderingSpecification, SpecialVisualization } from "./SpecialVisualization" import { RenderingSpecification, SpecialVisualization, SpecialVisualizationSvelte } from "./SpecialVisualization"
import { UploadToOsmViz } from "./Popup/UploadToOsmViz" import { UploadToOsmViz } from "./Popup/UploadToOsmViz"
import { MultiApplyViz } from "./Popup/MultiApplyViz" import { MultiApplyViz } from "./Popup/MultiApplyViz"
import AutoApplyButtonVis from "./Popup/AutoApplyButtonVis" import AutoApplyButtonVis from "./Popup/AutoApplyButtonVis"
@ -176,22 +176,26 @@ export default class SpecialVisualizations {
} }
private static initList(): SpecialVisualization[] { private static initList(): SpecialVisualization[] {
const specialVisualizations: SpecialVisualization[] = [ const specialVisualizationsSv: SpecialVisualizationSvelte[] = [
...ImageVisualisations.initList(), ...ImageVisualisations.initList(),
...NoteVisualisations.initList(),
...FavouriteVisualisations.initList(), ...FavouriteVisualisations.initList(),
...UISpecialVisualisations.initList(),
...SettingsVisualisations.initList(), ...SettingsVisualisations.initList(),
...ReviewSpecialVisualisations.initList(),
...DataImportSpecialVisualisations.initList(), ...DataImportSpecialVisualisations.initList(),
...TagrenderingManipulationSpecialVisualisations.initList(),
...WebAndCommunicationSpecialVisualisations.initList(),
...DataVisualisations.initList(),
...DataExportVisualisations.initList(), ...DataExportVisualisations.initList(),
new UploadToOsmViz(), new UploadToOsmViz(),
new MultiApplyViz(), new MultiApplyViz(),
] ]
const specialVisualizations: SpecialVisualization[] = [
...NoteVisualisations.initList(),
...UISpecialVisualisations.initList(),
...ReviewSpecialVisualisations.initList(),
...TagrenderingManipulationSpecialVisualisations.initList(),
...WebAndCommunicationSpecialVisualisations.initList(),
...DataVisualisations.initList(),
...specialVisualizationsSv
]
specialVisualizations.push(new AutoApplyButtonVis(specialVisualizations)) specialVisualizations.push(new AutoApplyButtonVis(specialVisualizations))
if (Utils.runningFromConsole) { if (Utils.runningFromConsole) {

View file

@ -1,6 +1,5 @@
import DOMPurify from "dompurify" import DOMPurify from "dompurify"
import { Lists } from "./Utils/Lists" import { Lists } from "./Utils/Lists"
import { Strings } from "./Utils/Strings"
export class Utils { export class Utils {
/** /**