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

Great script. I blended my clickable map.
http://www.knology.net/~blackjack52/wxhydro3.php

I was able to take his code listed and have it show up on my server just fine. Im thinking it maybe a server issue.

yeah I think so…its displaying fine on my guage-page…I had to take out guage “BDBC1” as it was showing several errors on the page…OK I’m going back to my guages…

Lee,

That is a pretty slick map you got there. I was going to search the AHPS site some more to see if they had “coordinates” on their maps. Then I might be able to make the map click able with little effort.

-Dennis

Thanks Dennis.
Unfortunately, there’s no easy way to do it.

Here’s my php. 1 setting to get the map url.
Then to get the map coords, goto the AHPS pg for your area and use View Source in your browser.


wxhydro3.txt (11.8 KB)

Hey Dennis and Chris, I tried the Script on a different server I have, my dondelingerphotography.com site.
It works great on that server. So I need to get with the people at my foresthillweather.com site and hopefully get them to fix it. I thank you guys very much for your help.

Thanks again Scott

I see your flood guage page is up and running…what was the problem???

Hi Chris and Dennis, The best way I can explain what they did is to pass the info they sent me via email.

This is what they sent me.

The problem does not seem to be with our server but with the PHP code
itself.

The PHP code (wxriverpage.php) uses simpleXML to parse the
river-XXX.txt files and breaks out the information in those XML into
different variables that are then used to generate the webpage based
on a bunch of if statements that uses math operations for comparisons.

The problem is that simpleXML returns values that are of type “Object”
and the comparisons utilize the number_format() function and this
function does not seem to know what to do with an “Object” variables.
So even though variables like $ObsStage seemed to have a valid integer
/ float value associated to it, number_format() would return a null or
something else that would make the comparisons invalid / wrong thus
generating the wrong results for the page output.

A simple fix was to convert the simpleXML objects to something that
number_format() likes so I update the code to convert all the
simpleXML objects to strings and the page now renders correctly.

Sample: Before

$ObsStage = $xmlData[“$riverid”]->observed->datum[0]->primary;

After:

$ObsStage = (string)$xmlData[“$riverid”]->observed->datum[0]->primary;

This seems to be a common issue coders run into when trying to use
math operations on variables created from simpleXML.

http://www.php.net/manual/en/book.simplexml.php#95762
http://www.php.net/manual/en/book.simplexml.php#94105

I’m not sure why the unmodified code seems to work on your other host
provider and not on our server but my guess is that our servers are
running different versions of PHP and they changed something between
versions.

What I have is a big band aid on that script within the server to make it work. My server is running the lastest PHP which is PHP 5.3.3 The script worked fine on my go daddy server, but that was PHP 5.2.8 I am still curious if anybody else is running version PHP 5.3.3. with this script.

Dennis I like what you have done with Jim at Juneau County Weather on the clickable map. Let me know if you do get a fix for this, or something you want me to test on my server. I will keep checking for updates. Also what this script does is so good it is well worth it.

Again thank you very much Scott

Version 2.00 - Set-18-2010 - Big changes, Clickable map- Thanks to Jim, also added the ability to put the images at the top or the bottom of the page. Hopefully fixed the script for the newest version of PHP.

Download at beginning of thread.

I would also like to apologize to everyone, I have been writing this between my computer at home and my computer at school. When writing new versions, sometimes improvements are left out that were incorporated in older versions. This version should have all the good stuff listed on the site.

-Dennis

Glad to offer this idea for huge improvement along with code for map.

Lee,

You’re right, your code is what got me thinking about it. The new version now scrapes the code from the AHPS site so that the mouseovers are always current.

Dennis,

I don’t think your changes made it to the download .zip because the most recent dates in there are the 12th.

  • Jim

Jim,

I think your right…doing too many things at the same time.

Now it is uploaded everyone.

Lee,

Thanks for giving us a starting point with the clickable map.

-Dennis

Thanks for the update guys! Works great

Tony 8)

Good day…I replaced the URL with my local clickable image, replaced what was needed in “river-fetch.php” and reuploaded…th emap isn’t displaying…was the URL suppose to be replace elsewhere also??

Has the cron job river-config run yet? I ran mine after I installed everything
and it was a-ok.

Yeah it ran…the map is displaying but its not click-able…

http://www.bucksweather.com/wxriverpage.php

Chris,

Looks like you need to change the permissions on your river-map.txt.

-Dennis

I have them at 664…I’ll check further.

Is the only place to change the url in the river-config.php file??

Got it…had to change permisions to 777 in the river-map file…

Thank you.