diff --git a/Logic/Actors/BackgroundLayerResetter.ts b/Logic/Actors/BackgroundLayerResetter.ts index 6d599827b..a80730e44 100644 --- a/Logic/Actors/BackgroundLayerResetter.ts +++ b/Logic/Actors/BackgroundLayerResetter.ts @@ -1,6 +1,6 @@ -import {Store, UIEventSource} from "../UIEventSource" -import {Utils} from "../../Utils" -import {RasterLayerPolygon, RasterLayerUtils,} from "../../Models/RasterLayers" +import { Store, UIEventSource } from "../UIEventSource" +import { Utils } from "../../Utils" +import { RasterLayerPolygon, RasterLayerUtils } from "../../Models/RasterLayers" /** * When a user pans around on the map, they might pan out of the range of the current background raster layer. @@ -35,7 +35,7 @@ export default class BackgroundLayerResetter { availableLayers, currentBgPolygon?.properties?.category ) - if(!availableInSameCat){ + if (!availableInSameCat) { return } console.log("Selecting a different layer:", availableInSameCat.properties.id) diff --git a/Logic/Actors/GeoLocationHandler.ts b/Logic/Actors/GeoLocationHandler.ts index c2cb5f50a..c8f47d76c 100644 --- a/Logic/Actors/GeoLocationHandler.ts +++ b/Logic/Actors/GeoLocationHandler.ts @@ -1,15 +1,15 @@ -import {QueryParameters} from "../Web/QueryParameters" -import {BBox} from "../BBox" +import { QueryParameters } from "../Web/QueryParameters" +import { BBox } from "../BBox" import Constants from "../../Models/Constants" -import {GeoLocationState} from "../State/GeoLocationState" -import {UIEventSource} from "../UIEventSource" -import {Feature, LineString, Point} from "geojson" -import {FeatureSource, WritableFeatureSource} from "../FeatureSource/FeatureSource" -import {LocalStorageSource} from "../Web/LocalStorageSource" -import {GeoOperations} from "../GeoOperations" -import {OsmTags} from "../../Models/OsmFeature" +import { GeoLocationState } from "../State/GeoLocationState" +import { UIEventSource } from "../UIEventSource" +import { Feature, LineString, Point } from "geojson" +import { FeatureSource, WritableFeatureSource } from "../FeatureSource/FeatureSource" +import { LocalStorageSource } from "../Web/LocalStorageSource" +import { GeoOperations } from "../GeoOperations" +import { OsmTags } from "../../Models/OsmFeature" import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource" -import {MapProperties} from "../../Models/MapProperties" +import { MapProperties } from "../../Models/MapProperties" /** * The geolocation-handler takes a map-location and a geolocation state. @@ -39,7 +39,9 @@ export default class GeoLocationHandler { /** * The last moment that the map has moved */ - public readonly mapHasMoved: UIEventSource = new UIEventSource(undefined) + public readonly mapHasMoved: UIEventSource = new UIEventSource< + Date | undefined + >(undefined) private readonly selectedElement: UIEventSource private readonly mapProperties?: MapProperties private readonly gpsLocationHistoryRetentionTime?: UIEventSource @@ -80,8 +82,11 @@ export default class GeoLocationHandler { // The map hasn't moved yet; we received our first coordinates, so let's move there! self.MoveMapToCurrentLocation() } - if (timeSinceLastRequest < Constants.zoomToLocationTimeout && - (this.mapHasMoved.data === undefined || this.mapHasMoved.data.getTime() < geolocationState.requestMoment.data?.getTime() ) + if ( + timeSinceLastRequest < Constants.zoomToLocationTimeout && + (this.mapHasMoved.data === undefined || + this.mapHasMoved.data.getTime() < + geolocationState.requestMoment.data?.getTime()) ) { // still within request time and the map hasn't moved since requesting to jump to the current location self.MoveMapToCurrentLocation() @@ -154,8 +159,8 @@ export default class GeoLocationHandler { return } - const properties = { - id: "gps-"+i, + const properties = { + id: "gps-" + i, "user:location": "yes", date: new Date().toISOString(), } @@ -164,7 +169,7 @@ export default class GeoLocationHandler { for (const k in keysToCopy) { // For some weird reason, the 'Object.keys' method doesn't work for the 'location: GeolocationCoordinates'-object and will thus not copy all the properties when using {...location} // As such, they are copied here - if(location[k]){ + if (location[k]) { properties[k] = location[k] } } diff --git a/Logic/DetermineLayout.ts b/Logic/DetermineLayout.ts index 3b0e11ae6..f1f28ee14 100644 --- a/Logic/DetermineLayout.ts +++ b/Logic/DetermineLayout.ts @@ -20,14 +20,15 @@ import { FixImages } from "../Models/ThemeConfig/Conversion/FixImages" import Svg from "../Svg" import { DoesImageExist, - PrevalidateTheme, ValidateTagRenderings, + PrevalidateTheme, + ValidateTagRenderings, ValidateThemeAndLayers, } from "../Models/ThemeConfig/Conversion/Validation" -import {DesugaringContext, Each, On} from "../Models/ThemeConfig/Conversion/Conversion"; -import {PrepareLayer, RewriteSpecial} from "../Models/ThemeConfig/Conversion/PrepareLayer"; -import {AllSharedLayers} from "../Customizations/AllSharedLayers"; -import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson"; -import questions from "../assets/tagRenderings/questions.json"; +import { DesugaringContext, Each, On } from "../Models/ThemeConfig/Conversion/Conversion" +import { PrepareLayer, RewriteSpecial } from "../Models/ThemeConfig/Conversion/PrepareLayer" +import { AllSharedLayers } from "../Customizations/AllSharedLayers" +import { TagRenderingConfigJson } from "../Models/ThemeConfig/Json/TagRenderingConfigJson" +import questions from "../assets/tagRenderings/questions.json" export default class DetermineLayout { private static readonly _knownImages = new Set(Array.from(licenses).map((l) => l.path)) diff --git a/Logic/ExtraFunctions.ts b/Logic/ExtraFunctions.ts index 7da38b9af..833ce0d9d 100644 --- a/Logic/ExtraFunctions.ts +++ b/Logic/ExtraFunctions.ts @@ -1,11 +1,11 @@ -import {GeoOperations} from "./GeoOperations" +import { GeoOperations } from "./GeoOperations" import Combine from "../UI/Base/Combine" import BaseUIElement from "../UI/BaseUIElement" import List from "../UI/Base/List" import Title from "../UI/Base/Title" -import {BBox} from "./BBox" -import {Feature, Geometry, MultiPolygon, Polygon} from "geojson" -import {GeoJSONFeature} from "maplibre-gl"; +import { BBox } from "./BBox" +import { Feature, Geometry, MultiPolygon, Polygon } from "geojson" +import { GeoJSONFeature } from "maplibre-gl" export interface ExtraFuncParams { /** @@ -13,7 +13,10 @@ export interface ExtraFuncParams { * Note that more features then requested can be given back. * Format: [ [ geojson, geojson, geojson, ... ], [geojson, ...], ...] */ - getFeaturesWithin: (layerId: string, bbox: BBox) => Feature>[][] + getFeaturesWithin: ( + layerId: string, + bbox: BBox + ) => Feature>[][] getFeatureById: (id: string) => Feature> } @@ -55,7 +58,6 @@ class EnclosingFunc implements ExtraFunction { } for (const otherFeatures of otherFeaturess) { for (const otherFeature of otherFeatures) { - if (seenIds.has(otherFeature.properties.id)) { continue } @@ -72,7 +74,7 @@ class EnclosingFunc implements ExtraFunction { >otherFeature ) ) { - result.push({feat: otherFeature}) + result.push({ feat: otherFeature }) } } } @@ -158,11 +160,14 @@ class IntersectionFunc implements ExtraFunction { } for (const otherFeatures of otherLayers) { for (const otherFeature of otherFeatures) { - const intersections = GeoOperations.LineIntersections(feat, >>otherFeature) + const intersections = GeoOperations.LineIntersections( + feat, + >>otherFeature + ) if (intersections.length === 0) { continue } - result.push({feat: otherFeature, intersections}) + result.push({ feat: otherFeature, intersections }) } } } @@ -254,7 +259,14 @@ class ClosestNObjectFunc implements ExtraFunction { const maxDistance = options?.maxDistance ?? 500 const uniqueTag: string | undefined = options?.uniqueTag let allFeatures: Feature[][] - console.log("Calculating closest", options?.maxFeatures, "features around", feature, "in layer", features) + console.log( + "Calculating closest", + options?.maxFeatures, + "features around", + feature, + "in layer", + features + ) if (typeof features === "string") { const name = features const bbox = GeoOperations.bbox( @@ -272,7 +284,6 @@ class ClosestNObjectFunc implements ExtraFunction { let closestFeatures: { feat: any; distance: number }[] = [] for (const feats of allFeatures) { - for (const otherFeature of feats) { if ( otherFeature === feature || @@ -333,7 +344,7 @@ class ClosestNObjectFunc implements ExtraFunction { const uniqueTagsMatch = otherFeature.properties[uniqueTag] !== undefined && closestFeature.feat.properties[uniqueTag] === - otherFeature.properties[uniqueTag] + otherFeature.properties[uniqueTag] if (uniqueTagsMatch) { targetIndex = -1 if (closestFeature.distance > distance) { @@ -341,7 +352,7 @@ class ClosestNObjectFunc implements ExtraFunction { // We want to see the tag `uniquetag=some_value` only once in the entire list (e.g. to prevent road segements of identical names to fill up the list of 'names of nearby roads') // AT this point, we have found a closer segment with the same, identical tag // so we replace directly - closestFeatures[i] = {feat: otherFeature, distance: distance} + closestFeatures[i] = { feat: otherFeature, distance: distance } } break } @@ -468,7 +479,15 @@ export class ExtraFunctions { .SetClass("flex-col") .AsMarkdown() - static readonly types = ["distanceTo", "overlapWith", "enclosingFeatures", "intersectionsWith", "closest", "closestn", "get"] as const + static readonly types = [ + "distanceTo", + "overlapWith", + "enclosingFeatures", + "intersectionsWith", + "closest", + "closestn", + "get", + ] as const private static readonly allFuncs = [ new DistanceToFunc(), new OverlapFunc(), @@ -479,8 +498,9 @@ export class ExtraFunctions { new GetParsed(), ] - - public static constructHelpers(params: ExtraFuncParams): Record Function> { + public static constructHelpers( + params: ExtraFuncParams + ): Record Function> { const record: Record Function> = {} for (const f of ExtraFunctions.allFuncs) { if (this.types.indexOf(f._name) < 0) { diff --git a/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts b/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts index 3ff9dd6e0..a4f2be3e7 100644 --- a/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts +++ b/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts @@ -1,5 +1,5 @@ -import {FeatureSource} from "../FeatureSource" -import {UIEventSource} from "../../UIEventSource" +import { FeatureSource } from "../FeatureSource" +import { UIEventSource } from "../../UIEventSource" /** * Constructs a UIEventStore for the properties of every Feature, indexed by id diff --git a/Logic/FeatureSource/Actors/TileLocalStorage.ts b/Logic/FeatureSource/Actors/TileLocalStorage.ts index 97feb53d3..a02f03e10 100644 --- a/Logic/FeatureSource/Actors/TileLocalStorage.ts +++ b/Logic/FeatureSource/Actors/TileLocalStorage.ts @@ -1,5 +1,5 @@ -import {IdbLocalStorage} from "../../Web/IdbLocalStorage" -import {UIEventSource} from "../../UIEventSource" +import { IdbLocalStorage } from "../../Web/IdbLocalStorage" +import { UIEventSource } from "../../UIEventSource" /** * A class which allows to read/write a tile to local storage. @@ -14,14 +14,18 @@ export default class TileLocalStorage { private readonly _layername: string private readonly inUse = new UIEventSource(false) private readonly cachedSources: Record & { flush: () => void }> = {} - private readonly _maxAgeSeconds: number; + private readonly _maxAgeSeconds: number private constructor(layername: string, maxAgeSeconds: number) { this._layername = layername - this._maxAgeSeconds = maxAgeSeconds; + this._maxAgeSeconds = maxAgeSeconds } - public static construct(backend: string, layername: string, maxAgeS: number): TileLocalStorage { + public static construct( + backend: string, + layername: string, + maxAgeS: number + ): TileLocalStorage { const key = backend + "_" + layername const cached = TileLocalStorage.perLayer[key] if (cached) { @@ -59,7 +63,10 @@ export default class TileLocalStorage { await this.inUse.AsPromise((inUse) => !inUse) this.inUse.setData(true) await IdbLocalStorage.SetDirectly(this._layername + "_" + tileIndex, data) - await IdbLocalStorage.SetDirectly(this._layername + "_" + tileIndex + "_date", Date.now()) + await IdbLocalStorage.SetDirectly( + this._layername + "_" + tileIndex + "_date", + Date.now() + ) this.inUse.setData(false) } catch (e) { @@ -80,7 +87,9 @@ export default class TileLocalStorage { if (!TileLocalStorage.useIndexedDb) { return undefined } - const date = await IdbLocalStorage.GetDirectly(this._layername + "_" + tileIndex + "_date") + const date = ( + await IdbLocalStorage.GetDirectly(this._layername + "_" + tileIndex + "_date") + ) const maxAge = this._maxAgeSeconds const timeDiff = Date.now() - date if (timeDiff >= maxAge) { diff --git a/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts b/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts index 4e782b5e1..8e7539756 100644 --- a/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts +++ b/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts @@ -1,8 +1,8 @@ -import {FeatureSource} from "./FeatureSource" +import { FeatureSource } from "./FeatureSource" import FilteredLayer from "../../Models/FilteredLayer" import SimpleFeatureSource from "./Sources/SimpleFeatureSource" -import {Feature} from "geojson" -import {UIEventSource} from "../UIEventSource" +import { Feature } from "geojson" +import { UIEventSource } from "../UIEventSource" /** * In some rare cases, some elements are shown on multiple layers (when 'passthrough' is enabled) @@ -59,8 +59,11 @@ export default class PerLayerFeatureSourceSplitter = new UIEventSource([]) @@ -70,7 +70,7 @@ export default class ChangeGeometryApplicator implements FeatureSource { // We only apply the last change as that one'll have the latest geometry const change = changesForFeature[changesForFeature.length - 1] copy.geometry = ChangeDescriptionTools.getGeojsonGeometry(change) - if(Utils.SameObject(copy.geometry, feature.geometry)){ + if (Utils.SameObject(copy.geometry, feature.geometry)) { // No actual changes: pass along the original newFeatures.push(feature) continue diff --git a/Logic/FeatureSource/Sources/FeatureSourceMerger.ts b/Logic/FeatureSource/Sources/FeatureSourceMerger.ts index 8b0292b7d..b3d921188 100644 --- a/Logic/FeatureSource/Sources/FeatureSourceMerger.ts +++ b/Logic/FeatureSource/Sources/FeatureSourceMerger.ts @@ -30,7 +30,7 @@ export default class FeatureSourceMerger implements IndexedFeatureSource { } public addSource(source: FeatureSource) { - if(!source){ + if (!source) { return } this._sources.push(source) diff --git a/Logic/FeatureSource/Sources/GeoJsonSource.ts b/Logic/FeatureSource/Sources/GeoJsonSource.ts index 4a244683b..998f88310 100644 --- a/Logic/FeatureSource/Sources/GeoJsonSource.ts +++ b/Logic/FeatureSource/Sources/GeoJsonSource.ts @@ -1,14 +1,14 @@ /** * Fetches a geojson file somewhere and passes it along */ -import {Store, UIEventSource} from "../../UIEventSource" -import {Utils} from "../../../Utils" -import {FeatureSource} from "../FeatureSource" -import {BBox} from "../../BBox" -import {GeoOperations} from "../../GeoOperations" -import {Feature} from "geojson" +import { Store, UIEventSource } from "../../UIEventSource" +import { Utils } from "../../../Utils" +import { FeatureSource } from "../FeatureSource" +import { BBox } from "../../BBox" +import { GeoOperations } from "../../GeoOperations" +import { Feature } from "geojson" import LayerConfig from "../../../Models/ThemeConfig/LayerConfig" -import {Tiles} from "../../../Models/TileRange" +import { Tiles } from "../../../Models/TileRange" export default class GeoJsonSource implements FeatureSource { public readonly features: Store @@ -65,13 +65,13 @@ export default class GeoJsonSource implements FeatureSource { return } this.LoadJSONFrom(url, eventsource, layer) - .then((fs) => console.debug("Loaded",fs.length, "features from", url)) + .then((fs) => console.debug("Loaded", fs.length, "features from", url)) .catch((err) => console.warn("Could not load ", url, "due to", err)) return true // data is loaded, we can safely unregister }) } else { this.LoadJSONFrom(url, eventsource, layer) - .then((fs) => console.debug("Loaded",fs.length, "features from", url)) + .then((fs) => console.debug("Loaded", fs.length, "features from", url)) .catch((err) => console.warn("Could not load ", url, "due to", err)) } this.features = eventsource @@ -105,7 +105,7 @@ export default class GeoJsonSource implements FeatureSource { let i = 0 let skipped = 0 for (const feature of json.features) { - if(feature.geometry.type === "Point"){ + if (feature.geometry.type === "Point") { // See https://github.com/maproulette/maproulette-backend/issues/242 feature.geometry.coordinates = feature.geometry.coordinates.map(Number) } diff --git a/Logic/FeatureSource/Sources/LastClickFeatureSource.ts b/Logic/FeatureSource/Sources/LastClickFeatureSource.ts index 796ba3722..da32a140e 100644 --- a/Logic/FeatureSource/Sources/LastClickFeatureSource.ts +++ b/Logic/FeatureSource/Sources/LastClickFeatureSource.ts @@ -32,7 +32,9 @@ export class LastClickFeatureSource implements WritableFeatureSource { } const renderings = Utils.Dedup( - allPresets.map((uiElem) => Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML) + allPresets.map((uiElem) => + Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML + ) ) const properties = { diff --git a/Logic/FeatureSource/Sources/LayoutSource.ts b/Logic/FeatureSource/Sources/LayoutSource.ts index de1c25c51..899b50f15 100644 --- a/Logic/FeatureSource/Sources/LayoutSource.ts +++ b/Logic/FeatureSource/Sources/LayoutSource.ts @@ -1,16 +1,16 @@ import GeoJsonSource from "./GeoJsonSource" import LayerConfig from "../../../Models/ThemeConfig/LayerConfig" -import {FeatureSource} from "../FeatureSource" -import {Or} from "../../Tags/Or" +import { FeatureSource } from "../FeatureSource" +import { Or } from "../../Tags/Or" import FeatureSwitchState from "../../State/FeatureSwitchState" import OverpassFeatureSource from "./OverpassFeatureSource" -import {Store, UIEventSource} from "../../UIEventSource" +import { Store, UIEventSource } from "../../UIEventSource" import OsmFeatureSource from "./OsmFeatureSource" import FeatureSourceMerger from "./FeatureSourceMerger" import DynamicGeoJsonTileSource from "../TiledFeatureSource/DynamicGeoJsonTileSource" -import {BBox} from "../../BBox" +import { BBox } from "../../BBox" import LocalStorageFeatureSource from "../TiledFeatureSource/LocalStorageFeatureSource" -import FullNodeDatabaseSource from "../TiledFeatureSource/FullNodeDatabaseSource"; +import FullNodeDatabaseSource from "../TiledFeatureSource/FullNodeDatabaseSource" /** * This source will fetch the needed data from various sources for the given layout. @@ -41,7 +41,7 @@ export default class LayoutSource extends FeatureSourceMerger { (l) => new LocalStorageFeatureSource(backend, l.id, 15, mapProperties, { isActive: isDisplayed(l.id), - maxAge: l.maxAgeOfCache + maxAge: l.maxAgeOfCache, }) ) @@ -127,7 +127,7 @@ export default class LayoutSource extends FeatureSourceMerger { backend, isActive, patchRelations: true, - fullNodeDatabase + fullNodeDatabase, }) } diff --git a/Logic/FeatureSource/Sources/OsmFeatureSource.ts b/Logic/FeatureSource/Sources/OsmFeatureSource.ts index 8ae25dc80..31616f439 100644 --- a/Logic/FeatureSource/Sources/OsmFeatureSource.ts +++ b/Logic/FeatureSource/Sources/OsmFeatureSource.ts @@ -7,7 +7,7 @@ import { TagsFilter } from "../../Tags/TagsFilter" import { Feature } from "geojson" import FeatureSourceMerger from "../Sources/FeatureSourceMerger" import OsmObjectDownloader from "../../Osm/OsmObjectDownloader" -import FullNodeDatabaseSource from "../TiledFeatureSource/FullNodeDatabaseSource"; +import FullNodeDatabaseSource from "../TiledFeatureSource/FullNodeDatabaseSource" /** * If a tile is needed (requested via the UIEventSource in the constructor), will download the appropriate tile and pass it via 'handleTile' @@ -24,16 +24,16 @@ export default class OsmFeatureSource extends FeatureSourceMerger { /** * If given: this featureSwitch will not update if the store contains 'false' */ - isActive?: Store, - patchRelations?: true | boolean, + isActive?: Store + patchRelations?: true | boolean fullNodeDatabase?: FullNodeDatabaseSource - }; + } public readonly isRunning: UIEventSource = new UIEventSource(false) private readonly _downloadedTiles: Set = new Set() private readonly _downloadedData: Feature[][] = [] - private readonly _patchRelations: boolean; + private readonly _patchRelations: boolean /** * Downloads data directly from the OSM-api within the given bounds. * All features which match the TagsFilter 'allowedFeatures' are kept and converted into geojson @@ -45,12 +45,12 @@ export default class OsmFeatureSource extends FeatureSourceMerger { /** * If given: this featureSwitch will not update if the store contains 'false' */ - isActive?: Store, - patchRelations?: true | boolean, + isActive?: Store + patchRelations?: true | boolean fullNodeDatabase?: FullNodeDatabaseSource }) { super() - this.options = options; + this.options = options this._bounds = options.bounds this.allowedTags = options.allowedFeatures this.isActive = options.isActive ?? new ImmutableStore(true) diff --git a/Logic/FeatureSource/Sources/StaticFeatureSource.ts b/Logic/FeatureSource/Sources/StaticFeatureSource.ts index 4811d3612..df1fe8f49 100644 --- a/Logic/FeatureSource/Sources/StaticFeatureSource.ts +++ b/Logic/FeatureSource/Sources/StaticFeatureSource.ts @@ -1,6 +1,6 @@ -import {FeatureSource} from "../FeatureSource" -import {ImmutableStore, Store} from "../../UIEventSource" -import {Feature} from "geojson" +import { FeatureSource } from "../FeatureSource" +import { ImmutableStore, Store } from "../../UIEventSource" +import { Feature } from "geojson" /** * A simple, read only feature store. @@ -8,13 +8,7 @@ import {Feature} from "geojson" export default class StaticFeatureSource implements FeatureSource { public readonly features: Store - constructor( - features: - | Store - | T[] - | { features: T[] } - | { features: Store } - ) { + constructor(features: Store | T[] | { features: T[] } | { features: Store }) { if (features === undefined) { throw "Static feature source received undefined as source" } diff --git a/Logic/FeatureSource/Sources/TouchesBboxFeatureSource.ts b/Logic/FeatureSource/Sources/TouchesBboxFeatureSource.ts index 182187da8..0ba5513f1 100644 --- a/Logic/FeatureSource/Sources/TouchesBboxFeatureSource.ts +++ b/Logic/FeatureSource/Sources/TouchesBboxFeatureSource.ts @@ -1,9 +1,9 @@ -import {FeatureSource, FeatureSourceForLayer} from "../FeatureSource" +import { FeatureSource, FeatureSourceForLayer } from "../FeatureSource" import StaticFeatureSource from "./StaticFeatureSource" -import {BBox} from "../../BBox" +import { BBox } from "../../BBox" import FilteredLayer from "../../../Models/FilteredLayer" -import {Store} from "../../UIEventSource" -import {Feature} from "geojson"; +import { Store } from "../../UIEventSource" +import { Feature } from "geojson" /** * Results in a feature source which has all the elements that touch the given features @@ -30,7 +30,10 @@ export default class BBoxFeatureSource extends Stat } } -export class BBoxFeatureSourceForLayer extends BBoxFeatureSource implements FeatureSourceForLayer { +export class BBoxFeatureSourceForLayer + extends BBoxFeatureSource + implements FeatureSourceForLayer +{ readonly layer: FilteredLayer constructor(features: FeatureSourceForLayer, mustTouch: Store) { diff --git a/Logic/FeatureSource/TiledFeatureSource/DynamicGeoJsonTileSource.ts b/Logic/FeatureSource/TiledFeatureSource/DynamicGeoJsonTileSource.ts index 0a3e77d90..9c37c0bc3 100644 --- a/Logic/FeatureSource/TiledFeatureSource/DynamicGeoJsonTileSource.ts +++ b/Logic/FeatureSource/TiledFeatureSource/DynamicGeoJsonTileSource.ts @@ -72,7 +72,9 @@ export default class DynamicGeoJsonTileSource extends DynamicTileSource { if (!isWhiteListed) { console.debug( "Not downloading tile", - zxy,"for layer",layer.id, + zxy, + "for layer", + layer.id, "as it is not on the whitelist" ) return undefined diff --git a/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource.ts b/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource.ts index 4127a33d1..f9b7738a9 100644 --- a/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource.ts +++ b/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource.ts @@ -1,11 +1,10 @@ -import {OsmNode, OsmObject, OsmWay} from "../../Osm/OsmObject" -import {UIEventSource} from "../../UIEventSource" -import {BBox} from "../../BBox"; -import StaticFeatureSource from "../Sources/StaticFeatureSource"; -import {Tiles} from "../../../Models/TileRange"; +import { OsmNode, OsmObject, OsmWay } from "../../Osm/OsmObject" +import { UIEventSource } from "../../UIEventSource" +import { BBox } from "../../BBox" +import StaticFeatureSource from "../Sources/StaticFeatureSource" +import { Tiles } from "../../../Models/TileRange" export default class FullNodeDatabaseSource { - private readonly loadedTiles = new Map>() private readonly nodeByIds = new Map() private readonly parentWays = new Map>() @@ -13,7 +12,7 @@ export default class FullNodeDatabaseSource { private smallestZoom = 99 private largestZoom = 0 - public handleOsmJson(osmJson: any, z: number, x: number, y: number) : void { + public handleOsmJson(osmJson: any, z: number, x: number, y: number): void { const allObjects = OsmObject.ParseObjects(osmJson.elements) const nodesById = new Map() @@ -81,14 +80,14 @@ export default class FullNodeDatabaseSource { * Gets (at least) all nodes which are part of this BBOX; might also return some nodes that fall outside of the bbox but are closeby * @param bbox */ - getNodesWithin(bbox: BBox) : Map{ + getNodesWithin(bbox: BBox): Map { const allById = new Map() for (let z = this.smallestZoom; z < this.largestZoom; z++) { const range = Tiles.tileRangeFrom(bbox, z) - Tiles.MapRange(range, (x, y ) => { + Tiles.MapRange(range, (x, y) => { const tileId = Tiles.tile_index(z, x, y) const nodesById = this.loadedTiles.get(tileId) - nodesById?.forEach((v,k) => allById.set(k,v)) + nodesById?.forEach((v, k) => allById.set(k, v)) }) } return allById diff --git a/Logic/FeatureSource/TiledFeatureSource/LocalStorageFeatureSource.ts b/Logic/FeatureSource/TiledFeatureSource/LocalStorageFeatureSource.ts index 16cc2b94e..7b23641ab 100644 --- a/Logic/FeatureSource/TiledFeatureSource/LocalStorageFeatureSource.ts +++ b/Logic/FeatureSource/TiledFeatureSource/LocalStorageFeatureSource.ts @@ -1,8 +1,8 @@ import DynamicTileSource from "./DynamicTileSource" -import {Store} from "../../UIEventSource" -import {BBox} from "../../BBox" +import { Store } from "../../UIEventSource" +import { BBox } from "../../BBox" import TileLocalStorage from "../Actors/TileLocalStorage" -import {Feature} from "geojson" +import { Feature } from "geojson" import StaticFeatureSource from "../Sources/StaticFeatureSource" export default class LocalStorageFeatureSource extends DynamicTileSource { @@ -15,26 +15,27 @@ export default class LocalStorageFeatureSource extends DynamicTileSource { zoom: Store }, options?: { - isActive?: Store, + isActive?: Store maxAge?: number // In seconds } ) { - const storage = TileLocalStorage.construct(backend, layername, options?.maxAge ?? 24 * 60 * 60) + const storage = TileLocalStorage.construct( + backend, + layername, + options?.maxAge ?? 24 * 60 * 60 + ) super( zoomlevel, (tileIndex) => new StaticFeatureSource( - storage - .getTileSource(tileIndex) - .mapD((features) => { - if (features.length === undefined) { - console.trace("These are not features:", features) - storage.invalidate(zoomlevel, tileIndex) - return [] - } - return features.filter((f) => !f.properties.id.match(/(node|way)\/-[0-9]+/)); - } - ) + storage.getTileSource(tileIndex).mapD((features) => { + if (features.length === undefined) { + console.trace("These are not features:", features) + storage.invalidate(zoomlevel, tileIndex) + return [] + } + return features.filter((f) => !f.properties.id.match(/(node|way)\/-[0-9]+/)) + }) ), mapProperties, options diff --git a/Logic/GeoOperations.ts b/Logic/GeoOperations.ts index 250e75182..48bf52f96 100644 --- a/Logic/GeoOperations.ts +++ b/Logic/GeoOperations.ts @@ -408,7 +408,10 @@ export class GeoOperations { /** * Calculates line intersection between two features. */ - public static LineIntersections(feature: Feature, otherFeature: Feature): [number, number][] { + public static LineIntersections( + feature: Feature, + otherFeature: Feature + ): [number, number][] { return turf .lineIntersect(feature, otherFeature) .features.map((p) => <[number, number]>p.geometry.coordinates) @@ -420,8 +423,7 @@ export class GeoOperations { * @param features * @param zoomlevel */ - public static spreadIntoBboxes(features: Feature[], zoomlevel: number) : Map { - + public static spreadIntoBboxes(features: Feature[], zoomlevel: number): Map { const perBbox = new Map() for (const feature of features) { @@ -430,7 +432,7 @@ export class GeoOperations { Tiles.MapRange(tilerange, (x, y) => { const tileNumber = Tiles.tile_index(zoomlevel, x, y) let newFeatureList = perBbox.get(tileNumber) - if(newFeatureList === undefined){ + if (newFeatureList === undefined) { newFeatureList = [] perBbox.set(tileNumber, newFeatureList) } @@ -703,18 +705,18 @@ export class GeoOperations { public static along(a: Coord, b: Coord, distanceMeter: number): Coord { return turf.along( - { - type:"Feature", - geometry:{ - type:"LineString", - coordinates: [a, b] - } - }, distanceMeter, {units: "meters"} - + { + type: "Feature", + geometry: { + type: "LineString", + coordinates: [a, b], + }, + }, + distanceMeter, + { units: "meters" } ).geometry.coordinates } - /** * Returns 'true' if one feature contains the other feature * diff --git a/Logic/ImageProviders/AllImageProviders.ts b/Logic/ImageProviders/AllImageProviders.ts index 6daabfa60..89318aeb3 100644 --- a/Logic/ImageProviders/AllImageProviders.ts +++ b/Logic/ImageProviders/AllImageProviders.ts @@ -1,10 +1,10 @@ -import { Mapillary } from "./Mapillary"; -import { WikimediaImageProvider } from "./WikimediaImageProvider"; -import { Imgur } from "./Imgur"; -import GenericImageProvider from "./GenericImageProvider"; -import { Store, UIEventSource } from "../UIEventSource"; -import ImageProvider, { ProvidedImage } from "./ImageProvider"; -import { WikidataImageProvider } from "./WikidataImageProvider"; +import { Mapillary } from "./Mapillary" +import { WikimediaImageProvider } from "./WikimediaImageProvider" +import { Imgur } from "./Imgur" +import GenericImageProvider from "./GenericImageProvider" +import { Store, UIEventSource } from "../UIEventSource" +import ImageProvider, { ProvidedImage } from "./ImageProvider" +import { WikidataImageProvider } from "./WikidataImageProvider" /** * A generic 'from the interwebz' image picker, without attribution @@ -44,7 +44,10 @@ export default class AllImageProviders { UIEventSource >() - public static LoadImagesFor(tags: Store>, tagKey?: string[]): Store { + public static LoadImagesFor( + tags: Store>, + tagKey?: string[] + ): Store { if (tags.data.id === undefined) { return undefined } diff --git a/Logic/Maproulette.ts b/Logic/Maproulette.ts index 161fc9b9d..50f550c43 100644 --- a/Logic/Maproulette.ts +++ b/Logic/Maproulette.ts @@ -80,12 +80,12 @@ export default class Maproulette { * Maproulette.codeToIndex("qdsf") // => undefined * */ - public static codeToIndex(code: string) : number | undefined{ - if(code === "Created"){ + public static codeToIndex(code: string): number | undefined { + if (code === "Created") { return Maproulette.STATUS_OPEN } for (let i = 0; i < 9; i++) { - if(Maproulette.STATUS_MEANING[""+i] === code){ + if (Maproulette.STATUS_MEANING["" + i] === code) { return i } } diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index 0e0129b9b..68ec0022f 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -1,14 +1,14 @@ -import SimpleMetaTaggers, {MetataggingState, SimpleMetaTagger} from "./SimpleMetaTagger" -import {ExtraFuncParams, ExtraFunctions, ExtraFuncType} from "./ExtraFunctions" +import SimpleMetaTaggers, { MetataggingState, SimpleMetaTagger } from "./SimpleMetaTagger" +import { ExtraFuncParams, ExtraFunctions, ExtraFuncType } from "./ExtraFunctions" import LayerConfig from "../Models/ThemeConfig/LayerConfig" -import {Feature} from "geojson" +import { Feature } from "geojson" import FeaturePropertiesStore from "./FeatureSource/Actors/FeaturePropertiesStore" import LayoutConfig from "../Models/ThemeConfig/LayoutConfig" -import {GeoIndexedStoreForLayer} from "./FeatureSource/Actors/GeoIndexedStore" -import {IndexedFeatureSource} from "./FeatureSource/FeatureSource" +import { GeoIndexedStoreForLayer } from "./FeatureSource/Actors/GeoIndexedStore" +import { IndexedFeatureSource } from "./FeatureSource/FeatureSource" import OsmObjectDownloader from "./Osm/OsmObjectDownloader" -import {Utils} from "../Utils"; -import {UIEventSource} from "./UIEventSource"; +import { Utils } from "../Utils" +import { UIEventSource } from "./UIEventSource" /** * Metatagging adds various tags to the elements, e.g. lat, lon, surface area, ... @@ -18,7 +18,10 @@ import {UIEventSource} from "./UIEventSource"; export default class MetaTagging { private static errorPrintCount = 0 private static readonly stopErrorOutputAt = 10 - private static retaggingFuncCache = new Map) => void)[]>() + private static retaggingFuncCache = new Map< + string, + ((feature: Feature, propertiesStore: UIEventSource) => void)[] + >() constructor(state: { layout: LayoutConfig @@ -96,7 +99,7 @@ export default class MetaTagging { // The calculated functions - per layer - which add the new keys // Calculated functions are defined by the layer const layerFuncs = this.createRetaggingFunc(layer, ExtraFunctions.constructHelpers(params)) - const state: MetataggingState = {layout, osmObjectDownloader} + const state: MetataggingState = { layout, osmObjectDownloader } let atLeastOneFeatureChanged = false let strictlyEvaluated = 0 @@ -177,20 +180,20 @@ export default class MetaTagging { } public static createExtraFuncParams(state: { - indexedFeatures: IndexedFeatureSource, + indexedFeatures: IndexedFeatureSource perLayer: ReadonlyMap }) { return { getFeatureById: (id) => state.indexedFeatures.featuresById.data.get(id), getFeaturesWithin: (layerId, bbox) => { - if (layerId === '*' || layerId === null || layerId === undefined) { + if (layerId === "*" || layerId === null || layerId === undefined) { const feats: Feature[][] = [] state.perLayer.forEach((layer) => { feats.push(layer.GetFeaturesWithin(bbox)) }) return feats } - return [state.perLayer.get(layerId).GetFeaturesWithin(bbox)]; + return [state.perLayer.get(layerId).GetFeaturesWithin(bbox)] }, } } @@ -202,23 +205,30 @@ export default class MetaTagging { * @param layerId * @private */ - private static createFunctionForFeature([key, code, isStrict]: [string, string, boolean], - helperFunctions: Record Function>, - layerId: string = "unkown layer" + private static createFunctionForFeature( + [key, code, isStrict]: [string, string, boolean], + helperFunctions: Record Function>, + layerId: string = "unkown layer" ): ((feature: Feature, propertiesStore?: UIEventSource) => void) | undefined { if (code === undefined) { return undefined } - - const calculateAndAssign: ((feat: Feature, store?: UIEventSource) => string | any) = (feat, store) => { + const calculateAndAssign: (feat: Feature, store?: UIEventSource) => string | any = ( + feat, + store + ) => { try { - let result = new Function("feat", "{" + ExtraFunctions.types.join(", ") + "}", "return " + code + ";")(feat, helperFunctions) + let result = new Function( + "feat", + "{" + ExtraFunctions.types.join(", ") + "}", + "return " + code + ";" + )(feat, helperFunctions) if (result === "") { result = undefined } - const oldValue= feat.properties[key] - if(oldValue == result){ + const oldValue = feat.properties[key] + if (oldValue == result) { return oldValue } delete feat.properties[key] @@ -229,16 +239,16 @@ export default class MetaTagging { if (MetaTagging.errorPrintCount < MetaTagging.stopErrorOutputAt) { console.warn( "Could not calculate a " + - (isStrict ? "strict " : "") + - " calculated tag for key " + - key + - " defined by " + - code + - " (in layer" + - layerId + - ") due to \n" + - e + - "\n. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", + (isStrict ? "strict " : "") + + " calculated tag for key " + + key + + " defined by " + + code + + " (in layer" + + layerId + + ") due to \n" + + e + + "\n. Are you the theme creator? Doublecheck your code. Note that the metatags might not be stable on new features", e, e.stack ) @@ -276,9 +286,12 @@ export default class MetaTagging { return undefined } - let functions: ((feature: Feature, propertiesStore?: UIEventSource) => void)[] = MetaTagging.retaggingFuncCache.get(layer.id) + let functions: ((feature: Feature, propertiesStore?: UIEventSource) => void)[] = + MetaTagging.retaggingFuncCache.get(layer.id) if (functions === undefined) { - functions = calculatedTags.map(spec => this.createFunctionForFeature(spec, helpers, layer.id)) + functions = calculatedTags.map((spec) => + this.createFunctionForFeature(spec, helpers, layer.id) + ) MetaTagging.retaggingFuncCache.set(layer.id, functions) } diff --git a/Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction.ts b/Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction.ts index 1cf3dd369..7b259e638 100644 --- a/Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction.ts +++ b/Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction.ts @@ -1,20 +1,23 @@ -import {OsmCreateAction, PreviewableAction} from "./OsmChangeAction" -import {Tag} from "../../Tags/Tag" -import {Changes} from "../Changes" -import {ChangeDescription} from "./ChangeDescription" +import { OsmCreateAction, PreviewableAction } from "./OsmChangeAction" +import { Tag } from "../../Tags/Tag" +import { Changes } from "../Changes" +import { ChangeDescription } from "./ChangeDescription" import CreateNewWayAction from "./CreateNewWayAction" -import CreateWayWithPointReuseAction, {MergePointConfig} from "./CreateWayWithPointReuseAction" -import {And} from "../../Tags/And" -import {TagUtils} from "../../Tags/TagUtils" -import {FeatureSource, IndexedFeatureSource} from "../../FeatureSource/FeatureSource" -import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig"; -import {Position} from "geojson"; -import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"; +import CreateWayWithPointReuseAction, { MergePointConfig } from "./CreateWayWithPointReuseAction" +import { And } from "../../Tags/And" +import { TagUtils } from "../../Tags/TagUtils" +import { FeatureSource, IndexedFeatureSource } from "../../FeatureSource/FeatureSource" +import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig" +import { Position } from "geojson" +import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" /** * More or less the same as 'CreateNewWay', except that it'll try to reuse already existing points */ -export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAction implements PreviewableAction { +export default class CreateMultiPolygonWithPointReuseAction + extends OsmCreateAction + implements PreviewableAction +{ public newElementId: string = undefined public newElementIdNumber: number = undefined private readonly _tags: Tag[] @@ -29,9 +32,9 @@ export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAct outerRingCoordinates: Position[], innerRingsCoordinates: Position[][], state: { - layout: LayoutConfig; - changes: Changes; - indexedFeatures: IndexedFeatureSource, + layout: LayoutConfig + changes: Changes + indexedFeatures: IndexedFeatureSource fullNodeDatabase?: FullNodeDatabaseSource }, config: MergePointConfig[], @@ -43,7 +46,7 @@ export default class CreateMultiPolygonWithPointReuseAction extends OsmCreateAct this.theme = state?.layout?.id ?? "" this.createOuterWay = new CreateWayWithPointReuseAction( [], - <[number,number][]> outerRingCoordinates, + <[number, number][]>outerRingCoordinates, state, config ) diff --git a/Logic/Osm/Actions/CreateNewWayAction.ts b/Logic/Osm/Actions/CreateNewWayAction.ts index 50e2628a6..8b44a0c2c 100644 --- a/Logic/Osm/Actions/CreateNewWayAction.ts +++ b/Logic/Osm/Actions/CreateNewWayAction.ts @@ -1,9 +1,9 @@ -import {ChangeDescription} from "./ChangeDescription" -import {OsmCreateAction} from "./OsmChangeAction" -import {Changes} from "../Changes" -import {Tag} from "../../Tags/Tag" +import { ChangeDescription } from "./ChangeDescription" +import { OsmCreateAction } from "./OsmChangeAction" +import { Changes } from "../Changes" +import { Tag } from "../../Tags/Tag" import CreateNewNodeAction from "./CreateNewNodeAction" -import {And} from "../../Tags/And" +import { And } from "../../Tags/And" export default class CreateNewWayAction extends OsmCreateAction { public newElementId: string = undefined diff --git a/Logic/Osm/Actions/CreateWayWithPointReuseAction.ts b/Logic/Osm/Actions/CreateWayWithPointReuseAction.ts index a4a60039d..9a87f7589 100644 --- a/Logic/Osm/Actions/CreateWayWithPointReuseAction.ts +++ b/Logic/Osm/Actions/CreateWayWithPointReuseAction.ts @@ -1,17 +1,17 @@ -import {OsmCreateAction, PreviewableAction} from "./OsmChangeAction" -import {Tag} from "../../Tags/Tag" -import {Changes} from "../Changes" -import {ChangeDescription} from "./ChangeDescription" -import {BBox} from "../../BBox" -import {TagsFilter} from "../../Tags/TagsFilter" -import {GeoOperations} from "../../GeoOperations" -import {FeatureSource, IndexedFeatureSource} from "../../FeatureSource/FeatureSource" +import { OsmCreateAction, PreviewableAction } from "./OsmChangeAction" +import { Tag } from "../../Tags/Tag" +import { Changes } from "../Changes" +import { ChangeDescription } from "./ChangeDescription" +import { BBox } from "../../BBox" +import { TagsFilter } from "../../Tags/TagsFilter" +import { GeoOperations } from "../../GeoOperations" +import { FeatureSource, IndexedFeatureSource } from "../../FeatureSource/FeatureSource" import StaticFeatureSource from "../../FeatureSource/Sources/StaticFeatureSource" import CreateNewNodeAction from "./CreateNewNodeAction" import CreateNewWayAction from "./CreateNewWayAction" -import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig"; -import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"; -import {Position} from "geojson"; +import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig" +import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" +import { Position } from "geojson" export interface MergePointConfig { withinRangeOfM: number @@ -56,7 +56,10 @@ interface CoordinateInfo { /** * More or less the same as 'CreateNewWay', except that it'll try to reuse already existing points */ -export default class CreateWayWithPointReuseAction extends OsmCreateAction implements PreviewableAction { +export default class CreateWayWithPointReuseAction + extends OsmCreateAction + implements PreviewableAction +{ public newElementId: string = undefined public newElementIdNumber: number = undefined private readonly _tags: Tag[] @@ -66,9 +69,9 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction imple */ private readonly _coordinateInfo: CoordinateInfo[] private readonly _state: { - layout: LayoutConfig; - changes: Changes; - indexedFeatures: IndexedFeatureSource, + layout: LayoutConfig + changes: Changes + indexedFeatures: IndexedFeatureSource fullNodeDatabase?: FullNodeDatabaseSource } private readonly _config: MergePointConfig[] @@ -77,9 +80,9 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction imple tags: Tag[], coordinates: Position[], state: { - layout: LayoutConfig; - changes: Changes; - indexedFeatures: IndexedFeatureSource, + layout: LayoutConfig + changes: Changes + indexedFeatures: IndexedFeatureSource fullNodeDatabase?: FullNodeDatabaseSource }, config: MergePointConfig[] @@ -90,7 +93,7 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction imple this._config = config // The main logic of this class: the coordinateInfo contains all the changes - this._coordinateInfo = this.CalculateClosebyNodes(<[number,number][]> coordinates) + this._coordinateInfo = this.CalculateClosebyNodes(<[number, number][]>coordinates) } public async getPreview(): Promise { @@ -245,7 +248,7 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction imple }, }) } - nodeIdsToUse.push({lat, lon, nodeId: id}) + nodeIdsToUse.push({ lat, lon, nodeId: id }) } const newWay = new CreateNewWayAction(this._tags, nodeIdsToUse, { @@ -321,7 +324,7 @@ export default class CreateWayWithPointReuseAction extends OsmCreateAction imple if (!config.ifMatches.matchesProperties(node.properties)) { continue } - closebyNodes.push({node, d, config}) + closebyNodes.push({ node, d, config }) } } diff --git a/Logic/Osm/Actions/DeleteAction.ts b/Logic/Osm/Actions/DeleteAction.ts index 97a865056..084a66624 100644 --- a/Logic/Osm/Actions/DeleteAction.ts +++ b/Logic/Osm/Actions/DeleteAction.ts @@ -8,7 +8,7 @@ import { And } from "../../Tags/And" import { Tag } from "../../Tags/Tag" import { OsmId } from "../../../Models/OsmFeature" import { Utils } from "../../../Utils" -import OsmObjectDownloader from "../OsmObjectDownloader"; +import OsmObjectDownloader from "../OsmObjectDownloader" export default class DeleteAction extends OsmChangeAction { private readonly _softDeletionTags: TagsFilter @@ -72,9 +72,11 @@ export default class DeleteAction extends OsmChangeAction { changes: Changes, object?: OsmObject ): Promise { - const osmObject = object ?? (await new OsmObjectDownloader(changes.backend, changes).DownloadObjectAsync(this._id)) + const osmObject = + object ?? + (await new OsmObjectDownloader(changes.backend, changes).DownloadObjectAsync(this._id)) - if(osmObject === "deleted"){ + if (osmObject === "deleted") { // already deleted in the meantime - no more changes necessary return [] } diff --git a/Logic/Osm/Actions/OsmChangeAction.ts b/Logic/Osm/Actions/OsmChangeAction.ts index b6043a886..4161dc967 100644 --- a/Logic/Osm/Actions/OsmChangeAction.ts +++ b/Logic/Osm/Actions/OsmChangeAction.ts @@ -4,7 +4,7 @@ */ import { Changes } from "../Changes" import { ChangeDescription } from "./ChangeDescription" -import {FeatureSource} from "../../FeatureSource/FeatureSource"; +import { FeatureSource } from "../../FeatureSource/FeatureSource" export default abstract class OsmChangeAction { public readonly trackStatistics: boolean diff --git a/Logic/Osm/Actions/ReplaceGeometryAction.ts b/Logic/Osm/Actions/ReplaceGeometryAction.ts index 70afff79e..3dd23b73a 100644 --- a/Logic/Osm/Actions/ReplaceGeometryAction.ts +++ b/Logic/Osm/Actions/ReplaceGeometryAction.ts @@ -1,21 +1,21 @@ -import OsmChangeAction, {PreviewableAction} from "./OsmChangeAction" -import {Changes} from "../Changes" -import {ChangeDescription} from "./ChangeDescription" -import {Tag} from "../../Tags/Tag" -import {FeatureSource} from "../../FeatureSource/FeatureSource" -import {OsmNode, OsmObject, OsmWay} from "../OsmObject" -import {GeoOperations} from "../../GeoOperations" +import OsmChangeAction, { PreviewableAction } from "./OsmChangeAction" +import { Changes } from "../Changes" +import { ChangeDescription } from "./ChangeDescription" +import { Tag } from "../../Tags/Tag" +import { FeatureSource } from "../../FeatureSource/FeatureSource" +import { OsmNode, OsmObject, OsmWay } from "../OsmObject" +import { GeoOperations } from "../../GeoOperations" import StaticFeatureSource from "../../FeatureSource/Sources/StaticFeatureSource" import CreateNewNodeAction from "./CreateNewNodeAction" import ChangeTagAction from "./ChangeTagAction" -import {And} from "../../Tags/And" -import {Utils} from "../../../Utils" -import {OsmConnection} from "../OsmConnection" -import {Feature} from "@turf/turf" -import {Geometry, LineString, Point} from "geojson" +import { And } from "../../Tags/And" +import { Utils } from "../../../Utils" +import { OsmConnection } from "../OsmConnection" +import { Feature } from "@turf/turf" +import { Geometry, LineString, Point } from "geojson" import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" -export default class ReplaceGeometryAction extends OsmChangeAction implements PreviewableAction{ +export default class ReplaceGeometryAction extends OsmChangeAction implements PreviewableAction { /** * The target feature - mostly used for the metadata */ @@ -45,7 +45,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr public readonly newElementId: string constructor( state: { - osmConnection: OsmConnection, + osmConnection: OsmConnection fullNodeDatabase?: FullNodeDatabaseSource }, feature: any, @@ -460,7 +460,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr } } - console.log("Adding tags", this.newTags,"to conflated way nr", this.wayToReplaceId) + console.log("Adding tags", this.newTags, "to conflated way nr", this.wayToReplaceId) if (this.newTags !== undefined && this.newTags.length > 0) { const addExtraTags = new ChangeTagAction( this.wayToReplaceId, diff --git a/Logic/Osm/Actions/SplitAction.ts b/Logic/Osm/Actions/SplitAction.ts index b4a8a93a3..7062bec6f 100644 --- a/Logic/Osm/Actions/SplitAction.ts +++ b/Logic/Osm/Actions/SplitAction.ts @@ -1,10 +1,10 @@ -import {OsmWay} from "../OsmObject" -import {Changes} from "../Changes" -import {GeoOperations} from "../../GeoOperations" +import { OsmWay } from "../OsmObject" +import { Changes } from "../Changes" +import { GeoOperations } from "../../GeoOperations" import OsmChangeAction from "./OsmChangeAction" -import {ChangeDescription} from "./ChangeDescription" +import { ChangeDescription } from "./ChangeDescription" import RelationSplitHandler from "./RelationSplitHandler" -import {Feature, LineString} from "geojson" +import { Feature, LineString } from "geojson" import OsmObjectDownloader from "../OsmObjectDownloader" interface SplitInfo { diff --git a/Logic/Osm/Changes.ts b/Logic/Osm/Changes.ts index 8ab80f151..208184848 100644 --- a/Logic/Osm/Changes.ts +++ b/Logic/Osm/Changes.ts @@ -1,16 +1,16 @@ -import {OsmNode, OsmObject, OsmRelation, OsmWay} from "./OsmObject" -import {Store, UIEventSource} from "../UIEventSource" +import { OsmNode, OsmObject, OsmRelation, OsmWay } from "./OsmObject" +import { Store, UIEventSource } from "../UIEventSource" import Constants from "../../Models/Constants" import OsmChangeAction from "./Actions/OsmChangeAction" -import {ChangeDescription, ChangeDescriptionTools} from "./Actions/ChangeDescription" -import {Utils} from "../../Utils" -import {LocalStorageSource} from "../Web/LocalStorageSource" +import { ChangeDescription, ChangeDescriptionTools } from "./Actions/ChangeDescription" +import { Utils } from "../../Utils" +import { LocalStorageSource } from "../Web/LocalStorageSource" import SimpleMetaTagger from "../SimpleMetaTagger" -import {FeatureSource, IndexedFeatureSource} from "../FeatureSource/FeatureSource" -import {GeoLocationPointProperties} from "../State/GeoLocationState" -import {GeoOperations} from "../GeoOperations" -import {ChangesetHandler, ChangesetTag} from "./ChangesetHandler" -import {OsmConnection} from "./OsmConnection" +import { FeatureSource, IndexedFeatureSource } from "../FeatureSource/FeatureSource" +import { GeoLocationPointProperties } from "../State/GeoLocationState" +import { GeoOperations } from "../GeoOperations" +import { ChangesetHandler, ChangesetTag } from "./ChangesetHandler" +import { OsmConnection } from "./OsmConnection" import FeaturePropertiesStore from "../FeatureSource/Actors/FeaturePropertiesStore" import OsmObjectDownloader from "./OsmObjectDownloader" @@ -408,7 +408,7 @@ export class Changes { neededIds.map(async (id) => { try { const osmObj = await downloader.DownloadObjectAsync(id) - return {id, osmObj} + return { id, osmObj } } catch (e) { console.error( "Could not download OSM-object", @@ -422,7 +422,7 @@ export class Changes { osmObjects = Utils.NoNull(osmObjects) - for (const {osmObj, id} of osmObjects) { + for (const { osmObj, id } of osmObjects) { if (osmObj === "deleted") { pending = pending.filter((ch) => ch.type + "/" + ch.id !== id) } @@ -573,9 +573,9 @@ export class Changes { ) console.log( "Using current-open-changeset-" + - theme + - " from the preferences, got " + - openChangeset.data + theme + + " from the preferences, got " + + openChangeset.data ) return await self.flushSelectChanges(pendingChanges, openChangeset) diff --git a/Logic/Osm/ChangesetHandler.ts b/Logic/Osm/ChangesetHandler.ts index 01c2da21c..dcdb8a936 100644 --- a/Logic/Osm/ChangesetHandler.ts +++ b/Logic/Osm/ChangesetHandler.ts @@ -131,7 +131,8 @@ export class ChangesetHandler { const changeset = generateChangeXML(csId, this._remappings) console.log( "Opened a new changeset (openChangeset.data is undefined):", - changeset, extraMetaTags + changeset, + extraMetaTags ) const changes = await this.UploadChange(csId, changeset) const hasSpecialMotivationChanges = ChangesetHandler.rewriteMetaTags( diff --git a/Logic/Osm/OsmObject.ts b/Logic/Osm/OsmObject.ts index 13327ca03..8004aa90e 100644 --- a/Logic/Osm/OsmObject.ts +++ b/Logic/Osm/OsmObject.ts @@ -1,8 +1,8 @@ -import {Utils} from "../../Utils" +import { Utils } from "../../Utils" import polygon_features from "../../assets/polygon-features.json" import OsmToGeoJson from "osmtogeojson" -import {OsmFeature, OsmId, OsmTags, WayId} from "../../Models/OsmFeature" -import {Feature, LineString, Polygon} from "geojson" +import { OsmFeature, OsmId, OsmTags, WayId } from "../../Models/OsmFeature" +import { Feature, LineString, Polygon } from "geojson" export abstract class OsmObject { private static defaultBackend = "https://www.openstreetmap.org/" @@ -198,7 +198,6 @@ export class OsmNode extends OsmObject { this.LoadData(extraData) } - /** * * const obj = new OsmNode(1234) @@ -213,11 +212,11 @@ export class OsmNode extends OsmObject { */ ChangesetXML(changesetId: string, header?: string): string { let tags = this.TagsXML() - return ( - ` + return ` ${tags} ` - ) } SaveExtraData(element) { @@ -269,11 +268,11 @@ export class OsmWay extends OsmObject { nds += ' \n' } - return ( - ` + return ` ${nds}${tags} ` - ) } SaveExtraData(element, allNodes: OsmNode[]) { diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index cc3565a49..fa6f38dca 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -132,7 +132,7 @@ class CountryTagger extends SimpleMetaTagger { CountryTagger.coder .GetCountryCodeAsync(lon, lat) .then((countries) => { - if(!countries){ + if (!countries) { console.warn("Country coder returned ", countries) return } @@ -315,8 +315,7 @@ export default class SimpleMetaTaggers { }, (feature) => { Utils.AddLazyProperty(feature.properties, "_surface", () => { - return "" + GeoOperations.surfaceAreaInSqMeters(feature) - + return "" + GeoOperations.surfaceAreaInSqMeters(feature) }) return true diff --git a/Logic/State/FeatureSwitchState.ts b/Logic/State/FeatureSwitchState.ts index 94d367e20..50fe731ea 100644 --- a/Logic/State/FeatureSwitchState.ts +++ b/Logic/State/FeatureSwitchState.ts @@ -2,38 +2,26 @@ * The part of the global state which initializes the feature switches, based on default values and on the layoutToUse */ import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" -import {UIEventSource} from "../UIEventSource" -import {QueryParameters} from "../Web/QueryParameters" +import { UIEventSource } from "../UIEventSource" +import { QueryParameters } from "../Web/QueryParameters" import Constants from "../../Models/Constants" -import {Utils} from "../../Utils" +import { Utils } from "../../Utils" class FeatureSwitchUtils { - static initSwitch( - key: string, - deflt:boolean, - documentation: string - ): UIEventSource { - const defaultValue = deflt - const queryParam = QueryParameters.GetQueryParameter( - key, - "" + defaultValue, - documentation - ) - - // It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened - return queryParam.sync( - (str) => (str === undefined ? defaultValue : str !== "false"), - [], - (b) => (b == defaultValue ? undefined : "" + b) - ) - - - } + static initSwitch(key: string, deflt: boolean, documentation: string): UIEventSource { + const defaultValue = deflt + const queryParam = QueryParameters.GetQueryParameter(key, "" + defaultValue, documentation) + // It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened + return queryParam.sync( + (str) => (str === undefined ? defaultValue : str !== "false"), + [], + (b) => (b == defaultValue ? undefined : "" + b) + ) + } } export class OsmConnectionFeatureSwitches { - public readonly featureSwitchFakeUser: UIEventSource public readonly featureSwitchApiURL: UIEventSource @@ -52,8 +40,7 @@ export class OsmConnectionFeatureSwitches { } } - -export default class FeatureSwitchState extends OsmConnectionFeatureSwitches{ +export default class FeatureSwitchState extends OsmConnectionFeatureSwitches { /** * The layout that is being used in this run */ @@ -154,7 +141,6 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches{ "Enable the export as GeoJSON and CSV button" ) - let testingDefaultValue = false if ( this.featureSwitchApiURL.data !== "osm-test" && diff --git a/Logic/State/GeoLocationState.ts b/Logic/State/GeoLocationState.ts index cca92aff3..e88b6bfa7 100644 --- a/Logic/State/GeoLocationState.ts +++ b/Logic/State/GeoLocationState.ts @@ -21,7 +21,9 @@ export class GeoLocationState { * 'granted' means that it is granted * 'denied' means that we don't have access */ - public readonly permission: UIEventSource = new UIEventSource("prompt") + public readonly permission: UIEventSource = new UIEventSource( + "prompt" + ) /** * Important to determine e.g. if we move automatically on fix or not diff --git a/Logic/State/LayerState.ts b/Logic/State/LayerState.ts index 4a13e3c93..9354cb407 100644 --- a/Logic/State/LayerState.ts +++ b/Logic/State/LayerState.ts @@ -69,7 +69,7 @@ export default class LayerState { new Tag("level", "" + level), new RegexTag("level", new RegExp("(.*;)?" + level + "(;.*)?")), ] - if(level === "0") { + if (level === "0") { conditionsOrred.push(new Tag("level", "")) // No level tag is the same as level '0' } console.log("Setting levels filter to", conditionsOrred) diff --git a/Logic/State/UserRelatedState.ts b/Logic/State/UserRelatedState.ts index 703242c59..d2161e14e 100644 --- a/Logic/State/UserRelatedState.ts +++ b/Logic/State/UserRelatedState.ts @@ -1,20 +1,20 @@ import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" -import {OsmConnection} from "../Osm/OsmConnection" -import {MangroveIdentity} from "../Web/MangroveReviews" -import {Store, Stores, UIEventSource} from "../UIEventSource" +import { OsmConnection } from "../Osm/OsmConnection" +import { MangroveIdentity } from "../Web/MangroveReviews" +import { Store, Stores, UIEventSource } from "../UIEventSource" import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource" -import {FeatureSource} from "../FeatureSource/FeatureSource" -import {Feature} from "geojson" -import {Utils} from "../../Utils" +import { FeatureSource } from "../FeatureSource/FeatureSource" +import { Feature } from "geojson" +import { Utils } from "../../Utils" import translators from "../../assets/translators.json" import codeContributors from "../../assets/contributors.json" import LayerConfig from "../../Models/ThemeConfig/LayerConfig" -import {LayerConfigJson} from "../../Models/ThemeConfig/Json/LayerConfigJson" +import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson" import usersettings from "../../assets/generated/layers/usersettings.json" import Locale from "../../UI/i18n/Locale" import LinkToWeblate from "../../UI/Base/LinkToWeblate" import FeatureSwitchState from "./FeatureSwitchState" -import Constants from "../../Models/Constants"; +import Constants from "../../Models/Constants" /** * The part of the state which keeps track of user-related stuff, e.g. the OSM-connection, @@ -34,8 +34,8 @@ export default class UserRelatedState { public readonly mangroveIdentity: MangroveIdentity public readonly installedUserThemes: Store public readonly showAllQuestionsAtOnce: UIEventSource - public static readonly SHOW_TAGS_VALUES = ["always","yes","full"] as const - public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full">; + public static readonly SHOW_TAGS_VALUES = ["always", "yes", "full"] as const + public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full"> public readonly homeLocation: FeatureSource public readonly language: UIEventSource /** @@ -102,26 +102,22 @@ export default class UserRelatedState { } private static initUserRelatedState(): LayerConfig { - try{ - - return new LayerConfig( - usersettings, - "userinformationpanel" - ) - }catch(e){ + try { + return new LayerConfig(usersettings, "userinformationpanel") + } catch (e) { return undefined } } public GetUnofficialTheme(id: string): | { - id: string - icon: string - title: any - shortDescription: any - definition?: any - isOfficial: boolean - } + id: string + icon: string + title: any + shortDescription: any + definition?: any + isOfficial: boolean + } | undefined { console.log("GETTING UNOFFICIAL THEME") const pref = this.osmConnection.GetLongPreference("unofficial-theme-" + id) @@ -146,8 +142,8 @@ export default class UserRelatedState { } catch (e) { console.warn( "Removing theme " + - id + - " as it could not be parsed from the preferences; the content is:", + id + + " as it could not be parsed from the preferences; the content is:", str ) pref.setData(null) @@ -184,7 +180,7 @@ export default class UserRelatedState { } private InitializeLanguage(availableLanguages?: string[]) { - this.language.addCallbackAndRunD(language => Locale.language.setData(language)) + this.language.addCallbackAndRunD((language) => Locale.language.setData(language)) Locale.language.addCallback((currentLanguage) => { if (Locale.showLinkToWeblate.data) { return true // Disable auto switching as we are in translators mode @@ -262,7 +258,8 @@ export default class UserRelatedState { _theme: layout?.id, _backend: this.osmConnection.Backend(), _applicationOpened: new Date().toISOString(), - _supports_sharing: (typeof window === "undefined") ? "no" : (window.navigator.share ? "yes" : "no") + _supports_sharing: + typeof window === "undefined" ? "no" : window.navigator.share ? "yes" : "no", }) for (const key in Constants.userJourney) { @@ -297,13 +294,13 @@ export default class UserRelatedState { const zenLinks: { link: string; id: string }[] = Utils.NoNull([ hasMissingTheme ? { - id: "theme:" + layout.id, - link: LinkToWeblate.hrefToWeblateZen( - language, - "themes", - layout.id - ), - } + id: "theme:" + layout.id, + link: LinkToWeblate.hrefToWeblateZen( + language, + "themes", + layout.id + ), + } : undefined, ...missingLayers.map((id) => ({ id: "layer:" + id, @@ -375,7 +372,7 @@ export default class UserRelatedState { // Language is managed seperately continue } - this.osmConnection.GetPreference(key, undefined, {prefix: ""}).setData(tags[key]) + this.osmConnection.GetPreference(key, undefined, { prefix: "" }).setData(tags[key]) } }) diff --git a/Logic/Tags/RegexTag.ts b/Logic/Tags/RegexTag.ts index 50a17ddf8..982b6fd7f 100644 --- a/Logic/Tags/RegexTag.ts +++ b/Logic/Tags/RegexTag.ts @@ -1,5 +1,5 @@ -import {Tag} from "./Tag" -import {TagsFilter} from "./TagsFilter" +import { Tag } from "./Tag" +import { TagsFilter } from "./TagsFilter" export class RegexTag extends TagsFilter { public readonly key: RegExp | string @@ -39,7 +39,6 @@ export class RegexTag extends TagsFilter { return fromTag === possibleRegex } return possibleRegex.test(fromTag) - } private static source(r: string | RegExp) { @@ -155,7 +154,7 @@ export class RegexTag extends TagsFilter { matchesProperties(tags: Record): boolean { if (typeof this.key === "string") { let value = tags[this.key] - if(!value || value === ""){ + if (!value || value === "") { // No tag is known, so we assume the empty string // If this regexTag matches the empty string, we return true, otherwise false // (Note: if inverted, we must reverse this) @@ -176,7 +175,7 @@ export class RegexTag extends TagsFilter { return !this.invert } } - if(typeof value !== "string"){ + if (typeof value !== "string") { value = JSON.stringify(value) } return RegexTag.doesMatch(value, this.value) != this.invert @@ -188,7 +187,7 @@ export class RegexTag extends TagsFilter { } if (RegexTag.doesMatch(key, this.key)) { let value = tags[key] ?? "" - if(typeof value !== "string"){ + if (typeof value !== "string") { value = JSON.stringify(value) } return RegexTag.doesMatch(value, this.value) != this.invert diff --git a/Logic/Tags/Tag.ts b/Logic/Tags/Tag.ts index 3db63a9c3..198d97dd2 100644 --- a/Logic/Tags/Tag.ts +++ b/Logic/Tags/Tag.ts @@ -47,14 +47,14 @@ export class Tag extends TagsFilter { // and it shouldn't be found! return true } - if(typeof foundValue !== "string"){ - if(foundValue === true && (this.value === "true" || this.value === "yes" )){ + if (typeof foundValue !== "string") { + if (foundValue === true && (this.value === "true" || this.value === "yes")) { return true } - if(foundValue === false && (this.value === "false" || this.value === "no" )){ + if (foundValue === false && (this.value === "false" || this.value === "no")) { return true } - foundValue = ""+foundValue + foundValue = "" + foundValue } return foundValue === this.value } diff --git a/Logic/Tags/TagUtils.ts b/Logic/Tags/TagUtils.ts index e3f093310..ff47a8776 100644 --- a/Logic/Tags/TagUtils.ts +++ b/Logic/Tags/TagUtils.ts @@ -22,7 +22,7 @@ export class TagUtils { ] static KVtoProperties(tags: Tag[]): Record { - const properties : Record = {} + const properties: Record = {} for (const tag of tags) { properties[tag.key] = tag.value } diff --git a/Logic/UIEventSource.ts b/Logic/UIEventSource.ts index c9b70de78..50543fb83 100644 --- a/Logic/UIEventSource.ts +++ b/Logic/UIEventSource.ts @@ -416,7 +416,7 @@ class MappedStore extends Store { this._upstreamPingCount = upstreamListenerHandler?.pingCount this._extraStores = extraStores this.registerCallbacksToUpstream() - if(onDestroy !== undefined){ + if (onDestroy !== undefined) { onDestroy(() => this.unregisterFromUpstream()) } } @@ -698,7 +698,11 @@ export class UIEventSource extends Store implements Writable { * srcSeen // => 21 * lastSeen // => 42 */ - public map(f: (t: T) => J, extraSources: Store[] = [], onDestroy?: (f : () => void ) => void): Store { + public map( + f: (t: T) => J, + extraSources: Store[] = [], + onDestroy?: (f: () => void) => void + ): Store { return new MappedStore(this, f, extraSources, this._callbacks, f(this.data), onDestroy) } /** diff --git a/Logic/Web/MangroveReviews.ts b/Logic/Web/MangroveReviews.ts index e2ed56e12..ec16f3445 100644 --- a/Logic/Web/MangroveReviews.ts +++ b/Logic/Web/MangroveReviews.ts @@ -76,7 +76,8 @@ export default class FeatureReviews { ) { const centerLonLat = GeoOperations.centerpointCoordinates(feature) ;[this._lon, this._lat] = centerLonLat - this._identity = mangroveIdentity ?? new MangroveIdentity(new UIEventSource(undefined)) + this._identity = + mangroveIdentity ?? new MangroveIdentity(new UIEventSource(undefined)) const nameKey = options?.nameKey ?? "name" if (feature.geometry.type === "Point") { @@ -103,7 +104,7 @@ export default class FeatureReviews { this._uncertainty = options?.uncertaintyRadius ?? maxDistance } - this._name = tagsSource .map((tags) => tags[nameKey] ?? options?.fallbackName) + this._name = tagsSource.map((tags) => tags[nameKey] ?? options?.fallbackName) this.subjectUri = this.ConstructSubjectUri() diff --git a/Logic/Web/ThemeViewStateHashActor.ts b/Logic/Web/ThemeViewStateHashActor.ts index c6e18b354..e69d00556 100644 --- a/Logic/Web/ThemeViewStateHashActor.ts +++ b/Logic/Web/ThemeViewStateHashActor.ts @@ -1,8 +1,8 @@ -import ThemeViewState from "../../Models/ThemeViewState"; -import Hash from "./Hash"; +import ThemeViewState from "../../Models/ThemeViewState" +import Hash from "./Hash" export default class ThemeViewStateHashActor { - private readonly _state: ThemeViewState; + private readonly _state: ThemeViewState /** * Converts the hash to the appropriate themeview state and, vice versa, sets the hash. @@ -15,27 +15,27 @@ export default class ThemeViewStateHashActor { * @param state */ constructor(state: ThemeViewState) { - this._state = state; + this._state = state // First of all, try to recover the selected element if (Hash.hash.data) { const hash = Hash.hash.data this.loadStateFromHash(hash) Hash.hash.setData(hash) // reapply the previous hash - state.indexedFeatures.featuresById.addCallbackAndRunD(_ => { - let unregister = this.loadSelectedElementFromHash(hash); + state.indexedFeatures.featuresById.addCallbackAndRunD((_) => { + let unregister = this.loadSelectedElementFromHash(hash) // once that we have found a matching element, we can be sure the indexedFeaturesource was popuplated and that the job is done return unregister }) } // Register a hash change listener to correctly handle the back button - Hash.hash.addCallback(hash => { + Hash.hash.addCallback((hash) => { if (!!hash) { // There is still a hash // We _only_ have to (at most) close the overlays in this case const parts = hash.split(";") - if(parts.indexOf("background") < 0){ + if (parts.indexOf("background") < 0) { state.guistate.backgroundLayerSelectionIsOpened.setData(false) } this.loadSelectedElementFromHash(hash) @@ -46,16 +46,14 @@ export default class ThemeViewStateHashActor { // At last, register callbacks on the state to update the hash when they change. // Note: these should use 'addCallback', not 'addCallbackAndRun' - state.selectedElement.addCallback(_ => this.setHash()) - state.guistate.allToggles.forEach(({toggle, submenu}) => { - submenu?.addCallback(_ => this.setHash()) - toggle.addCallback(_ => this.setHash()); + state.selectedElement.addCallback((_) => this.setHash()) + state.guistate.allToggles.forEach(({ toggle, submenu }) => { + submenu?.addCallback((_) => this.setHash()) + toggle.addCallback((_) => this.setHash()) }) // When all is done, set the hash. This must happen last to give the code above correct info this.setHash() - - } /** @@ -103,8 +101,7 @@ export default class ThemeViewStateHashActor { private loadStateFromHash(hash: string) { const state = this._state const parts = hash.split(";") - outer: for (const {toggle, name, showOverOthers, submenu} of state.guistate.allToggles) { - + outer: for (const { toggle, name, showOverOthers, submenu } of state.guistate.allToggles) { for (const part of parts) { if (part === name) { toggle.setData(true) @@ -125,17 +122,15 @@ export default class ThemeViewStateHashActor { // If we arrive here, the loop above has not found any match toggle.setData(false) } - - } private setHash() { const s = this._state let h = "" - for (const {toggle, showOverOthers, name, submenu} of s.guistate.allToggles) { + for (const { toggle, showOverOthers, name, submenu } of s.guistate.allToggles) { if (showOverOthers || !toggle.data) { - continue; + continue } h = name if (submenu?.data) { @@ -147,9 +142,9 @@ export default class ThemeViewStateHashActor { h = s.selectedElement.data.properties.id } - for (const {toggle, showOverOthers, name, submenu} of s.guistate.allToggles) { + for (const { toggle, showOverOthers, name, submenu } of s.guistate.allToggles) { if (!showOverOthers || !toggle.data) { - continue; + continue } if (h) { h += ";" + name @@ -161,7 +156,6 @@ export default class ThemeViewStateHashActor { } } Hash.hash.setData(h) - } private back() { @@ -176,5 +170,4 @@ export default class ThemeViewStateHashActor { return } } - } diff --git a/Models/Constants.ts b/Models/Constants.ts index 2d31e12b1..9764afe48 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -1,4 +1,4 @@ -import {Utils} from "../Utils" +import { Utils } from "../Utils" import * as meta from "../package.json" export type PriviligedLayerType = typeof Constants.priviliged_layers[number] @@ -119,7 +119,19 @@ export default class Constants { /** * These are the values that are allowed to use as 'backdrop' icon for a map pin */ - private static readonly _defaultPinIcons = ["square", "circle", "none", "pin", "person", "plus", "ring", "star", "teardrop", "triangle", "crosshair",] as const + private static readonly _defaultPinIcons = [ + "square", + "circle", + "none", + "pin", + "person", + "plus", + "ring", + "star", + "teardrop", + "triangle", + "crosshair", + ] as const public static readonly defaultPinIcons: string[] = Constants._defaultPinIcons private static isRetina(): boolean { @@ -131,8 +143,8 @@ export default class Constants { return ( (window.matchMedia && (window.matchMedia( - "only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx), only screen and (min-resolution: 75.6dpcm)" - ).matches || + "only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx), only screen and (min-resolution: 75.6dpcm)" + ).matches || window.matchMedia( "only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)" ).matches)) || diff --git a/Models/Denomination.ts b/Models/Denomination.ts index c4d119ea7..9dcdfc475 100644 --- a/Models/Denomination.ts +++ b/Models/Denomination.ts @@ -51,7 +51,6 @@ export class Denomination { return (this._humanSingular ?? this._human).Clone() } - /** * Create a representation of the given value * @param value: the value from OSM diff --git a/Models/MenuState.ts b/Models/MenuState.ts index 1c264e17d..c946402af 100644 --- a/Models/MenuState.ts +++ b/Models/MenuState.ts @@ -1,8 +1,8 @@ import LayerConfig from "./ThemeConfig/LayerConfig" -import {UIEventSource} from "../Logic/UIEventSource" +import { UIEventSource } from "../Logic/UIEventSource" import UserRelatedState from "../Logic/State/UserRelatedState" -import {Utils} from "../Utils" -import {LocalStorageSource} from "../Logic/Web/LocalStorageSource" +import { Utils } from "../Utils" +import { LocalStorageSource } from "../Logic/Web/LocalStorageSource" export type ThemeViewTabStates = typeof MenuState._themeviewTabs[number] export type MenuViewTabStates = typeof MenuState._menuviewTabs[number] @@ -14,8 +14,20 @@ export type MenuViewTabStates = typeof MenuState._menuviewTabs[number] * Some convenience methods are provided for this as well */ export class MenuState { - public static readonly _themeviewTabs = ["intro", "filters", "download", "copyright","share"] as const - public static readonly _menuviewTabs = ["about", "settings", "community", "privacy","advanced"] as const + public static readonly _themeviewTabs = [ + "intro", + "filters", + "download", + "copyright", + "share", + ] as const + public static readonly _menuviewTabs = [ + "about", + "settings", + "community", + "privacy", + "advanced", + ] as const public readonly themeIsOpened: UIEventSource public readonly themeViewTabIndex: UIEventSource public readonly themeViewTab: UIEventSource @@ -23,11 +35,13 @@ export class MenuState { public readonly menuViewTabIndex: UIEventSource public readonly menuViewTab: UIEventSource - public readonly backgroundLayerSelectionIsOpened: UIEventSource = new UIEventSource(false) + public readonly backgroundLayerSelectionIsOpened: UIEventSource = + new UIEventSource(false) public readonly allToggles: { - toggle: UIEventSource, name: string, - submenu?: UIEventSource, + toggle: UIEventSource + name: string + submenu?: UIEventSource showOverOthers?: boolean }[] @@ -81,16 +95,19 @@ export class MenuState { { toggle: this.menuIsOpened, name: "menu", - submenu: this.menuViewTab - }, { + submenu: this.menuViewTab, + }, + { toggle: this.themeIsOpened, name: "theme-menu", - submenu: this.themeViewTab - }, { + submenu: this.themeViewTab, + }, + { toggle: this.backgroundLayerSelectionIsOpened, name: "background", - showOverOthers: true - }] + showOverOthers: true, + }, + ] } public openFilterView(highlightLayer?: LayerConfig | string) { @@ -128,10 +145,13 @@ export class MenuState { * Returns 'true' if at least one menu was opened */ public closeAll(): boolean { - const toggles = [this.menuIsOpened, this.themeIsOpened, this.backgroundLayerSelectionIsOpened] - const somethingIsOpen = toggles.some(t => t.data) - toggles.forEach(t => t.setData(false)) + const toggles = [ + this.menuIsOpened, + this.themeIsOpened, + this.backgroundLayerSelectionIsOpened, + ] + const somethingIsOpen = toggles.some((t) => t.data) + toggles.forEach((t) => t.setData(false)) return somethingIsOpen } - } diff --git a/Models/RasterLayers.ts b/Models/RasterLayers.ts index 617f3f7cb..7a5f31e1d 100644 --- a/Models/RasterLayers.ts +++ b/Models/RasterLayers.ts @@ -1,10 +1,10 @@ -import {Feature, Polygon} from "geojson" +import { Feature, Polygon } from "geojson" import * as editorlayerindex from "../assets/editor-layer-index.json" import * as globallayers from "../assets/global-raster-layers.json" -import {BBox} from "../Logic/BBox" -import {Store, Stores} from "../Logic/UIEventSource" -import {GeoOperations} from "../Logic/GeoOperations" -import {RasterLayerProperties} from "./RasterLayerProperties" +import { BBox } from "../Logic/BBox" +import { Store, Stores } from "../Logic/UIEventSource" +import { GeoOperations } from "../Logic/GeoOperations" +import { RasterLayerProperties } from "./RasterLayerProperties" export class AvailableRasterLayers { public static EditorLayerIndex: (Feature & @@ -47,8 +47,8 @@ export class AvailableRasterLayers { type: "vector", attribution: { text: "Maptiler", - url: "https://www.maptiler.com/copyright/" - } + url: "https://www.maptiler.com/copyright/", + }, }, geometry: BBox.global.asGeometry(), } @@ -63,8 +63,8 @@ export class AvailableRasterLayers { type: "vector", attribution: { text: "Americana", - url: "https://github.com/ZeLonewolf/openstreetmap-americana/" - } + url: "https://github.com/ZeLonewolf/openstreetmap-americana/", + }, }, geometry: BBox.global.asGeometry(), } @@ -151,7 +151,14 @@ export interface EditorLayerIndexProperties extends RasterLayerProperties { * Whether the imagery name should be translated */ readonly i18n?: boolean - readonly type: "tms" | "wms" | "bing" | "scanex" | "wms_endpoint" | "wmts" | "vector" /* Vector is not actually part of the ELI-spec, we add it for vector layers */ + readonly type: + | "tms" + | "wms" + | "bing" + | "scanex" + | "wms_endpoint" + | "wmts" + | "vector" /* Vector is not actually part of the ELI-spec, we add it for vector layers */ /** * A rough categorisation of different types of layers. See https://github.com/osmlab/editor-layer-index/blob/gh-pages/CONTRIBUTING.md#categories for a description of the individual categories. */ diff --git a/Models/ThemeConfig/Conversion/Conversion.ts b/Models/ThemeConfig/Conversion/Conversion.ts index 66a4135b4..8ef98a428 100644 --- a/Models/ThemeConfig/Conversion/Conversion.ts +++ b/Models/ThemeConfig/Conversion/Conversion.ts @@ -297,8 +297,8 @@ export class Fuse extends DesugaringStep { const step = this.steps[i] try { let r = step.convert(json, "While running step " + step.name + ": " + context) - if(r.result["tagRenderings"]?.some(tr => tr === undefined)){ - throw step.name+" introduced an undefined tagRendering" + if (r.result["tagRenderings"]?.some((tr) => tr === undefined)) { + throw step.name + " introduced an undefined tagRendering" } errors.push(...(r.errors ?? [])) warnings.push(...(r.warnings ?? [])) diff --git a/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts b/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts index 59f9b318b..d4d84ded6 100644 --- a/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts +++ b/Models/ThemeConfig/Conversion/CreateNoteImportLayer.ts @@ -1,9 +1,9 @@ -import {Conversion} from "./Conversion" +import { Conversion } from "./Conversion" import LayerConfig from "../LayerConfig" -import {LayerConfigJson} from "../Json/LayerConfigJson" +import { LayerConfigJson } from "../Json/LayerConfigJson" import Translations from "../../../UI/i18n/Translations" import PointRenderingConfigJson from "../Json/PointRenderingConfigJson" -import {Translation, TypedTranslation} from "../../../UI/i18n/Translation" +import { Translation, TypedTranslation } from "../../../UI/i18n/Translation" export default class CreateNoteImportLayer extends Conversion { /** @@ -101,7 +101,7 @@ export default class CreateNoteImportLayer extends Conversion { private static readonly predefinedFilters = ExpandFilter.load_filters() @@ -446,11 +446,11 @@ class DetectInline extends DesugaringStep { information?: string[] } { if (json.freeform === undefined) { - return {result: json} + return { result: json } } let spec: Record if (typeof json.render === "string") { - spec = {"*": json.render} + spec = { "*": json.render } } else { spec = >json.render } @@ -459,7 +459,7 @@ class DetectInline extends DesugaringStep { if (spec[key].indexOf("= 0) { // We have a link element, it probably contains something that needs to be substituted... // Let's play this safe and not inline it - return {result: json} + return { result: json } } const fullSpecification = SpecialVisualizations.constructSpecification(spec[key]) if (fullSpecification.length > 1) { @@ -467,19 +467,19 @@ class DetectInline extends DesugaringStep { if (json.freeform.inline === true) { errors.push( "At " + - context + - ": 'inline' is set, but the rendering contains a special visualisation...\n " + - spec[key] + context + + ": 'inline' is set, but the rendering contains a special visualisation...\n " + + spec[key] ) } json = JSON.parse(JSON.stringify(json)) json.freeform.inline = false - return {result: json, errors} + return { result: json, errors } } } json = JSON.parse(JSON.stringify(json)) json.freeform.inline ??= true - return {result: json, errors} + return { result: json, errors } } } @@ -500,7 +500,7 @@ export class AddQuestionBox extends DesugaringStep { json.tagRenderings === undefined || json.tagRenderings.some((tr) => tr["id"] === "leftover-questions") ) { - return {result: json} + return { result: json } } json = JSON.parse(JSON.stringify(json)) const allSpecials: Exclude[] = [] @@ -521,8 +521,8 @@ export class AddQuestionBox extends DesugaringStep { if (noLabels.length > 1) { errors.push( "At " + - context + - ": multiple 'questions'-visualisations found which would show _all_ questions. Don't do this" + context + + ": multiple 'questions'-visualisations found which would show _all_ questions. Don't do this" ) } @@ -546,24 +546,24 @@ export class AddQuestionBox extends DesugaringStep { if (blacklisted?.length > 0 && used?.length > 0) { errors.push( "At " + - context + - ": the {questions()}-special rendering only supports either a blacklist OR a whitelist, but not both." + - "\n Whitelisted: " + - used.join(", ") + - "\n Blacklisted: " + - blacklisted.join(", ") + context + + ": the {questions()}-special rendering only supports either a blacklist OR a whitelist, but not both." + + "\n Whitelisted: " + + used.join(", ") + + "\n Blacklisted: " + + blacklisted.join(", ") ) } for (const usedLabel of used) { if (!allLabels.has(usedLabel)) { errors.push( "At " + - context + - ": this layers specifies a special question element for label `" + - usedLabel + - "`, but this label doesn't exist.\n" + - " Available labels are " + - Array.from(allLabels).join(", ") + context + + ": this layers specifies a special question element for label `" + + usedLabel + + "`, but this label doesn't exist.\n" + + " Available labels are " + + Array.from(allLabels).join(", ") ) } seen.add(usedLabel) @@ -619,7 +619,7 @@ export class AddEditingElements extends DesugaringStep { if (json.allowSplit && !ValidationUtils.hasSpecialVisualisation(json, "split_button")) { json.tagRenderings.push({ id: "split-button", - render: {"*": "{split_button()}"}, + render: { "*": "{split_button()}" }, }) delete json.allowSplit } @@ -627,13 +627,13 @@ export class AddEditingElements extends DesugaringStep { if (json.allowMove && !ValidationUtils.hasSpecialVisualisation(json, "move_button")) { json.tagRenderings.push({ id: "move-button", - render: {"*": "{move_button()}"}, + render: { "*": "{move_button()}" }, }) } if (json.deletion && !ValidationUtils.hasSpecialVisualisation(json, "delete_button")) { json.tagRenderings.push({ id: "delete-button", - render: {"*": "{delete_button()}"}, + render: { "*": "{delete_button()}" }, }) } @@ -650,7 +650,7 @@ export class AddEditingElements extends DesugaringStep { if (!ValidationUtils.hasSpecialVisualisation(json, "all_tags")) { const trc: TagRenderingConfigJson = { id: "all-tags", - render: {"*": "{all_tags()}"}, + render: { "*": "{all_tags()}" }, metacondition: { or: [ @@ -663,7 +663,7 @@ export class AddEditingElements extends DesugaringStep { json.tagRenderings?.push(trc) } - return {result: json} + return { result: json } } } @@ -1161,31 +1161,37 @@ class PreparePointRendering extends Fuse { constructor() { - super("sets the fullNodeDatabase-bit if needed", + super( + "sets the fullNodeDatabase-bit if needed", ["fullNodeDatabase"], - "SetFullNodeDatabase") + "SetFullNodeDatabase" + ) } - convert(json: LayerConfigJson, context: string): { - result: LayerConfigJson; - errors?: string[]; - warnings?: string[]; + convert( + json: LayerConfigJson, + context: string + ): { + result: LayerConfigJson + errors?: string[] + warnings?: string[] information?: string[] } { - const needsSpecial = json.tagRenderings?.some(tr => { - if (typeof tr === "string") { - return false - } - const specs = ValidationUtils.getSpecialVisualisations(tr) - return specs?.some(sp => sp.needsNodeDatabase) - }) ?? false + const needsSpecial = + json.tagRenderings?.some((tr) => { + if (typeof tr === "string") { + return false + } + const specs = ValidationUtils.getSpecialVisualisations(tr) + return specs?.some((sp) => sp.needsNodeDatabase) + }) ?? false if (!needsSpecial) { - return {result: json} + return { result: json } } return { - result: {...json, fullNodeDatabase: true}, - information: ["Layer " + json.id + " needs the fullNodeDatabase"] - }; + result: { ...json, fullNodeDatabase: true }, + information: ["Layer " + json.id + " needs the fullNodeDatabase"], + } } } @@ -1203,12 +1209,12 @@ export class AddMiniMap extends DesugaringStep { convert(layerConfig: LayerConfigJson, context: string): { result: LayerConfigJson } { if (!layerConfig.tagRenderings || layerConfig.source === "special") { - return {result: layerConfig} + return { result: layerConfig } } const state = this._state const hasMinimap = ValidationUtils.hasSpecialVisualisation(layerConfig, "minimap") if (!hasMinimap) { - layerConfig = {...layerConfig} + layerConfig = { ...layerConfig } layerConfig.tagRenderings = [...layerConfig.tagRenderings] const minimap = state.tagRenderings.get("minimap") if (minimap === undefined) { diff --git a/Models/ThemeConfig/Conversion/ValidationUtils.ts b/Models/ThemeConfig/Conversion/ValidationUtils.ts index 248a3a577..26e3d0589 100644 --- a/Models/ThemeConfig/Conversion/ValidationUtils.ts +++ b/Models/ThemeConfig/Conversion/ValidationUtils.ts @@ -1,8 +1,8 @@ -import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson" -import {Utils} from "../../../Utils" +import { TagRenderingConfigJson } from "../Json/TagRenderingConfigJson" +import { Utils } from "../../../Utils" import SpecialVisualizations from "../../../UI/SpecialVisualizations" -import {RenderingSpecification, SpecialVisualization} from "../../../UI/SpecialVisualization" -import {LayerConfigJson} from "../Json/LayerConfigJson" +import { RenderingSpecification, SpecialVisualization } from "../../../UI/SpecialVisualization" +import { LayerConfigJson } from "../Json/LayerConfigJson" export default class ValidationUtils { public static hasSpecialVisualisation( @@ -11,14 +11,15 @@ export default class ValidationUtils { ): boolean { return ( layer.tagRenderings?.some((tagRendering) => { - if(tagRendering === undefined){ - return false - } - - const spec = ValidationUtils.getSpecialVisualisations(tagRendering) - return spec.some((vis) => vis.funcName === specialVisualisation); + if (tagRendering === undefined) { + return false } - ) ?? false + + const spec = ValidationUtils.getSpecialVisualisations( + tagRendering + ) + return spec.some((vis) => vis.funcName === specialVisualisation) + }) ?? false ) } @@ -44,7 +45,7 @@ export default class ValidationUtils { const all: RenderingSpecification[] = [] for (let translation of translations) { if (typeof translation == "string") { - translation = {"*": translation} + translation = { "*": translation } } for (const key in translation) { diff --git a/Models/ThemeConfig/DeleteConfig.ts b/Models/ThemeConfig/DeleteConfig.ts index f5b2db036..0c7bfae69 100644 --- a/Models/ThemeConfig/DeleteConfig.ts +++ b/Models/ThemeConfig/DeleteConfig.ts @@ -3,9 +3,9 @@ import { TagsFilter } from "../../Logic/Tags/TagsFilter" import { DeleteConfigJson } from "./Json/DeleteConfigJson" import Translations from "../../UI/i18n/Translations" import { TagUtils } from "../../Logic/Tags/TagUtils" -import TagRenderingConfig from "./TagRenderingConfig"; -import {QuestionableTagRenderingConfigJson} from "./Json/QuestionableTagRenderingConfigJson"; -import {TagConfigJson} from "./Json/TagConfigJson"; +import TagRenderingConfig from "./TagRenderingConfig" +import { QuestionableTagRenderingConfigJson } from "./Json/QuestionableTagRenderingConfigJson" +import { TagConfigJson } from "./Json/TagConfigJson" export default class DeleteConfig { public static readonly deleteReasonKey = "_delete_reason" @@ -97,24 +97,24 @@ export default class DeleteConfig { public constructTagRendering(): TagRenderingConfig { const t = Translations.t.delete - const mappings: {if: TagConfigJson, then: Record} []= [] + const mappings: { if: TagConfigJson; then: Record }[] = [] for (const nonDeleteMapping of this.nonDeleteMappings) { mappings.push({ if: nonDeleteMapping.if, - then: nonDeleteMapping.then.translations + then: nonDeleteMapping.then.translations, }) } for (const deleteReason of this.deleteReasons) { mappings.push({ - if: DeleteConfig.deleteReasonKey+ "="+ deleteReason.changesetMessage, - then: deleteReason.explanation.translations + if: DeleteConfig.deleteReasonKey + "=" + deleteReason.changesetMessage, + then: deleteReason.explanation.translations, }) } const config: QuestionableTagRenderingConfigJson = { question: t.whyDelete.translations, - mappings + mappings, } return new TagRenderingConfig(config) } diff --git a/Models/ThemeConfig/DependencyCalculator.ts b/Models/ThemeConfig/DependencyCalculator.ts index 3267abef3..7d0ae9c3f 100644 --- a/Models/ThemeConfig/DependencyCalculator.ts +++ b/Models/ThemeConfig/DependencyCalculator.ts @@ -103,7 +103,11 @@ export default class DependencyCalculator { currentLine = i // Leak the state... currentKey = key try { - const func = new Function("feat", "{"+ExtraFunctions.types.join(",")+"}", "return " + code + ";") + const func = new Function( + "feat", + "{" + ExtraFunctions.types.join(",") + "}", + "return " + code + ";" + ) const result = func(obj, helpers) obj.properties[key] = JSON.stringify(result) } catch (e) {} diff --git a/Models/ThemeConfig/Json/LineRenderingConfigJson.ts b/Models/ThemeConfig/Json/LineRenderingConfigJson.ts index d93c31215..e234bdd11 100644 --- a/Models/ThemeConfig/Json/LineRenderingConfigJson.ts +++ b/Models/ThemeConfig/Json/LineRenderingConfigJson.ts @@ -31,7 +31,6 @@ export default interface LineRenderingConfigJson { */ lineCap?: "round" | "square" | "butt" | string | TagRenderingConfigJson - /** * The color to fill a polygon with. * If undefined, this will be slightly more opaque version of the stroke line. diff --git a/Models/ThemeConfig/LayerConfig.ts b/Models/ThemeConfig/LayerConfig.ts index cd4433fb9..8fc628274 100644 --- a/Models/ThemeConfig/LayerConfig.ts +++ b/Models/ThemeConfig/LayerConfig.ts @@ -417,7 +417,6 @@ export default class LayerConfig extends WithContextLoader { ) } this.popupInFloatover = json.popupInFloatover ?? false - } public defaultIcon(): BaseUIElement | undefined { diff --git a/Models/ThemeConfig/PointRenderingConfig.ts b/Models/ThemeConfig/PointRenderingConfig.ts index c3cc1059a..250f92e95 100644 --- a/Models/ThemeConfig/PointRenderingConfig.ts +++ b/Models/ThemeConfig/PointRenderingConfig.ts @@ -1,16 +1,16 @@ import PointRenderingConfigJson from "./Json/PointRenderingConfigJson" import TagRenderingConfig from "./TagRenderingConfig" -import {TagsFilter} from "../../Logic/Tags/TagsFilter" -import {TagUtils} from "../../Logic/Tags/TagUtils" -import {Utils} from "../../Utils" +import { TagsFilter } from "../../Logic/Tags/TagsFilter" +import { TagUtils } from "../../Logic/Tags/TagUtils" +import { Utils } from "../../Utils" import Svg from "../../Svg" import WithContextLoader from "./WithContextLoader" -import {Store} from "../../Logic/UIEventSource" +import { Store } from "../../Logic/UIEventSource" import BaseUIElement from "../../UI/BaseUIElement" -import {FixedUiElement} from "../../UI/Base/FixedUiElement" +import { FixedUiElement } from "../../UI/Base/FixedUiElement" import Img from "../../UI/Base/Img" import Combine from "../../UI/Base/Combine" -import {VariableUiElement} from "../../UI/Base/VariableUIElement" +import { VariableUiElement } from "../../UI/Base/VariableUIElement" export default class PointRenderingConfig extends WithContextLoader { static readonly allowed_location_codes: ReadonlySet = new Set([ @@ -83,7 +83,7 @@ export default class PointRenderingConfig extends WithContextLoader { } }) - const iconPath = this.icon?.GetRenderValue({id: "node/-1"})?.txt + const iconPath = this.icon?.GetRenderValue({ id: "node/-1" })?.txt if (iconPath !== undefined && iconPath.startsWith(Utils.assets_path)) { const iconKey = iconPath.substr(Utils.assets_path.length) if (Svg.All[iconKey] === undefined) { @@ -168,7 +168,7 @@ export default class PointRenderingConfig extends WithContextLoader { noFullWidth?: boolean } ): BaseUIElement { - tags = tags ?? {id: "node/-1"} + tags = tags ?? { id: "node/-1" } let defaultPin: BaseUIElement = undefined if (this.label === undefined) { defaultPin = Svg.teardrop_with_hole_green_svg() diff --git a/Models/ThemeConfig/TagRenderingConfig.ts b/Models/ThemeConfig/TagRenderingConfig.ts index 9ba3cfd35..dbc0ba2f3 100644 --- a/Models/ThemeConfig/TagRenderingConfig.ts +++ b/Models/ThemeConfig/TagRenderingConfig.ts @@ -1,20 +1,23 @@ -import {Translation, TypedTranslation} from "../../UI/i18n/Translation" -import {TagsFilter} from "../../Logic/Tags/TagsFilter" +import { Translation, TypedTranslation } from "../../UI/i18n/Translation" +import { TagsFilter } from "../../Logic/Tags/TagsFilter" import Translations from "../../UI/i18n/Translations" -import {TagUtils, UploadableTag} from "../../Logic/Tags/TagUtils" -import {And} from "../../Logic/Tags/And" -import {Utils} from "../../Utils" -import {Tag} from "../../Logic/Tags/Tag" +import { TagUtils, UploadableTag } from "../../Logic/Tags/TagUtils" +import { And } from "../../Logic/Tags/And" +import { Utils } from "../../Utils" +import { Tag } from "../../Logic/Tags/Tag" import BaseUIElement from "../../UI/BaseUIElement" import Combine from "../../UI/Base/Combine" import Title from "../../UI/Base/Title" import Link from "../../UI/Base/Link" import List from "../../UI/Base/List" -import {MappingConfigJson, QuestionableTagRenderingConfigJson,} from "./Json/QuestionableTagRenderingConfigJson" -import {FixedUiElement} from "../../UI/Base/FixedUiElement" -import {Paragraph} from "../../UI/Base/Paragraph" +import { + MappingConfigJson, + QuestionableTagRenderingConfigJson, +} from "./Json/QuestionableTagRenderingConfigJson" +import { FixedUiElement } from "../../UI/Base/FixedUiElement" +import { Paragraph } from "../../UI/Base/Paragraph" import Svg from "../../Svg" -import Validators, {ValidatorType} from "../../UI/InputElement/Validators"; +import Validators, { ValidatorType } from "../../UI/InputElement/Validators" export interface Mapping { readonly if: UploadableTag @@ -118,9 +121,9 @@ export default class TagRenderingConfig { this.question = Translations.T(json.question, translationKey + ".question") this.questionhint = Translations.T(json.questionHint, translationKey + ".questionHint") this.description = Translations.T(json.description, translationKey + ".description") - this.condition = TagUtils.Tag(json.condition ?? {and: []}, `${context}.condition`) + this.condition = TagUtils.Tag(json.condition ?? { and: [] }, `${context}.condition`) this.metacondition = TagUtils.Tag( - json.metacondition ?? {and: []}, + json.metacondition ?? { and: [] }, `${context}.metacondition` ) if (json.freeform) { @@ -537,11 +540,8 @@ export default class TagRenderingConfig { } } - if ( - this.freeform?.key === undefined || - tags[this.freeform.key] !== undefined - ) { - return {then: this.render} + if (this.freeform?.key === undefined || tags[this.freeform.key] !== undefined) { + return { then: this.render } } return undefined @@ -681,13 +681,13 @@ export default class TagRenderingConfig { ) } const and = TagUtils.FlattenMultiAnswer([...selectedMappings, ...unselectedMappings]) - if(and.and.length === 0){ + if (and.and.length === 0) { return undefined } return and } else { // Is at least one mapping shown in the answer? - const someMappingIsShown = this.mappings.some(m => { + const someMappingIsShown = this.mappings.some((m) => { if (typeof m.hideInAnswer === "boolean") { return !m.hideInAnswer } @@ -695,7 +695,9 @@ export default class TagRenderingConfig { return !isHidden }) // If all mappings are hidden for the current tags, we can safely assume that we should use the freeform key - const useFreeform = freeformValue !== undefined && (singleSelectedMapping === this.mappings.length || !someMappingIsShown) + const useFreeform = + freeformValue !== undefined && + (singleSelectedMapping === this.mappings.length || !someMappingIsShown) if (useFreeform) { return new And([ new Tag(this.freeform.key, freeformValue), @@ -711,7 +713,7 @@ export default class TagRenderingConfig { freeformValue, singleSelectedMapping, multiSelectedMapping, - currentProperties + currentProperties, }) return undefined } @@ -757,7 +759,7 @@ export default class TagRenderingConfig { if (m.ifnot !== undefined) { msgs.push( "Unselecting this answer will add " + - m.ifnot.asHumanString(true, false, {}) + m.ifnot.asHumanString(true, false, {}) ) } return msgs @@ -787,12 +789,12 @@ export default class TagRenderingConfig { this.description, this.question !== undefined ? new Combine([ - "The question is ", - new FixedUiElement(this.question.txt).SetClass("font-bold bold"), - ]) + "The question is ", + new FixedUiElement(this.question.txt).SetClass("font-bold bold"), + ]) : new FixedUiElement( - "This tagrendering has no question and is thus read-only" - ).SetClass("italic"), + "This tagrendering has no question and is thus read-only" + ).SetClass("italic"), new Combine(withRender), mappings, condition, diff --git a/Models/ThemeConfig/WithContextLoader.ts b/Models/ThemeConfig/WithContextLoader.ts index 8d480fb80..bd0d1d2e6 100644 --- a/Models/ThemeConfig/WithContextLoader.ts +++ b/Models/ThemeConfig/WithContextLoader.ts @@ -21,7 +21,10 @@ export default class WithContextLoader { if (deflt === undefined) { return undefined } - return new TagRenderingConfig(deflt, `${translationContext ?? this._context}.${key}.default value`) + return new TagRenderingConfig( + deflt, + `${translationContext ?? this._context}.${key}.default value` + ) } if (typeof v === "string") { const shared = SharedTagRenderings.SharedTagRendering.get(v) diff --git a/Models/ThemeViewState.ts b/Models/ThemeViewState.ts index ffdcdaad6..5d11d98dc 100644 --- a/Models/ThemeViewState.ts +++ b/Models/ThemeViewState.ts @@ -1,23 +1,27 @@ import LayoutConfig from "./ThemeConfig/LayoutConfig" -import {SpecialVisualizationState} from "../UI/SpecialVisualization" -import {Changes} from "../Logic/Osm/Changes" -import {ImmutableStore, Store, UIEventSource} from "../Logic/UIEventSource" -import {FeatureSource, IndexedFeatureSource, WritableFeatureSource,} from "../Logic/FeatureSource/FeatureSource" -import {OsmConnection} from "../Logic/Osm/OsmConnection" -import {ExportableMap, MapProperties} from "./MapProperties" +import { SpecialVisualizationState } from "../UI/SpecialVisualization" +import { Changes } from "../Logic/Osm/Changes" +import { ImmutableStore, Store, UIEventSource } from "../Logic/UIEventSource" +import { + FeatureSource, + IndexedFeatureSource, + WritableFeatureSource, +} from "../Logic/FeatureSource/FeatureSource" +import { OsmConnection } from "../Logic/Osm/OsmConnection" +import { ExportableMap, MapProperties } from "./MapProperties" import LayerState from "../Logic/State/LayerState" -import {Feature, Point, Polygon} from "geojson" +import { Feature, Point, Polygon } from "geojson" import FullNodeDatabaseSource from "../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" -import {Map as MlMap} from "maplibre-gl" +import { Map as MlMap } from "maplibre-gl" import InitialMapPositioning from "../Logic/Actors/InitialMapPositioning" -import {MapLibreAdaptor} from "../UI/Map/MapLibreAdaptor" -import {GeoLocationState} from "../Logic/State/GeoLocationState" +import { MapLibreAdaptor } from "../UI/Map/MapLibreAdaptor" +import { GeoLocationState } from "../Logic/State/GeoLocationState" import FeatureSwitchState from "../Logic/State/FeatureSwitchState" -import {QueryParameters} from "../Logic/Web/QueryParameters" +import { QueryParameters } from "../Logic/Web/QueryParameters" import UserRelatedState from "../Logic/State/UserRelatedState" import LayerConfig from "./ThemeConfig/LayerConfig" import GeoLocationHandler from "../Logic/Actors/GeoLocationHandler" -import {AvailableRasterLayers, RasterLayerPolygon, RasterLayerUtils} from "./RasterLayers" +import { AvailableRasterLayers, RasterLayerPolygon, RasterLayerUtils } from "./RasterLayers" import LayoutSource from "../Logic/FeatureSource/Sources/LayoutSource" import StaticFeatureSource from "../Logic/FeatureSource/Sources/StaticFeatureSource" import FeaturePropertiesStore from "../Logic/FeatureSource/Actors/FeaturePropertiesStore" @@ -28,24 +32,24 @@ import TitleHandler from "../Logic/Actors/TitleHandler" import ChangeToElementsActor from "../Logic/Actors/ChangeToElementsActor" import PendingChangesUploader from "../Logic/Actors/PendingChangesUploader" import SelectedElementTagsUpdater from "../Logic/Actors/SelectedElementTagsUpdater" -import {BBox} from "../Logic/BBox" +import { BBox } from "../Logic/BBox" import Constants from "./Constants" import Hotkeys from "../UI/Base/Hotkeys" import Translations from "../UI/i18n/Translations" -import {GeoIndexedStoreForLayer} from "../Logic/FeatureSource/Actors/GeoIndexedStore" -import {LastClickFeatureSource} from "../Logic/FeatureSource/Sources/LastClickFeatureSource" -import {MenuState} from "./MenuState" +import { GeoIndexedStoreForLayer } from "../Logic/FeatureSource/Actors/GeoIndexedStore" +import { LastClickFeatureSource } from "../Logic/FeatureSource/Sources/LastClickFeatureSource" +import { MenuState } from "./MenuState" import MetaTagging from "../Logic/MetaTagging" import ChangeGeometryApplicator from "../Logic/FeatureSource/Sources/ChangeGeometryApplicator" -import {NewGeometryFromChangesFeatureSource} from "../Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource" +import { NewGeometryFromChangesFeatureSource } from "../Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource" import OsmObjectDownloader from "../Logic/Osm/OsmObjectDownloader" import ShowOverlayRasterLayer from "../UI/Map/ShowOverlayRasterLayer" -import {Utils} from "../Utils" -import {EliCategory} from "./RasterLayerProperties" +import { Utils } from "../Utils" +import { EliCategory } from "./RasterLayerProperties" import BackgroundLayerResetter from "../Logic/Actors/BackgroundLayerResetter" import SaveFeatureSourceToLocalStorage from "../Logic/FeatureSource/Actors/SaveFeatureSourceToLocalStorage" import BBoxFeatureSource from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource" -import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor"; +import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor" /** * @@ -146,7 +150,7 @@ export default class ThemeViewState implements SpecialVisualizationState { rasterInfo.defaultState ?? true, "Wether or not overlayer layer " + rasterInfo.id + " is shown" ) - const state = {isDisplayed} + const state = { isDisplayed } overlayLayerStates.set(rasterInfo.id, state) new ShowOverlayRasterLayer(rasterInfo, this.map, this.mapProperties, state) } @@ -158,8 +162,7 @@ export default class ThemeViewState implements SpecialVisualizationState { * A bit tricky, as this is heavily intertwined with the 'changes'-element, which generate a stream of new and changed features too */ - - if (this.layout.layers.some(l => l._needsFullNodeDatabase)) { + if (this.layout.layers.some((l) => l._needsFullNodeDatabase)) { this.fullNodeDatabase = new FullNodeDatabaseSource() } @@ -176,18 +179,18 @@ export default class ThemeViewState implements SpecialVisualizationState { let currentViewIndex = 0 this.currentView = new StaticFeatureSource( this.mapProperties.bounds.map((bbox) => { - if (!bbox) { - return empty - } - currentViewIndex++ - return [bbox.asGeoJson({ - zoom: this.mapProperties.zoom.data, - ...this.mapProperties.location.data, - id: "current_view" - } - )]; + if (!bbox) { + return empty } - ) + currentViewIndex++ + return [ + bbox.asGeoJson({ + zoom: this.mapProperties.zoom.data, + ...this.mapProperties.location.data, + id: "current_view", + }), + ] + }) ) this.featuresInView = new BBoxFeatureSource(layoutSource, this.mapProperties.bounds) this.dataIsLoading = layoutSource.isLoading @@ -355,7 +358,7 @@ export default class ThemeViewState implements SpecialVisualizationState { private initHotkeys() { Hotkeys.RegisterHotkey( - {nomod: "Escape", onUp: true}, + { nomod: "Escape", onUp: true }, Translations.t.hotkeyDocumentation.closeSidebar, () => { this.selectedElement.setData(undefined) @@ -376,7 +379,7 @@ export default class ThemeViewState implements SpecialVisualizationState { ) Hotkeys.RegisterHotkey( - {shift: "O"}, + { shift: "O" }, Translations.t.hotkeyDocumentation.selectMapnik, () => { this.mapProperties.rasterLayer.setData(AvailableRasterLayers.osmCarto) @@ -395,17 +398,17 @@ export default class ThemeViewState implements SpecialVisualizationState { } Hotkeys.RegisterHotkey( - {nomod: "O"}, + { nomod: "O" }, Translations.t.hotkeyDocumentation.selectOsmbasedmap, () => setLayerCategory("osmbasedmap") ) - Hotkeys.RegisterHotkey({nomod: "M"}, Translations.t.hotkeyDocumentation.selectMap, () => + Hotkeys.RegisterHotkey({ nomod: "M" }, Translations.t.hotkeyDocumentation.selectMap, () => setLayerCategory("map") ) Hotkeys.RegisterHotkey( - {nomod: "P"}, + { nomod: "P" }, Translations.t.hotkeyDocumentation.selectAerial, () => setLayerCategory("photo") ) @@ -473,10 +476,10 @@ export default class ThemeViewState implements SpecialVisualizationState { ), range: new StaticFeatureSource( this.mapProperties.maxbounds.map((bbox) => - bbox === undefined ? empty : [bbox.asGeoJson({id: "range"})] + bbox === undefined ? empty : [bbox.asGeoJson({ id: "range" })] ) ), - current_view: this.currentView + current_view: this.currentView, } if (this.layout?.lockLocation) { const bbox = new BBox(this.layout.lockLocation) @@ -487,12 +490,19 @@ export default class ThemeViewState implements SpecialVisualizationState { this.featureSwitches.featureSwitchIsTesting ) } - const currentViewLayer = this.layout.layers.find(l => l.id === "current_view") + const currentViewLayer = this.layout.layers.find((l) => l.id === "current_view") if (currentViewLayer?.tagRenderings?.length > 0) { const params = MetaTagging.createExtraFuncParams(this) this.featureProperties.trackFeatureSource(specialLayers.current_view) - specialLayers.current_view.features.addCallbackAndRunD(features => { - MetaTagging.addMetatags(features, params, currentViewLayer, this.layout, this.osmObjectDownloader, this.featureProperties) + specialLayers.current_view.features.addCallbackAndRunD((features) => { + MetaTagging.addMetatags( + features, + params, + currentViewLayer, + this.layout, + this.osmObjectDownloader, + this.featureProperties + ) }) } @@ -537,7 +547,7 @@ export default class ThemeViewState implements SpecialVisualizationState { }) } { - this.selectedElement.addCallback(selected => { + this.selectedElement.addCallback((selected) => { if (selected === undefined) { // We did _unselect_ an item - we always remove the lastclick-object this.lastClickObject.features.setData([]) diff --git a/Models/Unit.ts b/Models/Unit.ts index 8b0f9adee..b28663e43 100644 --- a/Models/Unit.ts +++ b/Models/Unit.ts @@ -123,8 +123,15 @@ export class Unit { ) ) - if(json.defaultInput && !applicable.some(denom => denom.canonical.trim() === json.defaultInput)){ - throw `${ctx}: no denomination has the specified default denomination. The default denomination is '${json.defaultInput}', but the available denominations are ${applicable.map(denom => denom.canonical).join(", ")}` + if ( + json.defaultInput && + !applicable.some((denom) => denom.canonical.trim() === json.defaultInput) + ) { + throw `${ctx}: no denomination has the specified default denomination. The default denomination is '${ + json.defaultInput + }', but the available denominations are ${applicable + .map((denom) => denom.canonical) + .join(", ")}` } return new Unit(appliesTo, applicable, json.eraseInvalidValues ?? false) } diff --git a/StylesheetTestGui.ts b/StylesheetTestGui.ts index 2ebe1dfbb..6f6fe84c4 100644 --- a/StylesheetTestGui.ts +++ b/StylesheetTestGui.ts @@ -1,4 +1,4 @@ -import SvelteUIElement from "./UI/Base/SvelteUIElement"; -import StylesheetTestGui from "./UI/StylesheetTestGui.svelte"; +import SvelteUIElement from "./UI/Base/SvelteUIElement" +import StylesheetTestGui from "./UI/StylesheetTestGui.svelte" new SvelteUIElement(StylesheetTestGui, {}).AttachTo("main") diff --git a/UI/AllThemesGui.ts b/UI/AllThemesGui.ts index 722eec27e..437fb3ac4 100644 --- a/UI/AllThemesGui.ts +++ b/UI/AllThemesGui.ts @@ -9,8 +9,8 @@ import IndexText from "./BigComponents/IndexText" import { LoginToggle } from "./Popup/LoginButton" import { ImmutableStore } from "../Logic/UIEventSource" import { OsmConnection } from "../Logic/Osm/OsmConnection" -import {QueryParameters} from "../Logic/Web/QueryParameters"; -import {OsmConnectionFeatureSwitches} from "../Logic/State/FeatureSwitchState"; +import { QueryParameters } from "../Logic/Web/QueryParameters" +import { OsmConnectionFeatureSwitches } from "../Logic/State/FeatureSwitchState" export default class AllThemesGui { setup() { @@ -27,9 +27,10 @@ export default class AllThemesGui { }) const state = new UserRelatedState(osmConnection) const intro = new Combine([ - new LanguagePicker(Translations.t.index.title.SupportedLanguages(), state.language).SetClass( - "flex absolute top-2 right-3" - ), + new LanguagePicker( + Translations.t.index.title.SupportedLanguages(), + state.language + ).SetClass("flex absolute top-2 right-3"), new IndexText(), ]) new Combine([ diff --git a/UI/Base/BackButton.svelte b/UI/Base/BackButton.svelte index e39baa243..4b005e5d0 100644 --- a/UI/Base/BackButton.svelte +++ b/UI/Base/BackButton.svelte @@ -1,17 +1,20 @@ - dispatch("click")} options={{extraClasses:clss+ " flex items-center"}}> - - + dispatch("click")} + options={{ extraClasses: clss + " flex items-center" }} +> + + diff --git a/UI/Base/Checkbox.svelte b/UI/Base/Checkbox.svelte index 93fec9483..010992df9 100644 --- a/UI/Base/Checkbox.svelte +++ b/UI/Base/Checkbox.svelte @@ -1,13 +1,12 @@ diff --git a/UI/Base/DragInvitation.svelte b/UI/Base/DragInvitation.svelte index 93b1265c4..fda880f07 100644 --- a/UI/Base/DragInvitation.svelte +++ b/UI/Base/DragInvitation.svelte @@ -3,84 +3,82 @@ * This overlay element will regularly show a hand that swipes over the underlying element. * This element will hide as soon as the Store 'hideSignal' receives a change (which is not undefined) */ - import { Store } from "../../Logic/UIEventSource"; - import { onDestroy } from "svelte"; + import { Store } from "../../Logic/UIEventSource" + import { onDestroy } from "svelte" - let mainElem: HTMLElement; - export let hideSignal: Store; - function hide(){ - mainElem.style.visibility = "hidden"; + let mainElem: HTMLElement + export let hideSignal: Store + function hide() { + mainElem.style.visibility = "hidden" } if (hideSignal) { - onDestroy(hideSignal.addCallbackD(() => { - console.log("Received hide signal") - hide() - return true; - })); + onDestroy( + hideSignal.addCallbackD(() => { + console.log("Received hide signal") + hide() + return true + }) + ) } - -$: { - mainElem?.addEventListener("click",_ => hide()) - mainElem?.addEventListener("touchstart",_ => hide()) -} - + $: { + mainElem?.addEventListener("click", (_) => hide()) + mainElem?.addEventListener("touchstart", (_) => hide()) + } +
- +
diff --git a/UI/Base/Dropdown.svelte b/UI/Base/Dropdown.svelte index 2e711d954..0d4767bdb 100644 --- a/UI/Base/Dropdown.svelte +++ b/UI/Base/Dropdown.svelte @@ -1,15 +1,14 @@ - + diff --git a/UI/Base/FloatOver.svelte b/UI/Base/FloatOver.svelte index e7c4a0ca5..756f67cfc 100644 --- a/UI/Base/FloatOver.svelte +++ b/UI/Base/FloatOver.svelte @@ -1,31 +1,36 @@ -
-
-
- -
- - -
dispatch("close")}> - -
-
+
+
+
+
+ + +
dispatch("close")} + > + +
+
+
- diff --git a/UI/Base/Table.ts b/UI/Base/Table.ts index b5ee42531..e27dbff89 100644 --- a/UI/Base/Table.ts +++ b/UI/Base/Table.ts @@ -78,7 +78,7 @@ export default class Table extends BaseUIElement { for (let j = 0; j < row.length; j++) { try { let elem = row[j] - if(elem?.ConstructElement === undefined){ + if (elem?.ConstructElement === undefined) { continue } const htmlElem = elem?.ConstructElement() diff --git a/UI/Base/ToSvelte.svelte b/UI/Base/ToSvelte.svelte index 7edaddf1b..01386bf90 100644 --- a/UI/Base/ToSvelte.svelte +++ b/UI/Base/ToSvelte.svelte @@ -1,23 +1,21 @@ diff --git a/UI/Base/Tr.svelte b/UI/Base/Tr.svelte index 120b0e4c4..2f1a80a7f 100644 --- a/UI/Base/Tr.svelte +++ b/UI/Base/Tr.svelte @@ -2,36 +2,37 @@ /** * Properly renders a translation */ - import { Translation } from "../i18n/Translation"; - import { onDestroy } from "svelte"; - import Locale from "../i18n/Locale"; - import { Utils } from "../../Utils"; - import FromHtml from "./FromHtml.svelte"; - import WeblateLink from "./WeblateLink.svelte"; + import { Translation } from "../i18n/Translation" + import { onDestroy } from "svelte" + import Locale from "../i18n/Locale" + import { Utils } from "../../Utils" + import FromHtml from "./FromHtml.svelte" + import WeblateLink from "./WeblateLink.svelte" - export let t: Translation; + export let t: Translation export let cls: string = "" - export let tags: Record | undefined = undefined; + export let tags: Record | undefined = undefined // Text for the current language - let txt: string | undefined; - - $: onDestroy(Locale.language.addCallbackAndRunD(l => { - const translation = t?.textFor(l); - if (translation === undefined) { - return; - } - if (tags) { - txt = Utils.SubstituteKeys(txt, tags); - } else { - txt = translation; - } - })); + let txt: string | undefined + $: onDestroy( + Locale.language.addCallbackAndRunD((l) => { + const translation = t?.textFor(l) + if (translation === undefined) { + return + } + if (tags) { + txt = Utils.SubstituteKeys(txt, tags) + } else { + txt = translation + } + }) + ) {#if t} - - + + {/if} diff --git a/UI/Base/WeblateLink.svelte b/UI/Base/WeblateLink.svelte index 7a4b04274..868d1c407 100644 --- a/UI/Base/WeblateLink.svelte +++ b/UI/Base/WeblateLink.svelte @@ -1,25 +1,32 @@ - {#if !!context && context.indexOf(":") > 0} {#if $linkOnMobile} -
+ {:else if $linkToWeblate} - + {/if} diff --git a/UI/BigComponents/BackgroundSwitcher.svelte b/UI/BigComponents/BackgroundSwitcher.svelte index 1ff64c5f1..257901e6d 100644 --- a/UI/BigComponents/BackgroundSwitcher.svelte +++ b/UI/BigComponents/BackgroundSwitcher.svelte @@ -1,80 +1,88 @@ +
-
- - -
-
- -
- -
- - +
+ + +
+
+
+
+ + +
diff --git a/UI/BigComponents/CopyrightPanel.ts b/UI/BigComponents/CopyrightPanel.ts index d4d03763f..988a802ca 100644 --- a/UI/BigComponents/CopyrightPanel.ts +++ b/UI/BigComponents/CopyrightPanel.ts @@ -1,25 +1,25 @@ import Combine from "../Base/Combine" import Translations from "../i18n/Translations" -import {Store} from "../../Logic/UIEventSource" -import {FixedUiElement} from "../Base/FixedUiElement" +import { Store } from "../../Logic/UIEventSource" +import { FixedUiElement } from "../Base/FixedUiElement" import licenses from "../../assets/generated/license_info.json" import SmallLicense from "../../Models/smallLicense" -import {Utils} from "../../Utils" +import { Utils } from "../../Utils" import Link from "../Base/Link" -import {VariableUiElement} from "../Base/VariableUIElement" +import { VariableUiElement } from "../Base/VariableUIElement" import contributors from "../../assets/contributors.json" import translators from "../../assets/translators.json" import BaseUIElement from "../BaseUIElement" import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" import Title from "../Base/Title" -import {BBox} from "../../Logic/BBox" -import {OsmConnection} from "../../Logic/Osm/OsmConnection" +import { BBox } from "../../Logic/BBox" +import { OsmConnection } from "../../Logic/Osm/OsmConnection" import Constants from "../../Models/Constants" import ContributorCount from "../../Logic/ContributorCount" import Img from "../Base/Img" -import {TypedTranslation} from "../i18n/Translation" +import { TypedTranslation } from "../i18n/Translation" import GeoIndexedStore from "../../Logic/FeatureSource/Actors/GeoIndexedStore" -import {RasterLayerPolygon} from "../../Models/RasterLayers"; +import { RasterLayerPolygon } from "../../Models/RasterLayers" /** * The attribution panel in the theme menu. @@ -29,7 +29,10 @@ export default class CopyrightPanel extends Combine { constructor(state: { layout: LayoutConfig - mapProperties: { readonly bounds: Store, readonly rasterLayer: Store } + mapProperties: { + readonly bounds: Store + readonly rasterLayer: Store + } osmConnection: OsmConnection dataIsLoading: Store perLayer: ReadonlyMap @@ -90,27 +93,34 @@ export default class CopyrightPanel extends Combine { new Title(t.attributionTitle), t.attributionContent, - new VariableUiElement(state.mapProperties.rasterLayer.mapD(layer => { - const props = layer.properties - const attrUrl = props.attribution?.url - const attrText = props.attribution?.text + new VariableUiElement( + state.mapProperties.rasterLayer.mapD((layer) => { + const props = layer.properties + const attrUrl = props.attribution?.url + const attrText = props.attribution?.text - let bgAttr: BaseUIElement | string = undefined - if(attrText && attrUrl){ - bgAttr = ""+attrText+"" - }else if(attrUrl){ - bgAttr = attrUrl - }else{ - bgAttr = attrText - } - if(bgAttr){ - return Translations.t.general.attribution.attributionBackgroundLayerWithCopyright.Subs({ - name: props.name, - copyright: bgAttr - }) - } - return Translations.t.general.attribution.attributionBackgroundLayer.Subs(props) - })), + let bgAttr: BaseUIElement | string = undefined + if (attrText && attrUrl) { + bgAttr = + "" + attrText + "" + } else if (attrUrl) { + bgAttr = attrUrl + } else { + bgAttr = attrText + } + if (bgAttr) { + return Translations.t.general.attribution.attributionBackgroundLayerWithCopyright.Subs( + { + name: props.name, + copyright: bgAttr, + } + ) + } + return Translations.t.general.attribution.attributionBackgroundLayer.Subs( + props + ) + }) + ), maintainer, dataContributors, diff --git a/UI/BigComponents/ExtraLinkButton.ts b/UI/BigComponents/ExtraLinkButton.ts index d08bb73a7..c34ba305b 100644 --- a/UI/BigComponents/ExtraLinkButton.ts +++ b/UI/BigComponents/ExtraLinkButton.ts @@ -1,21 +1,21 @@ -import {UIElement} from "../UIElement" +import { UIElement } from "../UIElement" import BaseUIElement from "../BaseUIElement" -import {Store} from "../../Logic/UIEventSource" +import { Store } from "../../Logic/UIEventSource" import ExtraLinkConfig from "../../Models/ThemeConfig/ExtraLinkConfig" import Img from "../Base/Img" -import {SubtleButton} from "../Base/SubtleButton" +import { SubtleButton } from "../Base/SubtleButton" import Toggle from "../Input/Toggle" import Locale from "../i18n/Locale" -import {Utils} from "../../Utils" +import { Utils } from "../../Utils" import Svg from "../../Svg" import Translations from "../i18n/Translations" -import {Translation} from "../i18n/Translation" +import { Translation } from "../i18n/Translation" interface ExtraLinkButtonState { layout: { id: string; title: Translation } - featureSwitches: { featureSwitchWelcomeMessage: Store }, + featureSwitches: { featureSwitchWelcomeMessage: Store } mapProperties: { - location: Store<{ lon: number, lat: number }>; + location: Store<{ lon: number; lat: number }> zoom: Store } } @@ -23,10 +23,7 @@ export default class ExtraLinkButton extends UIElement { private readonly _config: ExtraLinkConfig private readonly state: ExtraLinkButtonState - constructor( - state: ExtraLinkButtonState, - config: ExtraLinkConfig - ) { + constructor(state: ExtraLinkButtonState, config: ExtraLinkConfig) { super() this.state = state this._config = config @@ -45,21 +42,24 @@ export default class ExtraLinkButton extends UIElement { } if (c.requirements?.has("no-iframe") && isIframe) { - return undefined + return undefined } let link: BaseUIElement const theme = this.state.layout?.id ?? "" const basepath = window.location.host - const href = this.state.mapProperties.location.map((loc) => { - const subs = { - ...loc, - theme: theme, - basepath, - language: Locale.language.data, - } - return Utils.SubstituteKeys(c.href, subs) - }, [this.state.mapProperties.zoom]) + const href = this.state.mapProperties.location.map( + (loc) => { + const subs = { + ...loc, + theme: theme, + basepath, + language: Locale.language.data, + } + return Utils.SubstituteKeys(c.href, subs) + }, + [this.state.mapProperties.zoom] + ) let img: BaseUIElement = Svg.pop_out_svg() if (c.icon !== undefined) { @@ -81,11 +81,19 @@ export default class ExtraLinkButton extends UIElement { }) if (c.requirements?.has("no-welcome-message")) { - link = new Toggle(undefined, link, this.state.featureSwitches.featureSwitchWelcomeMessage) + link = new Toggle( + undefined, + link, + this.state.featureSwitches.featureSwitchWelcomeMessage + ) } if (c.requirements?.has("welcome-message")) { - link = new Toggle(link, undefined, this.state.featureSwitches.featureSwitchWelcomeMessage) + link = new Toggle( + link, + undefined, + this.state.featureSwitches.featureSwitchWelcomeMessage + ) } return link diff --git a/UI/BigComponents/Filterview.svelte b/UI/BigComponents/Filterview.svelte index 6275dcd81..051c78fa3 100644 --- a/UI/BigComponents/Filterview.svelte +++ b/UI/BigComponents/Filterview.svelte @@ -1,107 +1,110 @@ - + {#if filteredLayer.layerDef.name} -
-
{/if} - diff --git a/UI/BigComponents/FilterviewWithFields.svelte b/UI/BigComponents/FilterviewWithFields.svelte index f482b57e9..240997d7a 100644 --- a/UI/BigComponents/FilterviewWithFields.svelte +++ b/UI/BigComponents/FilterviewWithFields.svelte @@ -1,60 +1,61 @@
- {#each parts as part, i} - {#if part.subs} - - - - - {:else} - {part.message} - {/if} - {/each} + {#each parts as part, i} + {#if part.subs} + + + + + {:else} + {part.message} + {/if} + {/each}
diff --git a/UI/BigComponents/Geosearch.svelte b/UI/BigComponents/Geosearch.svelte index 1b885a14e..67e2ba164 100644 --- a/UI/BigComponents/Geosearch.svelte +++ b/UI/BigComponents/Geosearch.svelte @@ -1,119 +1,116 @@
-
- - {#if isRunning} - {Translations.t.general.search.searching} - {:else if feedback !== undefined} -
feedback = undefined}> - {feedback} -
- {:else } - keypr.key === "Enter" ? performSearch() : undefined} - - bind:value={searchContents} - placeholder={Translations.t.general.search.search}> - {/if} - -
-
- -
+
+ {#if isRunning} + {Translations.t.general.search.searching} + {:else if feedback !== undefined} +
(feedback = undefined)}> + {feedback} +
+ {:else} + (keypr.key === "Enter" ? performSearch() : undefined)} + bind:value={searchContents} + placeholder={Translations.t.general.search.search} + /> + {/if} +
+
+ +
diff --git a/UI/BigComponents/HiddenThemeList.svelte b/UI/BigComponents/HiddenThemeList.svelte index 288d85a30..50ab4e9db 100644 --- a/UI/BigComponents/HiddenThemeList.svelte +++ b/UI/BigComponents/HiddenThemeList.svelte @@ -1,53 +1,50 @@ - - - -

{t.previouslyHiddenTitle.toString()}

-

- {t.hiddenExplanation.Subs({ - hidden_discovered: knownThemes.length.toString(), - total_hidden: hiddenThemes.length.toString(), - })} -

-
-
- + + +

{t.previouslyHiddenTitle.toString()}

+

+ {t.hiddenExplanation.Subs({ + hidden_discovered: knownThemes.length.toString(), + total_hidden: hiddenThemes.length.toString(), + })} +

+
+
diff --git a/UI/BigComponents/LevelSelector.svelte b/UI/BigComponents/LevelSelector.svelte index 9734cd9a0..3173ef248 100644 --- a/UI/BigComponents/LevelSelector.svelte +++ b/UI/BigComponents/LevelSelector.svelte @@ -2,28 +2,31 @@ /** * Shows a 'floorSelector' and maps the selected floor onto a global filter */ - import LayerState from "../../Logic/State/LayerState"; - import FloorSelector from "../InputElement/Helpers/FloorSelector.svelte"; - import { Store, UIEventSource } from "../../Logic/UIEventSource"; + import LayerState from "../../Logic/State/LayerState" + import FloorSelector from "../InputElement/Helpers/FloorSelector.svelte" + import { Store, UIEventSource } from "../../Logic/UIEventSource" - export let layerState: LayerState; - export let floors: Store; - export let zoom: Store; + export let layerState: LayerState + export let floors: Store + export let zoom: Store const maxZoom = 16 - let selectedFloor: UIEventSource = new UIEventSource(undefined); - - selectedFloor.stabilized(5).map(floor => { - if(floors.data === undefined || floors.data.length <= 1 || zoom.data < maxZoom){ - // Only a single floor is visible -> disable the 'level' global filter - // OR we might have zoomed out to much ant want to show all - layerState.setLevelFilter(undefined) - }else{ - layerState.setLevelFilter(floor) - } - }, [floors, zoom]) - + let selectedFloor: UIEventSource = new UIEventSource(undefined) + + selectedFloor.stabilized(5).map( + (floor) => { + if (floors.data === undefined || floors.data.length <= 1 || zoom.data < maxZoom) { + // Only a single floor is visible -> disable the 'level' global filter + // OR we might have zoomed out to much ant want to show all + layerState.setLevelFilter(undefined) + } else { + layerState.setLevelFilter(floor) + } + }, + [floors, zoom] + ) + {#if $zoom >= maxZoom} - - {/if} + +{/if} diff --git a/UI/BigComponents/MapillaryLink.svelte b/UI/BigComponents/MapillaryLink.svelte index fd6ee332c..2daf269e1 100644 --- a/UI/BigComponents/MapillaryLink.svelte +++ b/UI/BigComponents/MapillaryLink.svelte @@ -1,31 +1,29 @@ - Svg.mapillary_black_svg().SetClass("w-12 h-12 m-2 mr-4 shrink-0")}/> -
- - -
+ Svg.mapillary_black_svg().SetClass("w-12 h-12 m-2 mr-4 shrink-0")} /> +
+ + +
diff --git a/UI/BigComponents/MoreScreen.ts b/UI/BigComponents/MoreScreen.ts index b8ce36933..045bf3ec5 100644 --- a/UI/BigComponents/MoreScreen.ts +++ b/UI/BigComponents/MoreScreen.ts @@ -1,12 +1,12 @@ import Svg from "../../Svg" import Combine from "../Base/Combine" import Translations from "../i18n/Translations" -import LayoutConfig, {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig" -import {ImmutableStore, Store} from "../../Logic/UIEventSource" +import LayoutConfig, { LayoutInformation } from "../../Models/ThemeConfig/LayoutConfig" +import { ImmutableStore, Store } from "../../Logic/UIEventSource" import UserRelatedState from "../../Logic/State/UserRelatedState" -import {Utils} from "../../Utils" +import { Utils } from "../../Utils" import themeOverview from "../../assets/generated/theme_overview.json" -import {TextField} from "../Input/TextField" +import { TextField } from "../Input/TextField" import Locale from "../i18n/Locale" import SvelteUIElement from "../Base/SvelteUIElement" import ThemesList from "./ThemesList.svelte" @@ -29,7 +29,7 @@ export default class MoreScreen extends Combine { }) search.enterPressed.addCallbackD((searchTerm) => { searchTerm = searchTerm.toLowerCase() - if(!searchTerm){ + if (!searchTerm) { return } if (searchTerm === "personal") { diff --git a/UI/BigComponents/NewPointLocationInput.svelte b/UI/BigComponents/NewPointLocationInput.svelte index 01c942c74..660fa14f7 100644 --- a/UI/BigComponents/NewPointLocationInput.svelte +++ b/UI/BigComponents/NewPointLocationInput.svelte @@ -1,108 +1,113 @@ - - + diff --git a/UI/BigComponents/NoThemeResultButton.svelte b/UI/BigComponents/NoThemeResultButton.svelte index fa362a1bb..2b83ca1d0 100644 --- a/UI/BigComponents/NoThemeResultButton.svelte +++ b/UI/BigComponents/NoThemeResultButton.svelte @@ -1,35 +1,34 @@
-
{t.noMatchingThemes.toString()}
-
- - -
+
{t.noMatchingThemes.toString()}
+
+ +
diff --git a/UI/BigComponents/OpenBackgroundSelectorButton.svelte b/UI/BigComponents/OpenBackgroundSelectorButton.svelte index af9c6a4d0..e28e23b88 100644 --- a/UI/BigComponents/OpenBackgroundSelectorButton.svelte +++ b/UI/BigComponents/OpenBackgroundSelectorButton.svelte @@ -1,12 +1,11 @@ state.guistate.backgroundLayerSelectionIsOpened.setData(true)}> - + diff --git a/UI/BigComponents/OpenIdEditor.svelte b/UI/BigComponents/OpenIdEditor.svelte index 10c1556d6..8ab6f99ca 100644 --- a/UI/BigComponents/OpenIdEditor.svelte +++ b/UI/BigComponents/OpenIdEditor.svelte @@ -1,33 +1,32 @@ - - - + + diff --git a/UI/BigComponents/OpenJosm.ts b/UI/BigComponents/OpenJosm.ts index 9428adfe7..352082a7c 100644 --- a/UI/BigComponents/OpenJosm.ts +++ b/UI/BigComponents/OpenJosm.ts @@ -1,14 +1,14 @@ -import Combine from "../Base/Combine"; -import {OsmConnection} from "../../Logic/Osm/OsmConnection"; -import {Store, UIEventSource} from "../../Logic/UIEventSource"; -import {BBox} from "../../Logic/BBox"; -import Translations from "../i18n/Translations"; -import {VariableUiElement} from "../Base/VariableUIElement"; -import Toggle from "../Input/Toggle"; -import {SubtleButton} from "../Base/SubtleButton"; -import Svg from "../../Svg"; -import {Utils} from "../../Utils"; -import Constants from "../../Models/Constants"; +import Combine from "../Base/Combine" +import { OsmConnection } from "../../Logic/Osm/OsmConnection" +import { Store, UIEventSource } from "../../Logic/UIEventSource" +import { BBox } from "../../Logic/BBox" +import Translations from "../i18n/Translations" +import { VariableUiElement } from "../Base/VariableUIElement" +import Toggle from "../Input/Toggle" +import { SubtleButton } from "../Base/SubtleButton" +import Svg from "../../Svg" +import { Utils } from "../../Utils" +import Constants from "../../Models/Constants" export class OpenJosm extends Combine { constructor(osmConnection: OsmConnection, bounds: Store, iconStyle?: string) { @@ -32,20 +32,22 @@ export class OpenJosm extends Combine { ) const toggle = new Toggle( - new SubtleButton(Svg.josm_logo_svg().SetStyle(iconStyle), t.editJosm).onClick(() => { - const bbox = bounds.data - if (bbox === undefined) { - return - } - const top = bbox.getNorth() - const bottom = bbox.getSouth() - const right = bbox.getEast() - const left = bbox.getWest() - const josmLink = `http://127.0.0.1:8111/load_and_zoom?left=${left}&right=${right}&top=${top}&bottom=${bottom}` - Utils.download(josmLink) - .then((answer) => josmState.setData(answer.replace(/\n/g, "").trim())) - .catch((_) => josmState.setData("ERROR")) - }).SetClass("w-full"), + new SubtleButton(Svg.josm_logo_svg().SetStyle(iconStyle), t.editJosm) + .onClick(() => { + const bbox = bounds.data + if (bbox === undefined) { + return + } + const top = bbox.getNorth() + const bottom = bbox.getSouth() + const right = bbox.getEast() + const left = bbox.getWest() + const josmLink = `http://127.0.0.1:8111/load_and_zoom?left=${left}&right=${right}&top=${top}&bottom=${bottom}` + Utils.download(josmLink) + .then((answer) => josmState.setData(answer.replace(/\n/g, "").trim())) + .catch((_) => josmState.setData("ERROR")) + }) + .SetClass("w-full"), undefined, osmConnection.userDetails.map( (ud) => ud.loggedIn && ud.csCount >= Constants.userJourney.historyLinkVisible diff --git a/UI/BigComponents/OverlayToggle.svelte b/UI/BigComponents/OverlayToggle.svelte index 6d5961f25..d7d5c0c62 100644 --- a/UI/BigComponents/OverlayToggle.svelte +++ b/UI/BigComponents/OverlayToggle.svelte @@ -1,42 +1,45 @@ - + {#if layerproperties.name}