Show METAR labels for Wunderground realtime observations
This commit is contained in:
@@ -85,6 +85,15 @@ function getObservationSourceTag(detail: CityDetail): string {
|
|||||||
return "METAR";
|
return "METAR";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRealtimeObservationTag(detail: CityDetail): string {
|
||||||
|
const code = getObservationSourceCode(detail);
|
||||||
|
if (code === "wunderground") {
|
||||||
|
const icao = String(detail.risk?.icao || "").trim().toUpperCase();
|
||||||
|
return icao ? `${icao} METAR` : "METAR";
|
||||||
|
}
|
||||||
|
return getObservationSourceTag(detail);
|
||||||
|
}
|
||||||
|
|
||||||
function getNoaaStationCode(detail: CityDetail): string {
|
function getNoaaStationCode(detail: CityDetail): string {
|
||||||
return String(detail.current?.station_code || detail.risk?.icao || "NOAA")
|
return String(detail.current?.station_code || detail.risk?.icao || "NOAA")
|
||||||
.trim()
|
.trim()
|
||||||
@@ -188,7 +197,7 @@ export function getWeatherSummary(detail: CityDetail, locale: Locale = "zh-CN")
|
|||||||
export function getHeroMetaItems(detail: CityDetail, locale: Locale = "zh-CN") {
|
export function getHeroMetaItems(detail: CityDetail, locale: Locale = "zh-CN") {
|
||||||
const current = detail.current || {};
|
const current = detail.current || {};
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
const sourceTag = getObservationSourceTag(detail);
|
const sourceTag = getRealtimeObservationTag(detail);
|
||||||
const suppressAnkaraMgmObservation = isTurkishMgmCity(detail);
|
const suppressAnkaraMgmObservation = isTurkishMgmCity(detail);
|
||||||
|
|
||||||
if (current.obs_time) {
|
if (current.obs_time) {
|
||||||
@@ -281,7 +290,7 @@ export function getTemperatureChartData(
|
|||||||
currentIndex < 0 || index >= currentIndex ? temp : null,
|
currentIndex < 0 || index >= currentIndex ? temp : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
const observationTag = getObservationSourceTag(detail);
|
const observationTag = getRealtimeObservationTag(detail);
|
||||||
const observationCode = getObservationSourceCode(detail);
|
const observationCode = getObservationSourceCode(detail);
|
||||||
const settlementSource =
|
const settlementSource =
|
||||||
observationCode === "hko" ||
|
observationCode === "hko" ||
|
||||||
@@ -319,7 +328,9 @@ export function getTemperatureChartData(
|
|||||||
return `${icao} METAR`;
|
return `${icao} METAR`;
|
||||||
})();
|
})();
|
||||||
const observationDisplayTag =
|
const observationDisplayTag =
|
||||||
useSettlementObservationSource && shouldUseMetarFallback
|
observationCode === "wunderground"
|
||||||
|
? metarFallbackTag
|
||||||
|
: useSettlementObservationSource && shouldUseMetarFallback
|
||||||
? metarFallbackTag
|
? metarFallbackTag
|
||||||
: observationCode === "noaa"
|
: observationCode === "noaa"
|
||||||
? `NOAA ${getNoaaStationCode(detail)}`
|
? `NOAA ${getNoaaStationCode(detail)}`
|
||||||
|
|||||||
Reference in New Issue
Block a user