Skip to content

API Docs - v4.0.18

Geo

findCityFromIP (Function)

This function returns the city that is related to the give IP address.

Syntax

<STRING> geo:findCityFromIP(<STRING> ip)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
ip The IP address of which the related city needs to be fetched. STRING No No

Examples EXAMPLE 1

define stream IpStream(ip string);
from IpStream
select geo:getCity(ip) as city
insert into outputStream;

This query returns the corresponding city of the given IP address.

findCountryFromIP (Function)

This function returns the country that is related to the given IP address.

Syntax

<STRING> geo:findCountryFromIP(<STRING> ip)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
ip The IP address of which the related country needs to be fetched. STRING No No

Examples EXAMPLE 1

define stream IpStream(ip string);
from IpStream
select geo:getCountry(ip) as country 
insert into outputStream;

This query returns the corresponding country of the given IP address.

geocode (Stream Function)

The geo code stream function uses basic details relating to a location (e.g., street name, number,etc.) as the input and returns the longitude, latitude, and the address of that location.

Syntax

geo:geocode(<STRING> location)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
location Location details(Street name, number etc.). STRING No No
Extra Return Attributes
Name Description Possible Types
longitude The longitude of the location. DOUBLE
latitude The latitude of the location. DOUBLE
address Location details. STRING

Examples EXAMPLE 1

geocode("5 Avenue Anatole France, 75007 Paris, France")

This query returns the longitude and latitude of the given location with the location details. The expected results are 48.8588871d, 2.2944861d, "5 Avenue Anatole France, 75007 Paris, France"

reversegeocode (Stream Function)

This extension transforms pairs of latitude and longitude coordinates into precise address information. The output contains string properties including the 'streetNumber', 'neighborhood', 'route', 'administrativeAreaLevelTwo', 'administrativeAreaLevelOne', 'country', 'countryCode', 'postalCode', and the 'formattedAddress' in the given order. However, this information is not available for all the geo coordinates. e.g., If the latitude and longitude represent a place in a forest, only the high level information such as the country is returned. In such scenarios, "N/A" is returned as the value for return attributes of which the values cannot be derived.

Syntax

geo:reversegeocode(<DOUBLE> longitude, <DOUBLE> latitude)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
longitude The longitude value of the required location. DOUBLE No No
latitude The latitude value of the required location. DOUBLE No No

Examples EXAMPLE 1

reversegeocode(6.909785, 79.852603)

This query returns the precise address information of the given location. In this example, it returns the following value:
 "27", "N/A", "Palm Grove", "Colombo", "Western Province", "Sri Lanka", "LK", "00300", "27 Palm Grove, Colombo 00300, Sri Lanka"