forked from MapComplete/MapComplete
		
	Small UI tweaks for studio, improve linting and typing
This commit is contained in:
		
							parent
							
								
									b03ff4f148
								
							
						
					
					
						commit
						15aa141e15
					
				
					 5 changed files with 14 additions and 14 deletions
				
			
		| 
						 | 
					@ -214,7 +214,7 @@ export class OsmNode extends OsmObject {
 | 
				
			||||||
     * @constructor
 | 
					     * @constructor
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    ChangesetXML(changesetId: string, header?: string): string {
 | 
					    ChangesetXML(changesetId: string, header?: string): string {
 | 
				
			||||||
        let tags = this.TagsXML()
 | 
					        const tags = this.TagsXML()
 | 
				
			||||||
        return `    <node id="${this.id}" ${header ?? ""} ${
 | 
					        return `    <node id="${this.id}" ${header ?? ""} ${
 | 
				
			||||||
            changesetId ? ' changeset="' + changesetId + '" ' : ""
 | 
					            changesetId ? ' changeset="' + changesetId + '" ' : ""
 | 
				
			||||||
        }${this.VersionXML()} lat="${this.lat}" lon="${this.lon}">
 | 
					        }${this.VersionXML()} lat="${this.lat}" lon="${this.lon}">
 | 
				
			||||||
| 
						 | 
					@ -265,7 +265,7 @@ export class OsmWay extends OsmObject {
 | 
				
			||||||
     * obj.ChangesetXML("123").trim() // => '<way id="1234"  changeset="123"  >\n        <tag k="key" v="value"/>\n    </way>'
 | 
					     * obj.ChangesetXML("123").trim() // => '<way id="1234"  changeset="123"  >\n        <tag k="key" v="value"/>\n    </way>'
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    ChangesetXML(changesetId: string, header?: string): string {
 | 
					    ChangesetXML(changesetId: string, header?: string): string {
 | 
				
			||||||
        let tags = this.TagsXML()
 | 
					        const tags = this.TagsXML()
 | 
				
			||||||
        let nds = ""
 | 
					        let nds = ""
 | 
				
			||||||
        for (const node in this.nodes) {
 | 
					        for (const node in this.nodes) {
 | 
				
			||||||
            nds += '      <nd ref="' + this.nodes[node] + '"/>\n'
 | 
					            nds += '      <nd ref="' + this.nodes[node] + '"/>\n'
 | 
				
			||||||
| 
						 | 
					@ -302,14 +302,14 @@ ${nds}${tags}    </way>
 | 
				
			||||||
            latSum += node.lat
 | 
					            latSum += node.lat
 | 
				
			||||||
            lonSum += node.lon
 | 
					            lonSum += node.lon
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let count = this.coordinates.length
 | 
					        const count = this.coordinates.length
 | 
				
			||||||
        this.lat = latSum / count
 | 
					        this.lat = latSum / count
 | 
				
			||||||
        this.lon = lonSum / count
 | 
					        this.lon = lonSum / count
 | 
				
			||||||
        this.nodes = element.nodes
 | 
					        this.nodes = element.nodes
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public asGeoJson(): Feature<Polygon | LineString> & { properties: { id: WayId } } {
 | 
					    public asGeoJson(): Feature<Polygon | LineString> & { 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]
 | 
					            ([lat, lon]) => [lon, lat]
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        let geometry: LineString | Polygon
 | 
					        let geometry: LineString | Polygon
 | 
				
			||||||
| 
						 | 
					@ -375,9 +375,9 @@ export class OsmRelation extends OsmObject {
 | 
				
			||||||
                '"/>\n'
 | 
					                '"/>\n'
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let tags = this.TagsXML()
 | 
					        const tags = this.TagsXML()
 | 
				
			||||||
        let cs = ""
 | 
					        let cs = ""
 | 
				
			||||||
        if (changesetId !== undefined) {
 | 
					        if (changesetId) {
 | 
				
			||||||
            cs = `changeset="${changesetId}"`
 | 
					            cs = `changeset="${changesetId}"`
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return `    <relation id="${this.id}" ${header ?? ""} ${cs} ${this.VersionXML()}>
 | 
					        return `    <relation id="${this.id}" ${header ?? ""} ${cs} ${this.VersionXML()}>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,8 @@ import { ImmutableStore, Store } from "../UIEventSource"
 | 
				
			||||||
import { BBox } from "../BBox"
 | 
					import { BBox } from "../BBox"
 | 
				
			||||||
import osmtogeojson from "osmtogeojson"
 | 
					import osmtogeojson from "osmtogeojson"
 | 
				
			||||||
import { FeatureCollection } from "@turf/turf"
 | 
					import { FeatureCollection } from "@turf/turf"
 | 
				
			||||||
 | 
					import { Geometry } from "geojson"
 | 
				
			||||||
 | 
					import { OsmTags } from "../../Models/OsmFeature"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Interfaces overpass to get all the latest data
 | 
					 * Interfaces overpass to get all the latest data
 | 
				
			||||||
| 
						 | 
					@ -33,7 +35,7 @@ export class Overpass {
 | 
				
			||||||
        this._includeMeta = includeMeta
 | 
					        this._includeMeta = includeMeta
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection, Date]> {
 | 
					    public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection<Geometry, OsmTags>, Date]> {
 | 
				
			||||||
        const bbox =
 | 
					        const bbox =
 | 
				
			||||||
            "[bbox:" +
 | 
					            "[bbox:" +
 | 
				
			||||||
            bounds.getSouth() +
 | 
					            bounds.getSouth() +
 | 
				
			||||||
| 
						 | 
					@ -52,8 +54,8 @@ export class Overpass {
 | 
				
			||||||
        return `${this._interpreterUrl}?data=${encodeURIComponent(query)}`
 | 
					        return `${this._interpreterUrl}?data=${encodeURIComponent(query)}`
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private async ExecuteQuery(query: string): Promise<[FeatureCollection, Date]> {
 | 
					    private async ExecuteQuery(query: string): Promise<[FeatureCollection<Geometry, OsmTags>, Date]> {
 | 
				
			||||||
        const json = await Utils.downloadJson(this.buildUrl(query))
 | 
					        const json = await Utils.downloadJson<{elements: [], remark, osm3s: {timestamp_osm_base: string}}>(this.buildUrl(query))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (json.elements.length === 0 && json.remark !== undefined) {
 | 
					        if (json.elements.length === 0 && json.remark !== undefined) {
 | 
				
			||||||
            console.warn("Timeout or other runtime error while querying overpass", json.remark)
 | 
					            console.warn("Timeout or other runtime error while querying overpass", json.remark)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,6 @@
 | 
				
			||||||
  import QuestionPreview from "./QuestionPreview.svelte"
 | 
					  import QuestionPreview from "./QuestionPreview.svelte"
 | 
				
			||||||
  import ShowConversionMessages from "./ShowConversionMessages.svelte"
 | 
					  import ShowConversionMessages from "./ShowConversionMessages.svelte"
 | 
				
			||||||
  import RawEditor from "./RawEditor.svelte"
 | 
					  import RawEditor from "./RawEditor.svelte"
 | 
				
			||||||
  import NextButton from "../Base/NextButton.svelte"
 | 
					 | 
				
			||||||
  import BackButton from "../Base/BackButton.svelte"
 | 
					 | 
				
			||||||
  import DeleteButton from "./DeleteButton.svelte"
 | 
					  import DeleteButton from "./DeleteButton.svelte"
 | 
				
			||||||
  import StudioHashSetter from "./StudioHashSetter"
 | 
					  import StudioHashSetter from "./StudioHashSetter"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +82,7 @@
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="flex h-screen flex-col">
 | 
					<div class="flex h-screen flex-col">
 | 
				
			||||||
  <div class="my-2 flex w-full justify-between">
 | 
					  <div class="my-2 flex flex-wrap w-full justify-between">
 | 
				
			||||||
    <slot />
 | 
					    <slot />
 | 
				
			||||||
    {#if $title === undefined}
 | 
					    {#if $title === undefined}
 | 
				
			||||||
      <h3>Creating a new layer</h3>
 | 
					      <h3>Creating a new layer</h3>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,7 +292,7 @@ class ContextRewritingStep<T> extends Conversion<LayerConfigJson, T> {
 | 
				
			||||||
                return undefined
 | 
					                return undefined
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            const newPath = [...path]
 | 
					            const newPath = [...path]
 | 
				
			||||||
            const idToSearch = newTagRenderings[newPath[1]].id
 | 
					            const idToSearch = newTagRenderings[newPath[1]]?.id ?? ""
 | 
				
			||||||
            const oldIndex = originalIds.indexOf(idToSearch)
 | 
					            const oldIndex = originalIds.indexOf(idToSearch)
 | 
				
			||||||
            if (oldIndex < 0) {
 | 
					            if (oldIndex < 0) {
 | 
				
			||||||
                console.warn("Original ID was not found: ", idToSearch)
 | 
					                console.warn("Original ID was not found: ", idToSearch)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -367,7 +367,7 @@
 | 
				
			||||||
    {:else if state === "editing_layer"}
 | 
					    {:else if state === "editing_layer"}
 | 
				
			||||||
      <EditLayer state={editLayerState} {backToStudio}>
 | 
					      <EditLayer state={editLayerState} {backToStudio}>
 | 
				
			||||||
        <BackButton clss="small p-1" imageClass="w-8 h-8" on:click={() => backToStudio()}>
 | 
					        <BackButton clss="small p-1" imageClass="w-8 h-8" on:click={() => backToStudio()}>
 | 
				
			||||||
          MapComplete Studio
 | 
					            Studio
 | 
				
			||||||
        </BackButton>
 | 
					        </BackButton>
 | 
				
			||||||
      </EditLayer>
 | 
					      </EditLayer>
 | 
				
			||||||
    {:else if state === "editing_theme"}
 | 
					    {:else if state === "editing_theme"}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue