Horde_Service_Weather_Owm
extends Horde_Service_Weather_Base
in package
Horde_Service_Weather_Owm
Tags
Table of Contents
- API_URL = 'http://api.openweathermap.org/data/2.5'
- $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
- $_forecast : Horde_Service_Weather_Forecast_Base
- Local cache of forecast
- $_http : Horde_Http_Client
- The http client
- $_key : string
- Owm API key.
- $_lastLength : int
- Last requested forecast length.
- $_lastLocation : string
- Last location requested.
- $_locationCode : mixed
- $_params : array<string|int, mixed>
- Parameters
- $_radar : mixed
- $_station : Horde_Service_Weather_Station
- Local cache of station data
- __construct() : Horde_Service_Weather_Wwo
- Constructor.
- autocompleteLocation() : array<string|int, mixed>
- Return an autocomplete request result.
- getAlerts() : array<string|int, mixed>
- Return array of weather alerts, if available.
- getCurrentConditions() : Horde_Service_Weather_Current_Wwo
- Obtain the current observations.
- getForecast() : Horde_Service_Weather_Forecast_Base
- Obtain the forecast for the current location.
- 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>
- Return the 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
- Search for a valid location code.
- _getCodeFromLatLng() : mixed
- _getCommonElements() : mixed
- Populates some common data used by forecasts and current conditions.
- _ipIsUnique() : bool
- Check if an IP address is a globally unique address and not in RFC1918 or RFC3330 address space.
- _makeRequest() : mixed
- Make the remote API call.
- _parseAutocomplete() : mixed
- _parseCurrent() : Horde_Service_Weather_Current
- Parse the current_conditions response.
- _parseForecast() : Horde_Service_Weather_Forecast_Wwo
- Parses the forecast data.
- _parseSearchLocations() : array<string|int, mixed>
- Return an array of location search results.
- _parseStation() : Horde_Service_Weather_Station
- Parses the JSON response for a location request into a station object.
- _searchLocations() : string
- Execute a location search.
Constants
API_URL
public
mixed
API_URL
= 'http://api.openweathermap.org/data/2.5'
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(
'01d' => '32.png',
'01n' => '33.png',
'02d' => '30.png',
//Few Clouds,day
'02n' => '29.png',
//Few Clouds,pm
'03d' => '28.png',
//Broken clouds
'03n' => '27.png',
'04d' => '26.png',
//Overcast
'04d' => '26.png',
'09d' => '11.png',
'09n' => '40.png',
'10d' => '12.png',
'10n' => '30.png',
'11d' => '0.png',
'11n' => '47.png',
'13d' => '16.png',
'13n' => '42.png',
)
Tags
$link
URL to the provider's site
public
string
$link
= 'http://openweathermap.org'
Tags
$logo
URL to a logo for this provider
public
string
$logo
$title
Title for the provider
public
string
$title
= 'OpenWeatherMap'
Tags
$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
$_forecast
Local cache of forecast
protected
Horde_Service_Weather_Forecast_Base
$_forecast
$_http
The http client
protected
Horde_Http_Client
$_http
$_key
Owm API key.
protected
string
$_key
$_lastLength
Last requested forecast length.
protected
int
$_lastLength
$_lastLocation
Last location requested.
protected
string
$_lastLocation
$_locationCode
protected
mixed
$_locationCode
$_params
Parameters
protected
array<string|int, mixed>
$_params
$_radar
protected
mixed
$_radar
$_station
Local cache of station data
protected
Horde_Service_Weather_Station
$_station
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = array() ]) : Horde_Service_Weather_Wwo
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.
- apikey: (string) Require api key for Wwo.
- apiVersion: (integer) Version of the API to use. Defaults to v1 for BC reasons.
Return values
Horde_Service_Weather_Wwo —autocompleteLocation()
Return an autocomplete request result.
public
autocompleteLocation(mixed $search) : array<string|int, mixed>
Parameters
- $search : mixed
-
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()
Obtain the current observations.
public
getCurrentConditions(mixed $location) : Horde_Service_Weather_Current_Wwo
Parameters
- $location : mixed
-
The location string.
Tags
Return values
Horde_Service_Weather_Current_Wwo —getForecast()
Obtain the forecast for the current location.
public
getForecast(mixed $location[, mixed $length = Horde_Service_Weather::FORECAST_3DAY ][, mixed $type = Horde_Service_Weather::FORECAST_TYPE_STANDARD ]) : Horde_Service_Weather_Forecast_Base
Parameters
- $location : mixed
-
The location code.
- $length : mixed = Horde_Service_Weather::FORECAST_3DAY
-
The forecast length, a Horde_Service_Weather::FORECAST_* constant.
- $type : mixed = Horde_Service_Weather::FORECAST_TYPE_STANDARD
-
The type of forecast to return, a Horde_Service_Weather::FORECAST_TYPE_* constant
Tags
Return values
Horde_Service_Weather_Forecast_Base —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()
Return the supported forecast lengths.
public
getSupportedForecastLengths() : array<string|int, mixed>
Tags
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()
Search for a valid location code.
public
searchLocations(mixed $location[, mixed $type = Horde_Service_Weather::SEARCHTYPE_STANDARD ]) : Horde_Service_Weather_Station
Parameters
- $location : mixed
-
The location string to search.
- $type : mixed = 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.
_getCodeFromLatLng()
protected
_getCodeFromLatLng(mixed $lat, mixed $lng) : mixed
Parameters
- $lat : mixed
- $lng : mixed
Return values
mixed —_getCommonElements()
Populates some common data used by forecasts and current conditions.
protected
_getCommonElements(string $location[, int $length = Horde_Service_Weather::FORECAST_5DAY ]) : mixed
Parameters
- $location : string
-
The location identifier.
- $length : int = Horde_Service_Weather::FORECAST_5DAY
-
The forecast length.
Return values
mixed —_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()
Make the remote API call.
protected
_makeRequest(Horde_Url $url[, mixed $locationSearch = false ]) : mixed
Parameters
- $url : Horde_Url
-
The endpoint.
- $locationSearch : mixed = false
Tags
Return values
mixed —The unserialized results form the remote API call.
_parseAutocomplete()
protected
_parseAutocomplete(array<string|int, mixed> $results) : mixed
Parameters
- $results : array<string|int, mixed>
-
An array of Horde_Service_Weather_Station objects.
Return values
mixed —_parseCurrent()
Parse the current_conditions response.
protected
_parseCurrent(stdClass $current) : Horde_Service_Weather_Current
Parameters
- $current : stdClass
-
The current_condition request response object
Return values
Horde_Service_Weather_Current —_parseForecast()
Parses the forecast data.
protected
_parseForecast(stdClass $forecast) : Horde_Service_Weather_Forecast_Wwo
Parameters
- $forecast : stdClass
-
The result of the forecast request.
Return values
Horde_Service_Weather_Forecast_Wwo —The forecast.
_parseSearchLocations()
Return an array of location search results.
protected
_parseSearchLocations(stdClass $response) : array<string|int, mixed>
Parameters
- $response : stdClass
-
The results of a find query.
Tags
Return values
array<string|int, mixed> —An array of Horde_Service_Weather_Station objects.
_parseStation()
Parses the JSON response for a location request into a station object.
protected
_parseStation(StdClass $station) : Horde_Service_Weather_Station
Parameters
- $station : StdClass
-
The response from a Location request.
Return values
Horde_Service_Weather_Station —_searchLocations()
Execute a location search.
protected
_searchLocations(string $location) : string
Parameters
- $location : string
-
The location text to search.
Return values
string —The location code result(s).