Siddhi Execution Extension - Geo

WSO2 is an open source application development software company focused on providing service-oriented architecture solutions for professional developers.

License

License

Categories

Categories

Geo Business Logic Libraries Geospatial Siddhi Machine Learning
GroupId

GroupId

org.wso2.extension.siddhi.execution.geo
ArtifactId

ArtifactId

siddhi-execution-geo
Last Version

Last Version

5.0.1
Release Date

Release Date

Type

Type

bundle
Description

Description

Siddhi Execution Extension - Geo
WSO2 is an open source application development software company focused on providing service-oriented architecture solutions for professional developers.
Project Organization

Project Organization

WSO2

Download siddhi-execution-geo

Dependencies

compile (5)

Group / Artifact Type Version
io.siddhi : siddhi-core jar 5.0.0
org.apache.log4j.wso2 » log4j jar 1.2.17.wso2v1
org.apache.servicemix.bundles : org.apache.servicemix.bundles.geocoder-java jar 0.16_1
org.wso2.carbon.datasources : org.wso2.carbon.datasource.core jar 1.1.8
org.jacoco : org.jacoco.agent jar 0.7.9

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.8

Project Modules

There are no modules declared in this project.

Siddhi-execution-geo

The siddhi-execution-geo extension is an extension to Siddhi that 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.

Find some useful links below:

Latest API Docs

Latest API Docs is 5.0.1.

How to use

Using the extension in WSO2 Stream Processor

  • You can use this extension in the latest WSO2 Stream Processor that is a part of WSO2 Analytics offering, with editor, debugger and simulation support.

  • This extension is shipped by default with WSO2 Stream Processor, if you wish to use an alternative version of this extension you can replace the component jar that can be found in the <STREAM_PROCESSOR_HOME>/lib directory.

Using the extension as a java library

  • This extension can be added as a maven dependency along with other Siddhi dependencies to your project.
     <dependency>
        <groupId>org.wso2.extension.siddhi.execution.geo</groupId>
        <artifactId>siddhi-execution-geo</artifactId>
        <version>x.x.x</version>
     </dependency>

Jenkins Build Status


Branch Build Status
master Build Status

Features

  • findCityFromIP (Function)

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

  • findCountryFromIP (Function)

    This function returns the country that is related 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.

  • geocoordinate (Stream Function)

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

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

Dependencies

In order to use the functions supported by this extension, import the latest geo location data to the LOCATION and BLOCKS tables as follows:

  1. First, create an account in the Maxmind site.

  2. Then log in to the Maxmind site using your newly created credentials via the Login Form.

  3. Download the geoip-2-csv-converter that is compatible with your operating system from the maxmind/geoip2-csv-converter github repository.

  4. Download and install a database type of your choice. Then start it, and create the required database and tables as follows:

    !!!info
        This example uses MySQL.
    
    1. Create a database named GEO_LOCATION_DATA.

    2. To create the required tables in the database, execute one of the following scripts.

      It creates two tables named BLOCKS and LOCATION.

      !!! info - In this example, mysql.sql database script is executed. - To execute the database script, you can use MySQL Workbench. For detailed instructions to run the database script, see MySQL Documentation - The Workbench Scripting Shell.

  5. Prepare the database entries as follows:

    1. Unzip the latest CSV file and the geoip-2-csv-converter that you downloaded in the steps above.

    2. Run the update-geolocation-data.sh file by issuing the following command:

      sh update-geolocation-data.sh

    3. Enter the path to the extracted GeoLite2-City-Blocks-IPv4 directory that you downloaded as the response for the Enter path to GeoLite2-City-Blocks-IPv4 directory: prompt (e.g., /<PATH_TO>/GeoLite2-City-CSV_20171107).

    4. Enter the path to the geoip2-csv-converter directory as the response for the Enter path to geoip2-csv-converter home directory: prompt (e.g., /<PATH_TO>/geoip2-csv-converter-v1.0.0).

Once the script is executed, you can find the final.csv file inside your current directory.

  1. Import the data as follows:

    1. To import the final.csv file (which you previously generated) into the BLOCKS table, issue the following command after logging into the MySQL console.

      load data local infile '[PATH_TO_FINAL.CSV]/final.csv' into table BLOCKS
       fields terminated by ','
       enclosed by '"'
       lines terminated by '\n'
       (network_cidr, network, broadcast, geoname_id, registered_country_geoname_id, represented_country_geoname_id, is_anonymous_proxy, is_satellite_provider, postal_code, latitude, longitude, network_blocks);
      
    2. To import the GeoLite2-City-Locations-en.csv file located inside the extracted geoip-2-csv-converter directory (e.g., geoip-2-csv-converterGeoLite2-City-CSV_2017110) into the LOCATION table, issue the following command.

      load data local infile '[PATH_TO_GeoLite2-City-Locations-en]/GeoLite2-City-Locations-en.csv' into table LOCATION
       fields terminated by ','
       enclosed by '"'
       lines terminated by '\n'
       (geoname_id, locale_code, continent_code, continent_name, country_iso_code, country_name, subdivision_1_iso_code, subdivision_1_name, subdivision_2_iso_code, subdivision_2_name, city_name, metro_code, time_zone);
      
  2. Restart the Streaming Integrator. You have now updated the Geo Location Data Set.

How to Contribute

Contact us

Support

  • We are committed to ensuring support for this extension in production. Our unique approach ensures that all support leverages our open development methodology and is provided by the very same engineers who build the technology.

  • For more details and to take advantage of this unique opportunity contact us via http://wso2.com/support/.

org.wso2.extension.siddhi.execution.geo

WSO2 Extensions

Versions

Version
5.0.1
5.0.0
4.1.0
4.0.20
4.0.19
4.0.18
4.0.17
4.0.16
4.0.15
4.0.14
4.0.13
4.0.12
4.0.11
4.0.10
4.0.9
4.0.8
4.0.7
4.0.6
4.0.5
4.0.4
4.0.3