cloudy

Author Topic: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags  (Read 29288 times)

0 Members and 1 Guest are viewing this topic.

Offline Fox_Of_The_Wind

  • Anthony
  • Posts: 1,163
  • C:\DOS C:\DOS\RUN RUN\DOS\RUN
  • De Soto Wisconsin USA
    • De Soto Valley Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #15 on: January 08, 2008, 09:39:07 PM »
I will make a tutorial on my site for how I did the weather underground PHP upload. The script is very simple, but you have to be able to schedule a cron job on your web server. Give me a day or so to work on it.

Oh, It needs a cron job? I can't do that on my setup. So if it is just me asking please don't work on it.

Thanks anyway.

Anyway with the text overlay cam php script I am getting a error
Warning: chmod() [function.chmod]: Operation not permitted in "mypath"/imagecam.php on line 539

But if I hit refresh again the error goes away. It happens when the webcam updates. Any ideas what is up?

Thanks

Tony
« Last Edit: January 08, 2008, 09:44:56 PM by Fox_Of_The_Wind »


Offline jmcmurry

  • Jim McMurry
  • Posts: 2,213
  • Mauston, WI, USA
    • Juneau County Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #16 on: January 08, 2008, 09:45:10 PM »
Anthony,

We cannot schedule cron jobs on E-Rice, but I use a program named System Scheduler that will do the same thing by calling the PHP script at times that I schedule.  Same difference really.  The script for uploading to weather underground from the server will be very interesting!

- Jim

 Home of NSLog NexStorm Lightning Data Manager

Offline Fox_Of_The_Wind

  • Anthony
  • Posts: 1,163
  • C:\DOS C:\DOS\RUN RUN\DOS\RUN
  • De Soto Wisconsin USA
    • De Soto Valley Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #17 on: January 08, 2008, 09:46:14 PM »
Ok...Well I am up for it then if you are also. (you will have to help me hehe)


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #18 on: January 08, 2008, 10:02:03 PM »
I am working on a wunderground image upload by PHP tutorial right now.  :lol:

fox,
The chmod is so the new image file created can be world readable. I thought some servers might have different default permission settings that make the file not world readable. It looks like some severs may not be setup to support the chmod feature from a PHP script so I can disable that, maybe make it a feature that can be enabled if needed instead of enabled by default. I will put that feature in the next release maybe tonight.




Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #19 on: January 09, 2008, 01:35:15 AM »
fox,

I fixed the bug you had with chmod.

Version: 1.70 08-Jan-2008 - Bug fix for chmod error: Operation not permitted on some servers. added feature: setting to chmod images, disabled by default as most servers do not need it. added feature: setting to suppress output for cron job or System Scheduler usage, more compatible for web cam text overlay. added feature: setting for cached image file name, was previously automatic.

The script has it's own page now ..
http://www.642weather.com/weather/scripts-image-handler.php#ImageHandler

« Last Edit: December 17, 2008, 04:40:05 AM by MCHALLIS »

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,998
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #20 on: January 09, 2008, 02:28:39 AM »
Anthony,

We cannot schedule cron jobs on E-Rice, but I use a program named System Scheduler that will do the same thing by calling the PHP script at times that I schedule.  Same difference really.  The script for uploading to weather underground from the server will be very interesting!

- Jim

I'm an e-ricer too. Have you tried pseudo-chron on there?

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,213
  • Mauston, WI, USA
    • Juneau County Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #21 on: January 09, 2008, 02:37:14 AM »
Niko,

I run many of them.  It's just System Scheduler calling a PHP script using curl.exe at a scheduled time.

- Jim

http://www.splinterware.com/products/wincron.htm

http://curl.haxx.se/download.html
« Last Edit: January 09, 2008, 02:41:45 AM by jmcmurry »

 Home of NSLog NexStorm Lightning Data Manager

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #22 on: January 09, 2008, 06:54:29 AM »
New Tutorials online:

PHP Web Cam Image Text Overlay Tutorial by Mike Challis
http://www.642weather.com/weather/scripts-weather-cam-text.php

How To PHP Upload Your Web Cam Image to WeatherUnderground
http://www.642weather.com/weather/scripts-weather-cam-uploader.php
« Last Edit: December 17, 2008, 04:40:40 AM by MCHALLIS »

Offline Fox_Of_The_Wind

  • Anthony
  • Posts: 1,163
  • C:\DOS C:\DOS\RUN RUN\DOS\RUN
  • De Soto Wisconsin USA
    • De Soto Valley Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #23 on: January 09, 2008, 10:51:15 AM »
fox,

I fixed the bug you had with chmod.

Version: 1.70 08-Jan-2008 - Bug fix for chmod error: Operation not permitted on some servers. added feature: setting to chmod images, disabled by default as most servers do not need it. added feature: setting to suppress output for cron job or System Scheduler usage, more compatible for web cam text overlay. added feature: setting for cached image file name, was previously automatic.

The script has it's own page now ..
http://www.carmosaic.com/weather/scripts-image-handler.php#ImageHandler


Thanks for the update when I wake up I will give it a test.


Well good news I got it working again and no more errors http://www.desotowiwx.com/test.php

As for the Weather Underground script......I better stay away from it. I been trying to get it to work for the last 3 hours and it just makes IE say that it can't display the page. I will just keep the program uploading the camera to wunderground.

Thanks for the scripts!!!!
« Last Edit: January 09, 2008, 08:15:44 PM by Fox_Of_The_Wind »


Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #24 on: January 10, 2008, 12:10:53 AM »
fox,

I added better error handling to the
Weather Underground Web Cam Image Upload PHP Script

Version: 1.1  09-Jan-2008 - Added better error results

Do you want to download and try again?
http://www.642weather.com/weather/scripts/php-cam-image-upload.txt
« Last Edit: December 17, 2008, 04:41:11 AM by MCHALLIS »

Offline Weather Display

  • Posts: 64,521
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #25 on: January 10, 2008, 01:29:36 AM »
have you not been able to use the wunderground web cam upload built into WD?

Offline MCHALLIS

  • Posts: 2,102
  • Long Beach, WA USA
    • Weather for Long Beach, WA USA
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #26 on: January 10, 2008, 02:01:07 AM »
Brian,

Yes WD works great for web cam image overlay and wunderground web cam upload and I recommend that for most users.
I recently changed to all PHP for the text overlay and wunderground web cam upload.
Yes it is harder to do and took me some programming hours, but I prefer the flexibility of using my PHP method because I can alter any of the weather tags before putting them on my cam image.

Specifically, I use some php code to alter the current_summary to my own specifications. I have a solar sensor and do not use a Metar so I have coded some current conditions icon and summary optimizations/corrections. I use my new php web cam text overlay methods to integrate my conditions summary optimizations/corrections onto my web cam image.

Here is a sample of the corrections/optimizations from my testtags.php

Code: [Select]
   $forecasticonword = '%forecasticonword%';         # forecasticonword (used only at dawn / dusk)
   $weathercond      = '%weathercond%';              # weathercond
   $current_summary  = '%Currentsolardescription%';  # Currentsolardescription
   $dayornight       = '%dayornight%';               # dayornight

   # fixes some issues at dusk where sunny icon shows up
   $forecasticonword = str_replace("Mainly fine", 'Partly cloudy', $forecasticonword);
   $forecasticonword = str_replace("Snow", 'Partly cloudy', $forecasticonword);

   # clean up extra 'Dry'
   $current_summary = str_replace('/Dry/Dry', '/Dry', $current_summary);

   # fix Mostly sunny/Moderate drizzle
   $current_summary = str_replace('Mostly sunny/Moderate drizzle', 'Cloudy/Moderate drizzle', $current_summary);

   # remove a line break
   $current_summary = str_replace('/\n/', '', $current_summary);

   # replace both kinds of slashes, I like comma space instead
   $slash = '\\';
   $current_summary = str_replace($slash, ', ', $current_summary);
   $current_summary = str_replace('/', ', ', $current_summary);

   # if begins with comma space - remove the comma space
   if( preg_match("/^, /", $current_summary) ) {
     $current_summary = str_replace(', ', '', $current_summary);
   }

   # summary correction, fixes 'Windy' when it is supposed to be 'Windy, Rain'
   if( preg_match("/Windy/", $current_summary) && ($currentrainratehr > 0) ) {
     $current_summary = 'Windy, Rain';
      if ($dayornight == 'Night') $current_summary = 'Windy, Rain, Night time';
   }

   # summary correction, windy is normally over 20 mph average
   # changes icon and summary to 'Windy, Rain' when average above 10 mph with wind and rain
      $avgspdnomph = str_replace(' mph', '', $avgspd);
   if( $avgspdnomph > 10 && preg_match("/rain/", $current_summary) ) {
     $current_icon = 'windy.gif';
     $current_summary = "Windy, $current_summary";
   }

   # summary correction, fixes have windy icon, but not 'Windy' in summary
   if($current_icon == 'windy.gif' && !preg_match("/Windy/", $current_summary)) {
     $current_summary = "Windy, $current_summary";
   }

   # icon correction Sunny or Clear
   if( preg_match("/Sunny/", $current_summary)
   || preg_match("/Clear/", $current_summary)) {
     if ($dayornight == 'Day') $current_icon = 'day_clear.gif';
     if ($dayornight == 'Night') $current_icon = 'night_clear.gif';
   }

   # icon correction Mostly sunny
   if( preg_match("/Mostly sunny/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'day_mostly_sunny.gif';
   }

   # icon corrections for issues I have at Dusk when Mostly cloudy
   # mostly because I do not use metar, wd icons get confused at dusk
   if(
   ( preg_match("/Mostly cloudy/", $current_summary) )
   || ( preg_match("/^Dry$/", $current_summary) && preg_match("/^Partly cloudy$/", $forecasticonword ) )
   || ( preg_match("/^Dusk$/", $current_summary) && preg_match("/^Partly cloudy$/", $forecasticonword ) )
   || ( preg_match("/^Dusk, Dry$/", $current_summary) && preg_match("/^Partly cloudy$/", $forecasticonword ) )
   || ( preg_match("/^Dawn, Dry$/", $current_summary) && preg_match("/^Partly cloudy$/", $forecasticonword ) )
   ) {
     if ($dayornight == 'Day') $current_icon = 'day_partly_cloudy.gif';
     if ($dayornight == 'Night') $current_icon = 'night_partly_cloudy.gif';
   }

   # icon correction - fix Sunny icon when cloudy - at dawn dusk
   if(
   ( preg_match("/Cloudy/", $current_summary) )
   || ( preg_match("/Dawn/", $current_summary) && preg_match("/^Cloudy$/", $forecasticonword ) )
   || ( preg_match("/Dusk/", $current_summary) && preg_match("/^Cloudy$/", $forecasticonword ) )
   ) {
     if ($dayornight == 'Day') $current_icon = 'day_cloudy.gif';
     if ($dayornight == 'Night') $current_icon = 'night_cloudy.gif';
   }

   # summary correction - fix Sunny summary when cloudy icon stopped raining
   if( preg_match("/Stopped raining/", $current_summary) ) {
      $current_summary = str_replace('Sunny', 'Cloudy', $current_summary);
      $current_summary = str_replace('Mostly sunny', 'Cloudy', $current_summary);
   }

   # icon correction coudy
   if( preg_match("/Stopped raining/", $current_summary)
   || preg_match("/Cloudy/", $current_summary)
   || preg_match("/Overcast/", $current_summary)
   ) {
     if ($dayornight == 'Day') $current_icon = 'day_cloudy.gif';
     if ($dayornight == 'Night') $current_icon = 'night_cloudy.gif';
   }

   # icon correction when rain
   if( preg_match("/drizzle/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'mist.gif';
     if ($dayornight == 'Night') $current_icon = 'night_mist.gif';
   }

   # icon correction when rain
   if( preg_match("/Light rain/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'day_light_rain.gif';
     if ($dayornight == 'Night') $current_icon = 'night_light_rain.gif';
   }

   # icon correction when rain
   if( preg_match("/Moderate rain/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'day_rain.gif';
     if ($dayornight == 'Night') $current_icon = 'night_rain.gif';
   }

   # icon correction when rain
   if( preg_match("/Moderate drizzle/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'day_light_rain.gif';
     if ($dayornight == 'Night') $current_icon = 'night_light_rain.gif';
   }

   # icon correction when rain
   if( preg_match("/Heavy rain/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'day_heavy_rain.gif';
     if ($dayornight == 'Night') $current_icon = 'night_heavy_rain.gif';
   }

   # icon correction, fixes sometimes summary and icon is 'Dry' when it was just raining
    $totalrainlast3hoursnoin = str_replace(' in.', '', $totalrainlast3hours);
   if( preg_match("/^Dry$/", $current_summary) && ($totalrainlast3hoursnoin > 0) ) {
     if ($dayornight == 'Day') $current_icon = 'day_partly_cloudy.gif';
     if ($dayornight == 'Night') $current_icon = 'night_partly_cloudy.gif';
   }

   # icon correction, fixes sometimes icon is 'Cloudy' when summary is sleet fall
   if( preg_match("/Sleet fall/", $current_summary)
   || preg_match("/Snow fall/", $current_summary) ) {
     if ($dayornight == 'Day') $current_icon = 'snow.gif';
     if ($dayornight == 'Night') $current_icon = 'night_sleet.gif';
   }

# I do not have a nearby METAR so this is how I use the davis forecast icon word
# to show if it is cloudy or not, but only at night when solar sensor is mute
# If any of these conditions, then fill with forecast icon word
 if ($dayornight == 'Night' # at night when solar sensor is off
     || $current_summary == '' # sometimes there is nothing, so forecast icon word it is
     || preg_match("/Dusk/", $current_summary)  # at dusk there is no solar cloud words
     || preg_match("/^Dry$/", $current_summary)) { # sometimes at dusk there is just 'Dry'

     # at night do not use forecasticonword whith rain/snow/fog words
    if( ! preg_match("/ain/", $current_summary)
        && ! preg_match("/drizzle/", $current_summary)
        && ! preg_match("/shower/", $current_summary)
        && ! preg_match("/thunder/", $current_summary)
        && ! preg_match("/Snow/", $current_summary)
        && ! preg_match("/Sleet/", $current_summary)
        && ! preg_match("/Fog/", $current_summary)
        && ! preg_match("/Haze/", $current_summary)
       ) {
        $forecasticonword = str_replace(" night", '', $forecasticonword); # remove night word
        $current_summary = $current_summary .', '.  $forecasticonword; # add forecasticonword at night because no METAR
        # fixes icon was night clear
       if (preg_match("/^Partly cloudy$/", $forecasticonword ) ) {
          if ($dayornight == 'Night') $current_icon = 'night_partly_cloudy.gif';
       }
       # fixes icon was night clear
       if (preg_match("/^Cloudy$/", $forecasticonword ) ) {
          if ($dayornight == 'Night') $current_icon = 'night_cloudy.gif';
       }
    }
 }

 # windy icon trumps all
 if (preg_match("/Windy/", $current_summary)) {
     if ($dayornight == 'Day')   $current_icon = 'windy.gif';
     if ($dayornight == 'Night') $current_icon = 'night_windy.gif';
 }

 # add heatcolor word to front of summary, but only if it is set
 if( ! preg_match("/^---$/", $heatcolourword)) {
  $current_summary = $heatcolourword .', '.  $current_summary;
 }

 # cleanup - space on end
 $current_summary = trim($current_summary);

 # cleanup - if ends with comma - remove it
 if( preg_match("/,$/", $current_summary) ) {
     $current_summary = substr($current_summary, 0, -1);
 }

For most, WD web cam image overlay is just fine.


Offline jmcmurry

  • Jim McMurry
  • Posts: 2,213
  • Mauston, WI, USA
    • Juneau County Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #27 on: January 10, 2008, 01:00:52 PM »
I'm an e-ricer too. Have you tried pseudo-chron on there?

Niko,

In going back through this thread I realized that I misunderstood your question.  I've not run that program and in looking at their web page it's triggered by page requests.  My site isn't heavily traveled, so it can be a long time between requests and many of my scripts need to run on a schedule in order to maintain sequences of photos etc.

Maybe someone else has tried it?

- Jim

 Home of NSLog NexStorm Lightning Data Manager

Offline niko

  • syzygy
  • Global Moderator
  • Posts: 21,998
  • Crystal Ball broken! Please post the URL.
  • Northern California, U.S.A.
    • http://www.realweatherstation.com
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #28 on: January 10, 2008, 01:48:41 PM »
Jim: My site isn't heavily travelled either (aside from hits on my sticker from this forum of course  :D)  but it seems to me that it might be easier to set up pseudo-cron on there and just have a simple automated process on a local PC to hit the site regularly "just in case", instead of running all the scheduling locally.

Offline jmcmurry

  • Jim McMurry
  • Posts: 2,213
  • Mauston, WI, USA
    • Juneau County Weather
Re: New Script: Text Overlay Web Cam Image from PHP Weather-Display tags
« Reply #29 on: January 10, 2008, 03:01:47 PM »
Niko,

That sounds like a good idea!  One call from system scheduler every xxxx minutes to a "do nothing" script/page would trigger the cron which would look at it's task status and do whatever needs to be done at the moment.  One task in my system scheduler would replace about a dozen that are currently sitting there.  Good thing it's winter and the golf course isn't calling so I might be able to try it out.

Thanks for the idea.  - Jim

 Home of NSLog NexStorm Lightning Data Manager

 

cumulus