diff --git a/app/components/HourlyItem.svelte b/app/components/HourlyItem.svelte index 17450099..4e13b7ba 100644 --- a/app/components/HourlyItem.svelte +++ b/app/components/HourlyItem.svelte @@ -85,7 +85,7 @@ textPaint.setAlpha(150); if (item.precipAccumulation >= 0.1) { - canvas.drawText(formatWeatherValue(item, item.precipShowSnow ? WeatherProps.snowfall : WeatherProps.precipAccumulation), w2, h - deltaY * $fontScale, textPaint); + canvas.drawText(formatWeatherValue(item, WeatherProps.precipAccumulation), w2, h - deltaY * $fontScale, textPaint); deltaY += 10; } if (precipProbability > 0) { diff --git a/app/components/TopWeatherView.svelte b/app/components/TopWeatherView.svelte index f0b6dd4a..67b0905c 100644 --- a/app/components/TopWeatherView.svelte +++ b/app/components/TopWeatherView.svelte @@ -340,7 +340,7 @@ textPaint.setColor(colorOutline); canvas.drawLine(0, h, w, h - 1, textPaint); - const centeredItemsToDraw = weatherDataService.getAllIconsData({ item, filter: [WeatherProps.windBeaufort] }); + const centeredItemsToDraw = weatherDataService.getAllIconsData({ item, type: 'currently' }); canvas.clipRect(0, 0, w - weatherIconSize * (2 - $fontScale), h); switch ($weatherDataLayout) { case 'line': { diff --git a/app/helpers/formatter.ts b/app/helpers/formatter.ts index 56ee9274..5eac6acb 100644 --- a/app/helpers/formatter.ts +++ b/app/helpers/formatter.ts @@ -44,7 +44,6 @@ export function convertValueToUnit(value: any, unit: UNITS, defaultUnit: UNITS, const round = options.round ?? true; let digits = 1; let shouldRound = round; - switch (defaultUnit) { case UNITS.Celcius: shouldRound = true; @@ -61,17 +60,26 @@ export function convertValueToUnit(value: any, unit: UNITS, defaultUnit: UNITS, digits = 100; value *= 0.03937008; } else if (unit === UNITS.CM) { - value /= 10; + if (value < 1) { + unit = UNITS.MM; + } else { + value /= 10; + } + } + break; + case UNITS.CM: + digits = 10; + if (unit === UNITS.CM && value < 1) { + unit = UNITS.MM; + value *= 10; } + // if (unit === UNITS.Inch) { + // digits = 10; + // value *= 0.3937008; + // } else if (unit === UNITS.MM) { + // value *= 10; + // } break; - // case UNITS.CM: - // if (unit === UNITS.Inch) { - // digits = 10; - // value *= 0.3937008; - // } else if (unit === UNITS.MM) { - // value *= 10; - // } - // break; case UNITS.Meters: shouldRound = true; if (unit === UNITS.Feet) { @@ -528,7 +536,7 @@ export function formatAddress(address, startIndex = undefined, endIndex = undefi if (address.postcode?.indexOf(';') >= 0) { address.postcode = address.postcode.split(';')[0]; } - const { locality, county, ...cleanedUp } = address; + const { county, locality, ...cleanedUp } = address; const result = addressFormatter.format(cleanedUp, { fallbackCountryCode: langToCountryCode(lang) }); diff --git a/app/helpers/units.ts b/app/helpers/units.ts index a3d819ec..91e0b7f5 100644 --- a/app/helpers/units.ts +++ b/app/helpers/units.ts @@ -36,8 +36,8 @@ export enum UNIT_FAMILIES { } export const DEFAULT_IMPERIAL_UINTS = { - [UNIT_FAMILIES.DistanceSmall]: UNITS.CM, - [UNIT_FAMILIES.DistanceVerySmall]: UNITS.MM, + [UNIT_FAMILIES.DistanceSmall]: UNITS.Inch, + [UNIT_FAMILIES.DistanceVerySmall]: UNITS.Inch, [UNIT_FAMILIES.Uv]: UNITS.UV, [UNIT_FAMILIES.Percent]: UNITS.Percent, [UNIT_FAMILIES.Temperature]: UNITS.Fahrenheit, @@ -48,8 +48,8 @@ export const DEFAULT_IMPERIAL_UINTS = { }; export const DEFAULT_METRIC_UINTS = { - [UNIT_FAMILIES.DistanceSmall]: UNITS.Inch, - [UNIT_FAMILIES.DistanceVerySmall]: UNITS.Inch, + [UNIT_FAMILIES.DistanceSmall]: UNITS.CM, + [UNIT_FAMILIES.DistanceVerySmall]: UNITS.MM, [UNIT_FAMILIES.Uv]: UNITS.UV, [UNIT_FAMILIES.Percent]: UNITS.Percent, [UNIT_FAMILIES.Temperature]: UNITS.Celcius, diff --git a/app/services/weatherData.ts b/app/services/weatherData.ts index bf4858c6..4cae76ce 100644 --- a/app/services/weatherData.ts +++ b/app/services/weatherData.ts @@ -70,7 +70,7 @@ export function propToUnit(prop: WeatherProps, item?: CommonWeatherData) { return unitsSettings[UNIT_FAMILIES.Uv]; case WeatherProps.precipAccumulation: if (item?.precipUnitFamily) { - return item?.precipUnitFamily; + return unitsSettings[item?.precipUnitFamily]; } return unitsSettings[UNIT_FAMILIES.Precipitation]; case WeatherProps.snowfall: