You are here: PEAR::Services_Weather problem « All PHP « IT news, forums, messages
PEAR::Services_Weather problem

Posted by Paul on 05/10/05 21:18

I am having problems retrieving weather for a specific location using a
lat/long look up. The weather module works fine, using the provided
examples, but when I attempt to retrieve the weather for a locate, as
provided by the searchAirport method, as opposed to using the
searchLocation method, the following error is generated "Invalid
location provided. Error:1 Services_Weather (Metar.php:273)" . Both the
searchAirport and searchLocation methods return a valid location code.
In the example of Bonn Germany the location code of 'EDDK' is returned,
the latitude/longitude method returns 'K5R5'. When 'EDDK' is supplied to
the getWeather method, a weather report is returned, when 'K5R5' is
supplied I get the error.

I know 'K5R5' is a valid location code since it is returned by the
searchAirport method, and if I go to the Metar service site and enter
this code a weather report is returned.

Code Snippet..

// returns 'EDDK' only one of these functions is active in my code at a
// time searchLocation or searchAirport

$search = $metar->searchLocation($location, true);
if (Services_Weather::isError($search)) {
die("Error: ".$search->getMessage()."\n");
}
else{
print("Station found by name:$search2<br>");
}

// returns 'K5R5' only one of these functions is active in my code at a
// time searchLocation or searchAirport

$search = $metar->searchAirport($latitude,$longitude,1);
if(Services_Weather::isError($search)){
die("Error Lat//Long search Failed".$search->getMessage()."\n");
}
else{
print("Station found by lat/long: $search<br><br>");
}


// Retrieve data, store in variables, bail out on error
$fetch = array(
"location" => "getLocation",
"weather" => "getWeather",
"forecast" => "getForecast"
);

foreach ($fetch as $variable => $function) {
$$variable = $metar->$function($search);
if (Services_Weather::isError($$variable)) {
echo "Error:1 ".$$variable->getMessage()."\n";
continue;
}
}

// if $search = 'EDDK' success
// if $search = 'K5R5' fail

Pear class ref:
http://pear.php.net/package/Services_Weather/docs/latest/li_Services_Weather.html

Thank you for your time and interest.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация