PHP Class Horde_Service_Weather_Metar, horde

Responsible for parsing encoded METAR and TAF data.
Author: Michael J Rubinsky ([email protected])
Inheritance: extends Horde_Service_Weather_Base
Datei anzeigen Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_db Horde_Db_Adapter_Base Database handle. Expects to have the following table available:
$_locations array Local cache of locations.
$_metar_path string Default paths to download weather data.
$_tableName string Name of table containing the NOAA METAR database.
$_taf_path

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
autocompleteLocation ( string $search ) : array Searches for locations that begin with the text in $search.
getCurrentConditions ( string $location ) : Horde_Service_Weather_Current_Base Returns the current observations (METAR).
getForecast ( string $location, integer $length = Horde_Service_Weather::FORECAST_3DAY, integer $type = Horde_Service_Weather::FORECAST_TYPE_STANDARD ) : Horde_Service_Weather_Forecast_Base Returns the forecast for the current location.
getLocations ( ) : array Return an array containing all available METAR locations/airports.
getSupportedForecastLengths ( ) : array Get array of supported forecast lengths.
searchLocations ( string $location, integer $type = Horde_Service_Weather::SEARCHTYPE_STANDARD ) : Horde_Service_Weather_Station Searches locations.

Protected Methods

Method Description
_getLocations ( ) : array Perform DB query to obtain list of airport codes.
_getStation ( string $code ) : Horde_Service_Weather_Station Return a station object matching $code.
_makeRequest ( string $url, integer $lifetime = 86400 ) : string Performs a HTTP request.

Method Details

__construct() public method

In addtion to the params for the parent class, you can also set a database adapter for NOAA station lookups, and if you don't want to use the default METAR/TAF http locations, you can set them here too. Note only HTTP is currently supported, but file and ftp are @todo.
public __construct ( array $params = [] )
$params array Parameters: - cache: (Horde_Cache) Optional Horde_Cache object. - cache_lifetime: (integer) Lifetime of cached data, if caching. - http_client: (Horde_Http_Client) Required http client object. - db: (Horde_Db_Adapter_Base) DB Adapter for METAR DB. - metar_path: (string) Path or URL to METAR data. - taf_path: (string) Path or URL to TAF data.

_getLocations() protected method

Perform DB query to obtain list of airport codes.
protected _getLocations ( ) : array
return array An array of station information. Each entry contains: - icao: The ICAO identifier of the location. - name: The human readable name of the station. - country: The country the station is located in (if available).

_getStation() protected method

Return a station object matching $code.
protected _getStation ( string $code ) : Horde_Service_Weather_Station
$code string The ICAO station identifier.
return Horde_Service_Weather_Station The station object.

_makeRequest() protected method

Performs a HTTP request.
protected _makeRequest ( string $url, integer $lifetime = 86400 ) : string
$url string The URL endpoint.
$lifetime integer The cache lifetime.
return string The response body of the request.

autocompleteLocation() public method

Searches for locations that begin with the text in $search.
public autocompleteLocation ( string $search ) : array
$search string The text to search.
return array An array of stdClass objects with 'name' and 'code' properties.

getCurrentConditions() public method

Returns the current observations (METAR).
public getCurrentConditions ( string $location ) : Horde_Service_Weather_Current_Base
$location string The location string.
return Horde_Service_Weather_Current_Base

getForecast() public method

Returns the forecast for the current location.
public getForecast ( string $location, integer $length = Horde_Service_Weather::FORECAST_3DAY, integer $type = Horde_Service_Weather::FORECAST_TYPE_STANDARD ) : Horde_Service_Weather_Forecast_Base
$location string The location code.
$length integer The forecast length, a Horde_Service_Weather::FORECAST_* constant. (Ignored)
$type integer The type of forecast to return, a Horde_Service_Weather::FORECAST_TYPE_* constant (Ignored)
return Horde_Service_Weather_Forecast_Base

getLocations() public method

Return an array containing all available METAR locations/airports.
public getLocations ( ) : array
return array An array of station information. Each entry contains: - icao: The ICAO identifier of the location. - name: The human readable name of the station. - country: The country the station is located in (if available).

getSupportedForecastLengths() public method

Get array of supported forecast lengths.
public getSupportedForecastLengths ( ) : array
return array The array of supported lengths.

searchLocations() public method

Searches locations.
public searchLocations ( string $location, integer $type = Horde_Service_Weather::SEARCHTYPE_STANDARD ) : Horde_Service_Weather_Station
$location string The location string to search.
$type integer The type of search to perform, a Horde_Service_Weather::SEARCHTYPE_* constant.
return Horde_Service_Weather_Station The search location suitable to use directly in a weather request.

Property Details

$_db protected_oe property

Database handle. Expects to have the following table available:
protected Horde_Db_Adapter_Base $_db
return Horde_Db_Adapter_Base

$_locations protected_oe property

Local cache of locations.
protected array $_locations
return array

$_metar_path protected_oe property

Default paths to download weather data.
protected string $_metar_path
return string

$_tableName protected_oe property

Name of table containing the NOAA METAR database.
protected string $_tableName
return string

$_taf_path protected_oe property

protected $_taf_path