Page 1 of 1

NWS Forecast and minus temperatures

Posted: Wed Dec 26, 2018 12:40 am
by dmgould
Attached images show the NWS Forecast block on my page and the same data on the NWS official page. I couldn't figure out what was going on with the temperature numbers missing and in the wrong place in the block. It looks like there is an issue with displaying negative temperature values in the block version. The negative temperatures don't show and they cause the rest of the numbers to appear off by one space.
forecasterror.JPG
forecasterror.JPG (68.29 KiB) Viewed 5858 times
forecast.JPG
forecast.JPG (48.21 KiB) Viewed 5858 times

Re: NWS Forecast and minus temperatures

Posted: Wed Dec 26, 2018 9:06 pm
by dmgould
Checking my cache file nwsForcastChace.txt, <p class="temp temp-low">Low: -2 &deg;F is in the correct place with the correct value. It looks like code for that block sets up an array with a counter to line up the images and temperatures to display in the block. When it encounters a negative temperature something happens, maybe to the counter??, and it skips any negative temperatures. Also, this same thing happens in the nwsForecastCustom block. Whatever is happening occurs in both blocks with temperatures below zero.

Re: NWS Forecast and minus temperatures

Posted: Wed Dec 26, 2018 9:12 pm
by Jachym
Could be some minor change in their code, since the code uses HTML scraping this would affect it. I will have a look

Re: NWS Forecast and minus temperatures

Posted: Wed Dec 26, 2018 10:33 pm
by dmgould
Thanks for looking at this. I also noticed the link to that scraped code is still http. It forwards to https. If you end up making a change to the block you might want to change that link as well. I figured out it's setting up a table for each entry, but I get lost following the array.

Re: NWS Forecast and minus temperatures

Posted: Fri Dec 28, 2018 3:06 am
by dmgould
I made the follow minor change to line 90 in nwsForecastBlock.php. It seems to have fixed the issue of skipping past a negative (below zero) temperature. It now shows the minus sign and places the temperatures into the correct places. I'll keep track of it for a bit to see if the fix holds. If so, I'll make the same change in customLoader.php in the nwsForecastCustom Block which currently has the same issue with minus temperatures. I also updated the data source for the NWS images to https as that link was forwarding there.

Here are snips of the modified code and the block after the change.
nwsTry.JPG
nwsTry.JPG (17.14 KiB) Viewed 5817 times
forecastTry.JPG
forecastTry.JPG (58.34 KiB) Viewed 5817 times

Re: NWS Forecast and minus temperatures

Posted: Mon Jan 28, 2019 1:21 am
by MonyMony
Thanks everyone for the post as I was noticing the same issue.