forked from MapComplete/MapComplete
Studio: WIP
This commit is contained in:
parent
3549a10a15
commit
dc82ebbd58
165 changed files with 2588 additions and 3294 deletions
|
@ -2,7 +2,6 @@ import { Conversion } from "./Conversion"
|
|||
import LayerConfig from "../LayerConfig"
|
||||
import { LayerConfigJson } from "../Json/LayerConfigJson"
|
||||
import Translations from "../../../UI/i18n/Translations"
|
||||
import PointRenderingConfigJson from "../Json/PointRenderingConfigJson"
|
||||
import { Translation, TypedTranslation } from "../../../UI/i18n/Translation"
|
||||
|
||||
export default class CreateNoteImportLayer extends Conversion<LayerConfigJson, LayerConfigJson> {
|
||||
|
@ -45,13 +44,6 @@ export default class CreateNoteImportLayer extends Conversion<LayerConfigJson, L
|
|||
isShownIfAny.push({ and: mustMatchAll })
|
||||
}
|
||||
|
||||
const pointRenderings = (layerJson.mapRendering ?? []).filter(
|
||||
(r) => r !== null && r["location"] !== undefined
|
||||
)
|
||||
const firstRender = <PointRenderingConfigJson>pointRenderings[0]
|
||||
if (firstRender === undefined) {
|
||||
throw `Layer ${layerJson.id} does not have a pointRendering: ` + context
|
||||
}
|
||||
const title = layer.presets[0].title
|
||||
|
||||
const importButton = {}
|
||||
|
@ -186,7 +178,7 @@ export default class CreateNoteImportLayer extends Conversion<LayerConfigJson, L
|
|||
},
|
||||
},
|
||||
],
|
||||
mapRendering: [
|
||||
pointRendering: [
|
||||
{
|
||||
location: ["point"],
|
||||
icon: {
|
||||
|
|
|
@ -82,8 +82,8 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
}
|
||||
}
|
||||
|
||||
if (config.mapRendering === undefined) {
|
||||
config.mapRendering = []
|
||||
if (config["mapRendering"] === undefined) {
|
||||
config["mapRendering"] = []
|
||||
// This is a legacy format, lets create a pointRendering
|
||||
let location: ("point" | "centroid")[] = ["point"]
|
||||
let wayHandling: number = config["wayHandling"] ?? 0
|
||||
|
@ -99,7 +99,7 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
location,
|
||||
rotation: config["rotation"],
|
||||
}
|
||||
config.mapRendering.push(pointConfig)
|
||||
config["mapRendering"].push(pointConfig)
|
||||
}
|
||||
|
||||
if (wayHandling !== 1) {
|
||||
|
@ -109,10 +109,10 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
dashArray: config["dashArray"],
|
||||
}
|
||||
if (Object.keys(lineRenderConfig).length > 0) {
|
||||
config.mapRendering.push(lineRenderConfig)
|
||||
config["mapRendering"].push(lineRenderConfig)
|
||||
}
|
||||
}
|
||||
if (config.mapRendering.length === 0) {
|
||||
if (config["mapRendering"].length === 0) {
|
||||
throw (
|
||||
"Could not convert the legacy theme into a new theme: no renderings defined for layer " +
|
||||
config.id
|
||||
|
@ -132,7 +132,7 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
delete config["wayHandling"]
|
||||
delete config["hideUnderlayingFeaturesMinPercentage"]
|
||||
|
||||
for (const mapRenderingElement of config.mapRendering ?? []) {
|
||||
for (const mapRenderingElement of config["mapRendering"] ?? []) {
|
||||
if (mapRenderingElement["iconOverlays"] !== undefined) {
|
||||
mapRenderingElement["iconBadges"] = mapRenderingElement["iconOverlays"]
|
||||
}
|
||||
|
@ -144,13 +144,28 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
}
|
||||
}
|
||||
|
||||
for (const rendering of config.mapRendering ?? []) {
|
||||
if (!rendering["iconSize"]) {
|
||||
if (config["mapRendering"]) {
|
||||
const pointRenderings: PointRenderingConfigJson[] = []
|
||||
const lineRenderings: LineRenderingConfigJson[] = []
|
||||
for (const mapRenderingElement of config["mapRendering"]) {
|
||||
if (mapRenderingElement["location"]) {
|
||||
// This is a pointRendering
|
||||
pointRenderings.push(<any>mapRenderingElement)
|
||||
} else {
|
||||
lineRenderings.push(<any>mapRenderingElement)
|
||||
}
|
||||
}
|
||||
config["pointRendering"] = pointRenderings
|
||||
config["lineRendering"] = lineRenderings
|
||||
delete config["mapRendering"]
|
||||
}
|
||||
|
||||
for (const rendering of config.pointRendering ?? []) {
|
||||
const pr = rendering
|
||||
let iconSize = pr.iconSize
|
||||
if (!iconSize) {
|
||||
continue
|
||||
}
|
||||
const pr = <PointRenderingConfigJson>rendering
|
||||
let iconSize = pr.iconSize
|
||||
console.log("Iconsize is", iconSize)
|
||||
|
||||
if (Object.keys(pr.iconSize).length === 1 && pr.iconSize["render"] !== undefined) {
|
||||
iconSize = pr.iconSize["render"]
|
||||
|
@ -164,7 +179,22 @@ export class UpdateLegacyLayer extends DesugaringStep<
|
|||
}
|
||||
}
|
||||
|
||||
for (const rendering of config.mapRendering) {
|
||||
for (const rendering of config.pointRendering) {
|
||||
for (const key in rendering) {
|
||||
if (!rendering[key]) {
|
||||
continue
|
||||
}
|
||||
if (
|
||||
typeof rendering[key]["render"] === "string" &&
|
||||
Object.keys(rendering[key]).length === 1
|
||||
) {
|
||||
console.log("Rewrite: ", rendering[key])
|
||||
rendering[key] = rendering[key]["render"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const rendering of config.lineRendering) {
|
||||
for (const key in rendering) {
|
||||
if (!rendering[key]) {
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue