Tides Processor Script

I have added these features now;
Will work with rising and falling tide format.
Option to convert rising & falling format to standard high & low format
Days, months, high tide, low tide, rising & falling can all be translated to another language

I tested it out on your tide file.

I need to fix Budgie’s problem first before I release the update, so please bear with me.

No problem. :wink:

By the way I sent you a revision of the script to try out.

Hi David, I was just wondering how you generate and upload your tide file, and what you had to tweak to get this script to work with it?

Nothing recieved on the email, I do have problems with attachments on my email sometimes although it should be find as a .txt file.
Or send it to [email protected] and it’ll get through OK. :wink:

I have a scheduled task[1] that runs

C:\wdisplay\wxtide32.exe

using the parameters

-textfile “webfiles~dcwWxTide.txt” -text

~dcwWxTide.txt is just my arbitrary choice for the output file name.

I then use WD’s “General FTP” option to upload that file to the server, renaming it to tideprediction.txt along the way. For convenience I have the file uploaded at the same times as my WXSIM forceast is updated (though the tide file is only recalculated once a day).

If I knew what parameters WD used with WxTide I could presemably produce a file that is “just the same”, the above however gives a slightly different format.

The significant things I needed to change were:

a) In my tideprediction.txt the date above each day includes the year, so I needed to tweak the date format parameters in the date call within the strstr to accommodate that, i.e.

$tidedate = strstr($tideD, date("l Y-m-d", $time+(86400*$numb)));

b) For the same reason I would have needed to tweak your code that does “// Convert date format to short day and full month names (UK format)”, however, I cheated and just used a further call of the date function instead, i.e.

$dformat = date("D d F", $time+(86400*$numb));

c) Because my tideprediction.txt includes GMTDT (GMT Daylight (saving) Time?) and GMTST (GMT Standard Time?) after the times I needed to increase the value of 188 that you use to shorten the text to “just the relevant day plus a little more” to 300 (not a precise choice of figure, something a bit smaller would probably work).

That’s all. :smiley:

[1] I use a Splinterware System Scheduler event, but MS Scheduled Tasks could be used.

OK sent again to your scottishweather.net address.

Thanks for the info David. I was wondering whether there was some standard system you were using that the tides script should support. I guess not though :smiley:

Hi, just tried your script 35mm, and I have the same problem as budgie a blank page, I use my own script I wrote to parse the output from Tide Plotter as wxtide is no good for newquay, (tide prediction is still uploaded everyday, never got round to turning it off) I tried tweaking the values for newquay but height and tides hopelessly miles out hence my purchase of tide plotter earlier in the year.

Nice output, much better than the one I wrote. :smiley:
phil

I got the email this time but it’s still a no go.
I tried both the long & short version of the server address but still a blank page.

I don’t know if this helps at all: http://www.hebrides-photos.com/path.php

Thanks. I’m working on this blank screen issue. I think I know what the problem is and have fixed it, but Martin’s probably about to reply and tell me that I haven’t! lol

I was looking at that tide plotter a few weeks ago. What do you think of it?

but Martin's probably about to reply and tell me that I haven't! lol
Told you!

hmmm. Martin in the script I sent you, on line 59 or there abouts, comment out the line that says error_reporting(0); (put // infront of it). Then try it again. Let me know what errors it gives you. I will have to resume this tomorrow as I’m off to the pub now with my brother-in-law, so a hangover is brewing! :occasion5:

You were correct Al, I was posting when you were typing. :lol:

I tried my page on IE7 & FF, just in case it was a browser thing, but it’s the same on both.
Any chance it’s the server type, mine is running on Apache, yours & David’s wouldn’t be Windows based would they?

I commented out the error_reporting(0); and got no errors on the page, not even when reviewing the source. :?

Have a great hangover and we see what happens tomorrow.

Cheers,

Martin.

I like it, of course its not free and you have to get permission from the author and UK Hydrographic Office to publish tide times, seven days only, but dont worry there is no charge for the permission, just a few hoops to jump through, they were quick got mine following day I think, I know it was quick.

I saved the output for the year and my script just takes todays date and displays next seven days, the graph I’m afraid cant be automated so I have to display and save for everyday, thats my only gripe.

Just to add my server is Apache re your script and budgies previous comment

Phil

Mine’s not Windows based.

Oh well, that’s that idea out the window then.

Back home and nursing a hangover here, as expected! I’m running apache on unix, so no, it’s not a windows problem, but I can see how you may have come to that conclusion! Sorry about all these problems, but could you send me a copy of your exact settings from the script so I can try and see what’s going on. Don’t worry, I’ll sleep it off before I attenmpt anything technical!

I too have the same ‘blank page’ issue and did some investigation.

My tideprediction.html uses a date format for each section “ --” but it appears tides_processor.php is looking for “ -”.

A quick fix for me was to change line 45 from:


$tidedate = strstr($tideD, date("l m-d", $time+(86400*$numb)));

to:


$tidedate = strstr($tideD, date("l Y-m-d", $time+(86400*$numb)));

Obviously this is a quick-n-dirty fix and I’ll leave it up to 35mm to provide a more appropriate solution.

Edit: A few additional edits are needed to account for the additional ‘year’. I’ve also made an update to allow for arbitrary-length tide data since the hard-coded value was cutting off the fourth tide on my reports. I’ve attached an updated tidereport.php (remove the .txt extension) but note this will only work for tideprediction.html files that include the year on each daily forecast.


tides_processor.php.txt (5.1 KB)

I have been playing with this and cannot get good output from a tides(0) which should display todays tide. It shows just part of todays tide plus the date line for the next day, it also gives an error on line 79 with undefined $moonimage, this error goes away if I select a day with moon details but it still does not correctly display the tides.

I think it would be a good idea if you posted an example of how the tideprediction.html should look as there are obviously different formats depending on the WXTide32 options in use. Mine was obviously not the same as yours but I’m still not sure that the correct options are being used to create this file. Also maybe a screenshot of your WXTide prefs so we can see what options you are using would also be useful.

Stuart

Sounds like your raw tideprediction file is pretty much like mine. Your tweaks cover the same ground, but in a slightly different way.

I like your idea to look for the start of ‘next day’ as the basis for the chop.

The script is 35mm’s, so the choice of what to do is theirs, but can I offer up a couple of thoughts?

Perhaps the date format parameter in the strtstr could be made a string variable, initialised up in the configuration part of the script, maybe with comments showing some ‘common’ examples to help those with less programming experience.

Different date formats in the tideprediction file would also affect the code that builds $dformat, which could complicate matters. A way around that would be to make $dformat independent of the tideprediction file by using another date call instead, e.g.

$dformat = date("D d F", $time+(86400*$numb));

Just ideas. Use or ignore as you wish…