forked from MapComplete/MapComplete
Refactoring: switch specialVis constructor to an object
This commit is contained in:
parent
6bb33771b4
commit
1bd226a6fa
38 changed files with 369 additions and 563 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import { SpecialVisualization, SpecialVisualizationState } from "../../SpecialVisualization"
|
||||
import {
|
||||
SpecialVisualisationParams,
|
||||
SpecialVisualizationSvelte,
|
||||
SpecialVisualizationUtils,
|
||||
} from "../../SpecialVisualization"
|
||||
import { AutoAction } from "../AutoApplyButtonVis"
|
||||
import { Feature, LineString, Polygon } from "geojson"
|
||||
import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||
import BaseUIElement from "../../BaseUIElement"
|
||||
import { ImportFlowUtils } from "./ImportFlow"
|
||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||
import SvelteUIElement from "../../Base/SvelteUIElement"
|
||||
import WayImportFlow from "./WayImportFlow.svelte"
|
||||
import WayImportFlowState, { WayImportFlowArguments } from "./WayImportFlowState"
|
||||
|
|
@ -13,12 +15,11 @@ import ThemeConfig from "../../../Models/ThemeConfig/ThemeConfig"
|
|||
import { Changes } from "../../../Logic/Osm/Changes"
|
||||
import { IndexedFeatureSource } from "../../../Logic/FeatureSource/FeatureSource"
|
||||
import FullNodeDatabaseSource from "../../../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
|
||||
import { OsmTags } from "../../../Models/OsmFeature"
|
||||
|
||||
/**
|
||||
* 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"
|
||||
needsUrls = []
|
||||
group = "data_import"
|
||||
|
|
@ -60,25 +61,20 @@ export default class WayImportButtonViz extends SpecialVisualization implements
|
|||
public readonly supportsAutoAction = true
|
||||
public readonly needsNodeDatabase = true
|
||||
|
||||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<OsmTags>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
_: LayerConfig
|
||||
): BaseUIElement {
|
||||
constr({ state, tags, args, feature }: SpecialVisualisationParams): SvelteUIElement {
|
||||
const geometry = feature.geometry
|
||||
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 tagsToApply = ImportFlowUtils.getTagsToApply(tagSource, args)
|
||||
const parsedArgs: WayImportFlowArguments = <any>SpecialVisualizationUtils.parseArgs(this.args, args)
|
||||
console.log("Parsed args are", parsedArgs)
|
||||
const tagsToApply = ImportFlowUtils.getTagsToApply(tags, parsedArgs)
|
||||
const importFlow = new WayImportFlowState(
|
||||
state,
|
||||
<Feature<LineString | Polygon>>feature,
|
||||
args,
|
||||
parsedArgs,
|
||||
tagsToApply,
|
||||
tagSource
|
||||
tags,
|
||||
)
|
||||
return new SvelteUIElement(WayImportFlow, {
|
||||
importFlow,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue