From be24f9ba45151f7c9ab3a720c14f8269ed379a03 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 24 May 2024 15:39:32 +0200 Subject: [PATCH] Fix linting errors --- src/Logic/SimpleMetaTagger.ts | 38 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/Logic/SimpleMetaTagger.ts b/src/Logic/SimpleMetaTagger.ts index 41399a2398..d911a4602e 100644 --- a/src/Logic/SimpleMetaTagger.ts +++ b/src/Logic/SimpleMetaTagger.ts @@ -32,7 +32,7 @@ export abstract class SimpleMetaTagger { /*** * A function that adds some extra data to a feature - * @param docs: what does this extra data do? + * @param docs what does this extra data do? */ protected constructor(docs: { keys: string[] @@ -66,7 +66,7 @@ export abstract class SimpleMetaTagger { * @param state */ public abstract applyMetaTagsOnFeature( - feature: any, + feature: Feature, layer: LayerConfig, tagsStore: UIEventSource>, state: MetataggingState @@ -114,7 +114,7 @@ class CountryTagger extends SimpleMetaTagger { Constants.countryCoderEndpoint, Utils.downloadJson ) - public runningTasks: Set = new Set() + public runningTasks: Set = new Set() constructor() { super({ @@ -124,11 +124,9 @@ class CountryTagger extends SimpleMetaTagger { }) } - applyMetaTagsOnFeature(feature, _, tagsSource) { - let centerPoint: any = GeoOperations.centerpoint(feature) + applyMetaTagsOnFeature(feature: Feature, _, tagsSource) { + const [lat, lon] = GeoOperations.centerpointCoordinates(feature) const runningTasks = this.runningTasks - const lat = centerPoint.geometry.coordinates[1] - const lon = centerPoint.geometry.coordinates[0] runningTasks.add(feature) CountryTagger.coder .GetCountryCodeAsync(lon, lat) @@ -178,7 +176,7 @@ class CountryTagger extends SimpleMetaTagger { class InlineMetaTagger extends SimpleMetaTagger { public readonly applyMetaTagsOnFeature: ( - feature: any, + feature: Feature, layer: LayerConfig, tagsStore: UIEventSource, state: MetataggingState @@ -197,7 +195,7 @@ class InlineMetaTagger extends SimpleMetaTagger { cleanupRetagger?: boolean }, f: ( - feature: any, + feature: Feature, layer: LayerConfig, tagsStore: UIEventSource, state: MetataggingState @@ -259,7 +257,7 @@ export default class SimpleMetaTaggers { keys: ["_geometry:type"], doc: "Adds the geometry type as property. This is identical to the GoeJson geometry type and is one of `Point`,`LineString`, `Polygon` and exceptionally `MultiPolygon` or `MultiLineString`", }, - (feature, _) => { + (feature) => { const changed = feature.properties["_geometry:type"] === feature.geometry.type feature.properties["_geometry:type"] = feature.geometry.type return changed @@ -410,9 +408,6 @@ export default class SimpleMetaTaggers { } let rewritten = false for (const key in feature.properties) { - if (!feature.properties.hasOwnProperty(key)) { - continue - } for (const unit of units) { if (unit === undefined) { continue @@ -434,7 +429,7 @@ export default class SimpleMetaTaggers { const defaultDenom = unit.getDefaultDenomination( () => feature.properties["_country"] ) - let canonical = + const canonical = denomination?.canonicalValue(value, defaultDenom == denomination, unit.inverted) ?? undefined if (canonical === value) { @@ -514,7 +509,7 @@ export default class SimpleMetaTaggers { state: undefined, }, }, - { tag_key: "opening_hours" } + { tag_key: "opening_hours" } ) // Recalculate! @@ -644,13 +639,12 @@ export default class SimpleMetaTaggers { const currencies = {} // Check if there are any currency:XXX tags, add them to the map for (const key in feature.properties) { - if (key.startsWith("currency:")) { - if (feature.properties[key] === "yes") { - currencies[key.slice(9)] = true - } else { - currencies[key.slice(9)] = false - } + if (!key.startsWith("currency:")) { + continue } + const currency = key.slice(9) + const hasCurrency = feature.properties[key] === "yes" + currencies[currency] = hasCurrency } // Determine the default currency for the country @@ -700,7 +694,7 @@ export default class SimpleMetaTaggers { * Returns 'true' is at least one change has been made * @param tags */ - public static removeBothTagging(tags: any): boolean { + public static removeBothTagging(tags: Record): boolean { let somethingChanged = false /**