WXforum.net

Weather Related Organizations => noaaweatherradio.org => Topic started by: saratogaWX on December 08, 2019, 08:27:25 PM

Title: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on December 08, 2019, 08:27:25 PM
As the NWS moved the NOAA Weather Radio site from www.nws.noaa.gov to weather.gov, they took the opportunity to add some new dynamic features to their detailed radio transmitter displays (and thereby broke the V2.x version of the script).

Now, there's V3.00 of the script set available.  It includes two new features:
1) optional display of the transmitter propagation map as an overlay on the basemap
2) optional display of the county/SAME code coverage for the transmitter
Note that these features are only available on NOAA/NWS transmitters, and not for EC/Canadian transmitters nor for auxiliary streams hosted at noaaweatherradio.org home site.

Yes, you should replace ALL the old scripts with the updated ones, and there's a new (fairly large) shp.js file needed for handling the NWS shapefiles from the weather.gov site for the propagation and county overlay maps.

Download from the script page at https://saratoga-weather.org/scripts-wxradio.php  or
the GitHub distribution at https://github.com/ktrue/Weather-radio-player

I've attached an image of how the new display looks.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: ed2kayak on December 08, 2019, 09:46:38 PM
Thanks Ken  :-)

http://cvweather.org/wxradio.php
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: 92merc on December 09, 2019, 08:59:31 AM
Copy, paste, done.

Thanks Ken.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: tmabell on December 11, 2019, 04:47:53 PM
I haven't done my due diligence by checking these notices because I'm not sure that they even matter as everything works as it should, but the W3C CSS Validator is complaining:

http://jigsaw.w3.org/css-validator/validator?uri=https%3A%2F%2Fmymishawakaweather.com%2FWxRadioNational.php (http://jigsaw.w3.org/css-validator/validator?uri=https%3A%2F%2Fmymishawakaweather.com%2FWxRadioNational.php)
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on December 11, 2019, 05:16:42 PM
The CSS cited are from bootstrap and the leaflet CSS .. they include pseudo markups for vendor-specific tags as many of the features used were not native parts of CSS 2.  The HTML validates, the CSS is a bit old (but not harmful).
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: tmabell on December 11, 2019, 06:06:42 PM
Thanks very much Ken!
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: Bunty on December 12, 2019, 01:08:11 PM
My stand alone version, HTML 5 compliant.  Thanks Ken!

https://stillwaterweather.com/wxradio (https://stillwaterweather.com/wxradio)
Title: Re: NOAA Weather Radio Player scripts V3.01 now available
Post by: saratogaWX on May 25, 2020, 02:31:29 PM
Update today to V3.01 to add a padlock 🔒 (🔒 UTF-8) SSL indicator to all https: provided streams and a note
Quote
Streams with 🔒 are provided with SSL (https:) streaming.
Your browser may not support playing non-SSL streams if you are viewing this site with https:// (secure).
in the page.

Updates were to NWR-radios.js and NWR-radios-inc.php only.

The script page (https://saratoga-weather.org/scripts-wxradio.php#wxradio) has the demo and download.

Also available at GitHub (https://github.com/ktrue/Weather-radio-player)
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 25, 2020, 03:52:30 PM
Ken,

Just updated the 2 files and now see the lock on certain streams. However, it's not showing on my WXK36 stream that I set up on SSL over the weekend. Can you take a look at that for me?

Thanks,

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 25, 2020, 04:16:56 PM
Oops.. I'd checked the SITE url, not the RADIO url for SSL in NWR-radios.js.

I've pushed an update to the distribution (and GitHub).

Replace that script, then to make sure your cache file is current, run NWR-radios-data.php?cache=no to freshen the cache file.

Thanks for spotting the issue Steve.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 25, 2020, 04:39:11 PM
Ken,

Much better. Thanks for your quick response.

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 25, 2020, 05:06:36 PM
Ken,

When viewing the updated WxRadio script, my OCD unfortunately kicked in. I happened to notice a misspelled word in the verbiage just above the map. The word is near the end of this sentence "These audio streams are graciously provided by personal weather website owners and others though NOAAWEATHERRADIO.org." I believe the word "though" should be "through".

Sorry to be nit-picky.  :grin:

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 25, 2020, 05:19:30 PM
No issue with picking up on typos.. thanks!

I've pushed that update to NWR-radios-inc.php to the .zip and GitHub.

Thank you!
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 26, 2020, 04:04:17 PM
Ken,

It appears the "Street2" map in the legend (I think this is the Wikimedia map), doesn't load. I've tried it on my site, your site, and others as well, and it only shows "Loading Map".

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 04:39:47 PM
It's an issue with maps.wikimedia.org  .. some tiles get [HTTP/2 429 No Reason Phrase) returns instead of getting the tile pane and the content of the response is html
Quote
Error

Our servers are currently under maintenance or experiencing a technical problem. Please try again in a few minutes.

See the error message at the bottom of this page for more information.

When their servers are back to normal, the issue should disappear.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 26, 2020, 04:49:36 PM
Thanks Ken.

I've been looking at the various maps and have seen a couple more interesting issues.

1) In radios.php and wxradio.php, there is no $mapProvider defined for NatGeo even though NatGeo is in the legend and has code in NWR-radios-inc.php.
2) When I set $mapProvider='Terrain' in radios.php, the map that is displayed is the OSM map instead of the ESRI map and the 'Street' radio button is selected in the legend.

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: Forever on May 26, 2020, 05:16:49 PM
Hi Ken,

After this update the radio and the map will not load. The script is not modified at all.
I'm thinking it may be something with my server or old software?

http://www.weathercat.net/wxradio.php
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 05:30:28 PM
The NWR-radios-inc.php has the complete list of all the (current) map providers .. I guess I'd just forgotten to update the similar commented-out settings in radios.php and wxradio.php.

I'd coded a hierarchy of the settings for the NWR-radios-inc.php:
1) the local settings inside wxradio.php or radios.php are the initial ones.
2) If wxradio.php is loaded inside a saratoga template, then the following overrides can be made:
Code: [Select]
if(isset($SITE['WXRstartup']))    { $startup = $SITE['WXRstartup']; }
if(isset($SITE['WXRmapprovider']))    { $mapProvider = $SITE['WXRmapprovider']; }
if(isset($SITE['WXRprovider']))   { $streamprovider = $SITE['WXRprovider']; }
if(isset($SITE['WXRautoplay']))   { $autoplaystartup = $SITE['WXRautoplay']; }
if(isset($SITE['WXRbackground'])) { $backgroundColor = $SITE['WXRbackground']; }
if(isset($SITE['mapboxAPIkey']))  { $mapboxAPIkey = $SITE['mapboxAPIkey'];}
The currently supported maps are shown in the $mapTileProviders = array() with the 'key' as the map provider and the 'name'=> the map name displayed in the selection box.
Code: [Select]
$mapTileProviders = array(
  'OSM' => array(
   'name' => 'Street',
   'URL' =>'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
'attrib' => '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Points &copy 2012 LINZ',
'maxzoom' => 18
  ),
  'Wikimedia' => array(
  'name' => 'Street2',
    'URL' =>'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png',
  'attrib' =>  '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia</a>',
  'maxzoom' =>  18
    ),
  'Esri_WorldTopoMap' =>  array(
  'name' => 'Terrain',
    'URL' => 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
  'attrib' =>  'Tiles &copy; <a href="https://www.esri.com/en-us/home" title="Sources: Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community">Esri</a>',
  'maxzoom' =>  18
    ),
'Terrain' => array(
   'name' => 'Terrain2',
'URL' =>'http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.jpg',
'attrib' => '<a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> <a href="https://stamen.com">Stamen.com</a> | Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.',
'maxzoom' => 14
  ),
'NatGeo' => array(
   'name' => 'NatGeo',
'URL' =>'https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',
'attrib' => 'Tiles &copy; <a href="https://www.esri.com/en-us/home" title="Sources: Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community">Esri NatGeo</a>',
'maxzoom' => 16
  ),
'OpenTopo' => array(
   'name' => 'Topo',
'URL' =>'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
'attrib' => ' &copy; <a href="https://opentopomap.org/">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>) | Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.',
'maxzoom' => 15
  ),
'MapboxTer' => array(
   'name' => 'Terrain3',
'URL' =>'https://api.mapbox.com/styles/v1/mapbox/outdoors-v10/tiles/256/{z}/{x}/{y}?access_token='.
$mapboxAPIkey,
'attrib' => '&copy; <a href="https://mapbox.com">MapBox.com</a> | Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.',
'maxzoom' => 18
  ),
'MapboxSat' => array(
   'name' => 'Satellite',
'URL' =>'https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v10/tiles/256/{z}/{x}/{y}?access_token='.
$mapboxAPIkey,
'attrib' => '&copy; <a href="https://mapbox.com">MapBox.com</a> | Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.',
'maxzoom' => 18
  ),

);

For (2) above, the $mapProvider='Terrain' isn't a valid choice (no 'Terrain' entry in the $mapProvider array) so the script defaults to using 'OSM' with
Code: [Select]
  if(isset($mapTileProviders[$mapProvider]) ) {
$sct = "// using \$mapProvider = '$mapProvider' as default map tiles. \n";
} else {
$sct = "// invalid \$mapProvider = '$mapProvider' - using OSM for map tiles instead. \n";
$mapProvider = 'OSM';
  }
and 'OSM' will show 'Street' in the legend.

Guess I should add the valid choices in the comments in radios.php and wxradio.php so folks can just uncomment a line for their choice.

 
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 05:37:50 PM
Hi Ken,

After this update the radio and the map will not load. The script is not modified at all.
I'm thinking it may be something with my server or old software?

http://www.weathercat.net/wxradio.php
Hmmm... loads just fine for me.  Try clearing the browser cache and do a shift-reload of the page.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: Forever on May 26, 2020, 05:48:52 PM
I just tried that and still nothing. It looks like the attached image.
 [ You are not allowed to view attachments ]

Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 06:11:28 PM
Based on the screenshot, it looks like you're using IE11 for a browser.  I see it has the same problem for me in IE11.
Try using Edge, Firefox, Chrome or Opera .. they all work.

The developer tools in IE11 shows
Quote
jQuery.Deferred exception: Object doesn't support property or method 'includes' TypeError: Object doesn't support property or method 'includes'
so Microsoft's JavaScript engine doesn't like that particular thing in jQuery itself, so it stops execution of jQuery and so the rest of the page/map stops loading.

Time to switch to Edge (or Firefox/Chrome/Opera) .. IE11 is past it's prime.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: Forever on May 26, 2020, 06:13:19 PM
But I'm old and don't like change.

Thanks Ken.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 26, 2020, 06:21:14 PM
Ken,

I think I've got a better handle on it now. But of course, that leads to another question. If I want to use the Terrain Map from stamen.com, I assumed I could just uncomment the
$mapProvider = 'Terrain'; line and that the code following would be used.
Code: [Select]
'Terrain' => array(
   'name' => 'Terrain2',
'URL' =>'http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.jpg',
'attrib' => '<a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> <a href="https://stamen.com">Stamen.com</a> | Data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors.',
'maxzoom' => 14
  ),

But this gives me the OSM map because it's not finding something. I understand why it goes to OSM if it's not finding the $mapProvider, but it looks like it should find 'Terrain' just like it finds 'Street' or 'NatGeo' or the others.

I hope I've clarified my problem a little better.

Thanks,

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 06:31:55 PM
You're doing it correctly.  The issue is that the *.tile.stamen.com tiles are HTTP and so in an HTTPS page (view-source) you'll see
Quote
// skipping Terrain2 due to http only map tile link while our page is https

since the tiles there wouldn't load.
I just tested, and https://{*}.tile.stamen.com/ accesses just fail.. no map returned, so those tiles only work when the loading page is http, not https.
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: Forever on May 26, 2020, 07:02:29 PM
I got the script to work in IE11. It seems some web browsers have an issue with .includes() so adding the code below fixed it for me.

Code: [Select]
String.prototype.includes = function (str) {
  var returnValue = false;

  if (this.indexOf(str) !== -1) {
    returnValue = true;
  }

  return returnValue;
}
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: SteveFitz1 on May 26, 2020, 07:36:37 PM
You're doing it correctly.  The issue is that the *.tile.stamen.com tiles are HTTP and so in an HTTPS page (view-source) you'll see
Quote
// skipping Terrain2 due to http only map tile link while our page is https

since the tiles there wouldn't load.
I just tested, and https://{*}.tile.stamen.com/ accesses just fail.. no map returned, so those tiles only work when the loading page is http, not https.
Got it. Since I want everything secure, I'll have to pass on that option.

Thanks again.

Steve
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 07:44:18 PM
I got the script to work in IE11. It seems some web browsers have an issue with .includes() so adding the code below fixed it for me.

Code: [Select]
String.prototype.includes = function (str) {
  var returnValue = false;

  if (this.indexOf(str) !== -1) {
    returnValue = true;
  }

  return returnValue;
}
Ok, that's brilliant.  I'm going to incorporate that into the distribution (after a typeof check for undefined).
Thanks!
Ken
Title: Re: NOAA Weather Radio Player scripts V3.00 now available
Post by: saratogaWX on May 26, 2020, 08:42:04 PM
And.. it's done (Version 3.02 - 26-May-2020).
Update to NWR-radios-leaflet.js to add
Code: [Select]
if(typeof String.prototype.includes == 'undefined') { /* shim function for IE11 */
String.prototype.includes = function (str,start) {
  var returnValue = false;
  var tststr = str;
if (typeof start == 'number') {
tststr = str.substr(start);
}
  if (this.indexOf(tststr) !== -1) {
    returnValue = true;
  }

  return returnValue;
  }
}
.. I found that Edge12+ supports the function, IE11- does not.  Thanks for the idea to have a shim.

wxradio.php, radios.php  add commented-out setting for NatGeo map, and add http-only note to 'Terrain' (stamen.com) map.

Updated the .zip and GitHub distributions.
Title: Re: NOAA Weather Radio Player scripts V3.03 now available
Post by: saratogaWX on May 28, 2020, 09:55:26 PM
Another update but just to NWR-coverage.php V3.03 to now use Settings.php $SITE['cacheFileDir'] for the directory location of the NWR-radios-data.js file updated by NWR-radios-data.php.

You can get it from the
script page (https://saratoga-weather.org/scripts-wxradio.php#wxradio) or
GitHub distribution (https://github.com/ktrue/Weather-radio-player)
or just Download NWR-coverage.php V3.03 (https://saratoga-weather.org/NWR-coverage.php?sce=view)

This was a hidden bug from the release of 3.00 in December, 2019.  I couldn't understand how newly-added sites to noaaweatherradio.org weren't showing Propagation and Coverage overlays.. turns out the NWR-radios-data.php was updating the .js file in one place (./cache/ in Saratoga template) while the NWR-coverage.php was always looking for it in ./ (an old copy of NWR-radios-data.js).  Sigh... now fixed.