From 15aa141e15a4669474d20984326be1c617eb343d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 26 Jul 2024 18:13:26 +0200 Subject: [PATCH] Small UI tweaks for studio, improve linting and typing --- src/Logic/Osm/OsmObject.ts | 12 ++++++------ src/Logic/Osm/Overpass.ts | 8 +++++--- src/UI/Studio/EditLayer.svelte | 4 +--- src/UI/Studio/EditLayerState.ts | 2 +- src/UI/StudioGUI.svelte | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Logic/Osm/OsmObject.ts b/src/Logic/Osm/OsmObject.ts index 6782f4495..8ec4e692d 100644 --- a/src/Logic/Osm/OsmObject.ts +++ b/src/Logic/Osm/OsmObject.ts @@ -214,7 +214,7 @@ export class OsmNode extends OsmObject { * @constructor */ ChangesetXML(changesetId: string, header?: string): string { - let tags = this.TagsXML() + const tags = this.TagsXML() return ` @@ -265,7 +265,7 @@ export class OsmWay extends OsmObject { * obj.ChangesetXML("123").trim() // => '\n \n ' */ ChangesetXML(changesetId: string, header?: string): string { - let tags = this.TagsXML() + const tags = this.TagsXML() let nds = "" for (const node in this.nodes) { nds += ' \n' @@ -302,14 +302,14 @@ ${nds}${tags} latSum += node.lat lonSum += node.lon } - let count = this.coordinates.length + const count = this.coordinates.length this.lat = latSum / count this.lon = lonSum / count this.nodes = element.nodes } public asGeoJson(): Feature & { properties: { id: WayId } } { - let coordinates: [number, number][] | [number, number][][] = this.coordinates.map( + const coordinates: [number, number][] | [number, number][][] = this.coordinates.map( ([lat, lon]) => [lon, lat] ) let geometry: LineString | Polygon @@ -375,9 +375,9 @@ export class OsmRelation extends OsmObject { '"/>\n' } - let tags = this.TagsXML() + const tags = this.TagsXML() let cs = "" - if (changesetId !== undefined) { + if (changesetId) { cs = `changeset="${changesetId}"` } return ` diff --git a/src/Logic/Osm/Overpass.ts b/src/Logic/Osm/Overpass.ts index f3e9ce15a..29c28cbe8 100644 --- a/src/Logic/Osm/Overpass.ts +++ b/src/Logic/Osm/Overpass.ts @@ -4,6 +4,8 @@ import { ImmutableStore, Store } from "../UIEventSource" import { BBox } from "../BBox" import osmtogeojson from "osmtogeojson" import { FeatureCollection } from "@turf/turf" +import { Geometry } from "geojson" +import { OsmTags } from "../../Models/OsmFeature" /** * Interfaces overpass to get all the latest data @@ -33,7 +35,7 @@ export class Overpass { this._includeMeta = includeMeta } - public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection, Date]> { + public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection, Date]> { const bbox = "[bbox:" + bounds.getSouth() + @@ -52,8 +54,8 @@ export class Overpass { return `${this._interpreterUrl}?data=${encodeURIComponent(query)}` } - private async ExecuteQuery(query: string): Promise<[FeatureCollection, Date]> { - const json = await Utils.downloadJson(this.buildUrl(query)) + private async ExecuteQuery(query: string): Promise<[FeatureCollection, Date]> { + const json = await Utils.downloadJson<{elements: [], remark, osm3s: {timestamp_osm_base: string}}>(this.buildUrl(query)) if (json.elements.length === 0 && json.remark !== undefined) { console.warn("Timeout or other runtime error while querying overpass", json.remark) diff --git a/src/UI/Studio/EditLayer.svelte b/src/UI/Studio/EditLayer.svelte index ba79731e1..f3b3fad5f 100644 --- a/src/UI/Studio/EditLayer.svelte +++ b/src/UI/Studio/EditLayer.svelte @@ -17,8 +17,6 @@ import QuestionPreview from "./QuestionPreview.svelte" import ShowConversionMessages from "./ShowConversionMessages.svelte" import RawEditor from "./RawEditor.svelte" - import NextButton from "../Base/NextButton.svelte" - import BackButton from "../Base/BackButton.svelte" import DeleteButton from "./DeleteButton.svelte" import StudioHashSetter from "./StudioHashSetter" @@ -84,7 +82,7 @@
-
+
{#if $title === undefined}

Creating a new layer

diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index a6a2a9732..45ab9914e 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -292,7 +292,7 @@ class ContextRewritingStep extends Conversion { return undefined } const newPath = [...path] - const idToSearch = newTagRenderings[newPath[1]].id + const idToSearch = newTagRenderings[newPath[1]]?.id ?? "" const oldIndex = originalIds.indexOf(idToSearch) if (oldIndex < 0) { console.warn("Original ID was not found: ", idToSearch) diff --git a/src/UI/StudioGUI.svelte b/src/UI/StudioGUI.svelte index 7b5f88801..f4b947961 100644 --- a/src/UI/StudioGUI.svelte +++ b/src/UI/StudioGUI.svelte @@ -367,7 +367,7 @@ {:else if state === "editing_layer"} backToStudio()}> - MapComplete Studio + Studio {:else if state === "editing_theme"}