cvs: pear /Services_Weather Weather.php buildMetarDB.php /Services_Weather/Weather Common.php Ejse.php Globalweather.php Metar.php Weatherdotcom.php
| From: | Alexander Wirtz | Date: | Tue, 08 Nov 2005 17:37:39 +0000 |
| Subject: | cvs: pear /Services_Weather Weather.php buildMetarDB.php /Services_Weather/Weather Common.php Ejse.php Globalweather.php Metar.php Weatherdotcom.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-36158@lists.php.net to get a copy of this message | ||
eru Tue Nov 8 12:37:39 2005 EDT
Modified files:
/pear/Services_Weather/Weather Metar.php Common.php
Weatherdotcom.php Ejse.php
Globalweather.php
/pear/Services_Weather buildMetarDB.php Weather.php
Log:
o Changed header-style as proposed in RFC::Header Comment Blocks
http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Metar.php?r1=1.74&r2=1.75&ty=u Index: pear/Services_Weather/Weather/Metar.php diff -u pear/Services_Weather/Weather/Metar.php:1.74 pear/Services_Weather/Weather/Metar.php:1.75 --- pear/Services_Weather/Weather/Metar.php:1.74 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Metar.php Tue Nov 8 12:37:34 2005 @@ -1,123 +1,149 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Metar.php,v 1.74 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Metar + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Metar.php,v 1.75 2005/11/08 17:37:34 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/weather/metar.shtml + * @link http://weather.noaa.gov/weather/taf.shtml + * @example examples/metar-basic.php metar-basic.php + * @example examples/metar-extensive.php metar-extensive.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; require_once "DB.php"; // {{{ class Services_Weather_Metar /** -* PEAR::Services_Weather_Metar -* -* This class acts as an interface to the METAR/TAF service of -* weather.noaa.gov. It searches for locations given in ICAO notation and -* retrieves the current weather data. -* -* Of course the parsing of the METAR-data has its limitations, as it -* follows the Federal Meteorological Handbook No.1 with modifications to -* accomodate for non-US reports, so if the report deviates from these -* standards, you won't get it parsed correctly. -* Anything that is not parsed, is saved in the "noparse" array-entry, -* returned by getWeather(), so you can do your own parsing afterwards. This -* limitation is specifically given for remarks, as the class is not -* processing everything mentioned there, but you will get the most common -* fields like precipitation and temperature-changes. Again, everything not -* parsed, goes into "noparse". -* -* If you think, some important field is missing or not correctly parsed, -* please file a feature-request/bugreport at http://pear.php.net/ and be -* sure to provide the METAR (or TAF) report with a _detailed_ explanation! -* -* For working examples, please take a look at -* docs/Services_Weather/examples/metar-basic.php -* docs/Services_Weather/examples/metar-extensive.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://weather.noaa.gov/weather/metar.shtml -* @link http://weather.noaa.gov/weather/taf.shtml -* @example examples/metar-basic.php metar-basic.php -* @example examples/metar-extensive.php metar-extensive.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the METAR/TAF service of + * weather.noaa.gov. It searches for locations given in ICAO notation and + * retrieves the current weather data. + * + * Of course the parsing of the METAR-data has its limitations, as it + * follows the Federal Meteorological Handbook No.1 with modifications to + * accomodate for non-US reports, so if the report deviates from these + * standards, you won't get it parsed correctly. + * Anything that is not parsed, is saved in the "noparse" array-entry, + * returned by getWeather(), so you can do your own parsing afterwards. This + * limitation is specifically given for remarks, as the class is not + * processing everything mentioned there, but you will get the most common + * fields like precipitation and temperature-changes. Again, everything not + * parsed, goes into "noparse". + * + * If you think, some important field is missing or not correctly parsed, + * please file a feature-request/bugreport at http://pear.php.net/ and be + * sure to provide the METAR (or TAF) report with a _detailed_ explanation! + * + * For working examples, please take a look at + * docs/Services_Weather/examples/metar-basic.php + * docs/Services_Weather/examples/metar-extensive.php + * + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/weather/metar.shtml + * @link http://weather.noaa.gov/weather/taf.shtml + * @example examples/metar-basic.php metar-basic.php + * @example examples/metar-extensive.php metar-extensive.php + */ class Services_Weather_Metar extends Services_Weather_Common { // {{{ properties /** - * Information to access the location DB - * - * @var object DB $_db - * @access private - */ + * Information to access the location DB + * + * @var object DB $_db + * @access private + */ var $_db; /** - * The source METAR uses - * - * @var string $_sourceMetar - * @access private - */ + * The source METAR uses + * + * @var string $_sourceMetar + * @access private + */ var $_sourceMetar; /** - * The source TAF uses - * - * @var string $_sourceTaf - * @access private - */ + * The source TAF uses + * + * @var string $_sourceTaf + * @access private + */ var $_sourceTaf; /** - * This path is used to find the METAR data - * - * @var string $_sourcePathMetar - * @access private - */ + * This path is used to find the METAR data + * + * @var string $_sourcePathMetar + * @access private + */ var $_sourcePathMetar; /** - * This path is used to find the TAF data - * - * @var string $_sourcePathTaf - * @access private - */ + * This path is used to find the TAF data + * + * @var string $_sourcePathTaf + * @access private + */ var $_sourcePathTaf; // }}} // {{{ constructor /** - * Constructor - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Metar($options, &$error) { $perror = null; @@ -169,18 +195,18 @@ // {{{ setMetarDB() /** - * Sets the parameters needed for connecting to the DB, where the - * location-search is fetching its data from. You need to build a DB - * with the external tool buildMetarDB first, it fetches the locations - * and airports from a NOAA-website. - * - * @param string $dsn - * @param array $dbOptions - * @return DB_Error|bool - * @throws DB_Error - * @see DB::parseDSN - * @access public - */ + * Sets the parameters needed for connecting to the DB, where the + * location-search is fetching its data from. You need to build a DB + * with the external tool buildMetarDB first, it fetches the locations + * and airports from a NOAA-website. + * + * @param string $dsn + * @param array $dbOptions + * @return DB_Error|bool + * @throws DB_Error + * @see DB::parseDSN + * @access public + */ function setMetarDB($dsn, $dbOptions = array()) { $dsninfo = DB::parseDSN($dsn); @@ -201,17 +227,17 @@ // {{{ setMetarSource() /** - * Sets the source, where the class tries to locate the METAR/TAF data - * - * Source can be http, ftp or file. - * Alternate sourcepaths can be provided. - * - * @param string $sourceMetar - * @param string $sourcePathMetar - * @param string $sourceTaf - * @param string $sourcePathTaf - * @access public - */ + * Sets the source, where the class tries to locate the METAR/TAF data + * + * Source can be http, ftp or file. + * Alternate sourcepaths can be provided. + * + * @param string $sourceMetar + * @param string $sourcePathMetar + * @param string $sourceTaf + * @param string $sourcePathTaf + * @access public + */ function setMetarSource($sourceMetar, $sourcePathMetar = "", $sourceTaf = "", $sourcePathTaf = "") { if (in_array($sourceMetar, array("http", "ftp", "file"))) { @@ -255,15 +281,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * METAR server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * METAR server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -278,17 +304,17 @@ // {{{ _parseWeatherData() /** - * Parses the data returned by the provided source and caches it - * - * METAR KPIT 091955Z COR 22015G25KT 3/4SM R28L/2600FT TSRA OVC010CB - * 18/16 A2992 RMK SLP045 T01820159 - * - * @param string $source - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access private - */ + * Parses the data returned by the provided source and caches it + * + * METAR KPIT 091955Z COR 22015G25KT 3/4SM R28L/2600FT TSRA OVC010CB + * 18/16 A2992 RMK SLP045 T01820159 + * + * @param string $source + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access private + */ function _parseWeatherData($source) { static $compass; @@ -775,21 +801,21 @@ // {{{ _parseForecastData() /** - * Parses the data returned by the provided source and caches it - * - * TAF KLGA 271734Z 271818 11007KT P6SM -RA SCT020 BKN200 - * FM2300 14007KT P6SM SCT030 BKN150 - * FM0400 VRB03KT P6SM SCT035 OVC080 PROB30 0509 P6SM -RA BKN035 - * FM0900 VRB03KT 6SM -RA BR SCT015 OVC035 - * TEMPO 1215 5SM -RA BR SCT009 BKN015 - * BECMG 1517 16007KT P6SM NSW SCT015 BKN070 - * - * @param string $source - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access private - */ + * Parses the data returned by the provided source and caches it + * + * TAF KLGA 271734Z 271818 11007KT P6SM -RA SCT020 BKN200 + * FM2300 14007KT P6SM SCT030 BKN150 + * FM0400 VRB03KT P6SM SCT035 OVC080 PROB30 0509 P6SM -RA BKN035 + * FM0900 VRB03KT 6SM -RA BR SCT015 OVC035 + * TEMPO 1215 5SM -RA BR SCT009 BKN015 + * BECMG 1517 16007KT P6SM NSW SCT015 BKN070 + * + * @param string $source + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access private + */ function _parseForecastData($source) { static $compass; @@ -1177,14 +1203,14 @@ // {{{ _convertReturn() /** - * Converts the data in the return array to the desired units and/or - * output format. - * - * @param array $target - * @param string $units - * @param string $location - * @access private - */ + * Converts the data in the return array to the desired units and/or + * output format. + * + * @param array $target + * @param string $units + * @param string $location + * @access private + */ function _convertReturn(&$target, $units, $location) { if (is_array($target)) { @@ -1256,17 +1282,17 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string|array $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string|array $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1343,16 +1369,16 @@ // {{{ searchLocationByCountry() /** - * Returns IDs with location-name for a given country or all available - * countries, if no value was given - * - * @param string $country - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access public - */ + * Returns IDs with location-name for a given country or all available + * countries, if no value was given + * + * @param string $country + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access public + */ function searchLocationByCountry($country = "") { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1405,18 +1431,18 @@ // {{{ searchAirport() /** - * Searches the nearest airport(s) for given coordinates, returns array - * of IDs or single ID - * - * @param float $latitude - * @param float $longitude - * @param int $numResults - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access public - */ + * Searches the nearest airport(s) for given coordinates, returns array + * of IDs or single ID + * + * @param float $latitude + * @param float $longitude + * @param int $numResults + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access public + */ function searchAirport($latitude, $longitude, $numResults = 1) { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1485,13 +1511,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -1556,14 +1582,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PHP_Error|array - * @throws PHP_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PHP_Error|array + * @throws PHP_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $id = strtoupper($id); @@ -1617,16 +1643,16 @@ // {{{ getForecast() /** - * METAR provides no forecast per se, we use the TAF reports to generate - * a forecast for the announced timeperiod - * - * @param string $id - * @param int $days Ignored, not applicable - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * METAR provides no forecast per se, we use the TAF reports to generate + * a forecast for the announced timeperiod + * + * @param string $id + * @param int $days Ignored, not applicable + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = null, $unitsFormat = "") { $id = strtoupper($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Common.php?r1=1.41&r2=1.42&ty=u Index: pear/Services_Weather/Weather/Common.php diff -u pear/Services_Weather/Weather/Common.php:1.41 pear/Services_Weather/Weather/Common.php:1.42 --- pear/Services_Weather/Weather/Common.php:1.41 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Common.php Tue Nov 8 12:37:35 2005 @@ -1,30 +1,50 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php,v 1.41 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Common + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Common.php,v 1.42 2005/11/08 17:37:35 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @filesource + */ -/** -*/ require_once "Services/Weather.php"; // {{{ constants @@ -35,34 +55,35 @@ // {{{ class Services_Weather_Common /** -* PEAR::Services_Weather_Common -* -* Parent class for weather-services. Defines common functions for unit -* conversions, checks for cache enabling and does other miscellaneous -* things. -* -* @author Alexander Wirtz <alex@pc4p.net> -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * Parent class for weather-services. Defines common functions for unit + * conversions, checks for cache enabling and does other miscellaneous + * things. + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + */ class Services_Weather_Common { // {{{ properties /** - * Format of the units provided (standard/metric/custom) - * - * @var string $_unitsFormat - * @access private - */ + * Format of the units provided (standard/metric/custom) + * + * @var string $_unitsFormat + * @access private + */ var $_unitsFormat = "s"; /** - * Custom format of the units - * - * @var array $_customUnitsFormat - * @access private - */ + * Custom format of the units + * + * @var array $_customUnitsFormat + * @access private + */ var $_customUnitsFormat = array( "temp" => "f", "vis" => "sm", @@ -73,79 +94,79 @@ ); /** - * Timeout for HTTP requests - * - * @var int $_httpTimeout - * @access private - */ + * Timeout for HTTP requests + * + * @var int $_httpTimeout + * @access private + */ var $_httpTimeout = 60; /** - * Format of the used dates - * - * @var string $_dateFormat - * @access private - */ + * Format of the used dates + * + * @var string $_dateFormat + * @access private + */ var $_dateFormat = "m/d/y"; /** - * Format of the used times - * - * @var string $_timeFormat - * @access private - */ + * Format of the used times + * + * @var string $_timeFormat + * @access private + */ var $_timeFormat = "G:i A"; /** - * Object containing the location-data - * - * @var object stdClass $_location - * @access private - */ + * Object containing the location-data + * + * @var object stdClass $_location + * @access private + */ var $_location; /** - * Object containing the weather-data - * - * @var object stdClass $_weather - * @access private - */ + * Object containing the weather-data + * + * @var object stdClass $_weather + * @access private + */ var $_weather; /** - * Object containing the forecast-data - * - * @var object stdClass $_forecast - * @access private - */ + * Object containing the forecast-data + * + * @var object stdClass $_forecast + * @access private + */ var $_forecast; /** - * Cache, containing the data-objects - * - * @var object Cache $_cache - * @access private - */ + * Cache, containing the data-objects + * + * @var object Cache $_cache + * @access private + */ var $_cache; /** - * Provides check for Cache - * - * @var bool $_cacheEnabled - * @access private - */ + * Provides check for Cache + * + * @var bool $_cacheEnabled + * @access private + */ var $_cacheEnabled = false; // }}} // {{{ constructor /** - * Constructor - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Common($options, &$error) { // Set options accordingly @@ -184,16 +205,16 @@ // {{{ setCache() /** - * Enables caching the data, usage strongly recommended - * - * Requires Cache to be installed - * - * @param string $cacheType - * @param array $cacheOptions - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED - * @access public - */ + * Enables caching the data, usage strongly recommended + * + * Requires Cache to be installed + * + * @param string $cacheType + * @param array $cacheOptions + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED + * @access public + */ function setCache($cacheType = "file", $cacheOptions = array()) { // The error handling in Cache is a bit crummy (read: not existent) @@ -215,12 +236,12 @@ // {{{ setUnitsFormat() /** - * Changes the representation of the units (standard/metric) - * - * @param string $unitsFormat - * @param array $customUnitsFormat - * @access public - */ + * Changes the representation of the units (standard/metric) + * + * @param string $unitsFormat + * @param array $customUnitsFormat + * @access public + */ function setUnitsFormat($unitsFormat, $customUnitsFormat = array()) { static $acceptedFormats; @@ -252,11 +273,11 @@ // {{{ setHttpTimeout() /** - * Sets the timeout in seconds for HTTP requests - * - * @param int $httpTimeout - * @access public - */ + * Sets the timeout in seconds for HTTP requests + * + * @param int $httpTimeout + * @access public + */ function setHttpTimeout($httpTimeout) { if (is_int($httpTimeout)) { @@ -267,12 +288,12 @@ // {{{ getUnitsFormat() /** - * Returns the selected units format - * - * @param string $unitsFormat - * @return array - * @access public - */ + * Returns the selected units format + * + * @param string $unitsFormat + * @return array + * @access public + */ function getUnitsFormat($unitsFormat = "") { // This is cheap'o stuff @@ -306,12 +327,12 @@ // {{{ setDateTimeFormat() /** - * Changes the representation of time and dates (see http://www.php.net/date) - * - * @param string $dateFormat - * @param string $timeFormat - * @access public - */ + * Changes the representation of time and dates (see http://www.php.net/date) + * + * @param string $dateFormat + * @param string $timeFormat + * @access public + */ function setDateTimeFormat($dateFormat = "", $timeFormat = "") { if (strlen($dateFormat)) { @@ -325,14 +346,14 @@ // {{{ convertTemperature() /** - * Convert temperature between f and c - * - * @param float $temperature - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert temperature between f and c + * + * @param float $temperature + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertTemperature($temperature, $from, $to) { $from = strtolower($from{0}); @@ -353,18 +374,18 @@ // {{{ convertSpeed() /** - * Convert speed between mph, kmh, kt, mps, fps and bft - * - * Function will return "false" when trying to convert from - * Beaufort, as it is a scale and not a true measurement - * - * @param float $speed - * @param string $from - * @param string $to - * @return float|int|bool - * @access public - * @link http://www.spc.noaa.gov/faq/tornado/beaufort.html - */ + * Convert speed between mph, kmh, kt, mps, fps and bft + * + * Function will return "false" when trying to convert from + * Beaufort, as it is a scale and not a true measurement + * + * @param float $speed + * @param string $from + * @param string $to + * @return float|int|bool + * @access public + * @link http://www.spc.noaa.gov/faq/tornado/beaufort.html + */ function convertSpeed($speed, $from, $to) { $from = strtolower($from); @@ -417,14 +438,14 @@ // {{{ convertPressure() /** - * Convert pressure between in, hpa, mb, mm and atm - * - * @param float $pressure - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert pressure between in, hpa, mb, mm and atm + * + * @param float $pressure + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertPressure($pressure, $from, $to) { $from = strtolower($from); @@ -457,14 +478,14 @@ // {{{ convertDistance() /** - * Convert distance between km, ft and sm - * - * @param float $distance - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert distance between km, ft and sm + * + * @param float $distance + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertDistance($distance, $from, $to) { $to = strtolower($to); @@ -494,16 +515,16 @@ // {{{ calculateWindChill() /** - * Calculate windchill from temperature and windspeed (enhanced formula) - * - * Temperature has to be entered in deg F, speed in mph! - * - * @param float $temperature - * @param float $speed - * @return float - * @access public - * @link http://www.nws.noaa.gov/om/windchill/ - */ + * Calculate windchill from temperature and windspeed (enhanced formula) + * + * Temperature has to be entered in deg F, speed in mph! + * + * @param float $temperature + * @param float $speed + * @return float + * @access public + * @link http://www.nws.noaa.gov/om/windchill/ + */ function calculateWindChill($temperature, $speed) { return round(35.74 + 0.6215 * $temperature - 35.75 * pow($speed, 0.16) + 0.4275 * $temperature * pow($speed, 0.16)); @@ -512,18 +533,18 @@ // {{{ calculateHumidity() /** - * Calculate humidity from temperature and dewpoint - * This is only an approximation, there is no exact formula, this - * one here is called Magnus-Formula - * - * Temperature and dewpoint have to be entered in deg C! - * - * @param float $temperature - * @param float $dewPoint - * @return float - * @access public - * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ - */ + * Calculate humidity from temperature and dewpoint + * This is only an approximation, there is no exact formula, this + * one here is called Magnus-Formula + * + * Temperature and dewpoint have to be entered in deg C! + * + * @param float $temperature + * @param float $dewPoint + * @return float + * @access public + * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ + */ function calculateHumidity($temperature, $dewPoint) { // First calculate saturation steam pressure for both temperatures @@ -551,18 +572,18 @@ // {{{ calculateDewPoint() /** - * Calculate dewpoint from temperature and humidity - * This is only an approximation, there is no exact formula, this - * one here is called Magnus-Formula - * - * Temperature has to be entered in deg C! - * - * @param float $temperature - * @param float $humidity - * @return float - * @access public - * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ - */ + * Calculate dewpoint from temperature and humidity + * This is only an approximation, there is no exact formula, this + * one here is called Magnus-Formula + * + * Temperature has to be entered in deg C! + * + * @param float $temperature + * @param float $humidity + * @return float + * @access public + * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ + */ function calculateDewPoint($temperature, $humidity) { if ($temperature >= 0) { @@ -587,13 +608,13 @@ // {{{ polar2cartesian() /** - * Convert polar coordinates to cartesian coordinates - * - * @param float $latitude - * @param float $longitude - * @return array - * @access public - */ + * Convert polar coordinates to cartesian coordinates + * + * @param float $latitude + * @param float $longitude + * @return array + * @access public + */ function polar2cartesian($latitude, $longitude) { $theta = deg2rad($latitude); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Weatherdotcom.php?r1=1.47&r2=1.48&ty=u Index: pear/Services_Weather/Weather/Weatherdotcom.php diff -u pear/Services_Weather/Weather/Weatherdotcom.php:1.47 pear/Services_Weather/Weather/Weatherdotcom.php:1.48 --- pear/Services_Weather/Weather/Weatherdotcom.php:1.47 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Weatherdotcom.php Tue Nov 8 12:37:35 2005 @@ -1,109 +1,133 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Weatherdotcom.php,v 1.47 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Weatherdotcom + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Weatherdotcom.php,v 1.48 2005/11/08 17:37:35 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.weather.com/services/xmloap.html + * @example examples/weather.com-basic.php weather.com-basic.php + * @example examples/weather.com-extensive.php weather.com-extensive.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Weatherdotcom /** -* PEAR::Services_Weather_Weatherdotcom -* -* This class acts as an interface to the xml service of weather.com. It -* searches for given locations and retrieves current weather data as well -* as forecast for up to 10 days. -* -* For using the weather.com xml-service please visit -* http://www.weather.com/services/xmloap.html -* and follow the link to sign up, it's free! You will receive an email -* where to download the SDK with the needed images and guidelines how to -* publish live data from weather.com. Unfortunately the guidelines are a -* bit harsh, that's why there's no actual data-representation in this -* class, just the raw data. Also weather.com demands active caching, so I'd -* strongly recommend enabling the caching implemented in this class. It -* obeys to the times as written down in the guidelines. -* -* For working examples, please take a look at -* docs/Services_Weather/examples/weather.com-basic.php -* docs/Services_Weather/examples/weather.com-extensive.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.weather.com/services/xmloap.html -* @example examples/weather.com-basic.php weather.com-basic.php -* @example examples/weather.com-extensive.php weather.com-extensive.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the xml service of weather.com. It + * searches for given locations and retrieves current weather data as well + * as forecast for up to 10 days. + * + * For using the weather.com xml-service please visit + * http://www.weather.com/services/xmloap.html + * and follow the link to sign up, it's free! You will receive an email + * where to download the SDK with the needed images and guidelines how to + * publish live data from weather.com. Unfortunately the guidelines are a + * bit harsh, that's why there's no actual data-representation in this + * class, just the raw data. Also weather.com demands active caching, so I'd + * strongly recommend enabling the caching implemented in this class. It + * obeys to the times as written down in the guidelines. + * + * For working examples, please take a look at + * docs/Services_Weather/examples/weather.com-basic.php + * docs/Services_Weather/examples/weather.com-extensive.php + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.weather.com/services/xmloap.html + * @example examples/weather.com-basic.php weather.com-basic.php + * @example examples/weather.com-extensive.php weather.com-extensive.php + */ class Services_Weather_Weatherdotcom extends Services_Weather_Common { // {{{ properties /** - * Partner-ID at weather.com - * - * @var string $_partnerID - * @access private - */ + * Partner-ID at weather.com + * + * @var string $_partnerID + * @access private + */ var $_partnerID = ""; /** - * License key at weather.com - * - * @var string $_licenseKey - * @access private - */ + * License key at weather.com + * + * @var string $_licenseKey + * @access private + */ var $_licenseKey = ""; /** - * Object containing the promotional links-data - * - * @var object stdClass $_links - * @access private - */ + * Object containing the promotional links-data + * + * @var object stdClass $_links + * @access private + */ var $_links; /** - * XML_Unserializer, used for processing the xml - * - * @var object XML_Unserializer $_unserializer - * @access private - */ + * XML_Unserializer, used for processing the xml + * + * @var object XML_Unserializer $_unserializer + * @access private + */ var $_unserializer; // }}} // {{{ constructor /** - * Constructor - * - * Requires XML_Serializer to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * Requires XML_Serializer to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Weatherdotcom($options, &$error) { $perror = null; @@ -137,13 +161,13 @@ // {{{ setAccountData() /** - * Sets the neccessary account-information for weather.com, you'll - * receive them after registering for the XML-stream - * - * @param string $partnerID - * @param string $licenseKey - * @access public - */ + * Sets the neccessary account-information for weather.com, you'll + * receive them after registering for the XML-stream + * + * @param string $partnerID + * @param string $licenseKey + * @access public + */ function setAccountData($partnerID, $licenseKey) { if (strlen($partnerID) && ctype_digit($partnerID)) { @@ -157,15 +181,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * weather.com server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * weather.com server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -180,15 +204,15 @@ // {{{ _parseWeatherData() /** - * Parses the data returned by the provided URL and caches it - * - * @param string $id - * @param string $url - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error - * @access private - */ + * Parses the data returned by the provided URL and caches it + * + * @param string $id + * @param string $url + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error + * @access private + */ function _parseWeatherData($id, $url) { // Get data from URL... @@ -252,16 +276,16 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { // Get search data from server and unserialize @@ -299,14 +323,14 @@ // {{{ searchLocationByCountry() /** - * Returns only false, as weather.com offers no country listing via - * its XML services - * - * @param string $country - * @return bool - * @access public - * @deprecated - */ + * Returns only false, as weather.com offers no country listing via + * its XML services + * + * @param string $country + * @return bool + * @access public + * @deprecated + */ function searchLocationByCountry($country = "") { return false; @@ -315,13 +339,13 @@ // {{{ getLinks() /** - * Returns the data for the promotional links belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the promotional links belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLinks($id = "") { $status = $this->_checkLocationID($id); @@ -362,13 +386,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -408,14 +432,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $status = $this->_checkLocationID($id); @@ -482,15 +506,15 @@ // {{{ getForecast() /** - * Get the forecast for the next days - * - * @param string $id - * @param int $days Values between 1 and 10 - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Get the forecast for the next days + * + * @param string $id + * @param int $days Values between 1 and 10 + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = 2, $unitsFormat = "") { $status = $this->_checkLocationID($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Ejse.php?r1=1.19&r2=1.20&ty=u Index: pear/Services_Weather/Weather/Ejse.php diff -u pear/Services_Weather/Weather/Ejse.php:1.19 pear/Services_Weather/Weather/Ejse.php:1.20 --- pear/Services_Weather/Weather/Ejse.php:1.19 Tue Nov 8 07:21:34 2005 +++ pear/Services_Weather/Weather/Ejse.php Tue Nov 8 12:37:36 2005 @@ -1,82 +1,105 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Ejse.php,v 1.19 2005/11/08 12:21:34 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Ejse + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Ejse.php,v 1.20 2005/11/08 17:37:36 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.ejse.com/services/weather_xml_web_services.htm + * @example examples/ejse-basic.php ejse-basic.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Ejse /** -* PEAR::Services_Weather_Ejse -* -* This class acts as an interface to the soap service of EJSE. It retrieves -* current weather data and forecasts based on postal codes (ZIP). -* -* Currently this service is only available for US territory. -* -* For a working example, please take a look at -* docs/Services_Weather/examples/ejse-basic.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.ejse.com/services/weather_xml_web_services.htm -* @example examples/ejse-basic.php ejse-basic.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the soap service of EJSE. It retrieves + * current weather data and forecasts based on postal codes (ZIP). + * + * Currently this service is only available for US territory. + * + * For a working example, please take a look at + * docs/Services_Weather/examples/ejse-basic.php + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.ejse.com/services/weather_xml_web_services.htm + * @example examples/ejse-basic.php ejse-basic.php + */ class Services_Weather_Ejse extends Services_Weather_Common { // {{{ properties /** - * WSDL object, provided by EJSE - * - * @var object $_wsdl - * @access private - */ + * WSDL object, provided by EJSE + * + * @var object $_wsdl + * @access private + */ var $_wsdl; /** - * SOAP object to access weather data, provided by EJSE - * - * @var object $_weaterSoap - * @access private - */ + * SOAP object to access weather data, provided by EJSE + * + * @var object $_weaterSoap + * @access private + */ var $_weatherSoap; // }}} // {{{ constructor /** - * Constructor - * - * Requires SOAP to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * Requires SOAP to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Ejse($options, &$error) { $perror = null; @@ -89,12 +112,12 @@ // {{{ _connectServer() /** - * Connects to the SOAP server and retrieves the WSDL data - * - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function _connectServer() { include_once "SOAP/Client.php"; @@ -115,14 +138,14 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to EJSE server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to EJSE server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -137,15 +160,15 @@ // {{{ searchLocation() /** - * EJSE offers no search function to date, so this function is disabled. - * Maybe this is the place to interface to some online postcode service... - * - * @param string $location - * @param bool $useFirst - * @return bool - * @access public - * @deprecated - */ + * EJSE offers no search function to date, so this function is disabled. + * Maybe this is the place to interface to some online postcode service... + * + * @param string $location + * @param bool $useFirst + * @return bool + * @access public + * @deprecated + */ function searchLocation($location = null, $useFirst = null) { return false; @@ -154,14 +177,14 @@ // {{{ searchLocationByCountry() /** - * EJSE offers no search function to date, so this function is disabled. - * Maybe this is the place to interface to some online postcode service... - * - * @param string $country - * @return bool - * @access public - * @deprecated - */ + * EJSE offers no search function to date, so this function is disabled. + * Maybe this is the place to interface to some online postcode service... + * + * @param string $country + * @return bool + * @access public + * @deprecated + */ function searchLocationByCountry($country = null) { return false; @@ -170,13 +193,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -223,14 +246,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $status = $this->_checkLocationID($id); @@ -348,15 +371,15 @@ // {{{ getForecast() /** - * Get the forecast for the next days - * - * @param string $int - * @param int $days Values between 1 and 9 - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Get the forecast for the next days + * + * @param string $int + * @param int $days Values between 1 and 9 + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = 2, $unitsFormat = "") { $status = $this->_checkLocationID($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Globalweather.php?r1=1.30&r2=1.31&ty=u Index: pear/Services_Weather/Weather/Globalweather.php diff -u pear/Services_Weather/Weather/Globalweather.php:1.30 pear/Services_Weather/Weather/Globalweather.php:1.31 --- pear/Services_Weather/Weather/Globalweather.php:1.30 Tue Nov 8 07:21:34 2005 +++ pear/Services_Weather/Weather/Globalweather.php Tue Nov 8 12:37:36 2005 @@ -1,96 +1,120 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Globalweather.php,v 1.30 2005/11/08 12:21:34 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Globalweather + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Globalweather.php,v 1.31 2005/11/08 17:37:36 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.capescience.com/webservices/globalweather/index.shtml + * @example examples/globalweather-basic.php globalweather-basic.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Globalweather /** -* PEAR::Services_Weather_Globalweather -* -* This class acts as an interface to the soap service of capescience.com. -* It searches for given locations and retrieves current weather data. -* -* GlobalWeather is a SOAP frontend for METAR data, provided by CapeScience. -* If you want to use METAR, you should try this class first, as it is much -* more comfortable (and also a bit faster) than the native METAR-class -* provided by this package. On the other hand, this service won't supply -* TAFs, the forecast system accompanying METAR, so you have to make -* the call here... -* -* For a working example, please take a look at -* docs/Services_Weather/examples/globalweather-basic.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.capescience.com/webservices/globalweather/index.shtml -* @example examples/globalweather-basic.php globalweather-basic.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the soap service of capescience.com. + * It searches for given locations and retrieves current weather data. + * + * GlobalWeather is a SOAP frontend for METAR data, provided by CapeScience. + * If you want to use METAR, you should try this class first, as it is much + * more comfortable (and also a bit faster) than the native METAR-class + * provided by this package. On the other hand, this service won't supply + * TAFs, the forecast system accompanying METAR, so you have to make + * the call here... + * + * For a working example, please take a look at + * docs/Services_Weather/examples/globalweather-basic.php + * + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.capescience.com/webservices/globalweather/index.shtml + * @example examples/globalweather-basic.php globalweather-basic.php + */ class Services_Weather_Globalweather extends Services_Weather_Common { // {{{ properties /** - * WSDL object, provided by CapeScience - * - * @var object $_wsdl - * @access private - */ + * WSDL object, provided by CapeScience + * + * @var object $_wsdl + * @access private + */ var $_wsdl; /** - * SOAP object to access station data, provided by CapeScience - * - * @var object $_stationSoap - * @access private - */ + * SOAP object to access station data, provided by CapeScience + * + * @var object $_stationSoap + * @access private + */ var $_stationSoap; /** - * SOAP object to access weather data, provided by CapeScience - * - * @var object $_weatherSoap - * @access private - */ + * SOAP object to access weather data, provided by CapeScience + * + * @var object $_weatherSoap + * @access private + */ var $_weatherSoap; // }}} // {{{ constructor /** - * Constructor - * - * Requires SOAP to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Constructor + * + * Requires SOAP to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function Services_Weather_Globalweather($options, &$error) { $perror = null; @@ -103,12 +127,12 @@ // {{{ _connectServer() /** - * Connects to the SOAP server and retrieves the WSDL data - * - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function _connectServer() { include_once "SOAP/Client.php"; @@ -133,15 +157,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * GlobalWeather server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * GlobalWeather server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -156,16 +180,16 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data @@ -202,15 +226,15 @@ // {{{ searchLocationByCountry() /** - * Returns IDs with location-name for a given country or all available - * countries, if no value was given - * - * @param string $country - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Returns IDs with location-name for a given country or all available + * countries, if no value was given + * + * @param string $country + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocationByCountry($country = "") { // Return the available countries as no country was given @@ -252,13 +276,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -315,14 +339,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { static $clouds; @@ -440,16 +464,16 @@ // {{{ getForecast() /** - * GlobalWeather has no forecast per se, so this function is just for - * compatibility purposes. - * - * @param string $int - * @param int $days - * @param string $unitsFormat - * @return bool - * @access public - * @deprecated - */ + * GlobalWeather has no forecast per se, so this function is just for + * compatibility purposes. + * + * @param string $int + * @param int $days + * @param string $unitsFormat + * @return bool + * @access public + * @deprecated + */ function getForecast($id = null, $days = null, $unitsFormat = null) { return false; http://cvs.php.net/diff.php/pear/Services_Weather/buildMetarDB.php?r1=1.21&r2=1.22&ty=u Index: pear/Services_Weather/buildMetarDB.php diff -u pear/Services_Weather/buildMetarDB.php:1.21 pear/Services_Weather/buildMetarDB.php:1.22 --- pear/Services_Weather/buildMetarDB.php:1.21 Wed May 5 04:33:43 2004 +++ pear/Services_Weather/buildMetarDB.php Tue Nov 8 12:37:38 2005 @@ -1,51 +1,64 @@ #!/usr/local/bin/php <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: buildMetarDB.php,v 1.21 2004/05/05 08:33:43 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* This script downloads, saves and processes the textfiles needed for -* the building the databases to enable searching for METAR stations. -* -* You can download the locations, which is a database of about 12000 world- -* wide locations, which can be used to determine the coordinates of your -* city or you can download a file with 6500 airports providing the metar -* data. This database is used for the next-METAR-station search. Please see -* the apropriate documentation in the Services_Weather_Metar class. -* -* For usage of this script, invoke with '-h'. -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://weather.noaa.gov/tg/site.shtml -* @package Services_Weather -* @subpackage buildMetarDB -* @filesource -* @version 1.3 -*/ + * This script downloads, saves and processes the textfiles needed for + * the building the databases to enable searching for METAR stations. + * + * You can download the locations, which is a database of about 12000 world- + * wide locations, which can be used to determine the coordinates of your + * city or you can download a file with 6500 airports providing the metar + * data. This database is used for the next-METAR-station search. Please see + * the apropriate documentation in the Services_Weather_Metar class. + * + * For usage of this script, invoke with '-h'. + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @subpackage buildMetarDB + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: buildMetarDB.php,v 1.22 2005/11/08 17:37:38 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/tg/site.shtml + * @filesource + */ -/** -*/ require_once "DB.php"; -/** -* @ignore -*/ // {{{ constants // {{{ natural constants and measures define("SERVICES_WEATHER_RADIUS_EARTH", 6378.15); @@ -54,15 +67,15 @@ // {{{ Services_Weather_checkData() /** -* Services_Weather_checkData -* -* Checks the data for a certain string-length and if it either consists of -* a certain char-type or a string of "-" as replacement. -* -* @param array $data The data to be checked -* @param array $dataOrder Because the data is in different locations, we provide this -* @return bool -*/ + * Services_Weather_checkData + * + * Checks the data for a certain string-length and if it either consists of + * a certain char-type or a string of "-" as replacement. + * + * @param array $data The data to be checked + * @param array $dataOrder Because the data is in different locations, we provide this + * @return bool + */ function Services_Weather_checkData($data, $dataOrder) { $return = true; @@ -94,14 +107,14 @@ // {{{ Services_Weather_getNextArg() /** -* Services_Weather_getNextArg -* -* Checks, if the next argument is a parameter to a predecessing option. -* Returns either that parameter or false, if the next argument is an option -* -* @param int $c Internal argument counter -* @return string|bool -*/ + * Services_Weather_getNextArg + * + * Checks, if the next argument is a parameter to a predecessing option. + * Returns either that parameter or false, if the next argument is an option + * + * @param int $c Internal argument counter + * @return string|bool + */ function Services_Weather_getNextArg(&$c) { if ((($c + 1) < $_SERVER["argc"]) && ($_SERVER["argv"][$c + 1]{0} != "-")) { http://cvs.php.net/diff.php/pear/Services_Weather/Weather.php?r1=1.35&r2=1.36&ty=u Index: pear/Services_Weather/Weather.php diff -u pear/Services_Weather/Weather.php:1.35 pear/Services_Weather/Weather.php:1.36 --- pear/Services_Weather/Weather.php:1.35 Thu Oct 13 06:09:47 2005 +++ pear/Services_Weather/Weather.php Tue Nov 8 12:37:38 2005 @@ -12,19 +12,42 @@ * * PHP versions 4 and 5 * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category Web Services - * @package Services_Weather - * @author Alexander Wirtz <alex@pc4p.net> - * @copyright 1997-2005 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Weather.php,v 1.35 2005/10/13 10:09:47 eru Exp $ - * @link http://pear.php.net/package/Services_Weather + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Weather.php,v 1.36 2005/11/08 17:37:38 eru Exp $ + * @link http://pear.php.net/package/Services_Weather * @filesource */ @@ -59,13 +82,13 @@ /** * This class acts as an interface to various online weather-services. * - * @category Web Services - * @package Services_Weather - * @author Alexander Wirtz <alex@pc4p.net> - * @copyright 1997-2005 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: @package_version@ - * @link http://pear.php.net/package/Services_Weather + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather */ class Services_Weather { @@ -74,34 +97,34 @@ * Factory for creating the services-objects * * Usable keys for the options array are: - * o debug enables debugging output + * o debug enables debugging output * --- Common Options - * o cacheType defines what type of cache to use - * o cacheOptions passes cache options - * o unitsFormat use (US)-standard, metric or custom units - * o customUnitsFormat defines the customized units format - * o httpTimeout sets timeout for HTTP requests - * o dateFormat string to use for date output - * o timeFormat string to use for time output + * o cacheType defines what type of cache to use + * o cacheOptions passes cache options + * o unitsFormat use (US)-standard, metric or custom units + * o customUnitsFormat defines the customized units format + * o httpTimeout sets timeout for HTTP requests + * o dateFormat string to use for date output + * o timeFormat string to use for time output * --- EJSE Options * o none * --- GlobalWeather Options * o none * --- METAR/TAF Options - * o dsn String for defining the DB connection - * o dbOptions passes DB options - * o sourceMetar http, ftp or file - type of data-source for METAR - * o sourcePathMetar where to look for the source, URI or filepath, - * of METAR information - * o sourceTaf http, ftp or file - type of data-source for TAF - * o sourcePathTaf where to look for the source, URI or filepath, - * of TAF information + * o dsn String for defining the DB connection + * o dbOptions passes DB options + * o sourceMetar http, ftp or file - type of data-source for METAR + * o sourcePathMetar where to look for the source, URI or filepath, + * of METAR information + * o sourceTaf http, ftp or file - type of data-source for TAF + * o sourcePathTaf where to look for the source, URI or filepath, + * of TAF information * --- weather.com Options - * o partnerID You'll receive these keys after registering - * o licenseKey with the weather.com XML-service + * o partnerID You'll receive these keys after registering + * o licenseKey with the weather.com XML-service * - * @param string $service - * @param array $options + * @param string $service + * @param array $options * @return PEAR_Error|object * @throws PEAR_Error * @throws PEAR_Error::SERVICES_WEATHER_ERROR_SERVICE_NOT_FOUND @@ -146,8 +169,8 @@ /** * For your convenience, when I come up with changes in the API... * - * @return string - * @access public + * @return string + * @access public */ function apiVersion() { @@ -159,9 +182,9 @@ /** * Returns the message for a certain error code * - * @param PEAR_Error|int $value - * @return string - * @access private + * @param PEAR_Error|int $value + * @return string + * @access private */ function _errorMessage($value) { @@ -194,9 +217,9 @@ /** * Checks for an error object, same as in PEAR * - * @param PEAR_Error|mixed $value - * @return bool - * @access public + * @param PEAR_Error|mixed $value + * @return bool + * @access public */ function isError($value) { @@ -208,11 +231,11 @@ /** * Creates error, same as in PEAR with a customized flavor * - * @param int $code - * @param string $file - * @param int $line - * @return PEAR_Error - * @access private + * @param int $code + * @param string $file + * @param int $line + * @return PEAR_Error + * @access private */ function &raiseError($code = SERVICES_WEATHER_ERROR_UNKNOWN_ERROR, $file = "", $line = 0) {
http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Metar.php?r1=1.74&r2=1.75&ty=u Index: pear/Services_Weather/Weather/Metar.php diff -u pear/Services_Weather/Weather/Metar.php:1.74 pear/Services_Weather/Weather/Metar.php:1.75 --- pear/Services_Weather/Weather/Metar.php:1.74 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Metar.php Tue Nov 8 12:37:34 2005 @@ -1,123 +1,149 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Metar.php,v 1.74 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Metar + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Metar.php,v 1.75 2005/11/08 17:37:34 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/weather/metar.shtml + * @link http://weather.noaa.gov/weather/taf.shtml + * @example examples/metar-basic.php metar-basic.php + * @example examples/metar-extensive.php metar-extensive.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; require_once "DB.php"; // {{{ class Services_Weather_Metar /** -* PEAR::Services_Weather_Metar -* -* This class acts as an interface to the METAR/TAF service of -* weather.noaa.gov. It searches for locations given in ICAO notation and -* retrieves the current weather data. -* -* Of course the parsing of the METAR-data has its limitations, as it -* follows the Federal Meteorological Handbook No.1 with modifications to -* accomodate for non-US reports, so if the report deviates from these -* standards, you won't get it parsed correctly. -* Anything that is not parsed, is saved in the "noparse" array-entry, -* returned by getWeather(), so you can do your own parsing afterwards. This -* limitation is specifically given for remarks, as the class is not -* processing everything mentioned there, but you will get the most common -* fields like precipitation and temperature-changes. Again, everything not -* parsed, goes into "noparse". -* -* If you think, some important field is missing or not correctly parsed, -* please file a feature-request/bugreport at http://pear.php.net/ and be -* sure to provide the METAR (or TAF) report with a _detailed_ explanation! -* -* For working examples, please take a look at -* docs/Services_Weather/examples/metar-basic.php -* docs/Services_Weather/examples/metar-extensive.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://weather.noaa.gov/weather/metar.shtml -* @link http://weather.noaa.gov/weather/taf.shtml -* @example examples/metar-basic.php metar-basic.php -* @example examples/metar-extensive.php metar-extensive.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the METAR/TAF service of + * weather.noaa.gov. It searches for locations given in ICAO notation and + * retrieves the current weather data. + * + * Of course the parsing of the METAR-data has its limitations, as it + * follows the Federal Meteorological Handbook No.1 with modifications to + * accomodate for non-US reports, so if the report deviates from these + * standards, you won't get it parsed correctly. + * Anything that is not parsed, is saved in the "noparse" array-entry, + * returned by getWeather(), so you can do your own parsing afterwards. This + * limitation is specifically given for remarks, as the class is not + * processing everything mentioned there, but you will get the most common + * fields like precipitation and temperature-changes. Again, everything not + * parsed, goes into "noparse". + * + * If you think, some important field is missing or not correctly parsed, + * please file a feature-request/bugreport at http://pear.php.net/ and be + * sure to provide the METAR (or TAF) report with a _detailed_ explanation! + * + * For working examples, please take a look at + * docs/Services_Weather/examples/metar-basic.php + * docs/Services_Weather/examples/metar-extensive.php + * + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/weather/metar.shtml + * @link http://weather.noaa.gov/weather/taf.shtml + * @example examples/metar-basic.php metar-basic.php + * @example examples/metar-extensive.php metar-extensive.php + */ class Services_Weather_Metar extends Services_Weather_Common { // {{{ properties /** - * Information to access the location DB - * - * @var object DB $_db - * @access private - */ + * Information to access the location DB + * + * @var object DB $_db + * @access private + */ var $_db; /** - * The source METAR uses - * - * @var string $_sourceMetar - * @access private - */ + * The source METAR uses + * + * @var string $_sourceMetar + * @access private + */ var $_sourceMetar; /** - * The source TAF uses - * - * @var string $_sourceTaf - * @access private - */ + * The source TAF uses + * + * @var string $_sourceTaf + * @access private + */ var $_sourceTaf; /** - * This path is used to find the METAR data - * - * @var string $_sourcePathMetar - * @access private - */ + * This path is used to find the METAR data + * + * @var string $_sourcePathMetar + * @access private + */ var $_sourcePathMetar; /** - * This path is used to find the TAF data - * - * @var string $_sourcePathTaf - * @access private - */ + * This path is used to find the TAF data + * + * @var string $_sourcePathTaf + * @access private + */ var $_sourcePathTaf; // }}} // {{{ constructor /** - * Constructor - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Metar($options, &$error) { $perror = null; @@ -169,18 +195,18 @@ // {{{ setMetarDB() /** - * Sets the parameters needed for connecting to the DB, where the - * location-search is fetching its data from. You need to build a DB - * with the external tool buildMetarDB first, it fetches the locations - * and airports from a NOAA-website. - * - * @param string $dsn - * @param array $dbOptions - * @return DB_Error|bool - * @throws DB_Error - * @see DB::parseDSN - * @access public - */ + * Sets the parameters needed for connecting to the DB, where the + * location-search is fetching its data from. You need to build a DB + * with the external tool buildMetarDB first, it fetches the locations + * and airports from a NOAA-website. + * + * @param string $dsn + * @param array $dbOptions + * @return DB_Error|bool + * @throws DB_Error + * @see DB::parseDSN + * @access public + */ function setMetarDB($dsn, $dbOptions = array()) { $dsninfo = DB::parseDSN($dsn); @@ -201,17 +227,17 @@ // {{{ setMetarSource() /** - * Sets the source, where the class tries to locate the METAR/TAF data - * - * Source can be http, ftp or file. - * Alternate sourcepaths can be provided. - * - * @param string $sourceMetar - * @param string $sourcePathMetar - * @param string $sourceTaf - * @param string $sourcePathTaf - * @access public - */ + * Sets the source, where the class tries to locate the METAR/TAF data + * + * Source can be http, ftp or file. + * Alternate sourcepaths can be provided. + * + * @param string $sourceMetar + * @param string $sourcePathMetar + * @param string $sourceTaf + * @param string $sourcePathTaf + * @access public + */ function setMetarSource($sourceMetar, $sourcePathMetar = "", $sourceTaf = "", $sourcePathTaf = "") { if (in_array($sourceMetar, array("http", "ftp", "file"))) { @@ -255,15 +281,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * METAR server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * METAR server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -278,17 +304,17 @@ // {{{ _parseWeatherData() /** - * Parses the data returned by the provided source and caches it - * - * METAR KPIT 091955Z COR 22015G25KT 3/4SM R28L/2600FT TSRA OVC010CB - * 18/16 A2992 RMK SLP045 T01820159 - * - * @param string $source - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access private - */ + * Parses the data returned by the provided source and caches it + * + * METAR KPIT 091955Z COR 22015G25KT 3/4SM R28L/2600FT TSRA OVC010CB + * 18/16 A2992 RMK SLP045 T01820159 + * + * @param string $source + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access private + */ function _parseWeatherData($source) { static $compass; @@ -775,21 +801,21 @@ // {{{ _parseForecastData() /** - * Parses the data returned by the provided source and caches it - * - * TAF KLGA 271734Z 271818 11007KT P6SM -RA SCT020 BKN200 - * FM2300 14007KT P6SM SCT030 BKN150 - * FM0400 VRB03KT P6SM SCT035 OVC080 PROB30 0509 P6SM -RA BKN035 - * FM0900 VRB03KT 6SM -RA BR SCT015 OVC035 - * TEMPO 1215 5SM -RA BR SCT009 BKN015 - * BECMG 1517 16007KT P6SM NSW SCT015 BKN070 - * - * @param string $source - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access private - */ + * Parses the data returned by the provided source and caches it + * + * TAF KLGA 271734Z 271818 11007KT P6SM -RA SCT020 BKN200 + * FM2300 14007KT P6SM SCT030 BKN150 + * FM0400 VRB03KT P6SM SCT035 OVC080 PROB30 0509 P6SM -RA BKN035 + * FM0900 VRB03KT 6SM -RA BR SCT015 OVC035 + * TEMPO 1215 5SM -RA BR SCT009 BKN015 + * BECMG 1517 16007KT P6SM NSW SCT015 BKN070 + * + * @param string $source + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access private + */ function _parseForecastData($source) { static $compass; @@ -1177,14 +1203,14 @@ // {{{ _convertReturn() /** - * Converts the data in the return array to the desired units and/or - * output format. - * - * @param array $target - * @param string $units - * @param string $location - * @access private - */ + * Converts the data in the return array to the desired units and/or + * output format. + * + * @param array $target + * @param string $units + * @param string $location + * @access private + */ function _convertReturn(&$target, $units, $location) { if (is_array($target)) { @@ -1256,17 +1282,17 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string|array $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string|array $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1343,16 +1369,16 @@ // {{{ searchLocationByCountry() /** - * Returns IDs with location-name for a given country or all available - * countries, if no value was given - * - * @param string $country - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access public - */ + * Returns IDs with location-name for a given country or all available + * countries, if no value was given + * + * @param string $country + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access public + */ function searchLocationByCountry($country = "") { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1405,18 +1431,18 @@ // {{{ searchAirport() /** - * Searches the nearest airport(s) for given coordinates, returns array - * of IDs or single ID - * - * @param float $latitude - * @param float $longitude - * @param int $numResults - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access public - */ + * Searches the nearest airport(s) for given coordinates, returns array + * of IDs or single ID + * + * @param float $latitude + * @param float $longitude + * @param int $numResults + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access public + */ function searchAirport($latitude, $longitude, $numResults = 1) { if (!isset($this->_db) || !DB::isConnection($this->_db)) { @@ -1485,13 +1511,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -1556,14 +1582,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PHP_Error|array - * @throws PHP_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PHP_Error|array + * @throws PHP_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $id = strtoupper($id); @@ -1617,16 +1643,16 @@ // {{{ getForecast() /** - * METAR provides no forecast per se, we use the TAF reports to generate - * a forecast for the announced timeperiod - * - * @param string $id - * @param int $days Ignored, not applicable - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * METAR provides no forecast per se, we use the TAF reports to generate + * a forecast for the announced timeperiod + * + * @param string $id + * @param int $days Ignored, not applicable + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = null, $unitsFormat = "") { $id = strtoupper($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Common.php?r1=1.41&r2=1.42&ty=u Index: pear/Services_Weather/Weather/Common.php diff -u pear/Services_Weather/Weather/Common.php:1.41 pear/Services_Weather/Weather/Common.php:1.42 --- pear/Services_Weather/Weather/Common.php:1.41 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Common.php Tue Nov 8 12:37:35 2005 @@ -1,30 +1,50 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Common.php,v 1.41 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Common + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Common.php,v 1.42 2005/11/08 17:37:35 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @filesource + */ -/** -*/ require_once "Services/Weather.php"; // {{{ constants @@ -35,34 +55,35 @@ // {{{ class Services_Weather_Common /** -* PEAR::Services_Weather_Common -* -* Parent class for weather-services. Defines common functions for unit -* conversions, checks for cache enabling and does other miscellaneous -* things. -* -* @author Alexander Wirtz <alex@pc4p.net> -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * Parent class for weather-services. Defines common functions for unit + * conversions, checks for cache enabling and does other miscellaneous + * things. + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + */ class Services_Weather_Common { // {{{ properties /** - * Format of the units provided (standard/metric/custom) - * - * @var string $_unitsFormat - * @access private - */ + * Format of the units provided (standard/metric/custom) + * + * @var string $_unitsFormat + * @access private + */ var $_unitsFormat = "s"; /** - * Custom format of the units - * - * @var array $_customUnitsFormat - * @access private - */ + * Custom format of the units + * + * @var array $_customUnitsFormat + * @access private + */ var $_customUnitsFormat = array( "temp" => "f", "vis" => "sm", @@ -73,79 +94,79 @@ ); /** - * Timeout for HTTP requests - * - * @var int $_httpTimeout - * @access private - */ + * Timeout for HTTP requests + * + * @var int $_httpTimeout + * @access private + */ var $_httpTimeout = 60; /** - * Format of the used dates - * - * @var string $_dateFormat - * @access private - */ + * Format of the used dates + * + * @var string $_dateFormat + * @access private + */ var $_dateFormat = "m/d/y"; /** - * Format of the used times - * - * @var string $_timeFormat - * @access private - */ + * Format of the used times + * + * @var string $_timeFormat + * @access private + */ var $_timeFormat = "G:i A"; /** - * Object containing the location-data - * - * @var object stdClass $_location - * @access private - */ + * Object containing the location-data + * + * @var object stdClass $_location + * @access private + */ var $_location; /** - * Object containing the weather-data - * - * @var object stdClass $_weather - * @access private - */ + * Object containing the weather-data + * + * @var object stdClass $_weather + * @access private + */ var $_weather; /** - * Object containing the forecast-data - * - * @var object stdClass $_forecast - * @access private - */ + * Object containing the forecast-data + * + * @var object stdClass $_forecast + * @access private + */ var $_forecast; /** - * Cache, containing the data-objects - * - * @var object Cache $_cache - * @access private - */ + * Cache, containing the data-objects + * + * @var object Cache $_cache + * @access private + */ var $_cache; /** - * Provides check for Cache - * - * @var bool $_cacheEnabled - * @access private - */ + * Provides check for Cache + * + * @var bool $_cacheEnabled + * @access private + */ var $_cacheEnabled = false; // }}} // {{{ constructor /** - * Constructor - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Common($options, &$error) { // Set options accordingly @@ -184,16 +205,16 @@ // {{{ setCache() /** - * Enables caching the data, usage strongly recommended - * - * Requires Cache to be installed - * - * @param string $cacheType - * @param array $cacheOptions - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED - * @access public - */ + * Enables caching the data, usage strongly recommended + * + * Requires Cache to be installed + * + * @param string $cacheType + * @param array $cacheOptions + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED + * @access public + */ function setCache($cacheType = "file", $cacheOptions = array()) { // The error handling in Cache is a bit crummy (read: not existent) @@ -215,12 +236,12 @@ // {{{ setUnitsFormat() /** - * Changes the representation of the units (standard/metric) - * - * @param string $unitsFormat - * @param array $customUnitsFormat - * @access public - */ + * Changes the representation of the units (standard/metric) + * + * @param string $unitsFormat + * @param array $customUnitsFormat + * @access public + */ function setUnitsFormat($unitsFormat, $customUnitsFormat = array()) { static $acceptedFormats; @@ -252,11 +273,11 @@ // {{{ setHttpTimeout() /** - * Sets the timeout in seconds for HTTP requests - * - * @param int $httpTimeout - * @access public - */ + * Sets the timeout in seconds for HTTP requests + * + * @param int $httpTimeout + * @access public + */ function setHttpTimeout($httpTimeout) { if (is_int($httpTimeout)) { @@ -267,12 +288,12 @@ // {{{ getUnitsFormat() /** - * Returns the selected units format - * - * @param string $unitsFormat - * @return array - * @access public - */ + * Returns the selected units format + * + * @param string $unitsFormat + * @return array + * @access public + */ function getUnitsFormat($unitsFormat = "") { // This is cheap'o stuff @@ -306,12 +327,12 @@ // {{{ setDateTimeFormat() /** - * Changes the representation of time and dates (see http://www.php.net/date) - * - * @param string $dateFormat - * @param string $timeFormat - * @access public - */ + * Changes the representation of time and dates (see http://www.php.net/date) + * + * @param string $dateFormat + * @param string $timeFormat + * @access public + */ function setDateTimeFormat($dateFormat = "", $timeFormat = "") { if (strlen($dateFormat)) { @@ -325,14 +346,14 @@ // {{{ convertTemperature() /** - * Convert temperature between f and c - * - * @param float $temperature - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert temperature between f and c + * + * @param float $temperature + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertTemperature($temperature, $from, $to) { $from = strtolower($from{0}); @@ -353,18 +374,18 @@ // {{{ convertSpeed() /** - * Convert speed between mph, kmh, kt, mps, fps and bft - * - * Function will return "false" when trying to convert from - * Beaufort, as it is a scale and not a true measurement - * - * @param float $speed - * @param string $from - * @param string $to - * @return float|int|bool - * @access public - * @link http://www.spc.noaa.gov/faq/tornado/beaufort.html - */ + * Convert speed between mph, kmh, kt, mps, fps and bft + * + * Function will return "false" when trying to convert from + * Beaufort, as it is a scale and not a true measurement + * + * @param float $speed + * @param string $from + * @param string $to + * @return float|int|bool + * @access public + * @link http://www.spc.noaa.gov/faq/tornado/beaufort.html + */ function convertSpeed($speed, $from, $to) { $from = strtolower($from); @@ -417,14 +438,14 @@ // {{{ convertPressure() /** - * Convert pressure between in, hpa, mb, mm and atm - * - * @param float $pressure - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert pressure between in, hpa, mb, mm and atm + * + * @param float $pressure + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertPressure($pressure, $from, $to) { $from = strtolower($from); @@ -457,14 +478,14 @@ // {{{ convertDistance() /** - * Convert distance between km, ft and sm - * - * @param float $distance - * @param string $from - * @param string $to - * @return float - * @access public - */ + * Convert distance between km, ft and sm + * + * @param float $distance + * @param string $from + * @param string $to + * @return float + * @access public + */ function convertDistance($distance, $from, $to) { $to = strtolower($to); @@ -494,16 +515,16 @@ // {{{ calculateWindChill() /** - * Calculate windchill from temperature and windspeed (enhanced formula) - * - * Temperature has to be entered in deg F, speed in mph! - * - * @param float $temperature - * @param float $speed - * @return float - * @access public - * @link http://www.nws.noaa.gov/om/windchill/ - */ + * Calculate windchill from temperature and windspeed (enhanced formula) + * + * Temperature has to be entered in deg F, speed in mph! + * + * @param float $temperature + * @param float $speed + * @return float + * @access public + * @link http://www.nws.noaa.gov/om/windchill/ + */ function calculateWindChill($temperature, $speed) { return round(35.74 + 0.6215 * $temperature - 35.75 * pow($speed, 0.16) + 0.4275 * $temperature * pow($speed, 0.16)); @@ -512,18 +533,18 @@ // {{{ calculateHumidity() /** - * Calculate humidity from temperature and dewpoint - * This is only an approximation, there is no exact formula, this - * one here is called Magnus-Formula - * - * Temperature and dewpoint have to be entered in deg C! - * - * @param float $temperature - * @param float $dewPoint - * @return float - * @access public - * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ - */ + * Calculate humidity from temperature and dewpoint + * This is only an approximation, there is no exact formula, this + * one here is called Magnus-Formula + * + * Temperature and dewpoint have to be entered in deg C! + * + * @param float $temperature + * @param float $dewPoint + * @return float + * @access public + * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ + */ function calculateHumidity($temperature, $dewPoint) { // First calculate saturation steam pressure for both temperatures @@ -551,18 +572,18 @@ // {{{ calculateDewPoint() /** - * Calculate dewpoint from temperature and humidity - * This is only an approximation, there is no exact formula, this - * one here is called Magnus-Formula - * - * Temperature has to be entered in deg C! - * - * @param float $temperature - * @param float $humidity - * @return float - * @access public - * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ - */ + * Calculate dewpoint from temperature and humidity + * This is only an approximation, there is no exact formula, this + * one here is called Magnus-Formula + * + * Temperature has to be entered in deg C! + * + * @param float $temperature + * @param float $humidity + * @return float + * @access public + * @link http://www.faqs.org/faqs/meteorology/temp-dewpoint/ + */ function calculateDewPoint($temperature, $humidity) { if ($temperature >= 0) { @@ -587,13 +608,13 @@ // {{{ polar2cartesian() /** - * Convert polar coordinates to cartesian coordinates - * - * @param float $latitude - * @param float $longitude - * @return array - * @access public - */ + * Convert polar coordinates to cartesian coordinates + * + * @param float $latitude + * @param float $longitude + * @return array + * @access public + */ function polar2cartesian($latitude, $longitude) { $theta = deg2rad($latitude); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Weatherdotcom.php?r1=1.47&r2=1.48&ty=u Index: pear/Services_Weather/Weather/Weatherdotcom.php diff -u pear/Services_Weather/Weather/Weatherdotcom.php:1.47 pear/Services_Weather/Weather/Weatherdotcom.php:1.48 --- pear/Services_Weather/Weather/Weatherdotcom.php:1.47 Tue Nov 8 07:21:33 2005 +++ pear/Services_Weather/Weather/Weatherdotcom.php Tue Nov 8 12:37:35 2005 @@ -1,109 +1,133 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Weatherdotcom.php,v 1.47 2005/11/08 12:21:33 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Weatherdotcom + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Weatherdotcom.php,v 1.48 2005/11/08 17:37:35 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.weather.com/services/xmloap.html + * @example examples/weather.com-basic.php weather.com-basic.php + * @example examples/weather.com-extensive.php weather.com-extensive.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Weatherdotcom /** -* PEAR::Services_Weather_Weatherdotcom -* -* This class acts as an interface to the xml service of weather.com. It -* searches for given locations and retrieves current weather data as well -* as forecast for up to 10 days. -* -* For using the weather.com xml-service please visit -* http://www.weather.com/services/xmloap.html -* and follow the link to sign up, it's free! You will receive an email -* where to download the SDK with the needed images and guidelines how to -* publish live data from weather.com. Unfortunately the guidelines are a -* bit harsh, that's why there's no actual data-representation in this -* class, just the raw data. Also weather.com demands active caching, so I'd -* strongly recommend enabling the caching implemented in this class. It -* obeys to the times as written down in the guidelines. -* -* For working examples, please take a look at -* docs/Services_Weather/examples/weather.com-basic.php -* docs/Services_Weather/examples/weather.com-extensive.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.weather.com/services/xmloap.html -* @example examples/weather.com-basic.php weather.com-basic.php -* @example examples/weather.com-extensive.php weather.com-extensive.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the xml service of weather.com. It + * searches for given locations and retrieves current weather data as well + * as forecast for up to 10 days. + * + * For using the weather.com xml-service please visit + * http://www.weather.com/services/xmloap.html + * and follow the link to sign up, it's free! You will receive an email + * where to download the SDK with the needed images and guidelines how to + * publish live data from weather.com. Unfortunately the guidelines are a + * bit harsh, that's why there's no actual data-representation in this + * class, just the raw data. Also weather.com demands active caching, so I'd + * strongly recommend enabling the caching implemented in this class. It + * obeys to the times as written down in the guidelines. + * + * For working examples, please take a look at + * docs/Services_Weather/examples/weather.com-basic.php + * docs/Services_Weather/examples/weather.com-extensive.php + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.weather.com/services/xmloap.html + * @example examples/weather.com-basic.php weather.com-basic.php + * @example examples/weather.com-extensive.php weather.com-extensive.php + */ class Services_Weather_Weatherdotcom extends Services_Weather_Common { // {{{ properties /** - * Partner-ID at weather.com - * - * @var string $_partnerID - * @access private - */ + * Partner-ID at weather.com + * + * @var string $_partnerID + * @access private + */ var $_partnerID = ""; /** - * License key at weather.com - * - * @var string $_licenseKey - * @access private - */ + * License key at weather.com + * + * @var string $_licenseKey + * @access private + */ var $_licenseKey = ""; /** - * Object containing the promotional links-data - * - * @var object stdClass $_links - * @access private - */ + * Object containing the promotional links-data + * + * @var object stdClass $_links + * @access private + */ var $_links; /** - * XML_Unserializer, used for processing the xml - * - * @var object XML_Unserializer $_unserializer - * @access private - */ + * XML_Unserializer, used for processing the xml + * + * @var object XML_Unserializer $_unserializer + * @access private + */ var $_unserializer; // }}} // {{{ constructor /** - * Constructor - * - * Requires XML_Serializer to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * Requires XML_Serializer to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Weatherdotcom($options, &$error) { $perror = null; @@ -137,13 +161,13 @@ // {{{ setAccountData() /** - * Sets the neccessary account-information for weather.com, you'll - * receive them after registering for the XML-stream - * - * @param string $partnerID - * @param string $licenseKey - * @access public - */ + * Sets the neccessary account-information for weather.com, you'll + * receive them after registering for the XML-stream + * + * @param string $partnerID + * @param string $licenseKey + * @access public + */ function setAccountData($partnerID, $licenseKey) { if (strlen($partnerID) && ctype_digit($partnerID)) { @@ -157,15 +181,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * weather.com server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * weather.com server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -180,15 +204,15 @@ // {{{ _parseWeatherData() /** - * Parses the data returned by the provided URL and caches it - * - * @param string $id - * @param string $url - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error - * @access private - */ + * Parses the data returned by the provided URL and caches it + * + * @param string $id + * @param string $url + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error + * @access private + */ function _parseWeatherData($id, $url) { // Get data from URL... @@ -252,16 +276,16 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { // Get search data from server and unserialize @@ -299,14 +323,14 @@ // {{{ searchLocationByCountry() /** - * Returns only false, as weather.com offers no country listing via - * its XML services - * - * @param string $country - * @return bool - * @access public - * @deprecated - */ + * Returns only false, as weather.com offers no country listing via + * its XML services + * + * @param string $country + * @return bool + * @access public + * @deprecated + */ function searchLocationByCountry($country = "") { return false; @@ -315,13 +339,13 @@ // {{{ getLinks() /** - * Returns the data for the promotional links belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the promotional links belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLinks($id = "") { $status = $this->_checkLocationID($id); @@ -362,13 +386,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -408,14 +432,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $status = $this->_checkLocationID($id); @@ -482,15 +506,15 @@ // {{{ getForecast() /** - * Get the forecast for the next days - * - * @param string $id - * @param int $days Values between 1 and 10 - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Get the forecast for the next days + * + * @param string $id + * @param int $days Values between 1 and 10 + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = 2, $unitsFormat = "") { $status = $this->_checkLocationID($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Ejse.php?r1=1.19&r2=1.20&ty=u Index: pear/Services_Weather/Weather/Ejse.php diff -u pear/Services_Weather/Weather/Ejse.php:1.19 pear/Services_Weather/Weather/Ejse.php:1.20 --- pear/Services_Weather/Weather/Ejse.php:1.19 Tue Nov 8 07:21:34 2005 +++ pear/Services_Weather/Weather/Ejse.php Tue Nov 8 12:37:36 2005 @@ -1,82 +1,105 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Ejse.php,v 1.19 2005/11/08 12:21:34 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Ejse + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Ejse.php,v 1.20 2005/11/08 17:37:36 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.ejse.com/services/weather_xml_web_services.htm + * @example examples/ejse-basic.php ejse-basic.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Ejse /** -* PEAR::Services_Weather_Ejse -* -* This class acts as an interface to the soap service of EJSE. It retrieves -* current weather data and forecasts based on postal codes (ZIP). -* -* Currently this service is only available for US territory. -* -* For a working example, please take a look at -* docs/Services_Weather/examples/ejse-basic.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.ejse.com/services/weather_xml_web_services.htm -* @example examples/ejse-basic.php ejse-basic.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the soap service of EJSE. It retrieves + * current weather data and forecasts based on postal codes (ZIP). + * + * Currently this service is only available for US territory. + * + * For a working example, please take a look at + * docs/Services_Weather/examples/ejse-basic.php + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.ejse.com/services/weather_xml_web_services.htm + * @example examples/ejse-basic.php ejse-basic.php + */ class Services_Weather_Ejse extends Services_Weather_Common { // {{{ properties /** - * WSDL object, provided by EJSE - * - * @var object $_wsdl - * @access private - */ + * WSDL object, provided by EJSE + * + * @var object $_wsdl + * @access private + */ var $_wsdl; /** - * SOAP object to access weather data, provided by EJSE - * - * @var object $_weaterSoap - * @access private - */ + * SOAP object to access weather data, provided by EJSE + * + * @var object $_weaterSoap + * @access private + */ var $_weatherSoap; // }}} // {{{ constructor /** - * Constructor - * - * Requires SOAP to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @access private - */ + * Constructor + * + * Requires SOAP to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @access private + */ function Services_Weather_Ejse($options, &$error) { $perror = null; @@ -89,12 +112,12 @@ // {{{ _connectServer() /** - * Connects to the SOAP server and retrieves the WSDL data - * - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function _connectServer() { include_once "SOAP/Client.php"; @@ -115,14 +138,14 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to EJSE server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to EJSE server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -137,15 +160,15 @@ // {{{ searchLocation() /** - * EJSE offers no search function to date, so this function is disabled. - * Maybe this is the place to interface to some online postcode service... - * - * @param string $location - * @param bool $useFirst - * @return bool - * @access public - * @deprecated - */ + * EJSE offers no search function to date, so this function is disabled. + * Maybe this is the place to interface to some online postcode service... + * + * @param string $location + * @param bool $useFirst + * @return bool + * @access public + * @deprecated + */ function searchLocation($location = null, $useFirst = null) { return false; @@ -154,14 +177,14 @@ // {{{ searchLocationByCountry() /** - * EJSE offers no search function to date, so this function is disabled. - * Maybe this is the place to interface to some online postcode service... - * - * @param string $country - * @return bool - * @access public - * @deprecated - */ + * EJSE offers no search function to date, so this function is disabled. + * Maybe this is the place to interface to some online postcode service... + * + * @param string $country + * @return bool + * @access public + * @deprecated + */ function searchLocationByCountry($country = null) { return false; @@ -170,13 +193,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -223,14 +246,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { $status = $this->_checkLocationID($id); @@ -348,15 +371,15 @@ // {{{ getForecast() /** - * Get the forecast for the next days - * - * @param string $int - * @param int $days Values between 1 and 9 - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Get the forecast for the next days + * + * @param string $int + * @param int $days Values between 1 and 9 + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getForecast($id = "", $days = 2, $unitsFormat = "") { $status = $this->_checkLocationID($id); http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Globalweather.php?r1=1.30&r2=1.31&ty=u Index: pear/Services_Weather/Weather/Globalweather.php diff -u pear/Services_Weather/Weather/Globalweather.php:1.30 pear/Services_Weather/Weather/Globalweather.php:1.31 --- pear/Services_Weather/Weather/Globalweather.php:1.30 Tue Nov 8 07:21:34 2005 +++ pear/Services_Weather/Weather/Globalweather.php Tue Nov 8 12:37:36 2005 @@ -1,96 +1,120 @@ <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: Globalweather.php,v 1.30 2005/11/08 12:21:34 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* @package Services_Weather -* @filesource -*/ + * PEAR::Services_Weather_Globalweather + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Globalweather.php,v 1.31 2005/11/08 17:37:36 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.capescience.com/webservices/globalweather/index.shtml + * @example examples/globalweather-basic.php globalweather-basic.php + * @filesource + */ -/** -*/ require_once "Services/Weather/Common.php"; // {{{ class Services_Weather_Globalweather /** -* PEAR::Services_Weather_Globalweather -* -* This class acts as an interface to the soap service of capescience.com. -* It searches for given locations and retrieves current weather data. -* -* GlobalWeather is a SOAP frontend for METAR data, provided by CapeScience. -* If you want to use METAR, you should try this class first, as it is much -* more comfortable (and also a bit faster) than the native METAR-class -* provided by this package. On the other hand, this service won't supply -* TAFs, the forecast system accompanying METAR, so you have to make -* the call here... -* -* For a working example, please take a look at -* docs/Services_Weather/examples/globalweather-basic.php -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://www.capescience.com/webservices/globalweather/index.shtml -* @example examples/globalweather-basic.php globalweather-basic.php -* @package Services_Weather -* @license http://www.php.net/license/2_02.txt -* @version 1.3 -*/ + * This class acts as an interface to the soap service of capescience.com. + * It searches for given locations and retrieves current weather data. + * + * GlobalWeather is a SOAP frontend for METAR data, provided by CapeScience. + * If you want to use METAR, you should try this class first, as it is much + * more comfortable (and also a bit faster) than the native METAR-class + * provided by this package. On the other hand, this service won't supply + * TAFs, the forecast system accompanying METAR, so you have to make + * the call here... + * + * For a working example, please take a look at + * docs/Services_Weather/examples/globalweather-basic.php + * + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather + * @link http://www.capescience.com/webservices/globalweather/index.shtml + * @example examples/globalweather-basic.php globalweather-basic.php + */ class Services_Weather_Globalweather extends Services_Weather_Common { // {{{ properties /** - * WSDL object, provided by CapeScience - * - * @var object $_wsdl - * @access private - */ + * WSDL object, provided by CapeScience + * + * @var object $_wsdl + * @access private + */ var $_wsdl; /** - * SOAP object to access station data, provided by CapeScience - * - * @var object $_stationSoap - * @access private - */ + * SOAP object to access station data, provided by CapeScience + * + * @var object $_stationSoap + * @access private + */ var $_stationSoap; /** - * SOAP object to access weather data, provided by CapeScience - * - * @var object $_weatherSoap - * @access private - */ + * SOAP object to access weather data, provided by CapeScience + * + * @var object $_weatherSoap + * @access private + */ var $_weatherSoap; // }}} // {{{ constructor /** - * Constructor - * - * Requires SOAP to be installed - * - * @param array $options - * @param mixed $error - * @throws PEAR_Error - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Constructor + * + * Requires SOAP to be installed + * + * @param array $options + * @param mixed $error + * @throws PEAR_Error + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function Services_Weather_Globalweather($options, &$error) { $perror = null; @@ -103,12 +127,12 @@ // {{{ _connectServer() /** - * Connects to the SOAP server and retrieves the WSDL data - * - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @access private - */ + * Connects to the SOAP server and retrieves the WSDL data + * + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @access private + */ function _connectServer() { include_once "SOAP/Client.php"; @@ -133,15 +157,15 @@ // {{{ _checkLocationID() /** - * Checks the id for valid values and thus prevents silly requests to - * GlobalWeather server - * - * @param string $id - * @return PEAR_Error|bool - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION - * @access private - */ + * Checks the id for valid values and thus prevents silly requests to + * GlobalWeather server + * + * @param string $id + * @return PEAR_Error|bool + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_NO_LOCATION + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_INVALID_LOCATION + * @access private + */ function _checkLocationID($id) { if (is_array($id) || is_object($id) || !strlen($id)) { @@ -156,16 +180,16 @@ // {{{ searchLocation() /** - * Searches IDs for given location, returns array of possible locations - * or single ID - * - * @param string $location - * @param bool $useFirst If set, first ID of result-array is returned - * @return PEAR_Error|array|string - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Searches IDs for given location, returns array of possible locations + * or single ID + * + * @param string $location + * @param bool $useFirst If set, first ID of result-array is returned + * @return PEAR_Error|array|string + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocation($location, $useFirst = false) { // Check, if the stationSoap-Object is present. If not, connect to the Server and retrieve the WDSL data @@ -202,15 +226,15 @@ // {{{ searchLocationByCountry() /** - * Returns IDs with location-name for a given country or all available - * countries, if no value was given - * - * @param string $country - * @return PEAR_Error|array - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA - * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION - * @access public - */ + * Returns IDs with location-name for a given country or all available + * countries, if no value was given + * + * @param string $country + * @return PEAR_Error|array + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA + * @throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION + * @access public + */ function searchLocationByCountry($country = "") { // Return the available countries as no country was given @@ -252,13 +276,13 @@ // {{{ getLocation() /** - * Returns the data for the location belonging to the ID - * - * @param string $id - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the data for the location belonging to the ID + * + * @param string $id + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getLocation($id = "") { $status = $this->_checkLocationID($id); @@ -315,14 +339,14 @@ // {{{ getWeather() /** - * Returns the weather-data for the supplied location - * - * @param string $id - * @param string $unitsFormat - * @return PEAR_Error|array - * @throws PEAR_Error - * @access public - */ + * Returns the weather-data for the supplied location + * + * @param string $id + * @param string $unitsFormat + * @return PEAR_Error|array + * @throws PEAR_Error + * @access public + */ function getWeather($id = "", $unitsFormat = "") { static $clouds; @@ -440,16 +464,16 @@ // {{{ getForecast() /** - * GlobalWeather has no forecast per se, so this function is just for - * compatibility purposes. - * - * @param string $int - * @param int $days - * @param string $unitsFormat - * @return bool - * @access public - * @deprecated - */ + * GlobalWeather has no forecast per se, so this function is just for + * compatibility purposes. + * + * @param string $int + * @param int $days + * @param string $unitsFormat + * @return bool + * @access public + * @deprecated + */ function getForecast($id = null, $days = null, $unitsFormat = null) { return false; http://cvs.php.net/diff.php/pear/Services_Weather/buildMetarDB.php?r1=1.21&r2=1.22&ty=u Index: pear/Services_Weather/buildMetarDB.php diff -u pear/Services_Weather/buildMetarDB.php:1.21 pear/Services_Weather/buildMetarDB.php:1.22 --- pear/Services_Weather/buildMetarDB.php:1.21 Wed May 5 04:33:43 2004 +++ pear/Services_Weather/buildMetarDB.php Tue Nov 8 12:37:38 2005 @@ -1,51 +1,64 @@ #!/usr/local/bin/php <?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Alexander Wirtz <alex@pc4p.net> | -// +----------------------------------------------------------------------+ -// -// $Id: buildMetarDB.php,v 1.21 2004/05/05 08:33:43 eru Exp $ +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ /** -* This script downloads, saves and processes the textfiles needed for -* the building the databases to enable searching for METAR stations. -* -* You can download the locations, which is a database of about 12000 world- -* wide locations, which can be used to determine the coordinates of your -* city or you can download a file with 6500 airports providing the metar -* data. This database is used for the next-METAR-station search. Please see -* the apropriate documentation in the Services_Weather_Metar class. -* -* For usage of this script, invoke with '-h'. -* -* @author Alexander Wirtz <alex@pc4p.net> -* @link http://weather.noaa.gov/tg/site.shtml -* @package Services_Weather -* @subpackage buildMetarDB -* @filesource -* @version 1.3 -*/ + * This script downloads, saves and processes the textfiles needed for + * the building the databases to enable searching for METAR stations. + * + * You can download the locations, which is a database of about 12000 world- + * wide locations, which can be used to determine the coordinates of your + * city or you can download a file with 6500 airports providing the metar + * data. This database is used for the next-METAR-station search. Please see + * the apropriate documentation in the Services_Weather_Metar class. + * + * For usage of this script, invoke with '-h'. + * + * PHP versions 4 and 5 + * + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @subpackage buildMetarDB + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: buildMetarDB.php,v 1.22 2005/11/08 17:37:38 eru Exp $ + * @link http://pear.php.net/package/Services_Weather + * @link http://weather.noaa.gov/tg/site.shtml + * @filesource + */ -/** -*/ require_once "DB.php"; -/** -* @ignore -*/ // {{{ constants // {{{ natural constants and measures define("SERVICES_WEATHER_RADIUS_EARTH", 6378.15); @@ -54,15 +67,15 @@ // {{{ Services_Weather_checkData() /** -* Services_Weather_checkData -* -* Checks the data for a certain string-length and if it either consists of -* a certain char-type or a string of "-" as replacement. -* -* @param array $data The data to be checked -* @param array $dataOrder Because the data is in different locations, we provide this -* @return bool -*/ + * Services_Weather_checkData + * + * Checks the data for a certain string-length and if it either consists of + * a certain char-type or a string of "-" as replacement. + * + * @param array $data The data to be checked + * @param array $dataOrder Because the data is in different locations, we provide this + * @return bool + */ function Services_Weather_checkData($data, $dataOrder) { $return = true; @@ -94,14 +107,14 @@ // {{{ Services_Weather_getNextArg() /** -* Services_Weather_getNextArg -* -* Checks, if the next argument is a parameter to a predecessing option. -* Returns either that parameter or false, if the next argument is an option -* -* @param int $c Internal argument counter -* @return string|bool -*/ + * Services_Weather_getNextArg + * + * Checks, if the next argument is a parameter to a predecessing option. + * Returns either that parameter or false, if the next argument is an option + * + * @param int $c Internal argument counter + * @return string|bool + */ function Services_Weather_getNextArg(&$c) { if ((($c + 1) < $_SERVER["argc"]) && ($_SERVER["argv"][$c + 1]{0} != "-")) { http://cvs.php.net/diff.php/pear/Services_Weather/Weather.php?r1=1.35&r2=1.36&ty=u Index: pear/Services_Weather/Weather.php diff -u pear/Services_Weather/Weather.php:1.35 pear/Services_Weather/Weather.php:1.36 --- pear/Services_Weather/Weather.php:1.35 Thu Oct 13 06:09:47 2005 +++ pear/Services_Weather/Weather.php Tue Nov 8 12:37:38 2005 @@ -12,19 +12,42 @@ * * PHP versions 4 and 5 * - * LICENSE: This source file is subject to version 3.0 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_0.txt. If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category Web Services - * @package Services_Weather - * @author Alexander Wirtz <alex@pc4p.net> - * @copyright 1997-2005 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: Weather.php,v 1.35 2005/10/13 10:09:47 eru Exp $ - * @link http://pear.php.net/package/Services_Weather + * <LICENSE> + * Copyright (c) 2005, Alexander Wirtz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * o Neither the name of the software nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * </LICENSE> + * + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Weather.php,v 1.36 2005/11/08 17:37:38 eru Exp $ + * @link http://pear.php.net/package/Services_Weather * @filesource */ @@ -59,13 +82,13 @@ /** * This class acts as an interface to various online weather-services. * - * @category Web Services - * @package Services_Weather - * @author Alexander Wirtz <alex@pc4p.net> - * @copyright 1997-2005 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: @package_version@ - * @link http://pear.php.net/package/Services_Weather + * @category Web Services + * @package Services_Weather + * @author Alexander Wirtz <alex@pc4p.net> + * @copyright 2005 Alexander Wirtz + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Services_Weather */ class Services_Weather { @@ -74,34 +97,34 @@ * Factory for creating the services-objects * * Usable keys for the options array are: - * o debug enables debugging output + * o debug enables debugging output * --- Common Options - * o cacheType defines what type of cache to use - * o cacheOptions passes cache options - * o unitsFormat use (US)-standard, metric or custom units - * o customUnitsFormat defines the customized units format - * o httpTimeout sets timeout for HTTP requests - * o dateFormat string to use for date output - * o timeFormat string to use for time output + * o cacheType defines what type of cache to use + * o cacheOptions passes cache options + * o unitsFormat use (US)-standard, metric or custom units + * o customUnitsFormat defines the customized units format + * o httpTimeout sets timeout for HTTP requests + * o dateFormat string to use for date output + * o timeFormat string to use for time output * --- EJSE Options * o none * --- GlobalWeather Options * o none * --- METAR/TAF Options - * o dsn String for defining the DB connection - * o dbOptions passes DB options - * o sourceMetar http, ftp or file - type of data-source for METAR - * o sourcePathMetar where to look for the source, URI or filepath, - * of METAR information - * o sourceTaf http, ftp or file - type of data-source for TAF - * o sourcePathTaf where to look for the source, URI or filepath, - * of TAF information + * o dsn String for defining the DB connection + * o dbOptions passes DB options + * o sourceMetar http, ftp or file - type of data-source for METAR + * o sourcePathMetar where to look for the source, URI or filepath, + * of METAR information + * o sourceTaf http, ftp or file - type of data-source for TAF + * o sourcePathTaf where to look for the source, URI or filepath, + * of TAF information * --- weather.com Options - * o partnerID You'll receive these keys after registering - * o licenseKey with the weather.com XML-service + * o partnerID You'll receive these keys after registering + * o licenseKey with the weather.com XML-service * - * @param string $service - * @param array $options + * @param string $service + * @param array $options * @return PEAR_Error|object * @throws PEAR_Error * @throws PEAR_Error::SERVICES_WEATHER_ERROR_SERVICE_NOT_FOUND @@ -146,8 +169,8 @@ /** * For your convenience, when I come up with changes in the API... * - * @return string - * @access public + * @return string + * @access public */ function apiVersion() { @@ -159,9 +182,9 @@ /** * Returns the message for a certain error code * - * @param PEAR_Error|int $value - * @return string - * @access private + * @param PEAR_Error|int $value + * @return string + * @access private */ function _errorMessage($value) { @@ -194,9 +217,9 @@ /** * Checks for an error object, same as in PEAR * - * @param PEAR_Error|mixed $value - * @return bool - * @access public + * @param PEAR_Error|mixed $value + * @return bool + * @access public */ function isError($value) { @@ -208,11 +231,11 @@ /** * Creates error, same as in PEAR with a customized flavor * - * @param int $code - * @param string $file - * @param int $line - * @return PEAR_Error - * @access private + * @param int $code + * @param string $file + * @param int $line + * @return PEAR_Error + * @access private */ function &raiseError($code = SERVICES_WEATHER_ERROR_UNKNOWN_ERROR, $file = "", $line = 0) {