Author Topic: Weather Sticker PHP Script  (Read 39887 times)

0 Members and 1 Guest are viewing this topic.

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Version 5.5 is now available
« Reply #50 on: September 09, 2006, 06:55:35 AM »
Version 5.5 is now available:

http://scripts.anolecomputer.com/download.shtml

Bug Fix: corrected typo in config.txt where "$anti-alias" should have been "$anti_alias"

Thanks to Erik at http://MemphisWeather.Net for catching and reporting that one.

Offline W3DRM

  • Forecaster
  • *****
  • Posts: 3360
    • Emmett Weather
Weather Sticker PHP Script
« Reply #51 on: September 09, 2006, 06:40:53 PM »
Anole,

I'm not very proficient at PHP coding but is there a problem with the positioning of the current condition icon for the banner sticker? My icon shows up at the top but about 2/3 of the way over to the right and not at the far left of the banner.

It currently reads as follows:

   // $banner_icon_x: x coordinate on banner of the upper left most pixel of icon
   // $banner_icon_y: y coordinate on banner of the upper left most pixel of icon
   $banner_icon_x = '300';
   $banner_icon_y = '2';

If it is going to be in the upper left pixel of the icon shouldn't it be the same as you have for the other sticker types i.e.:

   $banner_icon_x = '2';
   $banner_icon_y = '2';

NOTE: I changed the "x" setting to 2 and it positions correctly.
Don - W3DRM - Emmett, Idaho --- Blitzortung ID: 808 --- FlightRadar24 ID: F-KBOI7
Davis Wireless VP2, WD 10.37s150,
StartWatch, VirtualVP, VPLive, Win10 Pro
--- Logitech HD Pro C920 webcam (off-line)
--- RIPE Atlas Probe - 32849

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Weather Sticker PHP Script
« Reply #52 on: September 09, 2006, 10:58:30 PM »
Yes, if you want it to appear in the banner at the upper left then you should set it at 2 and 2. I set it different by default intentionally as an illustration/example of how you can move it where you want to. I set it to 300 specifically because that's where I have it in my banner which you can see below.

Offline PSJohn

  • Senior Contributor
  • ****
  • Posts: 157
    • DesertWeather.com
Weather Sticker PHP Script
« Reply #53 on: September 15, 2006, 05:18:13 PM »
This topic is all over the place so I thought i'd ask my question here...  Ever since installing version 5.5 I get artifacts in the background and the font quality is lousey.  I have antialias set to 'off'.  I'm using Arial.  The artifacts come and go in different locations on the background.

Could the transparency feature be the cause and is there a way to disable it?

Thanks for any help.

my sticker page: http://www.desertweather.com/stickers.php

-John
John Slama
Palm Springs, California
Davis Vantage Pro 2, FARS

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Weather Sticker PHP Script
« Reply #54 on: September 15, 2006, 08:21:11 PM »
Yep, most likely the transparent color is causing the problem. Probably the easiest thing to do is to comment out the following line in config.txt:

 
Code: [Select]
$trans_color = imagecolortransparent($img,$trans_color);

like so:

Code: [Select]
//$trans_color = imagecolortransparent($img,$trans_color);

Let me know if that does the trick and I'll look at finding a way to "robustify" things a bit.

Offline PSJohn

  • Senior Contributor
  • ****
  • Posts: 157
    • DesertWeather.com
Weather Sticker PHP Script
« Reply #55 on: September 16, 2006, 12:53:08 PM »
Thank you, that seemed to work!

bye the way, thanks for this great piece of code, and sharing it for others to use!

-John
John Slama
Palm Springs, California
Davis Vantage Pro 2, FARS

Offline SolidState

  • Member
  • *
  • Posts: 6
Re: Weather Sticker PHP Script
« Reply #56 on: August 28, 2007, 07:01:28 AM »
I'm having trouble getting this script to work correctly.  My initial error is:

Fatal error: Call to undefined function: mb_convert_case() in /home/sandel/public_html/wxgraphic.php on line 290

If I comment out line 290 (or remove the call to mb_convert_case()), the script works to a degree.  I haven't seen anyone else post about this mb_convert_case issue so maybe I'm the first?

Also, when I can get the script to work, it only seems to populate my graphic with the default x,y coordinates.  In other words, whether the script calls the default, banner, banner_big or avatar subroutines, my text is always in the same area as default.  Here's an example:

http://216.73.124.252/wxgraphic.php?type=banner_big

What am I doing wrong?  This is another issue I haven't seen raised around here.

Todd
Ambient WS-2000

Offline Anole

  • Forecaster
  • *****
  • Posts: 585
    • http://pineislandweather.com
Re: Weather Sticker PHP Script
« Reply #57 on: August 28, 2007, 07:06:42 AM »
On the text positioning, this is a bug in the script. It doesn't affect everyone and I don't have a handle on why some people are having this while others don't. Regardless, there is a fix but I have to get some time to implement and test it.

On the mb_convert_case(), I've not seen anyone have this problem. What version of PHP are you running? What program are you using for your data (VWS, WD, WL etc.)?

Offline SolidState

  • Member
  • *
  • Posts: 6
Re: Weather Sticker PHP Script
« Reply #58 on: August 28, 2007, 07:25:29 AM »
Anole,

I figured it was a bug, but I couldn't figure out where in the code this would happen.  The weird part is that the script generates the correct size graphic outline, but the text is out of place.

I am using VWS to create/upload the .htm file (VWS_graphictags.htm -- from original unmodified .htx) which seems to be populating the fields in the sticker okay.

As far as PHP, I'm running v. 4.4.6

You can hit the PHP_verify.php file on the server from my previous post for more detailed info.

It may be a few hours before I can reply...I'm in Cali and I'm turning in after a nice night of eclipse photographing.

Todd

P.S. the .php script you clicked in the previous link had the mb_convert_case function removed so the line just reads:
Code: [Select]
$forecast = trim($data[13]);
Ambient WS-2000

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Weather Sticker PHP Script
« Reply #59 on: August 28, 2007, 03:35:39 PM »
You could also replace
Code: [Select]
    $forecast = trim(mb_convert_case($data[13], MB_CASE_UPPER));
with the built-in function strtoupper with the same effect
Code: [Select]
    $forecast = trim(strtoupper($data[13]));

The uppercase for the condition is needed to use the lookup table for the icon ;-)

The mb_convert_case function is part of the Unicode support and is available in PHP from (PHP 4 >= 4.3.0, PHP 5).  The strtoupper function has been around since PHP3 and uses only 8-bit characters, so it is sensitive to locale settings.  It won't uppercase any characters such as umlaut-a (ä), so Anole's use of the more general mb_convert_case is a wise choice for general use.  Your PHP 4.4.6 should have the function.. like Anole says, it's strange that you don't have it.

I'd recommend you use the strtoupper function instead so your condition icon can be set correctly.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SolidState

  • Member
  • *
  • Posts: 6
Re: Weather Sticker PHP Script
« Reply #60 on: August 28, 2007, 05:09:50 PM »
Ken,

Thanks for the suggestions.  I have made the code change.  I'm wondering why my PHP doesn't have the built-in fuction mb_convert_case, but I'll have to talk to my ISP about that one.

I was just inspecting my .htm file of my graphictags and noticed that the 14th variable ($data[13]), the one affected by the mb_convert_case function, is blank.  It is the only datapoint in the file without any info.  Maybe this is part of the cause of both errors?

I'm eager to get the sticker working, but without being able to generate a useable format (except for _default), I'm stuck.

Todd
Ambient WS-2000

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Weather Sticker PHP Script
« Reply #61 on: August 28, 2007, 06:31:56 PM »
Todd, you didn't say which weather software package you're using.
If it's VWS, then you need to pick a nearby METAR as your first entry to set the condition icon for your station.. that will be picked up by the ^climate_cconds1^ variable, and interpreted by the $vws_icon lookup to pick the right icon to use.

If you're using Weather-Display, then you should us the clientraw.txt file as the data source, and it will have the icon to use.

If you're using WeatherLink or another package, then the condition icon is not available, since the packages don't produce one :-(


BTW.. it would help if you updated your profile to include your weather software used and a link to the homepage of your weather website :-)

As for why mb_convert_case seems to be missing in your PHP, that's definitely a thing to take up with your ISP.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SolidState

  • Member
  • *
  • Posts: 6
Re: Weather Sticker PHP Script
« Reply #62 on: August 28, 2007, 07:15:46 PM »
Ken,

Thanks again for the info.  I've updated my profile.

I'm using VWS 13.01 p00 and a Davis VantagePro2.
Ambient WS-2000

Offline carseman

  • Member
  • *
  • Posts: 8
  • WH 1081 Weather Display Win XP
    • CarseWeather
Re: Weather Sticker PHP Script
« Reply #63 on: August 29, 2007, 04:43:59 AM »
Quote from: "SolidState"

Also, when I can get the script to work, it only seems to populate my graphic with the default x,y coordinates.  In other words, whether the script calls the default, banner, banner_big or avatar subroutines, my text is always in the same area as default.  Here's an example:

http://216.73.124.252/wxgraphic.php?type=banner_big

What am I doing wrong?  This is another issue I haven't seen raised around here.

Todd

Todd,
I was having the same problem.  We discussed it on the weather-watch forum here:
http://www.weather-watch.com/smf/index.php/topic,12227.300.html

Try insering the following code before the switch statements that start at approx line 508 in wxgraphic.php.
Code: [Select]
if ( isset($_REQUEST["type"] ))
   $type = $_REQUEST["type"];
else
   $type = "";

(With thanks to Kevin of tnetweather.com for help in tidying my fix of the code.)
Chris

Offline SolidState

  • Member
  • *
  • Posts: 6
Re: Weather Sticker PHP Script
« Reply #64 on: August 29, 2007, 06:20:14 AM »
Chris,

That seems to have done the trick! Thanks 1,000,000

Now, I've gotta pretty up the sticker and add it as a sig!

Todd
Ambient WS-2000

 

anything