Author Topic: wxStory 3.0  (Read 9011 times)

0 Members and 1 Guest are viewing this topic.

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
wxStory 3.0
« on: March 31, 2022, 02:52:11 PM »
Attached is wxStory 3.0 that adds the Eastern Stations, and re-classifies some of the others.  Also added are several options for map and dropdown list placement.

The attached .zip file is Curly's last version with the updated files included.  This will be replaced in this post with any future updates.

Jerry Wilkins was invaluable and spent a lot of time testing and helping to get this in its final form.  He identified many issues and reminded me that it should be validated before it was complete. 

Enjoy!

« Last Edit: August 24, 2022, 09:12:45 AM by jmcmurry »

Forum Search and Google Can be Your Best Friends

Offline rrrick8

  • Senior Contributor
  • ****
  • Posts: 238
    • Vermilion weather
Re: wxStory 3.0
« Reply #1 on: March 31, 2022, 08:49:58 PM »
Got it downloaded, then uploaded and working great Jim. Thanks a bunch.
Mine was working fine but this is far more efficient.

Rick
Severe Weather Manager-Vermilion County EMA
CWOP-CW9931 KILDANVI5

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #2 on: April 01, 2022, 04:40:52 AM »
Thanks Rick, it's good to hear that everything went smoothly.  - Jim

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #3 on: April 01, 2022, 08:12:37 AM »
Many thanks to you Jim and also Jerry!  This script has been needing attention for a long time.  Nice work  =D>

EDIT: I've confirmed that it validates HTML5.
« Last Edit: April 01, 2022, 08:18:28 AM by tmabell »

Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 522
    • Tyler Texas Weather
Re: wxStory 3.0
« Reply #4 on: April 01, 2022, 10:25:03 AM »
Great work Jim and Jerry. This works great.

I had one issue/suggestion for you. I noticed that on almost all the WFOs I visited that the weather story image appeared distorted, that is, the image height wasn't proportional to the width (I used the 700 default). Looking into the code, I noticed you chose to use the height as 58% of the width. Realizing there appears not to be a standard among the WFOs, I changed that value to .75 because it made the images I was viewing much less distorted.

My suggestion is to move the $imgheight variable under Main Settings and add a note in the readme telling the users they may want to play with this value to get the best looking images for the WFOs they use.

Thanks again for updating this script.

Steve

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #5 on: April 01, 2022, 10:41:50 AM »
Steve,

I'll make that change, but at my WFO that distorts the images terribly the other way.  I may have a better idea if I can get it to work.

Thanks for the input.  - Jim

Forum Search and Google Can be Your Best Friends

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #6 on: April 01, 2022, 06:34:30 PM »
Well, that worked and has been tested by both Steve and Jerry.  Attached here and updated in the .zip.  - Jim
« Last Edit: April 07, 2022, 04:14:24 AM by jmcmurry »

Forum Search and Google Can be Your Best Friends

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3366
    • Emmett Weather
Re: wxStory 3.0
« Reply #7 on: April 03, 2022, 02:06:26 PM »
Nice job guys! I've always wanted to know the east coast stories as have I family up and down the eastern seaboard and they have asked if anything like this was available. Now I can tell them YES.

It works great - WELL DONE!  [tup]

I just wish Boise, Idaho had weather story info too.
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 (temporarily off-line) --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s151,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: wxStory 3.0
« Reply #8 on: April 03, 2022, 07:48:47 PM »
Getting an error on my parent's page....

Warning: Division by zero in /homepages/14/d347616009/htdocs/wxStory_inc.php on line 570


if(preg_match("|$imName\"|",$hv)) {                                                //  IF the selected image is in the headline
      $hv = preg_replace('/-color:#F0F7FF/', '-color:#0071BC', $hv);                   //   change background color to blue
      $hv = preg_replace('/ color: #0071BC/', ' color:#FFF', $hv);                     //   change text color to white
      $hv = preg_replace('/td style="/', 'td style="width:'.$hdlnrwidth.'px; ', $hv);  //   adjust column width
   } else{                                                                               //  OR ELSE                                        <<<<<< LINE 570
      $hv = preg_replace('/ background-color:#F0F7FF;/', '', $hv);                     //   change background color to a light color
      $hv = preg_replace('/td style="/', 'td style="width:'.$hdlnrwidth.'px; ', $hv);  //   change column width
      $hv = preg_replace('/td style="/', 'td class="hdline" style="border-bottom: thin solid #0071BC; border-top: thin solid #0071BC; ', $hv);  //   change column width
   }
   $hdline .= $hv."\n";


Everything works fine on my page. Thanks

UPDATE: Turns out MS Edge is blocking the images from being loaded. Has anyone else seen that issue before?

« Last Edit: April 03, 2022, 08:06:39 PM by ALITTLEweird1 »
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #9 on: April 04, 2022, 04:39:21 AM »
Mark,

Are they still getting that error?  Was there a setting in Edge that needed changing?

- Jim

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #10 on: April 04, 2022, 05:45:14 AM »
EDIT: IWX has updated the image and the problem has dissapeared.  I wish I had saved a copy of the offending image for troubleshooting but I didn't think of it soon enough.

ORRIGINAL POST:
I'm getting a PHP fatal error this morning on line 570 of wxStory_inc.php.  This seems to be just on KIWX (Northern Indiana's) page but I have only checked a few.

570 $R = $height/$width; 

PHP Fatal error:  Uncaught DivisionByZeroError: Division by zero in C:\\www\\wxStory_inc.php:570\nStack trace:\n#0 C:\\www\\MidWestWXstory.php(226): include()\n#1 {main}\n  thrown in C:\\www\\wxStory_inc.php on line 570

I haven't had an issue with Edge unless this is related.
« Last Edit: April 04, 2022, 07:41:34 AM by tmabell »

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: wxStory 3.0
« Reply #11 on: April 04, 2022, 09:15:59 AM »
Hey Jim. It seems to have fixed itself. I'll keep an eye on it.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #12 on: April 04, 2022, 01:19:15 PM »
I just wish Boise, Idaho had weather story info too.
All you had to do is ask for it.  They have a Story today!!

Mark, good news!

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #13 on: April 04, 2022, 03:49:19 PM »
The error on line 70, when it occurs causes the script to break.  Could this happen if the image happened to be missing at the moment we attempt to access it?  If so, can that possibility be accounted for?   I'm thinking of that brief time when the images being replaced or updated.

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #14 on: April 04, 2022, 04:34:49 PM »
That happens when we get an incomplete image from the NWS.  I haven't seen that recently, but it used to happen a lot.  I'll see if there's a good way around that.  Are you set to use the cURL or the streaming function?

Thanks.  - Jim

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #15 on: April 04, 2022, 05:04:46 PM »
Yes, I made the change back to curl with your initial release of ver 3.0.

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #16 on: April 05, 2022, 10:24:34 AM »
I've attached Version 3.02 which

1) Fixed calculating the image display height for divide by 0.
2) Added the option for maintaining screen scroll position.
3) Added the option to show/hide the captions below the Weather Story image.

Please let me know if you have any problems or comments.  - Jim
« Last Edit: April 07, 2022, 04:13:14 AM by jmcmurry »

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #17 on: April 05, 2022, 10:56:58 AM »
I hate to report that there is still aa problem.  If you try BOI (Boise, ID) you'll get a script-breaking error again related to divide by zero.  I don't think they have a Weather Story today but trying theirs anyway exposed this bug.

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #18 on: April 05, 2022, 12:15:02 PM »
If you see it again, get a line number if you can.  Thanks, - Jim

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #19 on: April 05, 2022, 01:57:24 PM »
This happens every time I click on Boise, ID.  I noticed that it happens on your site also, Jim.  My Apache logs print this:

Quote
[Tue Apr 05 13:54:05.127905 2022] [php:warn] [pid 11708:tid 800] [client 192.168.10.1:52687] PHP Warning:  getimagesize(./wscache/wsimg_boi.png): Failed to open stream: No such file or directory in C:\\www\\wxStory_inc.php on line 583, referer: https://mymishawakaweather.com/MidwestWXStory.php
[Tue Apr 05 13:54:05.127905 2022] [php:error] [pid 11708:tid 800] [client 192.168.10.1:52687] PHP Fatal error:  Uncaught DivisionByZeroError: Division by zero in C:\\www\\wxStory_inc.php:587\nStack trace:\n#0 C:\\www\\MidWestWXstory.php(226): include()\n#1 {main}\n  thrown in C:\\www\\wxStory_inc.php on line 587, referer: https://mymishawakaweather.com/MidwestWXStory.php

For reference, the image is not in ./wscache.  I assume this occurs because BOI does not have an image presently.  Hope this helps.



Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #20 on: April 05, 2022, 05:33:32 PM »
Thanks, that's a huge help.  I see that now on my site too.  I've clicked on them many times before, so I'll bet it has something to do with them being "open for business" yesterday.

The attached should take care of it.  That's a very complicated part of Curly's code, so I don't know why that would happen only for Boise.

 - Jim
« Last Edit: April 07, 2022, 04:12:43 AM by jmcmurry »

Forum Search and Google Can be Your Best Friends

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: wxStory 3.0
« Reply #21 on: April 05, 2022, 05:58:09 PM »
Thanks Jim!  That seems to have solved it.  There is some errata in the logs but the script functions without fail.  I don't know if these matter but I'll pass them on just in case.

Quote
[Tue Apr 05 17:53:32.778895 2022] [php:warn] [pid 11708:tid 768] [client 192.168.10.1:51647] PHP Warning:  imagecreatefrompng(): gd-png: libpng warning: Interlace handling should be turned on when using png_read_image in C:\\www\\wxStory_inc.php on line 678, referer: https://mymishawakaweather.com/
[Tue Apr 05 17:53:50.870929 2022] [php:warn] [pid 11708:tid 808] [client 192.168.10.1:51670] PHP Warning:  Undefined variable $imgheight in C:\\www\\wxStory_inc.php on line 734, referer: https://mymishawakaweather.com/MidwestWXStory.php
[Tue Apr 05 17:53:58.436362 2022] [php:warn] [pid 11708:tid 768] [client 192.168.10.1:51671] PHP Warning:  Undefined variable $imgheight in C:\\www\\wxStory_inc.php on line 734, referer: https://mymishawakaweather.com/MidwestWXStory.php?i=pih

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #22 on: April 06, 2022, 07:10:11 AM »
We found that the first warning was due to a file version on the server, and the attached should take care of the other.  I left the version # the same because it's a minor mod to a previous fix.

- Jim

Forum Search and Google Can be Your Best Friends

Offline drrehak

  • Senior Member
  • **
  • Posts: 72
Re: wxStory 3.0
« Reply #23 on: April 12, 2022, 12:53:00 PM »
Installed this for the first time today and it seems to be working.
While testing, I tried Portland, and got the "no story today" header, but it still tried to display the nonexistent image from the cache directory, so I got the broken image icon and a large blank area on the page.

Don't know if there is a better solution or if I did something wrong, but I made the following change -- just added the conditional test to control the display of the table row with the image:
Code: [Select]
<?php if (file_exists($wsimg)) {?>
 <tr>
 <td style="text-align:center"><img src="<?php echo $wsimg ?>" style="width: <?php echo $tablewdth;  ?>px; height: <?php echo $imgheight ?>px;" alt=" " /></td>
 </tr>
 <tr>
<?php }; ?>
Dan Rehak | Pittsburgh PA
Davis Vantage Pro 2 Plus | Meteobridge Pro
Local Site | Raspberry Pi 4B

Offline jmcmurry

  • Jim McMurry
  • Forecaster
  • *****
  • Posts: 528
  • Davis Vantage Pro 2 Plus Wireless.
    • Juneau County Weather
Re: wxStory 3.0
« Reply #24 on: April 13, 2022, 05:52:45 AM »
Thanks Dan, I hadn't seen that problem.  That is a prudent change and I will add it.



[Edit] The updated script is attached.  Thanks again.  - Jim
« Last Edit: April 13, 2022, 06:19:35 AM by jmcmurry »

Forum Search and Google Can be Your Best Friends