River/Lake Height Display addon page for WD-AJAX-PHP-USA

Give me a second to upload…

Ok uploaded…

http://travelingrvwx.com/wxriverpage2.php

and

http://travelingrvwx.com/wxriverpage2-2.php

Dan thanks for hopping in, right now it looks that I have found the problem. The pages that are not working are not taking the date in the future and doing anything with it. So when the script does its loop it has already met its criteria and stops, so it does not pick up older trend data.

This is the last test for today, if it does not work I will have to go with another method to get it to work.

Thanks for your help guys,
-Dennis


wxriverpage2.php.txt (20.6 KB)

http://travelingrvwx.com/wxriverpage2-3.php

Hi Dennis and All,

Worked on this project last night and got it working without those errors that I posted earlier. Redid the entire page from scratch but a few issues.

Take a look at http://www.dwayneyamato.com/wx/wxriverpage.php.

  1. On the map there are not squares that indicate where the streams are located.

  2. A lot of feed back on my email from the cron daemon like:

    “Next update after Saturday July 13th, 2013 09:12 AM HST” A lot of these…

    “0 Gauges Near Flood Stage
    0 Gauges with Minor Flooding
    0 Gauges with Moderate Flooding
    0 Gauges with Major Flooding
    0 Gauges in Action or above
    Last Update: Saturday July 13th, 2013 05:15 AM HST
    Next Update: Saturday July 13th, 2013 09:12 AM HST” A few of these.

    And one of these:

    "Warning: simplexml_load_file(): ./river-IAOH1.txt:1: parser error : Document is empty in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109

Warning: simplexml_load_file(): in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109

Warning: simplexml_load_file(): ^ in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109

Warning: simplexml_load_file(): ./river-IAOH1.txt:1: parser error : Start tag expected, ‘<’ not found in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109

Warning: simplexml_load_file(): in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109

Warning: simplexml_load_file(): ^ in /home/dwayneya/public_html/wx/River/river-fetch.php on line 109
0 Gauges Near Flood Stage
0 Gauges with Minor Flooding
0 Gauges with Moderate Flooding
0 Gauges with Major Flooding
0 Gauges in Action or above
Last Update: Saturday July 13th, 2013 05:00 AM HST
Next Update: Saturday July 13th, 2013 08:57 AM HST"

Any suggest or solutions is very much appreciated.

Thank you for your support on this project.

–Stan Y.
Maui, Hawaii

Stan, what happens if you remove all the rivers from the config and just display the map? If it works, can you click on the squares and see valid data?

From looking at your errors I think the first one that says the document is empty is creating the follow on errors. Best guess is the script is not parsing the data correctly, hence the empty file.

Hi Dan,

Thanks for the suggestions but when I removed all the rivers from the config file, some errors showed up and still no squares on the map.

When I looked at the all the river files they have something in them, so there are data in them but don’t know why it is not parsing out.

Will let it run as is for the time being but the cron daemon is still emailing me those messages… I can live with that. At least it is not showing up on the page like the first time when it started. Will have to check and see what the cron job is like. Maybe something there the fetch does not like…

Thanks again for the suggestion and will wait to see what Dennis comes up with.

–Stan Y.
Maui, Hawaii

I don’t use cron. I setup WD to http download the river-fetch page. It’s the same thing as pointing your browser to the page. Not sure why your map isn’t showing anything. The only issue I have, that I know of, is the trends don’t seem to change. Might get some rain next week so will see if that makes any difference.

Compared your output after clicking on one of the river links and I don’t see any datum on your page. Maybe a clue for Dennis.

Did the squares ever show on your map?

Hi Dan,

Maybe I should dump the cron job and use WD and see what happens. How do I setup WD to do what you are doing with it?

Hope that Dennis kicks in when his time is available.

No, those squares have never appeared with this version that is using the long/lat method. When I first started this project, the squares were there using the iframe method of getting the location of the streams. Then I started getting those errors that is seen on my earlier posts.

Will let it ride as is for now and see what happens. I am still getting emails from the cron daemon as to when the next update is scheduled.

Thanks again for your inputs.

–Stan Y.
Maui, Hawaii

Here’s my setup


Thanks Dan for your setup on WD. Will give it a shot and turn off the cron job and see what happens. Maybe the host I am using does not like what is going on with the fetch file. I have another script to try on the cron job to test out too.

Hope one will satisfy this project.

Will let you know the outcome either way it goes.

Thanks again for your input.

–Stan Y.
Maui, Hawaii

Hey Dan,

Another question on scheduling with WD, do I have to have river-fetch.php file on the same computer as WD and if so, where do I put it. I as this because in one of the Local Filename window shows river-fetch and above it the Tick if a text file is checked. Also in the Local filename of the file to to downloaded.

Just some clarification please.

Thanks for all.

–Stan Y.
Maui, Hawaii

The river-fetch.php file is on your webserver. The setup I posted uses WD to “hit” the fetch file and that causes it to run. The actual download of the file is not important so just point it to wherever you want WD to save it and call it whatever you like.

Thanks Dan for that info. John G. has been working on this issue for me and resolved the square on the map issue. Had to edit the location to Hawaii and not NY. But still have other issues. The cron job seems to be working but some other issues with the fetch and config files seems to be the issue for now.

Got the http://www.dwayneyamato.com/wx/wxriverpage2.php working for trouble shooting for Dennis to see what is up with my site.

Thanks you all for trying to resolve my issue with this project.

–Stan Y.
Maui, Hawaii

We’ve had some local flooding over the past few days, so my interest in the wxriverpage script has been heightened as well. I was frustrated when the ‘Trend’ arrows were all blue horizontal ones even though the levels have been fluctuating markedly.

My simple fix for the problem, which boiled down to a failed ‘strtotime($old)’ statement in a ‘while’ loop, was to use this code:

// Get reading from 1 hour ago, then do some math.
if($trend==1){
	$data1= strtotime($ObsTime) - (60 * 60);
	$k=0;
	$old = 999999999999;
	while($data1<$old){
		$k++;
		$old = (string)$xmlData["$riverid"]->observed->datum[$k]->valid;
	}

instead of:

// Get reading from 1 hour ago, then do some math.
if($trend==1){
	$data1= strtotime($ObsTime) - (60 * 60);
	$k=0;
	$old = 999999999999;
	while($data1<strtotime($old)){
		$k++;
		$old = (string)$xmlData["$riverid"]->observed->datum[$k]->valid;
	}

The while loop was never entered because ‘strtotime($old)’ was always null when a time was used. Dennis had changed to the 99999999999 string in his latest iteration of this script, but somehow he left the ‘strtotime($old)’ in place. Even when a proper future date was entered as the initial ‘$old’, the ‘strtotime($old)’ remained null. Only when ‘while($data1<strtotime($old)){’ was changed to ‘while($data1<$old){’ did my trend arrows begin showing proper directional information.

As our streams are now back in their banks and with little immediate chance of rain, the NWS is backing off on forecasting most of our local river heights. This has left errors in any forecast with less than seven valid entries.

A fix for this in ‘riverdetail.php’ is to add a check for a valid forecast entry before attempting to display one by changing

while($i<$j+7){ ?>

to

while($xmlData->forecast->datum[$i]->valid && $i<$j+7){ ?>

This eliminates riverdetail.php’s attempt to display seven forecasts when less than seven exist. This forecast currently shows 4 forecast entries, but as time progresses they will dwindle to none after tomorrow, May 13.

Jerry,

If you do not mind I would like to add these changes to my site and then, add them to the actual release of the script. I am extremely limited in time, but I would like to help keep this script going.

Thank you for looking into this, and making the changes you did. Hopefully this will help others out too!

Thanks,
-Dennis

By all means do so, Dennis. Thank you for the script. It’s my go-to page for local stream conditions when we’re having storms in the area and I feel lost without it. While its complexity is often beyond me, I can often troubleshoot small bits here and there when the error messages point me in the right direction. Like they say, ‘Even a blind hog finds an acorn once in a while.’ :slight_smile:

After making a change published under this forum I noticed my readings now in the negatives??? I was at Washington’s crossing earlier today and the water is there…and looks deep near the gauge…