Refactoring: allow to reuse units, move all units into central file

This commit is contained in:
Pieter Vander Vennet 2023-12-12 03:46:51 +01:00
parent 067fb549c1
commit 94e07d5b13
30 changed files with 1495 additions and 1307 deletions

View file

@ -83,6 +83,7 @@ import NearbyImages from "./Image/NearbyImages.svelte"
import NearbyImagesCollapsed from "./Image/NearbyImagesCollapsed.svelte"
import { svelte } from "@sveltejs/vite-plugin-svelte"
import MoveWizard from "./Popup/MoveWizard.svelte"
import { Unit } from "../Models/Unit"
class NearbyImageVis implements SpecialVisualization {
// Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests
@ -890,7 +891,7 @@ export default class SpecialVisualizations {
if (value === undefined) {
return undefined
}
const allUnits = [].concat(
const allUnits: Unit[] = [].concat(
...(state?.layout?.layers?.map((lyr) => lyr.units) ?? [])
)
const unit = allUnits.filter((unit) =>
@ -899,7 +900,9 @@ export default class SpecialVisualizations {
if (unit === undefined) {
return value
}
return unit.asHumanLongValue(value)
const getCountry = () => tagSource.data._country
const [v, denom] = unit.findDenomination(value, getCountry)
return unit.asHumanLongValue(v, getCountry)
})
)
},