Add localized meteorology text and filter implausible METAR temps
This commit is contained in:
@@ -318,13 +318,16 @@ export interface MarketScan {
|
||||
|
||||
export interface IntradayMeteorologySignal {
|
||||
label?: string | null;
|
||||
label_en?: string | null;
|
||||
direction?: "support" | "suppress" | "neutral" | string | null;
|
||||
strength?: "weak" | "medium" | "strong" | string | null;
|
||||
summary?: string | null;
|
||||
summary_en?: string | null;
|
||||
}
|
||||
|
||||
export interface IntradayMeteorology {
|
||||
headline?: string | null;
|
||||
headline_en?: string | null;
|
||||
confidence?: "low" | "medium" | "high" | string | null;
|
||||
base_case_bucket?: string | null;
|
||||
upside_bucket?: string | null;
|
||||
@@ -332,7 +335,9 @@ export interface IntradayMeteorology {
|
||||
next_observation_time?: string | null;
|
||||
peak_window?: string | null;
|
||||
invalidation_rules?: string[] | null;
|
||||
invalidation_rules_en?: string[] | null;
|
||||
confirmation_rules?: string[] | null;
|
||||
confirmation_rules_en?: string[] | null;
|
||||
signal_contributions?: IntradayMeteorologySignal[] | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -696,15 +696,34 @@ export function getTemperatureChartData(
|
||||
: []
|
||||
: [];
|
||||
const currentObservationFallback = buildCurrentObservationFallback(detail);
|
||||
const metarObservationSource = detail.metar_today_obs?.length
|
||||
? detail.metar_today_obs
|
||||
: detail.trend?.recent?.length
|
||||
? detail.trend.recent
|
||||
: currentObservationFallback;
|
||||
const minPlausibleObservationTemp = (() => {
|
||||
const name = String(detail.name || "").trim().toLowerCase();
|
||||
const icao = String(detail.risk?.icao || "").trim().toUpperCase();
|
||||
if (name === "karachi" || name === "masroor air base" || icao === "OPKC" || icao === "OPMR") {
|
||||
return detail.temp_symbol === "°F" ? 41 : 5;
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
const filterPlausibleObservations = <T extends { temp?: number | null }>(
|
||||
rows?: T[] | null,
|
||||
) =>
|
||||
(Array.isArray(rows) ? rows : []).filter((row) => {
|
||||
const value = Number(row?.temp);
|
||||
if (!Number.isFinite(value)) return false;
|
||||
return minPlausibleObservationTemp == null || value >= minPlausibleObservationTemp;
|
||||
});
|
||||
const plausibleMetarTodayObs = filterPlausibleObservations(detail.metar_today_obs);
|
||||
const plausibleTrendRecent = filterPlausibleObservations(detail.trend?.recent);
|
||||
const plausibleCurrentFallback = filterPlausibleObservations(currentObservationFallback);
|
||||
const metarObservationSource = plausibleMetarTodayObs.length
|
||||
? plausibleMetarTodayObs
|
||||
: plausibleTrendRecent.length
|
||||
? plausibleTrendRecent
|
||||
: plausibleCurrentFallback;
|
||||
const usingCurrentObservationFallback =
|
||||
!detail.metar_today_obs?.length &&
|
||||
!detail.trend?.recent?.length &&
|
||||
currentObservationFallback.length > 0;
|
||||
!plausibleMetarTodayObs.length &&
|
||||
!plausibleTrendRecent.length &&
|
||||
plausibleCurrentFallback.length > 0;
|
||||
const currentFallbackTag =
|
||||
currentObservationFallback[0]?.sourceLabel ||
|
||||
getObservationSourceTag(detail);
|
||||
|
||||
Reference in New Issue
Block a user