hack metric units back in

This commit is contained in:
lif 2023-11-11 19:54:58 -08:00
parent 0393576e5f
commit 5cb2dc5375
6 changed files with 15 additions and 12 deletions

View file

@ -186,14 +186,15 @@ const parseData = (data) => {
// convert to us units // convert to us units
data.Temperature = celsiusToFahrenheit(data.Temperature); data.Temperature = celsiusToFahrenheit(data.Temperature);
data.TemperatureUnit = 'F'; // HACK
// data.TemperatureUnit = 'F';
data.DewPoint = celsiusToFahrenheit(data.DewPoint); data.DewPoint = celsiusToFahrenheit(data.DewPoint);
data.Ceiling = Math.round(metersToFeet(data.Ceiling) / 100) * 100; data.Ceiling = Math.round(metersToFeet(data.Ceiling) / 100) * 100;
data.CeilingUnit = 'ft.'; // data.CeilingUnit = 'ft.';
data.Visibility = kilometersToMiles(observations.visibility.value / 1000); data.Visibility = kilometersToMiles(observations.visibility.value / 1000);
data.VisibilityUnit = ' mi.'; // data.VisibilityUnit = ' mi.';
data.WindSpeed = kphToMph(data.WindSpeed); data.WindSpeed = kphToMph(data.WindSpeed);
data.WindUnit = 'MPH'; // data.WindUnit = 'MPH';
data.Pressure = pascalToInHg(data.Pressure).toFixed(2); data.Pressure = pascalToInHg(data.Pressure).toFixed(2);
data.HeatIndex = celsiusToFahrenheit(data.HeatIndex); data.HeatIndex = celsiusToFahrenheit(data.HeatIndex);
data.WindChill = celsiusToFahrenheit(data.WindChill); data.WindChill = celsiusToFahrenheit(data.WindChill);

View file

@ -26,7 +26,7 @@ class ExtendedForecast extends WeatherDisplay {
try { try {
forecast = await json(weatherParameters.forecast, { forecast = await json(weatherParameters.forecast, {
data: { data: {
units: 'us', units: 'si',
}, },
retryCount: 3, retryCount: 3,
stillWaiting: () => this.stillWaiting(), stillWaiting: () => this.stillWaiting(),

View file

@ -64,8 +64,9 @@ class LatestObservations extends WeatherDisplay {
// sort array by station name // sort array by station name
const sortedConditions = conditions.sort((a, b) => ((a.Name < b.Name) ? -1 : 1)); const sortedConditions = conditions.sort((a, b) => ((a.Name < b.Name) ? -1 : 1));
this.elem.querySelector('.column-headers .temp.english').classList.add('show'); //this.elem.querySelector('.column-headers .temp.english').classList.add('show');
this.elem.querySelector('.column-headers .temp.metric').classList.remove('show'); //this.elem.querySelector('.column-headers .temp.metric').classList.remove('show');
this.elem.querySelector('.column-headers .temp.metric').classList.add('show');
const lines = sortedConditions.map((condition) => { const lines = sortedConditions.map((condition) => {
const windDirection = directionToNSEW(condition.windDirection.value); const windDirection = directionToNSEW(condition.windDirection.value);

View file

@ -61,7 +61,7 @@ class LocalForecast extends WeatherDisplay {
try { try {
return await json(weatherParameters.forecast, { return await json(weatherParameters.forecast, {
data: { data: {
units: 'us', units: 'si',
}, },
retryCount: 3, retryCount: 3,
stillWaiting: () => this.stillWaiting(), stillWaiting: () => this.stillWaiting(),

View file

@ -80,7 +80,7 @@ class RegionalForecast extends WeatherDisplay {
// start off the observation task // start off the observation task
const observationPromise = utils.getRegionalObservation(point, city); const observationPromise = utils.getRegionalObservation(point, city);
const forecast = await json(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/forecast`); const forecast = await json(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/forecast?units=si`);
// get XY on map for city // get XY on map for city
const cityXY = utils.getXYForCity(city, minMaxLatLon.maxLat, minMaxLatLon.minLon, weatherParameters.state); const cityXY = utils.getXYForCity(city, minMaxLatLon.maxLat, minMaxLatLon.minLon, weatherParameters.state);

View file

@ -3,9 +3,10 @@
const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals; const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals;
const kphToMph = (Kph) => Math.round(Kph / 1.609_34); const kphToMph = (Kph) => Math.round(Kph / 1.609_34);
const celsiusToFahrenheit = (Celsius) => Math.round((Celsius * 9) / 5 + 32); // HACK!
const kilometersToMiles = (Kilometers) => Math.round(Kilometers / 1.609_34); const celsiusToFahrenheit = (Celsius) => Celsius; // Math.round((Celsius * 9) / 5 + 32);
const metersToFeet = (Meters) => Math.round(Meters / 0.3048); const kilometersToMiles = (Kilometers) => Kilometers; // Math.round(Kilometers / 1.609_34);
const metersToFeet = (Meters) => Meters; // Math.round(Meters / 0.3048);
const pascalToInHg = (Pascal) => round2(Pascal * 0.000_295_3, 2); const pascalToInHg = (Pascal) => round2(Pascal * 0.000_295_3, 2);
export { export {