diff --git a/.eslintignore b/.eslintignore index 944effc72..848b6b004 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ src/test.ts android/* +src/assets/generated/* diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ff3f3e8f9..18adaa757 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,4 +24,7 @@ module.exports = { browser: true, node: true, }, + rules:{ + '@typescript-eslint/no-explicit-any': 'off' + } } diff --git a/src/Customizations/AllSharedLayers.ts b/src/Customizations/AllSharedLayers.ts index 64a461bb4..8905b89bd 100644 --- a/src/Customizations/AllSharedLayers.ts +++ b/src/Customizations/AllSharedLayers.ts @@ -11,7 +11,7 @@ export class AllSharedLayers { if (layer.id === undefined) { continue } - sharedLayers.set(layer.id, layer) + sharedLayers.set(layer.id, layer) } return sharedLayers @@ -20,7 +20,6 @@ export class AllSharedLayers { const sharedLayers = new Map() for (const layer of known_layers["layers"]) { try { - // @ts-ignore const parsed = new LayerConfig(layer, "shared_layers") sharedLayers.set(layer.id, parsed) } catch (e) { diff --git a/src/Logic/Actors/PreferredRasterLayerSelector.ts b/src/Logic/Actors/PreferredRasterLayerSelector.ts index 4e9bbbf69..2e4713aeb 100644 --- a/src/Logic/Actors/PreferredRasterLayerSelector.ts +++ b/src/Logic/Actors/PreferredRasterLayerSelector.ts @@ -27,32 +27,30 @@ export class PreferredRasterLayerSelector { this._availableLayers = availableLayers this._queryParameter = queryParameter this._preferredBackgroundLayer = preferredBackgroundLayer - const self = this - this._rasterLayerSetting.addCallbackD((layer) => { this._queryParameter.setData(layer.properties.id) }) - this._queryParameter.addCallbackAndRunD((_) => { - const isApplied = self.updateLayer() + this._queryParameter.addCallbackAndRunD(() => { + const isApplied = this.updateLayer() if (!isApplied) { // A different layer was set as background // We remove this queryParameter instead - self._queryParameter.setData(undefined) + this._queryParameter.setData(undefined) return true // Unregister } }) - this._preferredBackgroundLayer.addCallbackD((_) => self.updateLayer()) + this._preferredBackgroundLayer.addCallbackD(() => this.updateLayer()) rasterLayerSetting.addCallbackAndRunD((layer) => { if (AvailableRasterLayers.globalLayers.find((l) => l.id === layer.properties.id)) { return } - this._availableLayers.store.addCallbackD((_) => self.updateLayer()) + this._availableLayers.store.addCallbackD(() => this.updateLayer()) return true // unregister }) - self.updateLayer() + this.updateLayer() } /** diff --git a/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts b/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts index 47fd12b2d..971c6293b 100644 --- a/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts +++ b/src/Logic/FeatureSource/Actors/FeaturePropertiesStore.ts @@ -83,10 +83,9 @@ export default class FeaturePropertiesStore { } public trackFeatureSource(source: FeatureSource) { - const self = this source.features.addCallbackAndRunD((features) => { for (const feature of features) { - self.trackFeature(feature) + this.trackFeature(feature) } }) } diff --git a/src/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts b/src/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts index 2b252fac8..9f3aadd9a 100644 --- a/src/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts +++ b/src/Logic/FeatureSource/PerLayerFeatureSourceSplitter.ts @@ -24,7 +24,7 @@ export default class PerLayerFeatureSourceSplitter[] = layers.map((_) => new Set()) + let layerIndexes: ReadonlySet[] = layers.map(() => new Set()) this.perLayer = knownLayers const layerSources = new Map>() const constructStore = @@ -47,8 +47,8 @@ export default class PerLayerFeatureSourceSplitter false) - const newIndices: Set[] = layers.map((_) => new Set()) + const hasChanged: boolean[] = layers.map(() => false) + const newIndices: Set[] = layers.map(() => new Set()) const noLayerFound: Feature[] = [] for (const layer of layers) { diff --git a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts index 1e2ab4513..555d16d9b 100644 --- a/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts +++ b/src/Logic/FeatureSource/Sources/FeatureSourceMerger.ts @@ -23,11 +23,10 @@ export default class FeatureSourceMerger>(new Map()) this.featuresById = this._featuresById - const self = this sources = Utils.NoNull(sources) for (const source of sources) { source.features.addCallback(() => { - self.addDataFromSources(sources) + this.addDataFromSources(sources) }) } this._sources = sources diff --git a/src/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts b/src/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts index a6408d1fe..939c270a9 100644 --- a/src/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts +++ b/src/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts @@ -38,8 +38,7 @@ export class NewGeometryFromChangesFeatureSource implements WritableFeatureSourc this._seenChanges = new Set() this._features = this.features.data this._backend = changes.backend - const self = this - changes.pendingChanges.addCallbackAndRunD((changes) => self.handleChanges(changes)) + changes.pendingChanges.addCallbackAndRunD((changes) => this.handleChanges(changes)) } private addNewFeature(feature: Feature) { diff --git a/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts b/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts index e884b1799..0c4c7e96f 100644 --- a/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts +++ b/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts @@ -161,7 +161,6 @@ export default class OsmFeatureSource extends FeatureSourceMerger { this.options?.fullNodeDatabase?.handleOsmJson(osmJson, z, x, y) let features = []>OsmToGeoJson( osmJson, - // @ts-ignore { flatProperties: true, } @@ -175,7 +174,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger { ) for (let i = 0; i < features.length; i++) { - features[i] = await this.patchIncompleteRelations(features[i], osmJson) + features[i] = await this.patchIncompleteRelations(features[i], osmJson) } features = Utils.NoNull(features) features.forEach((f) => { diff --git a/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts b/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts index a1e6be2b8..0c8e6a5ca 100644 --- a/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts +++ b/src/Logic/FeatureSource/TiledFeatureSource/PolygonSourceMerger.ts @@ -4,7 +4,7 @@ import { BBox } from "../../BBox" import { Utils } from "../../../Utils" import { Feature } from "geojson" import { GeoOperations } from "../../GeoOperations" -import DynamicTileSource, { UpdatableDynamicTileSource } from "./DynamicTileSource" +import { UpdatableDynamicTileSource } from "./DynamicTileSource" /** * The PolygonSourceMerger receives various small pieces of bigger polygons and stitches them together. diff --git a/src/Logic/GeoOperations.ts b/src/Logic/GeoOperations.ts index 6eece0674..0c763ee4d 100644 --- a/src/Logic/GeoOperations.ts +++ b/src/Logic/GeoOperations.ts @@ -370,7 +370,7 @@ export class GeoOperations { ): Feature[] { if (way.geometry.type === "Polygon") { const poly: Feature = >way - return poly.geometry.coordinates.map((linestringCoors, i) => { + return poly.geometry.coordinates.map(linestringCoors => { return >{ type: "Feature", geometry: { diff --git a/src/Logic/ImageProviders/GenericImageProvider.ts b/src/Logic/ImageProviders/GenericImageProvider.ts index e73bd8091..1c5d65ed0 100644 --- a/src/Logic/ImageProviders/GenericImageProvider.ts +++ b/src/Logic/ImageProviders/GenericImageProvider.ts @@ -46,7 +46,7 @@ export default class GenericImageProvider extends ImageProvider { return undefined } - public DownloadAttribution(_) { + public DownloadAttribution() { return undefined } diff --git a/src/Logic/Osm/Actions/InsertPointIntoWayAction.ts b/src/Logic/Osm/Actions/InsertPointIntoWayAction.ts index f50e9f9a6..1525fb6fc 100644 --- a/src/Logic/Osm/Actions/InsertPointIntoWayAction.ts +++ b/src/Logic/Osm/Actions/InsertPointIntoWayAction.ts @@ -46,7 +46,6 @@ export default class InsertPointIntoWayAction { console.log("Attempting to snap:", { geojson, projected, projectedCoor, index }) // We check that it isn't close to an already existing point let reusedPointId = undefined - let reusedPointCoordinates: [number, number] = undefined let outerring: [number, number][] if (geojson.geometry.type === "LineString") { @@ -62,7 +61,6 @@ export default class InsertPointIntoWayAction { ) { // We reuse this point instead! reusedPointId = this._snapOnto.nodes[index] - reusedPointCoordinates = this._snapOnto.coordinates[index] } const next = outerring[index + 1] if ( @@ -71,14 +69,13 @@ export default class InsertPointIntoWayAction { ) { // We reuse this point instead! reusedPointId = this._snapOnto.nodes[index + 1] - reusedPointCoordinates = this._snapOnto.coordinates[index + 1] } if (reusedPointId !== undefined) { return undefined } const locations = [ - ...this._snapOnto.coordinates?.map(([lat, lon]) => <[number, number]>[lon, lat]), + ...(this._snapOnto.coordinates ?? []).map(([lat, lon]) => <[number, number]>[lon, lat]), ] const ids = [...this._snapOnto.nodes] diff --git a/src/Logic/Osm/Actions/RelationSplitHandler.ts b/src/Logic/Osm/Actions/RelationSplitHandler.ts index 755cf0080..a6b1bab21 100644 --- a/src/Logic/Osm/Actions/RelationSplitHandler.ts +++ b/src/Logic/Osm/Actions/RelationSplitHandler.ts @@ -181,7 +181,7 @@ export class InPlaceReplacedmentRTSH extends AbstractRelationSplitHandler { super(input, theme, objectDownloader) } - async CreateChangeDescriptions(changes: Changes): Promise { + async CreateChangeDescriptions(): Promise { const wayId = this._input.originalWayId const relation = this._input.relation const members = relation.members diff --git a/src/Logic/Osm/Actions/ReplaceGeometryAction.ts b/src/Logic/Osm/Actions/ReplaceGeometryAction.ts index b8931b164..41f7e8567 100644 --- a/src/Logic/Osm/Actions/ReplaceGeometryAction.ts +++ b/src/Logic/Osm/Actions/ReplaceGeometryAction.ts @@ -382,7 +382,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr >() { // Lets check the unused ids: can they be detached or do they signify some relation with the object? - unusedIds.forEach(({}, id) => { + unusedIds.forEach((_, id) => { const info = nodeInfo.get(id) if (!(info.hasTags || info.partOfWay)) { // Nothing special here, we detach diff --git a/src/Logic/Osm/Actions/SplitAction.ts b/src/Logic/Osm/Actions/SplitAction.ts index efbb21f8f..4b303e138 100644 --- a/src/Logic/Osm/Actions/SplitAction.ts +++ b/src/Logic/Osm/Actions/SplitAction.ts @@ -144,9 +144,6 @@ export default class SplitAction extends OsmChangeAction { // Copy the tags from the original object onto the new const kv = [] for (const k in originalElement.tags) { - if (!originalElement.tags.hasOwnProperty(k)) { - continue - } if (k.startsWith("_") || k === "id") { continue } diff --git a/src/Logic/Osm/aspectedRouting.ts b/src/Logic/Osm/aspectedRouting.ts deleted file mode 100644 index a83477db7..000000000 --- a/src/Logic/Osm/aspectedRouting.ts +++ /dev/null @@ -1,200 +0,0 @@ -export default class AspectedRouting { - public readonly name: string - public readonly description: string - public readonly units: string - public readonly program: any - - public constructor(program) { - this.name = program.name - this.description = program.description - this.units = program.unit - this.program = JSON.parse(JSON.stringify(program)) - delete this.program.name - delete this.program.description - delete this.program.unit - } - - /** - * Interprets the given Aspected-routing program for the given properties - */ - public static interpret(program: any, properties: any) { - if (typeof program !== "object") { - return program - } - - let functionName /*: string*/ = undefined - let functionArguments /*: any */ = undefined - const otherValues = {} - // @ts-ignore - Object.entries(program).forEach((tag) => { - const [key, value] = tag - if (key.startsWith("$")) { - functionName = key - functionArguments = value - } else { - otherValues[key] = value - } - }) - - if (functionName === undefined) { - return AspectedRouting.interpretAsDictionary(program, properties) - } - - if (functionName === "$multiply") { - return AspectedRouting.multiplyScore(properties, functionArguments) - } else if (functionName === "$firstMatchOf") { - return AspectedRouting.getFirstMatchScore(properties, functionArguments) - } else if (functionName === "$min") { - return AspectedRouting.getMinValue(properties, functionArguments) - } else if (functionName === "$max") { - return AspectedRouting.getMaxValue(properties, functionArguments) - } else if (functionName === "$default") { - return AspectedRouting.defaultV(functionArguments, otherValues, properties) - } else { - console.error( - `Error: Program ${functionName} is not implemented yet. ${JSON.stringify(program)}` - ) - } - } - - /** - * Given a 'program' without function invocation, interprets it as a dictionary - * - * E.g., given the program - * - * { - * highway: { - * residential: 30, - * living_street: 20 - * }, - * surface: { - * sett : 0.9 - * } - * - * } - * - * in combination with the tags {highway: residential}, - * - * the result should be [30, undefined]; - * - * For the tags {highway: residential, surface: sett} we should get [30, 0.9] - * - * - * @param program - * @param tags - * @return {(undefined|*)[]} - */ - private static interpretAsDictionary(program, tags) { - // @ts-ignore - return Object.entries(tags).map((tag) => { - const [key, value] = tag - const propertyValue = program[key] - if (propertyValue === undefined) { - return undefined - } - if (typeof propertyValue !== "object") { - return propertyValue - } - // @ts-ignore - return propertyValue[value] - }) - } - - private static defaultV(subProgram, otherArgs, tags) { - // @ts-ignore - const normalProgram = Object.entries(otherArgs)[0][1] - const value = AspectedRouting.interpret(normalProgram, tags) - if (value !== undefined) { - return value - } - return AspectedRouting.interpret(subProgram, tags) - } - - /** - * Multiplies the default score with the proper values - * @param tags {object} the active tags to check against - * @param subprograms which should generate a list of values - * @returns score after multiplication - */ - private static multiplyScore(tags, subprograms) { - let number = 1 - - let subResults: any[] - if (subprograms.length !== undefined) { - subResults = AspectedRouting.concatMap(subprograms, (subprogram) => - AspectedRouting.interpret(subprogram, tags) - ) - } else { - subResults = AspectedRouting.interpret(subprograms, tags) - } - - subResults.filter((r) => r !== undefined).forEach((r) => (number *= parseFloat(r))) - return number.toFixed(2) - } - - private static getFirstMatchScore(tags, order: any) { - /*Order should be a list of arguments after evaluation*/ - order = AspectedRouting.interpret(order, tags) - for (const key of order) { - // @ts-ignore - for (const entry of Object.entries(JSON.parse(tags))) { - const [tagKey, value] = entry - if (key === tagKey) { - // We have a match... let's evaluate the subprogram - const evaluated = AspectedRouting.interpret(value, tags) - if (evaluated !== undefined) { - return evaluated - } - } - } - } - - // Not a single match found... - return undefined - } - - private static getMinValue(tags, subprogram) { - const minArr = subprogram - .map((part) => { - if (typeof part === "object") { - const calculatedValue = this.interpret(part, tags) - return parseFloat(calculatedValue) - } else { - return parseFloat(part) - } - }) - .filter((v) => !isNaN(v)) - return Math.min(...minArr) - } - - private static getMaxValue(tags, subprogram) { - const maxArr = subprogram - .map((part) => { - if (typeof part === "object") { - return parseFloat(AspectedRouting.interpret(part, tags)) - } else { - return parseFloat(part) - } - }) - .filter((v) => !isNaN(v)) - return Math.max(...maxArr) - } - - private static concatMap(list, f): any[] { - const result = [] - list = list.map(f) - for (const elem of list) { - if (elem.length !== undefined) { - // This is a list - result.push(...elem) - } else { - result.push(elem) - } - } - return result - } - - public evaluate(properties) { - return AspectedRouting.interpret(this.program, properties) - } -} diff --git a/src/Models/ThemeConfig/DependencyCalculator.ts b/src/Models/ThemeConfig/DependencyCalculator.ts index fd196f625..c47bb6aea 100644 --- a/src/Models/ThemeConfig/DependencyCalculator.ts +++ b/src/Models/ThemeConfig/DependencyCalculator.ts @@ -3,7 +3,6 @@ import { ExtraFuncParams, ExtraFunctions } from "../../Logic/ExtraFunctions" import LayerConfig from "./LayerConfig" import { SpecialVisualization } from "../../UI/SpecialVisualization" import SpecialVisualizations from "../../UI/SpecialVisualizations" -import { LayerConfigJson } from "./Json/LayerConfigJson" export default class DependencyCalculator { /** diff --git a/src/Models/ThemeConfig/PointRenderingConfig.ts b/src/Models/ThemeConfig/PointRenderingConfig.ts index 4c74a4843..7513920a3 100644 --- a/src/Models/ThemeConfig/PointRenderingConfig.ts +++ b/src/Models/ThemeConfig/PointRenderingConfig.ts @@ -4,7 +4,7 @@ import { TagsFilter } from "../../Logic/Tags/TagsFilter" import { TagUtils } from "../../Logic/Tags/TagUtils" import { Utils } from "../../Utils" import WithContextLoader from "./WithContextLoader" -import { ImmutableStore, Store } from "../../Logic/UIEventSource" +import { Store } from "../../Logic/UIEventSource" import BaseUIElement from "../../UI/BaseUIElement" import { FixedUiElement } from "../../UI/Base/FixedUiElement" import Combine from "../../UI/Base/Combine" diff --git a/src/UI/Base/DirectionIndicator.svelte b/src/UI/Base/DirectionIndicator.svelte index 9eb2c52d4..9c3cbf681 100644 --- a/src/UI/Base/DirectionIndicator.svelte +++ b/src/UI/Base/DirectionIndicator.svelte @@ -16,7 +16,6 @@ import { ariaLabelStore } from "../../Utils/ariaLabel" import type { SpecialVisualizationState } from "../SpecialVisualization" import Center from "../../assets/svg/Center.svelte" - import Tr from "./Tr.svelte" export let state: SpecialVisualizationState export let feature: Feature diff --git a/src/UI/Base/FloatOver.svelte b/src/UI/Base/FloatOver.svelte index b75bfcb33..406ddd11f 100644 --- a/src/UI/Base/FloatOver.svelte +++ b/src/UI/Base/FloatOver.svelte @@ -1,8 +1,5 @@ - - - - {#if imageUrl !== undefined} - {#if typeof imageUrl === "string"} - - {:else} -