Weather object constructor
Accepts an array of configuration parameters as key/value pairs:
- 'url' => 'Weather service XML url' default NOAA/NWS
- 'obs_station' => 'observation station code' default 'KIAG'
- 'image_dir' => 'local image directory' default NULL
- 'cache_dir' => 'local cache directory' default NULL
- 'cache_time' => 'local cache time in minutes' default 60 minutes
- 'cache_time_sid' => 'local cache time in minutes' for station data. Default 10080 (7 days)
- 'fetch_weather' => boolean flag, TRUE fetches weather data (default)
- 'fetch_stations' => boolean flag, TRUE fetches available weather stations data
- 'cache_stations' => boolean flag, TRUE serializes station data to cache
Weather
__construct
([array $params = array()])
Get the local XML data cache directory.
string
getCacheDir
()
Get the local cache valid time in minutes.
int
getCacheTime
()
Get the local station cache valid time in minutes.
int
getCacheTimeSid
()
Get the error status and messages.
array
getError
()
Get the local conditions image directory.
string
getImageDir
()
Get the weather observation station.
string
getObsStation
()
Get the weather station data array.
string
getStationArray
()
Get the weather stations from the station data array.
array
getStations
(string $state)
-
string
$state: The location's stations.
Get the weather service URL.
string
getUrl
()
Get the weather data array.
string
getWeatherArray
()
Get a single element from the weather data array.
string
getWeatherElement
(string $a)
Get an array of all available data points from the weather data array.
array
getWeatherElements
()
Get the weather xml data.
string
getXml
()
Set the local XML data cache directory.
NULL
setCacheDir
(string $a)
Set the local XML data cache valid time in minutes.
NULL
setCacheTime
(int $a)
Set the local XML station data cache valid time in minutes.
NULL
setCacheTimeSid
(int $a)
Set the error flag and message.
NULL
setError
(boolean $err, [string $usr_msg = NULL], [string $dbg_msg = NULL])
-
boolean
$err
-
string
$usr_msg: The user error message
-
string
$dbg_msg: The debug error message
Set the local conditions image directory.
NULL
setImageDir
(string $a)
Set the weather observation station.
NULL
setObsStation
(string $a)
Set the weather data base URL.
NULL
setUrl
(string $a)
Set the weather xml data.
NULL
setXml
(string $a)
Retrieve XML weather station data
boolean
_getWeatherStationXml
()
Retrieve XML weather data
boolean
_getWeatherXml
([string $station_id = NULL], [int $cache_time = -1])
-
string
$station_id: Optional station ID. Default is getObsStation().
-
int
$cache_time: Optional cache_time override
Checks and retrieves the local conditions image.
NULL
_setLocalImage
()
Convert XML weather station data to array
boolean
_setStationArray
()
Serializes weather station data array and saves it to cache_dir
boolean
_setStationCache
()
Convert XML weather data to array
boolean
_setWeatherArray
()
Return an array dump of the (parsed XML) weather data
array
__toArray
()
Return a dump of the XML data
array
__toString
()