WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: Hugh Whalen on September 09, 2021, 09:14:53 AM
-
I am setting up a new Weather Site and I am using the Saratoga templates. The site is www.flowers-cove.ca/wxindex.php
Most everything is working except for the Barometer. It shows NaN, which I assume means Not a Number.
I am using the Base Canada template and WeatherCat software.
Anybody have any idea what is going on here? [ You are not allowed to view attachments ]
-
I have been trying to figure out what is going on here.
If I look at the WCT_realtime.txt file on the server it shows some strange things. The current pressure is 1,012.0
In fact, all the pressure readings (min today, max today, etc) are recorded as x,xxx.x That is, there is a comma there. Shouldn't it be xxxx.x eg no comma?
-
The javascript code (ajaxWCTwx.js) expects no comma in the data. You hit the multiply by 1.0 below as your UOM is "mb" and that is what results in the NaN.
function cBaroToHPA ( rawbaro ) {
// convert input pressure to hPa if need be
var cpat=/mb|hpa/i;
if(cpat.test(rBaroUOM)) { // baro already in mb/hPa
return rawbaro * 1.0;
} else { // convert inHg to mb/hPa
return rawbaro * 33.86;
}
}
-
Also note on http://www.flowers-cove.ca/wxstatus.php (http://www.flowers-cove.ca/wxstatus.php) that the realtime file status is Not Current.
-
It appears that your locale settings on your mac has 'use commas in thousands' displays for numbers. You need to turn that off so the barometer will show without embedded commas. That should fix the issue.
example in WCTtags.php STAT:PRESSURE:CURRENT|1,011.7|// Current Pressure:|:
STAT:PRESSURE:DELTA1|-0.4|// Current Pressure change over 1 hour.:|:
STAT:PRESSURE:DELTA24|-2.4|// Current Pressure change over 24 hours.:|:
STAT:PRESSURE:24HRSAGO|1,014.2|// Current Pressure value 24 hours ago.:|:
-
That fixed the problem. Thank you very much for your help.
Hugh