Documentation

Horde_Service_Weather_Wwo extends Horde_Service_Weather_Base
in package

Horde_Service_Weather_Wwo

Tags
author

Michael J Rubinsky mrubinsk@horde.org

category

Horde

Table of Contents

API_URL  = 'http://api.worldweatheronline.com/premium/v1/weather.ashx'
API_URL_v2  = 'https://api.worldweatheronline.com/premium/v2/weather.ashx'
SEARCH_URL  = 'http://api.worldweatheronline.com/premium/v1/search.ashx'
SEARCH_URL_v2  = 'https://api.worldweatheronline.com/premium/v2/search.ashx'
$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
Wwo API key.
$_lastLength  : int
Last requested forecast length.
$_lastLocation  : string
Last location requested.
$_params  : array<string|int, mixed>
Parameters
$_radar  : mixed
$_station  : Horde_Service_Weather_Station
Local cache of station data
$_version  : int
API Version
__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.
_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()  : mixed
_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.worldweatheronline.com/premium/v1/weather.ashx'

API_URL_v2

public mixed API_URL_v2 = 'https://api.worldweatheronline.com/premium/v2/weather.ashx'

SEARCH_URL

public mixed SEARCH_URL = 'http://api.worldweatheronline.com/premium/v1/search.ashx'

SEARCH_URL_v2

public mixed SEARCH_URL_v2 = 'https://api.worldweatheronline.com/premium/v2/search.ashx'

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('wsymbol_0001_sunny' => '32.png', 'wsymbol_0002_sunny_intervals' => '30.png', 'wsymbol_0003_white_cloud' => '26.png', 'wsymbol_0004_black_low_cloud' => '26.png', 'wsymbol_0006_mist' => '34.png', 'wsymbol_0007_fog' => '20.png', 'wsymbol_0008_clear_sky_night' => '33.png', 'wsymbol_0009_light_rain_showers' => '11.png', 'wsymbol_0010_heavy_rain_showers' => '12.png', 'wsymbol_0011_light_snow_showers' => '14.png', 'wsymbol_0012_heavy_snow_showers' => '16.png', 'wsymbol_0013_sleet_showers' => '7.png', 'wsymbol_0016_thundery_showers' => '0.png', 'wsymbol_0017_cloudy_with_light_rain' => '11.png', 'wsymbol_0018_cloudy_with_heavy_rain' => '12.png', 'wsymbol_0019_cloudy_with_light_snow' => '13.png', 'wsymbol_0020_cloudy_with_heavy_snow' => '16.png', 'wsymbol_0021_cloudy_with_sleet' => '8.png', 'wsymbol_0024_thunderstorms' => '0.png', 'wsymbol_0025_light_rain_showers_night' => '40.png', 'wsymbol_0026_heavy_rain_showers_night' => '30.png', 'wsymbol_0027_light_snow_showers_night' => '41.png', 'wsymbol_0028_heavy_snow_showers_night' => '42.png', 'wsymbol_0029_sleet_showers_night' => '7.png', 'wsymbol_0032_thundery_showers_night' => '47.png', 'wsymbol_0033_cloudy_with_light_rain_night' => '45.png', 'wsymbol_0034_cloudy_with_heavy_rain_night' => '45.png', 'wsymbol_0035_cloudy_with_light_snow_night' => '46.png', 'wsymbol_0036_cloudy_with_heavy_snow_night' => '46.png', 'wsymbol_0037_cloudy_with_sleet_night' => '8.png', 'wsymbol_0040_thunderstorms_night' => '47.png')
Tags
see
Horde_Service_Weather::$iconMap

URL to a logo for this provider

public string $logo

$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

$_http

The http client

protected Horde_Http_Client $_http

$_key

Wwo API key.

protected string $_key

$_lastLength

Last requested forecast length.

protected int $_lastLength

$_lastLocation

Last location requested.

protected string $_lastLocation

$_params

Parameters

protected array<string|int, mixed> $_params

$_radar

protected mixed $_radar

$_version

API Version

protected int $_version

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
see
Horde_Service_Weather_Base::autocompleteLocation
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>

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
see
Horde_Service_Weather_Base::getForecast
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.

getSupportedForecastLengths()

Return the supported forecast lengths.

public getSupportedForecastLengths() : array<string|int, mixed>
Tags
see
Horde_Service_Weather_Base::getSupportedForecastLengths
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
see
Horde_Service_Weather_Base::searchLocations
Return values
Horde_Service_Weather_Station

The search location suitable to use directly in a weather request.

_getCommonElements()

Populates some common data used by forecasts and current conditions.

protected _getCommonElements(string $location[, int $length = Horde_Service_Weather::FORECAST_5DAY ]) : mixed

Weather Underground allows requesting multiple features per request, and only counts it as a single request against your API key. So we trade a bit of request time/traffic for a smaller number of requests to obtain information for e.g., a typical weather portal display.

Parameters
$location : string

The location identifier.

$length : int = Horde_Service_Weather::FORECAST_5DAY

The forecast length.

Return values
mixed

_makeRequest()

Make the remote API call.

protected _makeRequest(Horde_Url $url) : mixed
Parameters
$url : Horde_Url

The endpoint.

Tags
throws
Horde_Service_Weather_Exception
Return values
mixed

The unserialized results form the remote API call.

_parseAutocomplete()

protected _parseAutocomplete(mixed $results) : mixed
Parameters
$results : mixed
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

_parseSearchLocations()

protected _parseSearchLocations(mixed $response) : mixed
Parameters
$response : mixed
Return values
mixed

_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).

Search results