Obtain, run, and extend a Node.js starter application that uses the IBM Cloud Geospatial Analytics service. With the Geospatial Analytics service, you can monitor moving devices from the Internet of Things. The service analyzes a device message stream from MQTT and tracks device locations in real time with respect to a set of dynamically defined geographic regions.

Introduction

The Internet of Things already connects billions of devices, with forecasts predicting steep growth rates in the coming years. Many of these devices, such as smartphones and connected vehicles, are mobile. Awareness of the location of on-the-move devices opens up exciting new application opportunities. Support for these new applications requires highly-scalable services that can analyze high volumes of data in real time.
With the Geospatial Analytics service in IBM Cloud™, you can monitor moving devices from the Internet of Things. The service tracks device locations in real time with respect to one or more geographic regions. Geospatial Analytics can be used as a building block in applications that support several use cases. For example, a retail business might want to monitor for potential customers nearby its stores and send them promotions via push notifications or tweets. Geospatial Analytics could also be used to detect connected motorists entering areas that they might want to avoid due to an accident, weather conditions, or other temporal event.

Application Overview

This tutorial explains how to obtain, run, and extend a starter application written in Node.js that uses the Geospatial Analytics service. The geo-starter app uses:
  • A generated set of device information for devices near Las Vegas, Nevada.
  • The Geospatial Analytics REST API to configure the service to subscribe to an MQTT message stream containing the device data. This subscription causes device location messages to flow to the service.
  • The Geospatial Analytics REST API to define a set of geographic regions for the service to monitor.
  • A demo instance of the Internet of Things Platform service in IBM Cloud that serves are the MQTT broker for both device location messages and any geospatial events (geofence, hangout) that are detected.
The Geospatial Analytics service analyzes the location of each device with respect to the set of geographic regions that are defined and sends a events back to MQTT.  Events are triggered for a region depending on its definition parameters.  You can define a region to detect any or all of the following conditions:
  • a device entering a region
  • a device leaving a region
  • a device hanging out in a region
The geo-starter app processes any triggered events and displays them in an event listing in its web UI.  It also provides a visualizer application that shows the current location of each device with respect to the geographic regions.  A high-level diagram of the different parts of the application is shown below.

Take a Look

To see the geo-starter app in action, access an already running copy of the app at:  https://geo-starter.mybluemix.net/
Access the map directly at http://geo-starter-visualizer.mybluemix.net

Run the App Yourself

You can obtain the source code for the app and run it yourself.  To do this, download the geo-starter zip file, unzip it, and follow the instructions in the README.md file to deploy it to IBM Cloud.

After you’ve successfully run the app, you can customize or extend it to get more familiar with the Geospatial Analytics service, or to adapt it to your own use case.  For example, you could:

  • Add or alter the geographic regions and the events they can trigger by modifying the parameters passed to the addRegion operation of the service’s REST API.
  • Take an action when a region-location event is received. For example, you might want to extend the application to send a push notification to a device when it enters a monitored region.
  • Switch to your own instance of the Internet of Things Platform service.  This will allow you to publish your own device information for analysis by the app.

To modify the app:

  1. Plan your modifications.
  2. Change the source code to reflect your desired customizations.
  3. Deploy the modified application by pushing the new version to IBM Cloud.

Conclusion

Keeping track of connected devices on the move is easier than it might seem.  With the Geospatial Analytics service, you can monitor the location of these devices in real-time with respect to geographic regions that are important to you. The starter application used in this tutorial demonstrates how you can control the Geospatial Analytics service to meet your requirements. With Geospatial Analytics, the potential for new location-aware applications in the Internet of Things is limitless, with you setting the boundaries.

4 comments on"Build a real-time location-monitoring application on IBM Cloud with Geospatial Analytics and Node.js"

Join The Discussion