Horde_Service_Weather_Metar
extends Horde_Service_Weather_Base
in package
Horde_Service_Weather_Metar
Responsible for parsing encoded METAR and TAF data.
Tags
Table of Contents
- $iconMap : array<string|int, mixed>
- Driver spcific icon map for condition icons. Made public so icons can be overridden in client code if desired.
- $link : string
- URL to the provider's site
- $logo : string
- URL to a logo for this provider
- $title : string
- Title for the provider
- $units : int
- Units to display results in.
- $_alerts : mixed
- $_cache : Horde_Cache
- Cache object
- $_cache_lifetime : int
- Lifetime for cached data.
- $_current : mixed
- Local cache of current conditions
- $_db : Horde_Db_Adapter_Base
- Database handle. Expects to have the following table available:
- $_forecast : Horde_Service_Weather_Forecast_Base
- Local cache of forecast
- $_http : Horde_Http_Client
- The http client
- $_lastLength : int
- Last requested forecast length.
- $_lastLocation : string
- Last location requested.
- $_locations : array<string|int, mixed>
- Local cache of locations.
- $_metar_path : string
- Default paths to download weather data.
- $_params : array<string|int, mixed>
- Parameters
- $_radar : mixed
- $_station : Horde_Service_Weather_Station
- Local cache of station data
- $_tableName : string
- Name of table containing the NOAA METAR database.
- $_taf_path : mixed
- __construct() : mixed
- Constructor.
- autocompleteLocation() : array<string|int, mixed>
- Searches for locations that begin with the text in $search.
- getAlerts() : array<string|int, mixed>
- Return array of weather alerts, if available.
- getCurrentConditions() : Horde_Service_Weather_Current_Base
- Returns the current observations (METAR).
- getForecast() : Horde_Service_Weather_Forecast_Base
- Returns the forecast for the current location.
- getLocations() : array<string|int, mixed>
- Return an array containing all available METAR locations/airports.
- getRadarImageUrl() : string|bool
- Return the URL to a (possibly animated) radar image.
- getStation() : Horde_Service_Weather_Station
- Returns the station information associated with the last request.
- getSupportedForecastLengths() : array<string|int, mixed>
- Get array of supported forecast lengths.
- getTileServerUrl() : string|bool
- Return the URL a OpenLayers suitable tile server.
- getUnits() : array<string|int, mixed>
- Returns a mapping of units for each UNIT type.
- searchLocations() : Horde_Service_Weather_Station
- Searches locations.
- _getLocations() : array<string|int, mixed>
- Perform DB query to obtain list of airport codes.
- _getStation() : Horde_Service_Weather_Station
- Return a station object matching $code.
- _ipIsUnique() : bool
- Check if an IP address is a globally unique address and not in RFC1918 or RFC3330 address space.
- _makeRequest() : string
- Performs a HTTP request.
Properties
$iconMap
Driver spcific icon map for condition icons. Made public so icons can be overridden in client code if desired.
public
array<string|int, mixed>
$iconMap
= array()
$link
URL to the provider's site
public
string
$link
$logo
URL to a logo for this provider
public
string
$logo
$title
Title for the provider
public
string
$title
$units
Units to display results in.
public
int
$units
= Horde_Service_Weather::UNITS_STANDARD
$_alerts
protected
mixed
$_alerts
= array()
$_cache
Cache object
protected
Horde_Cache
$_cache
$_cache_lifetime
Lifetime for cached data.
protected
int
$_cache_lifetime
= 21600
$_current
Local cache of current conditions
protected
mixed
$_current
$_db
Database handle. Expects to have the following table available:
protected
Horde_Db_Adapter_Base
$_db
$_forecast
Local cache of forecast
protected
Horde_Service_Weather_Forecast_Base
$_forecast
$_http
The http client
protected
Horde_Http_Client
$_http
$_lastLength
Last requested forecast length.
protected
int
$_lastLength
$_lastLocation
Last location requested.
protected
string
$_lastLocation
$_locations
Local cache of locations.
protected
array<string|int, mixed>
$_locations
$_metar_path
Default paths to download weather data.
protected
string
$_metar_path
= 'http://tgftp.nws.noaa.gov/data/observations/metar/stations'
$_params
Parameters
protected
array<string|int, mixed>
$_params
$_radar
protected
mixed
$_radar
$_station
Local cache of station data
protected
Horde_Service_Weather_Station
$_station
$_tableName
Name of table containing the NOAA METAR database.
protected
string
$_tableName
= 'horde_metar_airports'
$_taf_path
protected
mixed
$_taf_path
= 'http://tgftp.nws.noaa.gov/data/forecasts/taf/stations'
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = array() ]) : mixed
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.
Parameters
- $params : array<string|int, mixed> = 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.
Return values
mixed —autocompleteLocation()
Searches for locations that begin with the text in $search.
public
autocompleteLocation(string $search) : array<string|int, mixed>
Parameters
- $search : string
-
The text to search.
Tags
Return values
array<string|int, mixed> —An array of stdClass objects with 'name' and 'code' properties.
getAlerts()
Return array of weather alerts, if available.
public
getAlerts(mixed $location) : array<string|int, mixed>
Parameters
- $location : mixed
Return values
array<string|int, mixed> —getCurrentConditions()
Returns the current observations (METAR).
public
getCurrentConditions(string $location) : Horde_Service_Weather_Current_Base
Parameters
- $location : string
-
The location string.
Tags
Return values
Horde_Service_Weather_Current_Base —getForecast()
Returns the forecast for the current location.
public
getForecast(string $location[, int $length = Horde_Service_Weather::FORECAST_3DAY ][, int $type = Horde_Service_Weather::FORECAST_TYPE_STANDARD ]) : Horde_Service_Weather_Forecast_Base
Parameters
- $location : string
-
The location code.
- $length : int = Horde_Service_Weather::FORECAST_3DAY
-
The forecast length, a Horde_Service_Weather::FORECAST_* constant. (Ignored)
- $type : int = Horde_Service_Weather::FORECAST_TYPE_STANDARD
-
The type of forecast to return, a Horde_Service_Weather::FORECAST_TYPE_* constant (Ignored)
Tags
Return values
Horde_Service_Weather_Forecast_Base —getLocations()
Return an array containing all available METAR locations/airports.
public
getLocations() : array<string|int, mixed>
Return values
array<string|int, mixed> —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).
getRadarImageUrl()
Return the URL to a (possibly animated) radar image.
public
getRadarImageUrl(string $location) : string|bool
Parameters
- $location : string
-
The location
Return values
string|bool —The Url, or false if not available.
getStation()
Returns the station information associated with the last request.
public
getStation() : Horde_Service_Weather_Station
Tags
Return values
Horde_Service_Weather_Station —getSupportedForecastLengths()
Get array of supported forecast lengths.
public
getSupportedForecastLengths() : array<string|int, mixed>
Return values
array<string|int, mixed> —The array of supported lengths.
getTileServerUrl()
Return the URL a OpenLayers suitable tile server.
public
getTileServerUrl(string $location[, string $type = null ]) : string|bool
Parameters
- $location : string
-
The location.
- $type : string = null
-
The optional layer type.
Return values
string|bool —The Url, or false if not available.
getUnits()
Returns a mapping of units for each UNIT type.
public
getUnits([int $type = null ]) : array<string|int, mixed>
Parameters
- $type : int = null
-
The units for measurement. A Horde_Service_Weather::UNITS_* constant.
Return values
array<string|int, mixed> —The mapping of measurements (as keys) and units (as values).
searchLocations()
Searches locations.
public
searchLocations(string $location[, int $type = Horde_Service_Weather::SEARCHTYPE_STANDARD ]) : Horde_Service_Weather_Station
Parameters
- $location : string
-
The location string to search.
- $type : int = Horde_Service_Weather::SEARCHTYPE_STANDARD
-
The type of search to perform, a Horde_Service_Weather::SEARCHTYPE_* constant.
Tags
Return values
Horde_Service_Weather_Station —The search location suitable to use directly in a weather request.
_getLocations()
Perform DB query to obtain list of airport codes.
protected
_getLocations() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —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()
Return a station object matching $code.
protected
_getStation(string $code) : Horde_Service_Weather_Station
Parameters
- $code : string
-
The ICAO station identifier.
Tags
Return values
Horde_Service_Weather_Station —The station object.
_ipIsUnique()
Check if an IP address is a globally unique address and not in RFC1918 or RFC3330 address space.
protected
_ipIsUnique(string $ip) : bool
Parameters
- $ip : string
-
The IPv4 IP address to check.
Tags
Return values
bool —True if the IP address is globally unique, otherwise false.
_makeRequest()
Performs a HTTP request.
protected
_makeRequest(string $url[, int $lifetime = 86400 ]) : string
Parameters
- $url : string
-
The URL endpoint.
- $lifetime : int = 86400
-
The cache lifetime.
Tags
Return values
string —The response body of the request.