This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, go to https://wso2.com/documentation/.

Geo Extension

This extension provides geo data related functionality such as checking whether a given geo coordinate is within a predefined geo-fence, etc. Following are the functions of the Geo extension.

Geo Coordinates function

Syntax<double, double, string> geocode (<string> location  )
Extension TypeStreamProcessor
DescriptionTransforms a location to its geo-coordinates (  longitude  and  latitude  ) and formatted address.
Examplegeocode(duplication rd) returns the following data with adherring latitude, longitude, and formattedAddress attribute names respectively.
6.8995244d, 79.8556202d, "R A De Mel Mawatha, Colombo, Sri Lanka"

Reverse Geocode Stream Function

Syntax<object>geo:reversegeocode(<int,long,double,float>latitude, <int,long,double,float>longitude)
Extension TypeStream Function Processor
DescriptionTransforms latitude and longitude coordinates into precise address information.
Parameters

latitude: The input location specified in terms of latitude.

longitude: The input location specified in terms of longitude.
Return

The output object contains an array of string properties including the streetNumber, neighborhood, route, administrativeAreaLevelTwo, administrativeAreaLevelOne, country, countryCode, postalCode and formattedAddress in the given order.


However, all this information is not available for all the geo coordinates. For example, if the latitude and longitude represent a place in a forest, only the high level information such as the country is returned. N/A is returned for properties for which values cannot be obtained.
Examplegeo:reversegeocode(40.715229, -73.8564082) returns {"67-53", "Flushing", "Loubet Street", "Queens County", "New York", "United States", "US", "11375", "67-53 Loubet St, Flushing, NY 11375, USA"}