lightmaster / Meteobridge-Weather34-Template

Github repository for the Meteobridge version of the weather34 template
Other
18 stars 10 forks source link

shared.php - possible debug code left behind #45

Closed steepleian closed 5 years ago

steepleian commented 5 years ago

At line 156, possible debug code left behind which may effect F display

}

$weather["temp_units"]='C'; if ($weather["temp_units"] == 'C'){ $heatIndex = fToCDirect($heatIndex); }

lightmaster commented 5 years ago

You're probably right, but I'm gonna take a look at it tomorrow when the heat index is high enough to activate that formula.

steepleian commented 5 years ago

Thanks. Well one thing is for sure its not going to ever be that high here to check it out!

lightmaster commented 5 years ago

Yea.... My real temp yesterday hit 100.9°F, lol

steepleian commented 5 years ago

Also same file: - Lines 184-186 function anyToF($field){

    return cToFDirect ($field);

Should be: - function anyToF($field){ global $weather; if ($weather["temp_units"] == 'F'){ return $field; } else {

            return cToFDirect ($field);
steepleian commented 5 years ago

Sorry forget that last comment

lightmaster commented 5 years ago

I can't see any difference between those changes and the original. And the heat index here is varying between 98-101°F. Don't see a change when I switch to Celsius either.

lightmaster commented 5 years ago

Okay, I figured it out. The $weather["temp_units"] = 'C'; is irrelevant because livedata.php has already set $weather["temp_units"] equal to 'C'. This is because that's not the units that your site is currently displaying, that's the units that the data is received as, and with MB at least, all temps are received as Celsius. The second correct is immaterial as well, for the same reason. Data flows in as 'C', is converted to 'F' because the Heat Index only applies to 'F', and its then converted back to 'C'. Only then once the Heat Index is calculated is it finally converted to whichever unit is currently being displayed. Thankfully, temp conversion uses precise fractions and not rounded decimals, so there's not really any loss of precision when converting the units so many times.

All that being said, I will add these corrections anyway in case someone down the line converts their copy to store the data in Imperial, that way they won't be confused as to why the Heat Index is messed up for them.