Fix linting errors

This commit is contained in:
Pieter Vander Vennet 2024-05-24 15:39:32 +02:00
parent db2c3fb7a4
commit be24f9ba45

View file

@ -32,7 +32,7 @@ export abstract class SimpleMetaTagger {
/*** /***
* A function that adds some extra data to a feature * 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: { protected constructor(docs: {
keys: string[] keys: string[]
@ -66,7 +66,7 @@ export abstract class SimpleMetaTagger {
* @param state * @param state
*/ */
public abstract applyMetaTagsOnFeature( public abstract applyMetaTagsOnFeature(
feature: any, feature: Feature,
layer: LayerConfig, layer: LayerConfig,
tagsStore: UIEventSource<Record<string, string>>, tagsStore: UIEventSource<Record<string, string>>,
state: MetataggingState state: MetataggingState
@ -114,7 +114,7 @@ class CountryTagger extends SimpleMetaTagger {
Constants.countryCoderEndpoint, Constants.countryCoderEndpoint,
Utils.downloadJson Utils.downloadJson
) )
public runningTasks: Set<any> = new Set<any>() public runningTasks: Set<Feature> = new Set<Feature>()
constructor() { constructor() {
super({ super({
@ -124,11 +124,9 @@ class CountryTagger extends SimpleMetaTagger {
}) })
} }
applyMetaTagsOnFeature(feature, _, tagsSource) { applyMetaTagsOnFeature(feature: Feature, _, tagsSource) {
let centerPoint: any = GeoOperations.centerpoint(feature) const [lat, lon] = GeoOperations.centerpointCoordinates(feature)
const runningTasks = this.runningTasks const runningTasks = this.runningTasks
const lat = centerPoint.geometry.coordinates[1]
const lon = centerPoint.geometry.coordinates[0]
runningTasks.add(feature) runningTasks.add(feature)
CountryTagger.coder CountryTagger.coder
.GetCountryCodeAsync(lon, lat) .GetCountryCodeAsync(lon, lat)
@ -178,7 +176,7 @@ class CountryTagger extends SimpleMetaTagger {
class InlineMetaTagger extends SimpleMetaTagger { class InlineMetaTagger extends SimpleMetaTagger {
public readonly applyMetaTagsOnFeature: ( public readonly applyMetaTagsOnFeature: (
feature: any, feature: Feature,
layer: LayerConfig, layer: LayerConfig,
tagsStore: UIEventSource<OsmTags>, tagsStore: UIEventSource<OsmTags>,
state: MetataggingState state: MetataggingState
@ -197,7 +195,7 @@ class InlineMetaTagger extends SimpleMetaTagger {
cleanupRetagger?: boolean cleanupRetagger?: boolean
}, },
f: ( f: (
feature: any, feature: Feature,
layer: LayerConfig, layer: LayerConfig,
tagsStore: UIEventSource<OsmTags>, tagsStore: UIEventSource<OsmTags>,
state: MetataggingState state: MetataggingState
@ -259,7 +257,7 @@ export default class SimpleMetaTaggers {
keys: ["_geometry:type"], 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`", 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 const changed = feature.properties["_geometry:type"] === feature.geometry.type
feature.properties["_geometry:type"] = feature.geometry.type feature.properties["_geometry:type"] = feature.geometry.type
return changed return changed
@ -410,9 +408,6 @@ export default class SimpleMetaTaggers {
} }
let rewritten = false let rewritten = false
for (const key in feature.properties) { for (const key in feature.properties) {
if (!feature.properties.hasOwnProperty(key)) {
continue
}
for (const unit of units) { for (const unit of units) {
if (unit === undefined) { if (unit === undefined) {
continue continue
@ -434,7 +429,7 @@ export default class SimpleMetaTaggers {
const defaultDenom = unit.getDefaultDenomination( const defaultDenom = unit.getDefaultDenomination(
() => feature.properties["_country"] () => feature.properties["_country"]
) )
let canonical = const canonical =
denomination?.canonicalValue(value, defaultDenom == denomination, unit.inverted) ?? denomination?.canonicalValue(value, defaultDenom == denomination, unit.inverted) ??
undefined undefined
if (canonical === value) { if (canonical === value) {
@ -514,7 +509,7 @@ export default class SimpleMetaTaggers {
state: undefined, state: undefined,
}, },
}, },
<any>{ tag_key: "opening_hours" } <any> { tag_key: "opening_hours" }
) )
// Recalculate! // Recalculate!
@ -644,13 +639,12 @@ export default class SimpleMetaTaggers {
const currencies = {} const currencies = {}
// Check if there are any currency:XXX tags, add them to the map // Check if there are any currency:XXX tags, add them to the map
for (const key in feature.properties) { for (const key in feature.properties) {
if (key.startsWith("currency:")) { if (!key.startsWith("currency:")) {
if (feature.properties[key] === "yes") { continue
currencies[key.slice(9)] = true
} else {
currencies[key.slice(9)] = false
}
} }
const currency = key.slice(9)
const hasCurrency = feature.properties[key] === "yes"
currencies[currency] = hasCurrency
} }
// Determine the default currency for the country // 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 * Returns 'true' is at least one change has been made
* @param tags * @param tags
*/ */
public static removeBothTagging(tags: any): boolean { public static removeBothTagging(tags: Record<string, string | number>): boolean {
let somethingChanged = false let somethingChanged = false
/** /**