Home » Web Services » Services_Weather » Manual
Class Summary Services_Weather
Class Summary Services_Weather – PEAR::Services_Weather
PEAR::Services_Weather
This class acts as an interface to various online weather-services.
Services_Weather searches for given locations and retrieves current weather data and, dependant on the used service, also forecasts. Up to now, SOAP services from CapeScience and EJSE, XML from weather.com and METAR from noaa.gov are supported, further services will get included, if they become available and are properly documented.
Class Trees for Services_Weather
- Services_Weather
Services_Weather::apiVersion
Services_Weather::apiVersion() – For your convenience, when I come up with changes in the API...
Synopsis
require_once '/Weather.php';
string
Services_Weather::apiVersion
(
)
Description
This package is not documented yet.
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather::isError
Services_Weather::isError() – Checks for an error object, same as in PEAR
Synopsis
require_once '/Weather.php';
bool
Services_Weather::isError
(
PEAR_Error|mixed
$value
)
Description
This package is not documented yet.
Parameter
-
PEAR_Error|mixed
$value
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather::service
Services_Weather::service() – Factory for creating the services-objects
Synopsis
require_once '/Weather.php';
PEAR_Error|object&
Services_Weather::service
(
string
$service
,
array
$options
= null
)
Description
Usable keys for the options array are:
- debug enables debugging output
--- Common Options
- cacheType defines what type of cache to use
- cacheOptions passes cache options
- unitsFormat use (US)-standard, metric or custom units
- customUnitsFormat defines the customized units format
- httpTimeout sets timeout for HTTP requests
- dateFormat string to use for date output
- timeFormat string to use for time output
--- EJSE Options
- none
--- GlobalWeather Options
- none
--- METAR Options
- dsn String for defining the DB connection
- dbOptions passes DB options
- source http, ftp or file - type of data-source
- sourcePath where to look for the source, URI or filepath
--- weather.com Options
- partnerID You'll receive these keys after registering
- licenseKey with the weather.com XML-service
Parameter
-
string
$service
-
array
$options
Throws
throws PEAR_Error
throws PEAR_Error::SERVICES_WEATHER_ERROR_SERVICE_NOT_FOUND
Note
This function can not be called statically.
Class Summary Services_Weather_Common
Class Summary Services_Weather_Common – PEAR::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.
Class Trees for Services_Weather_Common
- Services_Weather_Common
| Class | Summary |
|---|---|
| Services_Weather_Ejse | PEAR::Services_Weather_Ejse |
| Services_Weather_Globalweather | PEAR::Services_Weather_Globalweather |
| Services_Weather_Metar | PEAR::Services_Weather_Metar |
| Services_Weather_Weatherdotcom | PEAR::Services_Weather_Weatherdotcom |
Services_Weather_Common::calculateDewPoint
Services_Weather_Common::calculateDewPoint() – Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::calculateDewPoint
(
float
$temperature
,
float
$humidity
)
Description
Temperature has to be entered in deg C!
Parameter
-
float
$temperature
-
float
$humidity
Throws
No exceptions thrown.
See
see http://www.faqs.org/faqs/meteorology/temp-dewpoint/
Note
This function can not be called statically.
Services_Weather_Common::calculateHumidity
Services_Weather_Common::calculateHumidity() – Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::calculateHumidity
(
float
$temperature
,
float
$dewPoint
)
Description
Temperature and dewpoint have to be entered in deg C!
Parameter
-
float
$temperature
-
float
$dewPoint
Throws
No exceptions thrown.
See
see http://www.faqs.org/faqs/meteorology/temp-dewpoint/
Note
This function can not be called statically.
Services_Weather_Common::calculateWindChill
Services_Weather_Common::calculateWindChill() – Calculate windchill from temperature and windspeed (enhanced formula)
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::calculateWindChill
(
float
$temperature
,
float
$speed
)
Description
Temperature has to be entered in deg F, speed in mph!
Parameter
-
float
$temperature
-
float
$speed
Throws
No exceptions thrown.
See
see http://www.nws.noaa.gov/om/windchill/
Note
This function can not be called statically.
Services_Weather_Common::convertDistance
Services_Weather_Common::convertDistance() – Convert distance between km, ft and sm
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::convertDistance
(
float
$distance
,
string
$from
,
string
$to
)
Description
This package is not documented yet.
Parameter
-
float
$distance
-
string
$from
-
string
$to
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::convertPressure
Services_Weather_Common::convertPressure() – Convert pressure between in, hpa, mb, mm and atm
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::convertPressure
(
float
$pressure
,
string
$from
,
string
$to
)
Description
This package is not documented yet.
Parameter
-
float
$pressure
-
string
$from
-
string
$to
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::convertSpeed
Services_Weather_Common::convertSpeed() – Convert speed between mph, kmh, kt, mps and fps
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::convertSpeed
(
float
$speed
,
string
$from
,
string
$to
)
Description
This package is not documented yet.
Parameter
-
float
$speed
-
string
$from
-
string
$to
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::convertTemperature
Services_Weather_Common::convertTemperature() – Convert temperature between f and c
Synopsis
require_once '/Weather/Common.php';
float
Services_Weather_Common::convertTemperature
(
float
$temperature
,
string
$from
,
string
$to
)
Description
This package is not documented yet.
Parameter
-
float
$temperature
-
string
$from
-
string
$to
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::getUnitsFormat
Services_Weather_Common::getUnitsFormat() – Returns the selected units format
Synopsis
require_once '/Weather/Common.php';
array
Services_Weather_Common::getUnitsFormat
(
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$unitsFormat
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::polar2cartesian
Services_Weather_Common::polar2cartesian() – Convert polar coordinates to cartesian coordinates
Synopsis
require_once '/Weather/Common.php';
array
Services_Weather_Common::polar2cartesian
(
float
$latitude
,
float
$longitude
)
Description
This package is not documented yet.
Parameter
-
float
$latitude
-
float
$longitude
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::setCache
Services_Weather_Common::setCache() – Enables caching the data, usage strongly recommended
Synopsis
require_once '/Weather/Common.php';
PEAR_Error|bool
Services_Weather_Common::setCache
(
string
$cacheType = "file"
,
array
$cacheOptions = array()
)
Description
Requires Cache to be installed
Parameter
-
string
$cacheType
-
array
$cacheOptions
Throws
throws PEAR_Error::SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED
Note
This function can not be called statically.
Services_Weather_Common::setDateTimeFormat
Services_Weather_Common::setDateTimeFormat() – Changes the representation of time and dates (see http://www.php.net/date)
Synopsis
require_once '/Weather/Common.php';
void
Services_Weather_Common::setDateTimeFormat
(
string
$dateFormat = ""
,
string
$timeFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$dateFormat
-
string
$timeFormat
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::setHttpTimeout
Services_Weather_Common::setHttpTimeout() – Sets the timeout in seconds for HTTP requests
Synopsis
require_once '/Weather/Common.php';
void
Services_Weather_Common::setHttpTimeout
(
int
$httpTimeout
)
Description
This package is not documented yet.
Parameter
-
integer
$httpTimeout
Throws
No exceptions thrown.
Note
This function can not be called statically.
Services_Weather_Common::setUnitsFormat
Services_Weather_Common::setUnitsFormat() – Changes the representation of the units (standard/metric)
Synopsis
require_once '/Weather/Common.php';
void
Services_Weather_Common::setUnitsFormat
(
string
$unitsFormat
,
array
$customUnitsFormat = array()
)
Description
This package is not documented yet.
Parameter
-
string
$unitsFormat
-
array
$customUnitsFormat
Throws
No exceptions thrown.
Note
This function can not be called statically.
Class Summary Services_Weather_Ejse
Class Summary Services_Weather_Ejse – PEAR::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
Class Trees for Services_Weather_Ejse
-
Services_Weather_Common
- Services_Weather_Ejse
Services_Weather_Ejse Inherited Methods
| Method Name | Summary |
|---|---|
| Services_Weather_Common::calculateDewPoint() | Calculate dewpoint from temperature and humidity. This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateHumidity() | Calculate humidity from temperature and dewpoint. This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateWindChill() | Calculate windchill from temperature and windspeed (enhanced formula) |
| Services_Weather_Common::convertDistance() | Convert distance between km, ft and sm |
| Services_Weather_Common::convertPressure() | Convert pressure between in, hpa, mb, mm and atm |
| Services_Weather_Common::convertSpeed() | Convert speed between mph, kmh, kt, mps and fps |
| Services_Weather_Common::convertTemperature() | Convert temperature between f and c |
| Services_Weather_Common::getUnitsFormat() | Returns the selected units format |
| Services_Weather_Common::polar2cartesian() | Convert polar coordinates to cartesian coordinates |
| Services_Weather_Common::setCache() | Enables caching the data, usage strongly recommended |
| Services_Weather_Common::setDateTimeFormat() | Changes the representation of time and dates (see http://www.php.net/date) |
| Services_Weather_Common::setHttpTimeout() | Sets the timeout in seconds for HTTP requests |
| Services_Weather_Common::setUnitsFormat() | Changes the representation of the units (standard/metric) |
Services_Weather_Ejse::getForecast
Services_Weather_Ejse::getForecast() – Get the forecast for the next days
Synopsis
require_once '/Weather/Ejse.php';
PEAR_Error|array
Services_Weather_Ejse::getForecast
(
mixed
$id = ""
,
int
$days = 2
,
string
$unitsFormat = ""
,
string
$int
)
Description
This package is not documented yet.
Parameter
-
mixed
$id
-
integer
$days -
Values between 1 and 9
-
string
$unitsFormat
-
string
$int
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Ejse::getLocation
Services_Weather_Ejse::getLocation() – Returns the data for the location belonging to the ID
Synopsis
require_once '/Weather/Ejse.php';
PEAR_Error|array
Services_Weather_Ejse::getLocation
(
string
$id = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Ejse::getUnits
Services_Weather_Ejse::getUnits() – Returns the units for the current query
Synopsis
require_once '/Weather/Ejse.php';
array
Services_Weather_Ejse::getUnits
(
string
$id
= null
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Ejse::getWeather
Services_Weather_Ejse::getWeather() – Returns the weather-data for the supplied location
Synopsis
require_once '/Weather/Ejse.php';
PEAR_Error|array
Services_Weather_Ejse::getWeather
(
string
$id = ""
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Ejse::searchLocation
Services_Weather_Ejse::searchLocation() – EJSE offers no search function to date, so this function is disabled.
Synopsis
require_once '/Weather/Ejse.php';
bool
Services_Weather_Ejse::searchLocation
(
string
$location
= null
,
bool
$useFirst
= null
)
Description
Maybe this is the place to interface to some online postcode service...
Parameter
-
string
$location
-
boolean
$useFirst
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Ejse::searchLocationByCountry
Services_Weather_Ejse::searchLocationByCountry() – EJSE offers no search function to date, so this function is disabled.
Synopsis
require_once '/Weather/Ejse.php';
bool
Services_Weather_Ejse::searchLocationByCountry
(
string
$country
= null
)
Description
Maybe this is the place to interface to some online postcode service...
Parameter
-
string
$country
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Class Summary Services_Weather_Globalweather
Class Summary Services_Weather_Globalweather – PEAR::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.
For a working example, please take a look at docs/Services_Weather/examples/globalweather-basic.php
Class Trees for Services_Weather_Globalweather
-
Services_Weather_Common
- Services_Weather_Globalweather
Services_Weather_Globalweather Inherited Methods
| Method Name | Summary |
|---|---|
| Services_Weather_Common::calculateDewPoint() | Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateHumidity() | Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateWindChill() | Calculate windchill from temperature and windspeed (enhanced formula) |
| Services_Weather_Common::convertDistance() | Convert distance between km, ft and sm |
| Services_Weather_Common::convertPressure() | Convert pressure between in, hpa, mb, mm and atm |
| Services_Weather_Common::convertSpeed() | Convert speed between mph, kmh, kt, mps and fps |
| Services_Weather_Common::convertTemperature() | Convert temperature between f and c |
| Services_Weather_Common::getUnitsFormat() | Returns the selected units format |
| Services_Weather_Common::polar2cartesian() | Convert polar coordinates to cartesian coordinates |
| Services_Weather_Common::setCache() | Enables caching the data, usage strongly recommended |
| Services_Weather_Common::setDateTimeFormat() | Changes the representation of time and dates (see http://www.php.net/date) |
| Services_Weather_Common::setHttpTimeout() | Sets the timeout in seconds for HTTP requests |
| Services_Weather_Common::setUnitsFormat() | Changes the representation of the units (standard/metric) |
Services_Weather_Globalweather::getForecast
Services_Weather_Globalweather::getForecast() – GlobalWeather has no forecast per se, so this function is just for compatibility purposes.
Synopsis
require_once '/Weather/Globalweather.php';
bool
Services_Weather_Globalweather::getForecast
(
mixed
$id
= null
,
int
$days
= null
,
string
$unitsFormat
= null
,
string
$int
)
Description
This package is not documented yet.
Parameter
-
mixed
$id
-
integer
$days
-
string
$unitsFormat
-
string
$int
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Globalweather::getLocation
Services_Weather_Globalweather::getLocation() – Returns the data for the location belonging to the ID
Synopsis
require_once '/Weather/Globalweather.php';
PEAR_Error|array
Services_Weather_Globalweather::getLocation
(
string
$id = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Globalweather::getUnits
Services_Weather_Globalweather::getUnits() – Returns the units for the current query
Synopsis
require_once '/Weather/Globalweather.php';
array
Services_Weather_Globalweather::getUnits
(
string
$id
= null
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Globalweather::getWeather
Services_Weather_Globalweather::getWeather() – Returns the weather-data for the supplied location
Synopsis
require_once '/Weather/Globalweather.php';
PEAR_Error|array
Services_Weather_Globalweather::getWeather
(
string
$id = ""
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Globalweather::searchLocation
Services_Weather_Globalweather::searchLocation() – Searches IDs for given location, returns array of possible locations or single ID
Synopsis
require_once '/Weather/Globalweather.php';
PEAR_Error|array|string
Services_Weather_Globalweather::searchLocation
(
string
$location
,
bool
$useFirst
= false
)
Description
This package is not documented yet.
Parameter
-
string
$location
-
boolean
$useFirst -
If set, first ID of result-array is returned
Throws
throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA
throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
Note
This function can not be called statically.
Services_Weather_Globalweather::searchLocationByCountry
Services_Weather_Globalweather::searchLocationByCountry() – Returns IDs with location-name for a given country or all available countries, if no value was given
Synopsis
require_once '/Weather/Globalweather.php';
PEAR_Error|array
Services_Weather_Globalweather::searchLocationByCountry
(
string
$country = ""
)
Description
This package is not documented yet.
Parameter
-
string
$country
Throws
throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA
throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
Note
This function can not be called statically.
Class Summary Services_Weather_Metar
Class Summary Services_Weather_Metar – PEAR::Services_Weather_Metar
PEAR::Services_Weather_Metar
This class acts as an interface to the metar 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 accommodate 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 report with a _detailed_ explanation!
For a working example, please take a look at docs/Services_Weather/examples/metar-basic.php
Class Trees for Services_Weather_Metar
-
Services_Weather_Common
- Services_Weather_Metar
Services_Weather_Metar Inherited Methods
| Method Name | Summary |
|---|---|
| Services_Weather_Common::calculateDewPoint() | Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateHumidity() | Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateWindChill() | Calculate windchill from temperature and windspeed (enhanced formula) |
| Services_Weather_Common::convertDistance() | Convert distance between km, ft and sm |
| Services_Weather_Common::convertPressure() | Convert pressure between in, hpa, mb, mm and atm |
| Services_Weather_Common::convertSpeed() | Convert speed between mph, kmh, kt, mps and fps |
| Services_Weather_Common::convertTemperature() | Convert temperature between f and c |
| Services_Weather_Common::getUnitsFormat() | Returns the selected units format |
| Services_Weather_Common::polar2cartesian() | Convert polar coordinates to cartesian coordinates |
| Services_Weather_Common::setCache() | Enables caching the data, usage strongly recommended |
| Services_Weather_Common::setDateTimeFormat() | Changes the representation of time and dates (see http://www.php.net/date) |
| Services_Weather_Common::setHttpTimeout() | Sets the timeout in seconds for HTTP requests |
| Services_Weather_Common::setUnitsFormat() | Changes the representation of the units (standard/metric) |
Services_Weather_Metar::getForecast
Services_Weather_Metar::getForecast() – METAR has no forecast per se, so this function is just for compatibility purposes.
Synopsis
require_once '/Weather/Metar.php';
bool
Services_Weather_Metar::getForecast
(
mixed
$id
= null
,
int
$days
= null
,
string
$unitsFormat
= null
,
string
$int
)
Description
This package is not documented yet.
Parameter
-
mixed
$id
-
integer
$days
-
string
$unitsFormat
-
string
$int
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Metar::getLocation
Services_Weather_Metar::getLocation() – Returns the data for the location belonging to the ID
Synopsis
require_once '/Weather/Metar.php';
PEAR_Error|array
Services_Weather_Metar::getLocation
(
string
$id = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Metar::getUnits
Services_Weather_Metar::getUnits() – Returns the units for the current query
Synopsis
require_once '/Weather/Metar.php';
array
Services_Weather_Metar::getUnits
(
string
$id
= null
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Metar::getWeather
Services_Weather_Metar::getWeather() – Returns the weather-data for the supplied location
Synopsis
require_once '/Weather/Metar.php';
PHP_Error|array
Services_Weather_Metar::getWeather
(
string
$id = ""
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
throws PHP_Error
Note
This function can not be called statically.
Services_Weather_Metar::searchAirport
Services_Weather_Metar::searchAirport() – Searches the nearest airport(s) for given coordinates, returns array of IDs or single ID
Synopsis
require_once '/Weather/Metar.php';
PEAR_Error|array|string
Services_Weather_Metar::searchAirport
(
float
$latitude
,
float
$longitude
,
int
$numResults = 1
)
Description
This package is not documented yet.
Parameter
-
float
$latitude
-
float
$longitude
-
integer
$numResults
Throws
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
Note
This function can not be called statically.
Services_Weather_Metar::searchLocation
Services_Weather_Metar::searchLocation() – Searches IDs for given location, returns array of possible locations or single ID
Synopsis
require_once '/Weather/Metar.php';
PEAR_Error|array|string
Services_Weather_Metar::searchLocation
(
string|array
$location
,
bool
$useFirst
= false
)
Description
This package is not documented yet.
Parameter
-
string|array
$location
-
boolean
$useFirst -
If set, first ID of result-array is returned
Throws
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
Note
This function can not be called statically.
Services_Weather_Metar::searchLocationByCountry
Services_Weather_Metar::searchLocationByCountry() – Returns IDs with location-name for a given country or all available countries, if no value was given
Synopsis
require_once '/Weather/Metar.php';
PEAR_Error|array
Services_Weather_Metar::searchLocationByCountry
(
string
$country = ""
)
Description
This package is not documented yet.
Parameter
-
string
$country
Throws
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
Note
This function can not be called statically.
Services_Weather_Metar::setMetarDB
Services_Weather_Metar::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.
Synopsis
require_once '/Weather/Metar.php';
DB_Error|bool
Services_Weather_Metar::setMetarDB
(
string
$dsn
,
array
$dbOptions = array()
)
Description
This package is not documented yet.
Parameter
-
string
$dsn
-
array
$dbOptions
See
see DB::parseDSN
Throws
throws DB_Error
Note
This function can not be called statically.
Services_Weather_Metar::setMetarSource
Services_Weather_Metar::setMetarSource() – Sets the source, where the class tries to locate the METAR data
Synopsis
require_once '/Weather/Metar.php';
void
Services_Weather_Metar::setMetarSource
(
string
$source
,
string
$sourcePath = ""
)
Description
Source can be http, ftp or file. An alternate sourcepath can be provided.
Parameter
-
string
$source
-
string
$sourcePath
Throws
No exceptions thrown.
Note
This function can not be called statically.
Class Summary Services_Weather_Weatherdotcom
Class Summary Services_Weather_Weatherdotcom – PEAR::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 a working example, please take a look at docs/Services_Weather/examples/weather.com-basic.php
Class Trees for Services_Weather_Weatherdotcom
-
Services_Weather_Common
- Services_Weather_Weatherdotcom
Services_Weather_Weatherdotcom Inherited Methods
| Method Name | Summary |
|---|---|
| Services_Weather_Common::calculateDewPoint() | Calculate dewpoint from temperature and humidity This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateHumidity() | Calculate humidity from temperature and dewpoint This is only an approximation, there is no exact formula, this one here is called Magnus-Formula |
| Services_Weather_Common::calculateWindChill() | Calculate windchill from temperature and windspeed (enhanced formula) |
| Services_Weather_Common::convertDistance() | Convert distance between km, ft and sm |
| Services_Weather_Common::convertPressure() | Convert pressure between in, hpa, mb, mm and atm |
| Services_Weather_Common::convertSpeed() | Convert speed between mph, kmh, kt, mps and fps |
| Services_Weather_Common::convertTemperature() | Convert temperature between f and c |
| Services_Weather_Common::getUnitsFormat() | Returns the selected units format |
| Services_Weather_Common::polar2cartesian() | Convert polar coordinates to cartesian coordinates |
| Services_Weather_Common::setCache() | Enables caching the data, usage strongly recommended |
| Services_Weather_Common::setDateTimeFormat() | Changes the representation of time and dates (see http://www.php.net/date) |
| Services_Weather_Common::setHttpTimeout() | Sets the timeout in seconds for HTTP requests |
| Services_Weather_Common::setUnitsFormat() | Changes the representation of the units (standard/metric) |
Services_Weather_Weatherdotcom::getForecast
Services_Weather_Weatherdotcom::getForecast() – Get the forecast for the next days
Synopsis
require_once '/Weather/Weatherdotcom.php';
PEAR_Error|array
Services_Weather_Weatherdotcom::getForecast
(
string
$id = ""
,
int
$days = 2
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
integer
$days -
Values between 1 and 10
-
string
$unitsFormat
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::getLocation
Services_Weather_Weatherdotcom::getLocation() – Returns the data for the location belonging to the ID
Synopsis
require_once '/Weather/Weatherdotcom.php';
PEAR_Error|array
Services_Weather_Weatherdotcom::getLocation
(
string
$id = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::getUnits
Services_Weather_Weatherdotcom::getUnits() – Returns the units for the current query
Synopsis
require_once '/Weather/Weatherdotcom.php';
array
Services_Weather_Weatherdotcom::getUnits
(
string
$id
= null
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::getWeather
Services_Weather_Weatherdotcom::getWeather() – Returns the weather-data for the supplied location
Synopsis
require_once '/Weather/Weatherdotcom.php';
PEAR_Error|array
Services_Weather_Weatherdotcom::getWeather
(
string
$id = ""
,
string
$unitsFormat = ""
)
Description
This package is not documented yet.
Parameter
-
string
$id
-
string
$unitsFormat
Throws
throws PEAR_Error
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::searchLocation
Services_Weather_Weatherdotcom::searchLocation() – Searches IDs for given location, returns array of possible locations or single ID
Synopsis
require_once '/Weather/Weatherdotcom.php';
PEAR_Error|array|string
Services_Weather_Weatherdotcom::searchLocation
(
string
$location
,
bool
$useFirst
= false
)
Description
This package is not documented yet.
Parameter
-
string
$location
-
boolean
$useFirst -
If set, first ID of result-array is returned
Throws
throws PEAR_Error::SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA
throws PEAR_Error::SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::searchLocationByCountry
Services_Weather_Weatherdotcom::searchLocationByCountry() – Returns only false, as weather.com offers no country listing via its XML services
Synopsis
require_once '/Weather/Weatherdotcom.php';
bool
Services_Weather_Weatherdotcom::searchLocationByCountry
(
string
$country = ""
)
Description
This package is not documented yet.
Parameter
-
string
$country
Throws
No exceptions thrown.
Deprecated
deprecated
Note
This function can not be called statically.
Services_Weather_Weatherdotcom::setAccountData
Services_Weather_Weatherdotcom::setAccountData() – Sets the necessary account-information for weather.com, you'll receive them after registering for the XML-stream
Synopsis
require_once '/Weather/Weatherdotcom.php';
void
Services_Weather_Weatherdotcom::setAccountData
(
string
$partnerID
,
string
$licenseKey
)
Description
This package is not documented yet.
Parameter
-
string
$partnerID
-
string
$licenseKey
Throws
No exceptions thrown.
Note
This function can not be called statically.
Package Services_Weather Constants
Package Services_Weather Constants – Constants defined in and used by Services_Weather
All Constants
Constants defined in Weather.php
| Name | Value | Line Number |
|---|---|---|
| SERVICES_WEATHER_ERROR_CACHE_INIT_FAILED | 13 | 41 |
| SERVICES_WEATHER_ERROR_DB_NOT_CONNECTED | 14 | 42 |
| SERVICES_WEATHER_ERROR_INVALID_LICENSE_KEY | 102 | 51 |
| SERVICES_WEATHER_ERROR_INVALID_LOCATION | 2 | 48 |
| SERVICES_WEATHER_ERROR_INVALID_PARTNER_ID | 100 | 49 |
| SERVICES_WEATHER_ERROR_INVALID_PRODUCT_CODE | 101 | 50 |
| SERVICES_WEATHER_ERROR_NO_LOCATION | 1 | 47 |
| SERVICES_WEATHER_ERROR_SERVICE_NOT_FOUND | 10 | 38 |
| SERVICES_WEATHER_ERROR_UNKNOWN_ERROR | 46 | |
| SERVICES_WEATHER_ERROR_UNKNOWN_LOCATION | 11 | 39 |
| SERVICES_WEATHER_ERROR_WRONG_SERVER_DATA | 12 | 40 |
| SERVICES_WEATHER_EXPIRES_FORECAST | 7200 | 33 |
| SERVICES_WEATHER_EXPIRES_LINKS | 43200 | 34 |
| SERVICES_WEATHER_EXPIRES_LOCATION | 900 | 31 |
| SERVICES_WEATHER_EXPIRES_UNITS | 900 | 30 |
| SERVICES_WEATHER_EXPIRES_WEATHER | 1800 | 32 |
Constants defined in WeatherCommon.php
| Name | Value | Line Number |
|---|---|---|
| SERVICES_WEATHER_RADIUS_EARTH | 6378.15 | 32 |