cloudy

Author Topic: Tides Processor Script  (Read 28725 times)

0 Members and 1 Guest are viewing this topic.

Offline 35mm

  • Posts: 225
  • Plymouth, England
    • Newton Ferrers & Noss Mayo
Tides Processor Script
« on: October 09, 2008, 02:21:58 PM »
Updated 19 October 2008 v2.01
I've just released a tide processor php script. It's designed to work with the tideprediction.html file that WD uploads to your site. This script will separate each day and it's tides, so that you can place them on any page of your site and lay them out how ever you like.


For example - laid out in cells...

The script also gives the tides a more aesthetically pleasing date format, and includes moon phase icons. Even if you don't have WD uploading a tide file to your site, you could use this script to fetch a WD tide file from another site on another server, but obviously with the permission of the site owner of course!

Given the last feature, I'm thinking of possibly developing an exchange system where WD users can exchange their tide info, and display other local tides via a drop down list, and maybe a search feature, so you can search by port. That's just an idea, so if you might be interested in that please let me know.

Update:12 Oct 08 version 1.03 now includes the following extra features...
Will work with dates that have years in them as well as those that don't
Will work with tides that do not include sun rise/set and moon rise/set as well as those that do
Will work with rising and falling tide format as well as standard high and low
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

The tides processor script is simple to install and use. You can get this, and other scripts, tips and stuff from my site here.
« Last Edit: October 19, 2008, 02:32:39 PM by 35mm »

"You don't need a weatherman to know which way the wind blows."
- Bob Dylan

Offline strandvejr

  • Seaman
  • Posts: 167
  • Sortsų Strand - Denmark
    • Vejrstation Sortsų Strand
Re: Tides Processor Script
« Reply #1 on: October 09, 2008, 05:59:23 PM »
Hi

thx for a great script. I 've tried and It works ok at my site www.strandvejr.dj/wxtest1.php
and yet: If you take a look at the original tide file www.strandvejr.dk/tideprediction.html you will see that some data is missing.

The php script prints :
Quote
Thu 09 October
High Tide: 0200 0.1
Falling: 0408 -0.0
Low Tide: 0752 -0.2
Rising: 1057 0.0

and from the original file this data is missing

Quote
High Tide:  1415   0.1
    Falling:  1704  -0.0
   Low Tide:  2047  -0.2

How can I remove the data on falling and rise of tide - a replace it with high and low tide...

another thing:

If I want to do a translation from english to danish - any ideas how to do that.

The translation will be of Dayname - monthname - High tide - Low tide.

best

strandvejr

Offline 35mm

  • Posts: 225
  • Plymouth, England
    • Newton Ferrers & Noss Mayo
Re: Tides Processor Script
« Reply #2 on: October 09, 2008, 06:57:58 PM »
Hi

thx for a great script. I 've tried and It works ok at my site www.strandvejr.dj/wxtest1.php
and yet: If you take a look at the original tide file www.strandvejr.dk/tideprediction.html you will see that some data is missing.

The php script prints :
and from the original file this data is missing

How can I remove the data on falling and rise of tide - a replace it with high and low tide...

another thing:

If I want to do a translation from english to danish - any ideas how to do that.

The translation will be of Dayname - monthname - High tide - Low tide.

best

strandvejr
Hi strandvejr,
The script was designed for high tide and low tide only (UK format), because that's what I'm used to. However, I can change it to suite other formats. I'll update it to work with "rising & falling" format if that's a common format - I've never seen that before. Or are you saying that you don't want "rising & falling", just high and low? I am going to develop the script more, and add more options to it, so your feedback is useful!

As far as translations go, I will build that in as an option too. So that you can add your own translations for the words. I hadn't thought of that! So thanks.

"You don't need a weatherman to know which way the wind blows."
- Bob Dylan

Offline strandvejr

  • Seaman
  • Posts: 167
  • Sortsų Strand - Denmark
    • Vejrstation Sortsų Strand
Re: Tides Processor Script
« Reply #3 on: October 09, 2008, 07:27:22 PM »
Hi

Great - looking forward to updates of the script..

Yes - I dont want the rise and falling datas - just the high and low tide datas.

Thanks for your work - much appreciated.

best

strandvejr

Offline skyewright

  • Posts: 1,996
  • Isle of Skye, Scotland
    • 24 Elgol
Re: Tides Processor Script
« Reply #4 on: October 09, 2008, 07:43:52 PM »
Great script. Thank you.
I needed to tweak the script a bit to get it to work for me because I generate my tideprediction.txt outside WD[1] and the format is a little different - but it was easy enough to understand your logic and adapt it.

The result is at http://www.isleofskyeweather.org.uk/24elgol/wxtides.php

[1] When set for auto, WD likes to calculate the page at a time when my computer isn't usually on, otherwise I'd be more than happy to use the WD facility.
Regards
David

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,957
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: Tides Processor Script
« Reply #5 on: October 09, 2008, 09:56:13 PM »
I've run into a wee problem.
I've uploaded the files, set the PHP code on the page and all I've getting is the "Tide data is being updated. Please refresh the page."

I know I can't go that far wrong so here are my settings:

Code: [Select]
//   Set the server path to your tideprediction.html file                       //
$tidefile = "/html/hebrides-photos.com/weather";                                //
//                                                                              //
//   Set the URL to the moon icons - no trailing slash                          //
$moonimg = "/tides_processor/icons";   

The server settings for the tideprediction.html file are correct, according to my server, and the tideprediction.html file is on the server here.
Oh, and here's the page I'm trying to get it to work on.
Any ideas as to what I could try?

Cheers,

Martin.

Offline BfdWx

  • Posts: 1,586
  • Branford Connecticut
    • Branford Weather
Re: Tides Processor Script
« Reply #6 on: October 10, 2008, 01:34:34 AM »
Quote
I've uploaded the files, set the PHP code on the page and all I've getting is the "Tide data is being updated. Please refresh the page."

I'm getting the same message on my site. Looks like it will be a great script though, I like how your data looks!

Regards,

Jack

Offline 35mm

  • Posts: 225
  • Plymouth, England
    • Newton Ferrers & Noss Mayo
Re: Tides Processor Script
« Reply #7 on: October 10, 2008, 06:04:24 AM »
I've run into a wee problem.
I've uploaded the files, set the PHP code on the page and all I've getting is the "Tide data is being updated. Please refresh the page."

I know I can't go that far wrong so here are my settings:

Code: [Select]
//   Set the server path to your tideprediction.html file                       //
$tidefile = "/html/hebrides-photos.com/weather";                                //
//                                                                              //
//   Set the URL to the moon icons - no trailing slash                          //
$moonimg = "/tides_processor/icons";   

The server settings for the tideprediction.html file are correct, according to my server, and the tideprediction.html file is on the server here.
Oh, and here's the page I'm trying to get it to work on.
Any ideas as to what I could try?

Cheers,

Martin.
Martin, you need to enter the full server path to your tide file, including the name of the tide file which is normally tideprediction.html. The full server path will normally start with /home/ eg.
Code: [Select]
/home/username/public_html/.......
or
/home/username/www/......
Basically you get that message if the tide file can not be found at the location you specified.

If you copy and paste the following code into a file, save it as path.php, and upload it to the same directory where your tide file is, it should give you the full server path.
Code: [Select]
<?php echo dirname(__FILE__);?>then adding /tideprediction.html on the end will be what the script is asking for.

"You don't need a weatherman to know which way the wind blows."
- Bob Dylan

Offline skyewright

  • Posts: 1,996
  • Isle of Skye, Scotland
    • 24 Elgol
Re: Tides Processor Script
« Reply #8 on: October 10, 2008, 07:53:00 AM »
I've run into a wee problem.
I've uploaded the files, set the PHP code on the page and all I've getting is the "Tide data is being updated. Please refresh the page."
I had the same problem, initially.
Rather than use the full internal server path, I used a relative path
Code: [Select]
$tidefile = "./tideprediction.txt";
i.e. telling the script to look in the same folder that it is in.

N.B. My file is called tideprediction.txt rather than the usual tideprediction.html, but I'm sure you spotted that!
Regards
David

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,957
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: Tides Processor Script
« Reply #9 on: October 10, 2008, 09:20:24 AM »
Thanks guys,
I tried both ways and get the same result, a blank page.
When I look at the source it doesn't seem to have parsed anything.

I have the tidegraph.gif image at the top of the html page, could at be causing a problem?

Offline 35mm

  • Posts: 225
  • Plymouth, England
    • Newton Ferrers & Noss Mayo
Re: Tides Processor Script
« Reply #10 on: October 10, 2008, 10:03:18 AM »
Thanks guys,
I tried both ways and get the same result, a blank page.
When I look at the source it doesn't seem to have parsed anything.

I have the tidegraph.gif image at the top of the html page, could at be causing a problem?

The tide image should make no difference. I did notice in your original setup;
Code: [Select]
$tidefile = "/html/hebrides-photos.com/weather";you did not have the tide file at the end i.e ..../weather/tideprediction.html

If you have the script and tideprediction.html in your weather directory then as skyewright said, you can use a relative path, which would be;
Code: [Select]
"./tideprediction.html"Note the "." before the "/"

"You don't need a weatherman to know which way the wind blows."
- Bob Dylan

Offline 35mm

  • Posts: 225
  • Plymouth, England
    • Newton Ferrers & Noss Mayo
Re: Tides Processor Script
« Reply #11 on: October 10, 2008, 10:18:57 AM »
Budgie, also, if you are completely sure you have got the path right, and it's still not working, we'll make sure php is setup on your server to support the method of getting the file contents.

Copy the following code, and past it in a file. Name the file test.php, upload it, and open it in your browser.
Code: [Select]
<?php
if (ini_get('allow_url_fopen') == "1")
{
echo 
"Test passed ok!";
}else{
echo 
"Test failed. PHP is not setup to support this on your server.";
}
?>


Let me know the result.

"You don't need a weatherman to know which way the wind blows."
- Bob Dylan

Offline BfdWx

  • Posts: 1,586
  • Branford Connecticut
    • Branford Weather
Re: Tides Processor Script
« Reply #12 on: October 10, 2008, 10:54:02 AM »
Hi Guys,

Tried all the suggestions above with no luck also. The test.php worked OK but I still get a blank page.

Regards,

Jack

Offline Budgie

  • Martin
  • Global Moderator
  • Posts: 4,957
  • WML Station: WD00934 CWOP: CW7959
  • Isle of Lewis, Scotland
    • Hebrides-Weather
Re: Tides Processor Script
« Reply #13 on: October 10, 2008, 11:03:30 AM »
The PHP side is fine, the whole site is PHP.  :wink:
Which PHP version has this been written for? I'm using PHP4 on my server at the moment so it maybe that I need PHP5?
I've used both the full server address, including the file name, and the relative path and as nothing is showing on the page when the correct path is put in then I'm assuming that the script is seeing the html file but can't parse it for some reason.

Jack, which version of PHP are you using on your server? 

Offline BfdWx

  • Posts: 1,586
  • Branford Connecticut
    • Branford Weather
Re: Tides Processor Script
« Reply #14 on: October 10, 2008, 11:11:54 AM »
Quote
Jack, which version of PHP are you using on your server? 

Using 4 also Martin.

Jack