Skip to content

API Docs - v5.0.0

Geo

findCityFromIP (Function)

This function returns the city that is related to the given 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 country corresponding to 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 The basic location details. For example the 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 The location details including the longitude and the latitude of the location. 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".

geocoordinate (Stream Function)

The geocoordinate stream function returns the longitude and latitude values of a location relating to a given IPV4 or IPV6 address.

Syntax

geo:geocoordinate(<STRING> ip)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
ip The IP address for which the user needs the longitude and latitude values. STRING No No

System Parameters

Name Description Default Value Possible Parameters
apiurl ipInfoDB(https://www.ipinfodb.com/) provides an API toget information relating to an IP address based on their geolocation database.This API provides a URL to get the latitude and longitude of a given IP address. N/A N/A
Extra Return Attributes
Name Description Possible Types
longitude The longitude of the location corresponding to the given IP. DOUBLE
latitude The latitude of the location corresponding to the given IP. DOUBLE

Examples EXAMPLE 1

define stream IpStream(ip string); from IpStream#geo:geocoordinate(ip) select latitude, longitude insert into OutputStream;

This returns the longitude and the latitude of the given IPV4 or IPV6 address. The results for the geocoordinate(95.31.18.119) are 55.7522 and 37.6156.

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. For example, 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 required in order to derive at the location. DOUBLE No No
latitude The latitude value required in order to derive at the 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".