- Posts: 12
- Thank you received: 0
Formatting NWAC Snotel data for Palm Pilot browser
- Major_Geek
-
Topic Author
- User
-
Less
More
18 years 1 month ago - 18 years 1 month ago #180314
by Major_Geek
Formatting NWAC Snotel data for Palm Pilot browser was created by Major_Geek
I've been having trouble formatting the NWAC snotel data in a compact form for my Palm Pilot, and I thought there probably plenty of geeks on this forum that could tell me what I'm doing wrong.
For some reason the output from www.nwac.us/products/OSOWPS has a .txt extension on it, so my Palm Pilot PDA browser, Blazer, doesn't want to display it. Instead I have to save the file and figure out some way to view it off line. I thought it would be an interesting exercise in php to take output from NW Avalanche Center for the White Pass snow pack and reformat it a little more compact for my PDA. I can screen scrape the file with curl and get the relevant data, but I'm having a hard time getting the Blazer browser to process my formatting tags correctly, and without a non proportional font, the columns get out of line. It looks good on my desktop in Firefox (see ykfp.org/php/nwac/getwhitepass.php , but Blazer is funny. It has two font size options that are set with pull down menus, small or large, and although some of my formatting tabs like bold seem to work, neither of the font choices seem to be monospace. I've tried monospace font specifications in the CSS setting and inside the <pre> tags, but it's not working.
If this forum permits it, I'll try to insert the code in its latest form below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " www.w3.org/TR/html4/loose.dtd"> ;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>White Pass snow</title>
<style type="text/css">
<!--
.style1 {
font-family: monospace;
font-size: small;
font-weight:bold;
line-height:.9;
}
-->
</style>
</head>
<body class="style1">
<pre>
<?php
// Paul Huffman, 1-2-2008
//retrieve the White Pass text file from NWAC
$theurl=" www.nwac.us/products/OSOWPS ";
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $theurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//Trim feed to useful data
$cStartStr = "MM";
$cEndStr= " ";
//$cUsefulContents=stristr($contents,$cStartStr);
$cPageTail = stristr($contents, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos);
// display file
echo "White Pass Ski Area, Washington<br/>";
echo $cUsefulData;
?>
</pre>
</body>
</html>
For some reason the output from www.nwac.us/products/OSOWPS has a .txt extension on it, so my Palm Pilot PDA browser, Blazer, doesn't want to display it. Instead I have to save the file and figure out some way to view it off line. I thought it would be an interesting exercise in php to take output from NW Avalanche Center for the White Pass snow pack and reformat it a little more compact for my PDA. I can screen scrape the file with curl and get the relevant data, but I'm having a hard time getting the Blazer browser to process my formatting tags correctly, and without a non proportional font, the columns get out of line. It looks good on my desktop in Firefox (see ykfp.org/php/nwac/getwhitepass.php , but Blazer is funny. It has two font size options that are set with pull down menus, small or large, and although some of my formatting tabs like bold seem to work, neither of the font choices seem to be monospace. I've tried monospace font specifications in the CSS setting and inside the <pre> tags, but it's not working.
If this forum permits it, I'll try to insert the code in its latest form below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " www.w3.org/TR/html4/loose.dtd"> ;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>White Pass snow</title>
<style type="text/css">
<!--
.style1 {
font-family: monospace;
font-size: small;
font-weight:bold;
line-height:.9;
}
-->
</style>
</head>
<body class="style1">
<pre>
<?php
// Paul Huffman, 1-2-2008
//retrieve the White Pass text file from NWAC
$theurl=" www.nwac.us/products/OSOWPS ";
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $theurl);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//Trim feed to useful data
$cStartStr = "MM";
$cEndStr= " ";
//$cUsefulContents=stristr($contents,$cStartStr);
$cPageTail = stristr($contents, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos);
// display file
echo "White Pass Ski Area, Washington<br/>";
echo $cUsefulData;
?>
</pre>
</body>
</html>
Please Log in or Create an account to join the conversation.
- Major_Geek
-
Topic Author
- User
-
Less
More
- Posts: 12
- Thank you received: 0
18 years 1 week ago #180775
by Major_Geek
Replied by Major_Geek on topic Re: Formatting NWAC Snotel data for Palm Pilot bro
OK, I have a solution that works. I create a image and printed the text into the image, so the text formatting stays put. Try it on your mobile device at
ykfp.org/php/nwac/whitepasssno.php
.
I tried to find out more about Blazer and couldn't. I asked Palm tech support and it took a little more than a month to get back to me with a really lame response:
"Thank you for contacting Palm Technical Support. My name is Janice and I understand that you are developing a script for a webpage and you would like to know if we have a list of what fonts are available for Blazer.
"Paul, unfortunately, we do have any information about the font types available in Blazer. In order to best assist you, we suggest that you contact Blazer."
I know you get what you pay for when you get free advice, but how the heck to I contact Blazer except through Palm? It's a Palm product, isn't it?
There are other browsers for Palm available, and so far Opera mini has worked best. ISilo seems to be more of a html reader, and Xiino gives me line wrap problems.
<?php
header("Content-type: image/png");
$url = " www.nwac.us/products/OSOWPS ";
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//Trim feed to useful data
$cStartStr = "MM";
$cEndStr= " ";
//$cUsefulContents=stristr($contents,$cStartStr);
$cPageTail = stristr($contents, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos);
// Construct an image file with the data printed in
$im = imagecreatetruecolor(400, 310);
$backgroundcolor = imagecolorallocate($im, 232, 255, 255);
$foregroundcolor = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 339, $backgroundcolor);
$font = '../../fonts/COURBD.TTF';
$fontsize = 7; // size in points
imagettftext($im, $fontsize, 0, 0, 10, $foregroundcolor, $font, $cUsefulData);
imagepng($im);
imagedestroy($im);
?>
I tried to find out more about Blazer and couldn't. I asked Palm tech support and it took a little more than a month to get back to me with a really lame response:
"Thank you for contacting Palm Technical Support. My name is Janice and I understand that you are developing a script for a webpage and you would like to know if we have a list of what fonts are available for Blazer.
"Paul, unfortunately, we do have any information about the font types available in Blazer. In order to best assist you, we suggest that you contact Blazer."
I know you get what you pay for when you get free advice, but how the heck to I contact Blazer except through Palm? It's a Palm product, isn't it?
There are other browsers for Palm available, and so far Opera mini has worked best. ISilo seems to be more of a html reader, and Xiino gives me line wrap problems.
<?php
header("Content-type: image/png");
$url = " www.nwac.us/products/OSOWPS ";
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//Trim feed to useful data
$cStartStr = "MM";
$cEndStr= " ";
//$cUsefulContents=stristr($contents,$cStartStr);
$cPageTail = stristr($contents, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos);
// Construct an image file with the data printed in
$im = imagecreatetruecolor(400, 310);
$backgroundcolor = imagecolorallocate($im, 232, 255, 255);
$foregroundcolor = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 339, $backgroundcolor);
$font = '../../fonts/COURBD.TTF';
$fontsize = 7; // size in points
imagettftext($im, $fontsize, 0, 0, 10, $foregroundcolor, $font, $cUsefulData);
imagepng($im);
imagedestroy($im);
?>
Please Log in or Create an account to join the conversation.
- Scotsman
-
- User
-
Less
More
- Posts: 2432
- Thank you received: 0
18 years 1 week ago #180777
by Scotsman
Replied by Scotsman on topic Re: Formatting NWAC Snotel data for Palm Pilot browser
This post is useless without pictures >
Please Log in or Create an account to join the conversation.
- Major_Geek
-
Topic Author
- User
-
Less
More
- Posts: 12
- Thank you received: 0
18 years 1 week ago #180784
by Major_Geek
Replied by Major_Geek on topic Re: Formatting NWAC Snotel data for Palm Pilot bro
Please Log in or Create an account to join the conversation.
- Scotsman
-
- User
-
Less
More
- Posts: 2432
- Thank you received: 0
18 years 1 week ago #180785
by Scotsman
Replied by Scotsman on topic Re: Formatting NWAC Snotel data for Palm Pilot browser
Very funny Major Geek. I love it
Please Log in or Create an account to join the conversation.
- Tony_Bentley
-
- User
-
Less
More
- Posts: 26
- Thank you received: 0
18 years 1 week ago #180792
by Tony_Bentley
Replied by Tony_Bentley on topic Re: Formatting NWAC Snotel data for Palm Pilot browser
I was just trying to parse the text string from one of their readings last week so I could syndicate it in an rss format but unfortunately it isn't easy as I was hoping. Coldfusion ends up reading the returns and multiple spaces as single spaces and so I end up with single spaces in between every group of spaces. I'm not sure asp or php can do any better. Unfortunately I am not familiar enough with document parsing to work with their current format.
My idea was to first format them into XML so anyone could just attach different style sheets for multipule platforms like palm and cellular phones.
If they use a SQL database and allowed me to run queries every 60 minutes, it would be much easier than working with the txt files. I think the NWAC site is great and a very valuable resource for backcountry skiers, snowboarders and hikers but it would be great to see the information syndicated beyond their site with RSS. If I can help in any way, let me know.
My idea was to first format them into XML so anyone could just attach different style sheets for multipule platforms like palm and cellular phones.
If they use a SQL database and allowed me to run queries every 60 minutes, it would be much easier than working with the txt files. I think the NWAC site is great and a very valuable resource for backcountry skiers, snowboarders and hikers but it would be great to see the information syndicated beyond their site with RSS. If I can help in any way, let me know.
Please Log in or Create an account to join the conversation.