Retrieve weather information for a given location using
http://openweathermap.org .
The location input is given as an object with two numeric fields,
"latitude" and "longitude". The default is
{"latitude": 37.85, "longitude": -122.26}
, which is
the location of Berkeley, California.
This accessor requires a key for the API, which you can obtain for free at http://openweathermap.org/appid .
This accessor looks for key in $KEYSTORE/weatherKey, which resolves to $HOME/.ptKeystore/weatherKey.
This accessor does not block waiting for the response, but if any additional location input is received before a pending request has received a response or timed out, then the new request will be queued and sent out only after the pending request has completed. This strategy ensures that outputs are produced in the same order as the input requests.
- Version:
- $$Id$$
- Source:
Inputs:
Name | Type | Description |
---|---|---|
location |
The location, an object with two fields (default is Berkeley). |
Outputs:
Name | Type | Description |
---|---|---|
response |
An object containing the raw response from the service. | |
weather |
An object containing more readable weather data. |
Parameters:
Name | Type | Description |
---|---|---|
temperature |
string | One of 'Fahrenheit', 'Celsius', or 'Kelvin'. |
Methods
(static) filterResponse()
Filter the response, extracting the weather information and outputting it on the weather output. The full response is produced on the 'response' output.
(static) setup()
Set up the accessor by defining the inputs and outputs.
(inner) convertTemperature(kelvin, units)
Convert the temperature in kelvins to the units specified in the temperature parameter. Also, round the result to a precision of 0.01 degrees.
Parameters:
Name | Type | Description |
---|---|---|
kelvin |
The temperature in degrees Kelvin. |
|
units |
The units to convert to, one of 'Fahrenheit' or 'Celsius'. |
Returns:
The temperature in the desired units.