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

OperationDescription

getWeatherStationWithObservation

Retrieves a weather station with the most recent weather observation.

listRecentEarthquakes

Retrieves a list of earthquakes, ordered by magnitude.

listWeatherStationsRetrieves 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.

getWeatherStationWithObservation
<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
  • longitude: The longitude to retrieve nearby weather stations.
  • latitude: The latitude to retrieve nearby weather stations.
  • responseType: The responseType to get the response of the getWeatherStationWithObservation method.
  • radius: The radius which is used to buffer in km for closest timezone in coastal areas.
  • callback: The callback value of the listPlacesForPostalcode function.
   Sample request

Following is a sample REST/JSON request that can be handled by the getWeatherStationWithObservation operation.

Sample Request for getWeatherStationWithObservation
{
	"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 listRecentEarthquakes 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
  • responseType: The responseType to get the response of the listRecentEarthquakes method.
  • 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 bounding box, only features within the box are returned.
  • callback: The name of JavaScript function.
  • date: The date to which earthquakes are retrieved.
  • minMagnitude: The minimal magnitude to which the earthquakes are retrieved.
  • maxRows: The maximal number of rows in the document returned by the service. Default is 10.
   Sample request

Following is a sample REST/JSON request that can be handled by the listRecentEarthquakes operation.

Sample Request for listRecentEarthquakes
{
	"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 listWeatherStations 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
  • responseType: The responseType of the listWeatherStations method.
  • 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 bounding box, only features within the box are returned.
  • callback: The name of JavaScript function.
  • maxRows: The maximal number of rows in the document returned by the service. Default is 10.
   Sample request

Following is a sample REST/JSON request that can be handled by the listWeatherStations operation.

Sample Request for listWeatherStations
{
	"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.

Sample Proxy
<?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>