Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Location-based services services (LBS) uses real-time location or geo-data from devices to monitor and track devices. The  The geo extension in WSO2 IoT Server provides real-time information about geospatial objects. It processes spatial data from an external source of events and analyzes/manipulates this data to produce meaningful information to end users. You can interact with it to generate a variety of alerts and warnings. 

You can specify a geo area and if the configured device comes into the specified area, an alert is generated.
Alert type
Description
Within alert (Enter fence alert)Description
Exit fence alertYou can specify a geo area and if the configured device leaves the specified area, an alert is generated.
Speed Within alert (Enter fence alert)You can specify a maximum speed limit for the movement of the device. If the device exceeds the specified speedgeo area and if the configured device comes into the specified area, an alert is generated.
Stationery alert You can specify a geo area, a fluctuation radius, and a time, which generates an alert if the configured device is located in that area during the specified time. The fluctuation radius is used to minimize the fluctuation effect of the device.
Speed alertYou can specify a maximum speed limit for the movement of the device. If the device exceeds the specified speed, an alert is generated.

The following sections guide you through installing the geo extension, using geofencing, and setting up alerts. 

...

  1. Download the WSO2 IoT Server.

    Tipnote

    If you are running WSO2 IoT Server already, stop the server before proceeding to the next step.

  2. Navigate to the <IOTS_HOME>/wso2/analytics/scripts folder directory and run the following command. This installs the required geo extension feature to WSO2 IoT Server.

    Code Block
    mvn clean install -f siddhi-geo-extention-deployer.xml
  3. Open the cdm-config.xml file found in the in the <IOTS_HOME>/conf folder  folder and set the following properties under the <GeoLocationConfiguration> tag to true. 
    This enables the geo extension feature in WSO2 IoT Server.

    Code Block
    <GeoLocationConfiguration>
          <isEnabled>true</isEnabled>
          <PublishLocationOperationResponse>true</PublishLocationOperationResponse>
    </GeoLocationConfiguration>
  4. Start the WSO2 IoT Server core and analytics profiles and sign in to the WSO2 IoT Server Device Management Console.

    Expand
    titleClick here for more information.
    Panel
    borderColor#11375B
    bgColor#ffffff
    borderWidth2
    1. Start the WSO2 IoT Server broker profile.

      Code Block
      cd <IOTS_HOME>/bin
      sh broker.sh
    2. Start the WSO2 IoT Server core profile.

      Code Block
      cd <IOTS_HOME>/bin
      sh iot-server.sh
    3. Next, start the WSO2 IoT Server analytics profile.

      Code Block
      cd <IOTS_HOME>/bin
      sh analytics.sh
    4. Access the device management console.

      • For access via HTTP:

     
      • http://<IOTS_HTTP_HOST>:9763/devicemgt/ 

        For example:
     http
      •  http://localhost:9763/devicemgt/
      • For access via secured HTTP:
     
      • https://<IOTS_HTTPS_HOST>:9443/devicemgt/ 
        For example:
     https
      •  https://localhost:9443/devicemgt/ 
    1. Enter the username and password, and sign in.

      Info

      The system administrator will be able to log in using admin for both the username and password. However, other users will have to first register with

    IoTS
    1. WSO2 IoT Server before being able to log into the

    IoTS
    1. IoT Server device management console. For more information on creating a new account, see Registering with WSO2 IoT Server.

      Image Modified

    Click 
    1. Click LOGIN. The respective device management console will change, based on the permissions assigned to the user.
      For example, the device management console for an administrator is as follows:

      Image Modified
    Tip
    titleDeploying in a multi-tenant environment

    The geo analytics artifacts are deployed by default in the WSO2 IoT Server super tenant. However, if you are setting up geofencing in a multi-tenant environment, you have to deploy the geo analytics artifacts in each tenant. 

    1. Login Log in to the device management console using the tenant credentials.

    2. Click on the menu Image Added button Image Removed and select Configuration Management>Platform Management > Platform Configurations.

    3. Click the Deploy Geo Analytics Artifacts button. You If required, you can also use this button to redeploy re-deploy the geo analytics artifacts in the super tenant mode if required.
      Image RemovedImage Added
  5. Enroll a device. For this tutorial, Let's enroll an Android device has been enrolled. 

    tip

    for this tutorial.

    Info

    For more information on how to enroll an Android device, see Android.

    For more information on how to enroll other sample device types, see Enrolling Sample Devices

  6. Access the geofencing map for the device you just enrolled by doing the following:
    1. Click the menu iconImage Removed Image Added icon, and then click Device Management.
    2. Click view on the device you just enrolled and select the Location tab. 

...

Geofencing alerts allow users to set up triggers a pop-up alert when alerts when a device enters or exits the defined geometry boundaries defined by the user. You can set up the following alerts using the WSO2 IoT Server geo extensionextensions.

Table of Contents
maxLevel4
minLevel4

...

A geofence exit alert notifies the user when the device leaves the specified geofence area. For example, a school administrator may set a geofence exit alert for the school laboratory's tablet devices so that when a device leaves the school premises, the admin is alerted and can disable the device. 

Follow the steps given below to define a geo area and set up a geofence exit alert. 

  1. Click on the Add Geofence Exit Alert button. 
  2. Define a geo area.

    Expand
    titleClick to see more information
    Panel
    borderColor#11375B
    bgColor#ffffff
    borderWidth2

    There are two ways to define a geofence area.

    • Draw area - Draw an area on the map to set the boundaries of the geofence.
    • Enter area - Enter a geoJSON containing coordinates to set the boundaries of the geofence. You can import a geofence using this option.
    Draw area
    1. Click Draw Area.
      Image Modified
    2. Select a shape (pentagon or square) on the drawing palette
    found
    1. that is on the left corner of the map.
      Image Modified
    2. Select the points on the map to draw a pentagon geofence, or click and drag to draw a square

    or circle
    1. geofence.

      Image Modified
    Enter an appropriate name for the geofence, and click Save
    1. Enter an appropriate name for the geofence, and do one of the following actions:

      1. Click Save to save your geofence.

      2. Click Edit to edit the geoJSON that is generated when you draw the geofence.
      3. Click Export to export the geofence and download a geoJSON file. You can use this file to import the same geofence to a different device.
    Enter area (Import area)

    To enter or import an area using a geoJSON, you have to first draw an area using the map, as shown above, and then export it.

    Tip

    Entering an area using a geoJSON is

    particularly

    useful when you want to import the exact same geofence for another device or another system. You can draw the geofence in the first device and then copy over the same fence with the exact coordinates to define the same geofence for a different device.

    1. Draw an area using the map, as shown above.
    2. Enter an appropriate name for the geofence and click Export. A geoJSON file
    will be downloaded
    1. downloads on to your machine.
    2. Open the JSON file and copy the JSON code.
    3. Click Enter Area.

    1. Image Modified
    2. Do one of the following to import the geofence:
      • Click Choose File and select the JSON file you exported in step b. Click Import.

      • Enter the JSON you copied in step c to define the geofence boundary and click Import.The code block below shows a sample JSON.

        Code Block
        {
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            79.85129186650738,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.910663750244661
                        ]
                    ]
                ]
            }
        }

Geofence enter alert

A geofence enter alert notifies the user when the device enters the specified geofence area. For example, an employer may set up a geofence enter alert to a room that contains files with highly classified information in them to notify him or prevent certain employees with restricted access from entering the room. 

...

  1. Click on the Add Geofence Enter Alert button. 
  2. Define a geo area.

    Expand
    titleClick to see more information
    To adjust the coordinates or the geofence
    1. drag to draw a square geofence.

      Image Added
    2. Enter an appropriate name for the geofence, and do one of the following actions:

      1. Click Save to save your geofence.

      2. Click Edit to edit the geoJSON that is generated when you draw the geofence.
      3. Click Export to export the geofence and download a geoJSON file. You can use this file to import the same geofence to a different device.
    Enter area (Import area)

    To enter or import an area using a geoJSON, you have to first draw an area using the map, as shown above, and then export it.

    Panel
    borderColor#11375B
    bgColor#ffffff
    borderWidth2

    There are two ways to define a geofence area.

    • Draw area - Draw an area on the map to set the boundaries of the geofence.
    • Enter area - Enter a geoJSON containing coordinates to set the boundaries of the geofence. You can import a geofence using this option.
    Draw area
    1. Click Draw Area.
      Image Modified
    2. Select a shape (pentagon or square) on the drawing palette found on the left corner of the map.
      Image Modified
    3. Select the points on the map to draw a pentagon geofence, or click and

    drag to draw a square or circle geofence. Image Removed

    Enter an appropriate name for the geofence, and click Save.

    Tip
    Tip

    Entering an area using a geoJSON is

    particularly

    useful when you want to import the exact same geofence for another device or another system. You can draw the geofence in the first device and then copy over the same fence with the exact coordinates to define the same geofence for a different device.

    1. Draw an area using the map, as shown above.
    2. Enter an appropriate name for the geofence and click Export. A geoJSON file
    will be downloaded
    1. downloads on to your machine.
    2. Open the JSON file and copy the JSON code.
    3. Click Enter Area. Image Modified
    4. Do one of the following to import the geofence:
      • Click Choose File and select the JSON file you exported in step b. Click Import.

      • Enter the JSON you copied in step c to define the geofence boundary and click Import.The code block below shows a sample JSON.

        Code Block
        {
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            79.85129186650738,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.910663750244661
                        ]
                    ]
                ]
            }
        }

Stationary alert

Stationary alerts notify the users about the state changes of a device in a predefined geo area. If a device remains stationed within the predefined defined geo area for a predefined specific time period of time, an alert is generated. For example, you can use this alert to track a lost phone that you may have left in a taxi cab or a public bus. When the device stops moving, you can identify the taxi/bus location and retrieve your phone. 

  1. Click on the Add Stationary Alert button. 
  2. Define a geo area.

    Expand
    titleClick to see more information
    Panel
    borderColor#11375B
    bgColor#ffffff
    borderWidth2

    There are two ways to define a geofence area.

    • Draw area - Draw an area on the map to set the boundaries of the geofence.
    • Enter area - Enter a geoJSON containing coordinates to set the boundaries of the geofence. You can also import a geofence using this option.
    Draw area
    1. Click Draw Area.
      Image Modified
    2. Select a shape (pentagon, square, or circle) on the drawing palette found on the left corner of the map.
      Image Modified
    3. Select points on the map to draw a pentagon

    geo-fence
    1. geofence, or click and drag to draw a square

    or circle
    1. geofence.

      Image Modified

    2. Enter the following details

    and click Save.
    1. :

      1. Fence name - Enter an appropriate name for the geo area.
      2. Fluctuation radius - Specify a radius. The fluctuation radius is used to minimize the fluctuation effect of the device.
      3. Time - The device should be stationary for the number of seconds specified in this field to generate a pop-up
    alert
      1. alert.
    1. Do one of the following actions:

      1. Click Save to save your geofence.

      2. Click Edit to edit the geoJSON that is generated when you draw the geofence.
      3. Click Export to export the geofence and download a geoJSON file. You can use this file to import the same geofence to a different device.
    Enter area (Import area)

    To enter or import an area using a geoJSON, you have to first draw an area using the map, as shown above, and then export it.

    Tip

    Entering an area using a geoJSON is particularly useful when you want to import the exact same geofence for another device or another system. You can draw the geofence in the first device and then copy over the same fence with the exact coordinates to define the same geofence for a different device.

    1. Draw an area using the map as shown above.
    2. Enter an appropriate name for the geofence and click Export. A geoJSON file will be downloaded on to your machine.
    3. Open the JSON file and copy the JSON code.
    4. Click Enter Area.

    1. Image Modified
    2. Do one of the following to import the geofence:
      • Click Choose File and select the JSON file you exported in step b. Click Import.

      • Enter the JSON you copied in step c to define the geofence boundary and click Import.The code block below shows a sample JSON.

        Code Block
        {
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            79.85129186650738,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.911776767011602
                        ],
                        [
                            79.85373804112896,
                            6.910663750244661
                        ],
                        [
                            79.85129186650738,
                            6.910663750244661
                        ]
                    ]
                ]
            }
        }

Speed alert

Speed alerts notify users when a device is traveling above the predefined speed limit. This alert does not require a geofence and is applied globally (wherever the device is located). For example, a system administrator for a taxi service may use this to monitor whether any of the taxi drivers are driving above the allowed speed limit. 

...

driving above the allowed speed limit. 

  1. Click on the Set Speed Alert button. 
  2. Specify a global speed limit (km/h). 
    Image Added

What's next?

  • You can customize the alert or set up the geo extension to send SMS/email alerts instead of pop-up alerts on the geo map. For more information on how to do this, see Extending and Customizing Location Based Services.
  • Try the Android Sense tutorial to connect an Android device to WSO2 IoT Server and monitor sensor data.