Author Topic: Open Weather Forecast script error?  (Read 463 times)

0 Members and 1 Guest are viewing this topic.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Open Weather Forecast script error?
« on: April 23, 2023, 01:51:57 PM »
I think I have found a typo in the OWM-forecast.php script. It's on line 122 of the distributed file.

The code reads as follows:

  // Units: Temp,Baro,Wind,Rain,Snow,Distance
  // 'si' = C,hPa,m/s,mm,mm,km
  // 'ca' = C,hPa,km/h,mm,mm,km
  // 'uk' = C,mb,mph,mm,mm,km
  // 'us' = F,inHg,mph,in,in,km

The last entry in the "us" line is the one in question. Since the US uses miles for distance and not kilometers, shouldn't this be "mi" or whatever designation is used to indicate miles?


Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Open Weather Forecast script error?
« Reply #1 on: April 23, 2023, 06:14:41 PM »
The API docs state
Quote
current.visibility Average visibility, metres. The maximum value of the visibility is 10km
so km is correct (I divide by 1000 and round for visibility in KM -- I don't convert it to miles for the US returns)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Re: Open Weather Forecast script error?
« Reply #2 on: April 24, 2023, 12:34:46 PM »
Ok, thanks Ken. Guess I'm getting too much into the weeds...
« Last Edit: April 24, 2023, 12:41:58 PM by W3DRM »
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Re: Open Weather Forecast script error?
« Reply #3 on: April 25, 2023, 11:22:11 AM »
Not to belabor this topic but, on the scripts-OWMforecast.php page of your website under the setup instructions, I see the following:

    $showUnitsAs

        This setting controls the units of measure for the forecasts.
        ='si' SI units (C,m/s,hPa,mm,km)
        ='ca' same as si, except that windSpeed and windGust are in kilometers per hour
        ='uk' same as si, except that nearestStormDistance and visibility are in miles, and
        windSpeed and windGust in miles per hour
        ='us' Imperial units (F,mph,inHg,in,miles)Saratoga template users: This setting will be overridden by the
        $SITE['OWMshowUnitsAs'] specified in your Settings.php.


This is what triggered my initial comment and thus, the confusion on my part.

And, as always, thanks for all you do and have done for those of us who thoroughly enjoy working with your scripts! Have a GREAT Day - Don-w3drm
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Open Weather Forecast script error?
« Reply #4 on: April 25, 2023, 12:17:31 PM »
Guilty of inconsistent comments, I am.  I fixed it on the scripts page.  It will always be km for visibility as the API always returns metric for that data.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Re: Open Weather Forecast script error?
« Reply #5 on: April 25, 2023, 12:38:07 PM »
Well, it was me who misinterpreted the settings. I guess that is the problem with having so many different, but similar, variables that can lead to confusion. It's just like the wxastronomy scripts - two different but similar routines with the same script name.

Oh well, it helps keep this old brain working and active.

Best regards
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Open Weather Forecast script error?
« Reply #6 on: April 25, 2023, 12:43:43 PM »
I was running fairly fast and loose to clone/adapt the original DarkSky script to the three new services (PirateWeather, VisualCrossing, OpenWeatherMap) while renaming variables and some internal logic and docs for each script.  Thanks for your keen eyes to spot the inconsistency.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP