This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Weather in GeoNames
Overview
The following operations allow you to work with weather. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with weather, see Sample configuration.
Operation | Description |
---|---|
Retrieves a weather station with the most recent weather observation. | |
listRecentEarthquakes | Retrieves a list of earthquakes, ordered by magnitude. |
listWeatherStations | Retrieves a list of weather stations with the most recent weather observation. |
Operation details
This section provides further details on the operations related to weather.
Retrieving a weather station with the most recent weather observation
The getWeatherStationWithObservation operation retrieves a weather station with the most recent weather observation.
<geonames.getWeatherStationWithObservation> <longitude>{$ctx:longitude}</longitude> <latitude>{$ctx:latitude}</latitude> <responseType>{$ctx:responseType}</responseType> <radius>{$ctx:radius}</radius> <callback>{$ctx:callback}</callback> </geonames.getWeatherStationWithObservation>
Properties
The longitude to retrieve nearby weather stations.longitude:
The latitude to retrieve nearby weather stations.latitude:
The responseType to get the response of the getWeatherStationWithObservation method.responseType:
The radius which is used to buffer in km for closest timezone in coastal areas.radius:
The callback value of the listPlacesForPostalcode function.callback:
Sample request
Following is a sample REST/JSON request that can be handled by the getWeatherStationWithObservation
operation.
{ "apiUrl": "http://api.geonames.org", "username": "buddhima", "responseType": "json", "longitude": "9", "latitude": "47", "radius": "100", "callback": "callbackFunction" }
Related GeoNames documentation
http://www.geonames.org/export/JSON-webservices.html#findNearByWeatherJSON
Retrieving a list of earthquakes, ordered by magnitude
The
operation retrieves a list of earthquakes, ordered by magnitude.listRecentEarthquakes
<geonames.listRecentEarthquakes> <responseType>{$ctx:responseType}</responseType> <north>{$ctx:north}</north> <south>{$ctx:south}</south> <east>{$ctx:east}</east> <west>{$ctx:west}</west> <callback>{$ctx:callback}</callback> <date>{$ctx:date}</date> <minMagnitude>{$ctx:minMagnitude}</minMagnitude> <maxRows>{$ctx:maxRows}</maxRows> </geonames.listRecentEarthquakes>
Properties
The responseType to get the response of the listRecentEarthquakes method.responseType:
The bounding box, only features within the box are returned.north:
The bounding box, only features within the box are returned.south:
The bounding box, only features within the box are returned.east:
The bounding box, only features within the box are returned.west:
The name of JavaScript function.callback:
The date to which earthquakes are retrieved.date:
The minimal magnitude to which the earthquakes are retrieved.minMagnitude:
The maximal number of rows in the document returned by the service. Default is 10.maxRows:
Sample request
Following is a sample REST/JSON request that can be handled by the listRecentEarthquakes
operation.
{ "apiUrl": "http://api.geonames.org", "username": "buddhima", "responseType": "json", "north": "44.1", "south": "9.9", "east": "22.4", "west": "55.2", "callback": "callbackFunction", "maxRows": "2", "date": "2011-03-11 04:46:23", "minMagnitude": "55.2" }
Related GeoNames documentation
http://www.geonames.org/export/JSON-webservices.html#earthquakesJSON
Retrieving a list of weather stations with the most recent weather observation
The
operation retrieves a list of weather stations with the most recent weather observation.listWeatherStations
<geonames.listWeatherStations> <responseType>{$ctx:responseType}</responseType> <north>{$ctx:north}</north> <south>{$ctx:south}</south> <east>{$ctx:east}</east> <west>{$ctx:west}</west> <callback>{$ctx:callback}</callback> <maxRows>{$ctx:maxRows}</maxRows> </geonames.listWeatherStations>
Properties
The responseType of the listWeatherStations method.responseType:
The bounding box, only features within the box are returned.north:
The bounding box, only features within the box are returned.south:
The bounding box, only features within the box are returned.east:
The bounding box, only features within the box are returned.west:
The name of JavaScript function.callback:
The maximal number of rows in the document returned by the service. Default is 10.maxRows:
Sample request
Following is a sample REST/JSON request that can be handled by the listWeatherStations
operation.
{ "apiUrl": "http://api.geonames.org", "username": "buddhima", "responseType": "json", "north": "44.1", "south": "9.9", "east": "22.4", "west": "55.2", "callback": "callbackFunction", "maxRows": "2" }
Related GeoNames documentation
http://www.geonames.org/export/JSON-webservices.html#weatherJSON
Sample configuration
Following is a sample proxy service that illustrates how to connect to GeoNames with the init
operation and use the getWeatherStationWithObservation operation. The sample request for this proxy can be found in the getWeatherStationWithObservation sample request.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="geonames_getWeatherStationWithObservation" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="apiUrl" expression="json-eval($.apiUrl)" /> <property name="username" expression="json-eval($.username)" /> <property name="longitude" expression="json-eval($.longitude)" /> <property name="latitude" expression="json-eval($.latitude)" /> <property name="responseType" expression="json-eval($.responseType)" /> <property name="radius" expression="json-eval($.radius)" /> <property name="callback" expression="json-eval($.callback)" /> <geonames.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <username>{$ctx:username}</username> </geonames.init> <geonames.getWeatherStationWithObservation> <longitude>{$ctx:longitude}</longitude> <latitude>{$ctx:latitude}</latitude> <responseType>{$ctx:responseType}</responseType> <radius>{$ctx:radius}</radius> <callback>{$ctx:callback}</callback> </geonames.getWeatherStationWithObservation> <respond /> </inSequence> <outSequence> <send /> </outSequence> </target> <description /> </proxy>