Author Topic: Drought Pages Need Updated  (Read 2468 times)

0 Members and 1 Guest are viewing this topic.

Offline Bunty

  • Forecaster
  • *****
  • Posts: 2429
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Drought Pages Need Updated
« on: April 01, 2017, 09:26:51 PM »
Due to change in graphics or URLs drought pages need updated.  A good project for someone expert, I suppose.

http://droughtmonitor.unl.edu/Home/StateDroughtMonitor.aspx?OK

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #1 on: April 02, 2017, 12:38:38 PM »
It's a simple change, really.  They just renamed ../pngs/.. to ../png/.. so just modify any references in your scripts accordingly.  Here's mine with the source.  Oddly, they're not using SSL at this time.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: Drought Pages Need Updated
« Reply #2 on: April 02, 2017, 12:47:12 PM »
Be careful.. I had to write a PHP to pull out the correct date time group. They are storing the images in directories based on that...In addition to the PNGS->PNG change

Jim

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #3 on: April 02, 2017, 02:25:54 PM »
Be careful.. I had to write a PHP to pull out the correct date time group. They are storing the images in directories based on that...In addition to the PNGS->PNG change

Jim
There's an easier way, Jim: http://droughtmonitor.unl.edu/data/png/current/current_total_trd.png will give you the map you want to display, albeit with a smaller map that also includes historical information.  In order to get the map you display you will need to add a 'ymd' along with manipulating the 'ymd' to update to a Tuesday after a Thursday or Friday when new maps are posted.  My current script doesn't rely on date mashing to get the latest maps.  They come up when they're available.

I just created a test script that includes your map, but without the historical information I don't think it's worth the effort.  I'm pretty sure the date scheme isn't up to snuff either.
« Last Edit: April 02, 2017, 02:29:53 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: Drought Pages Need Updated
« Reply #4 on: April 02, 2017, 02:36:01 PM »
Not for states..... You have to still break it out.....
Jim

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #5 on: April 02, 2017, 02:48:39 PM »
Not for states..... You have to still break it out.....
Jim
The same applies to the states.  For example here is the Nebraska url: http://droughtmonitor.unl.edu/data/png/current/current_ne_trd.png which only needs to be modified by the two-letter state abbreviation to get any state map you desire.  These state maps include historical information no matter how you access them, so don't waste time trying to mash dates for them.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: Drought Pages Need Updated
« Reply #6 on: April 02, 2017, 03:07:29 PM »
Well I got screwed again... They other day, my images failed to be up to date... nearly a week old.. Even when I changed from pngs to png they were still old...I resorted to this method since I was able to get to the latest directory.. It appears that THEY were not updating the current images in a timely manner...Now it looks like they have....


This is enough to give up on all of this crap....and chuck it.....

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #7 on: April 02, 2017, 04:00:39 PM »
Sites in transition can give us fits!  Currently the NWS MDL (Meteorological Development Lab) is mostly offline.

I only check the latest drought conditions on Thursday after 8AM, and until their directory switch had no problems.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: Drought Pages Need Updated
« Reply #8 on: April 02, 2017, 04:15:08 PM »
Jim & Jerry,

I'm interested in how a php script works to pull the correct date from the directory.  There are some images that I'd like to use on other noaa sites that have the dates in the file names so I am unable to link to them directly.

Tom

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #9 on: April 02, 2017, 04:28:30 PM »
Jim & Jerry,

I'm interested in how a php script works to pull the correct date from the directory.  There are some images that I'd like to use on other noaa sites that have the dates in the file names so I am unable to link to them directly.

Tom
Date mashing is risky because you're trying to mimic an external site's schedule and code without really knowing what it is.  You don't know when the failure will come, but come it will.  My 'flumaps' script mashes dates, but it took quite a while to understand the variables in play before the script would work fairly reliably.  Even now it requires occasional revision when it falls over.  The main file source is here and the 'includes' file is here.  They serve as a fairly extreme example of the perils of date mashing.  There's a lot of commented out code in the includes file I need for debugging work, which makes it look even more gnarly than it is.

What images did you have in mind, Tom?
« Last Edit: April 02, 2017, 04:30:48 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #10 on: April 02, 2017, 07:47:13 PM »
It's a simple change, really.  They just renamed ../pngs/.. to ../png/.. so just modify any references in your scripts accordingly.  Here's mine with the source.  Oddly, they're not using SSL at this time.

Hi Jerry. I tried your code from your source, but it's not working. Any ideas? Thanks

https://www.northbendweather.com/wxdrought.php
"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 Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Drought Pages Need Updated
« Reply #11 on: April 02, 2017, 08:05:12 PM »
First I noticed an error in the Javascript function show_tab
Then I went to see the source and the script ends in the middle of the JS because of this error:

Call to undefined function getUniqueImageURL() in <b>/homepages/8/d252567151/htdocs/wxdrought.php</b> on line <b>200

This looks like some missing included file, it is trying to execute a PHP function getUniqueImageURL, which it does not know, I dont know the script well, but check that all the files that should be included are there

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #12 on: April 02, 2017, 08:08:16 PM »
I see that error too under source. I just copied what he had posted and this is what happened. The original script didn't need anything else to work.
"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 Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Drought Pages Need Updated
« Reply #13 on: April 02, 2017, 08:41:17 PM »
Try adding this in your script PHP part:

Code: [Select]

if (!function_exists('getUniqueImageURL')) {
function getUniqueImageURL($image_url){
$timestamp = time();
if(strpos($image_url, '?')){
$image_url = str_replace('?', "?$timestamp&", $image_url);
}
else{
$image_url .= "?$timestamp";
}
return $image_url;
}
}

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #14 on: April 02, 2017, 08:44:09 PM »
It's already there.
"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 gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #15 on: April 02, 2017, 08:51:13 PM »
Sorry for the delayed response.  I took a break.  :-)

The source is the working fine from my web site.  As you can see, it does work.

You might try removing the conditional from the 'getUniqueImageURL()' code by changing
Code: [Select]
if (!function_exists('getUniqueImageURL')) {
function getUniqueImageURL($image_url){
$timestamp = time();
if(strpos($image_url, '?')){
$image_url = str_replace('?', "?$timestamp&", $image_url);
}
else{
$image_url .= "?$timestamp";
}
return $image_url;
}
}
to
Code: [Select]
function getUniqueImageURL($image_url){
$timestamp = time();
if(strpos($image_url, '?')){
$image_url = str_replace('?', "?$timestamp&", $image_url);
}
else{
$image_url .= "?$timestamp";
}
return $image_url;
}
« Last Edit: April 02, 2017, 09:06:31 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #16 on: April 02, 2017, 08:56:26 PM »
That worked. Thanks Jerry.
"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 gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #17 on: April 02, 2017, 08:57:48 PM »
Good to know!

A little work is left for you, though.  The link to the animated gif's still goes to my site, which is in two parts.  The first is the main script, and the 'includes' script is here.  They're relatively straightforward. :-)
« Last Edit: April 02, 2017, 09:04:53 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #18 on: April 02, 2017, 09:27:45 PM »
I did remove the one,  but missed the other.  I'll fix that now.
"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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: Drought Pages Need Updated
« Reply #19 on: April 02, 2017, 09:32:42 PM »
Actually looking through the script, I did remove everything going to your site. The only thing there to your site is the modified by, which I left.
"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 gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #20 on: April 02, 2017, 09:36:09 PM »
Actually looking through the script, I did remove everything going to your site. The only thing there to your site is the modified by, which I left.
8-)
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline tmabell

  • Forecaster
  • *****
  • Posts: 394
    • Mishawaka Weather
Re: Drought Pages Need Updated
« Reply #21 on: April 04, 2017, 09:25:48 AM »
Jerry it has been so long I can't even find the images I wanted to use!  When it comes up again I will let you know.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Drought Pages Need Updated
« Reply #22 on: April 04, 2017, 10:20:21 AM »
Jerry it has been so long I can't even find the images I wanted to use!  When it comes up again I will let you know.
Most of the images are found on my site.  If the image is displayed, just right click to get the URL or left click to open it in a new tab and get the URL from the address bar.  I would discourage using images without the history because they're not as informative without a trend alongside.
Regards, Jerry Wilkins
gwwilk@gmail.com