Skip to content

Commit

Permalink
Fix properties.value.HS is possibly undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Dec 29, 2024
1 parent 1911f57 commit 30c8d27
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/StationEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ const properties = computed(() => props.feature.properties);
const outdated = computed(
() =>
!properties.value.date ||
new Date(properties.value.date).getTime() + 3 * 60 * 60 * 1000 < Date.now(),
new Date(properties.value.date).getTime() + 3 * 60 * 60 * 1000 < Date.now()
);
const region = computed(() => properties.value["LWD-Region"]);
const name = computed(() => properties.value.name);
const compass = ["NN", "NE", "EE", "SE", "SS", "SW", "WW", "NW", "NN"];
const windDirection = computed(() =>
typeof properties.value.WR !== "number"
? "--"
: compass[Math.round(((properties.value.WR + 360 - 22.5) % 360) / 45)],
: compass[Math.round(((properties.value.WR + 360 - 22.5) % 360) / 45)]
);
const HSor0 = computed(() => properties.value.HS ?? 0);
const HSD72or0 = computed(() => properties.value.HSD72 ?? 0);
const hsHistogram = computed(() => ({
base: "#".repeat(Math.max(0, properties.value.HS - HSD72or0.value) / 4),
base: "#".repeat(Math.max(0, HSor0.value - HSD72or0.value) / 4),
add: "#".repeat(Math.max(0, HSD72or0.value) / 4),
del: "-".repeat(-Math.min(0, HSD72or0.value) / 4),
}));
Expand Down

0 comments on commit 30c8d27

Please sign in to comment.