Real-time hangout detection with Streaming Geospacial Analytics

Share this post:

We are happy to announce today that the Geospatial Analytics service in IBM Bluemix (powered by Streaming Analytics) now supports real-time hangout detection.

Hangout is a concept in geospatial analysis where an entity is said to be hanging out or in a hangout if it has been dwelling in the same region for a specified period of time.  Once an entity (for example, a smartphone or a vehicle) has been in a region longer than a specified dwell time, it is considered to be hanging out in that region.  You can use hangout detection in a variety of mobile device and Internet of Things (IoT) scenarios, including:

  • Marketing: Offering real-time promotions to people who remain in a particular area for a significant period of time.
  • Intelligence: Are two ships passing in the night, or are they hanging out together, possibly indicating some nefarious activity?
  • Transportation: Has a vehicle in your fleet made its stops at the anticipated locations?

Two options for real-time hangout detection

Bluemix developers have two options available to fulfill their requirements for real-time hangout detection.

Option 1 – Using the Geospatial Analytics microservice:

  • All you need is your Bluemix application and the Geospatial Analytics service.
  • Your application controls the service through the Geospatial Analytics REST API.
  • Geospatial Analytics provides the geofencing and hangout functions required by your application.
  • The advantage of this approach is that you don’t have to write your own analytic application. You are leveraging the analytic functions provided by a prebuilt Streams application that provides the analytics for the Geospatial Analytics micro service.

Option 2 – Using the Streaming Analytics Platform-as-a-Service (PaaS):

  • You build a custom analytic application that does exactly what you need.
  • Your application can use building blocks from the Streams Geospatial toolkit to implement hangout, geofencing, and map matching. It also provides a rich set of functions for location data manipulation, determining distances, figuring out if geometries intersect, and more.
  • The advantages of this approach are both function and flexibility. Your analytic application is open to use any of the features of the Streams Geospatial Toolkit, and you can combine your geospatial analysis with any other analytics and features offered by the the Streams platform.

Detect hangouts using Geospatial Analytics

Geospatial Analytics is a microservice that provides real-time geofencing in addition to the new hangout support. With Geospatial Analytics, you ingest a stream of device data containing location attributes.  The service monitors the locations of these devices with respect to a dynamic set of  geographic regions, detecting geofencing as well as hangout events.

A starter application exists for Geospatial Analytics, and it has been updated to utilize the new hangout feature of the service. The geo-starter application is a Node.js application that you can deploy to Bluemix to experiment with the Geospatial Analytics service.  In the modified geo-starter application, one of four monitored regions has hangout detection turned on, so the app produces Hangout events, in addition to Entry and Exit (geofencing) events.

Below is two partial screen shots from the geo-starter application. At the top is a snippet from the geo-starter-visualizer showing car 54 hanging out in the region outlined in red. At the bottom is a portion of the geo-starter event list, showing hangout events for car 54 along with some geofencing events for other vehicles. Once a device is determined to be hanging out, each subsequent report of its location while remaining in the region will trigger another hangout event.


To explore the geo-starter application, try the running starter application utilizing the new hangout support. Also see the following references:

Geospatial Analytics and Watson IoT

The Geospatial Analytics service depends on an MQTT message broker to handle the messaging between the service and the devices.  Most users of  Geospatial Analytics use the Watson IoT service in Bluemix to fulfill this requirement.  The figure below shows a Bluemix application using the Geospatial Analytics and Watson IoT services together to monitor for geofencing and hangout events:


The Bluemix application shown above (written in Node.js) is bound to the IoT Platform and Geospatial Analytics service.  Devices publish telemetry messages to the IoT Platform service over the MQTT protocol.  Geospatial Analytics subscribes to these messages and analyzes them with respect to the current set of geographic regions that have been defined by the application.  The Geo service publishes geofencing and hangout events back to the IoT Platform service.  The Bluemix application subscribes to these events and takes the appropriate action when they occur.

The Build a connected-car IoT app with Geospatial Analytics tutorial provides a sample application that follows the architecture shown above.  It also provides a map-based visualizer showing the moving devices and allows you to create new regions from the visualizer.

Detect hangouts using Streaming Analytics

Streaming Analytics is a PaaS offering in Bluemix built upon the IBM Streams technology.  Streams is an advanced analytic platform allowing user-developed applications to quickly ingest, analyze, and correlate information as it arrives from a wide variety of real-time sources.  If your application requires hangout detection in addition to other types of real-time analytics, it makes sense to build a custom analytic application and deploy it to the Streaming Analytics service in the Bluemix cloud.  The Streams platform provides a highly scalable runtime to host your analytic applications, and Streams provides many real-time analytic toolkits, offering hundreds of analytic building blocks to choose from.  For an example of a Streams application using analytics from the geospatial toolkit, see the post Real-time Map Matching in Streaming Analytics Service.

Streaming Analytics and Watson IoT

Like Geospatial Analytics, the Streaming Analytics service is also tightly integrated with Watson IoT.  Streaming Analytics can quickly ingest, analyze, and correlate the events published by IoT devices, on the IBM Watson IoT Platform.  See Integrating Streaming Analytics with the Watson IoT Platform for a recipe demonstrating how to use the two services together.

In addition to running analytics on Watson IoT data in the cloud, the Apache Quarks project allows you to run analytics embedded in gateways and small footprint edge devices.  Streaming Analytics, Watson IoT and Apache Quarks form a trifecta of technologies that deliver a hierarchy of analytic processing, providing the ability to react locally to events while also allowing centralized analytic processing across devices.  For an end-to-end example of this type of use case, see the tutorial Connect Apache Quarks on Pi to the Streaming Analytics Service.

Add Comment
One Comment

Leave a Reply

Your email address will not be published.Required fields are marked *


Excellent idea, now, just need back information to “car”, a system in car should read this, and suggest to driver a “change way” based in systems decisions.

More Data Analytics stories

Upcoming changes to RStudio in Db2 Warehouse on Cloud

We've decided to deprecate built-in support of RStudio in all existing and future Db2 Warehouse on Cloud deployments starting April 24th, 2018, in favor of having DSX as an single, collaborative hub for your data science workflow.

Continue reading

Cloud Functions: Easy Database Setup the Serverless Way

A tutorial I wrote, featuring a database-backed Slack chatbot, is now live. It uses Db2 as database system to store event data. The client accessing the database is written in Node.js and is implement with IBM Cloud Functions in a serverless way. During the development of that tutorial I faced the question on how to perform the database setup. Should I guide users through the user interface to create a table and insert data? Should they install a Db2 client and execute a script locally? I solved the problem in a serverless fashion. Here are the details.

Continue reading

Database-driven Slack chatbot with Conversation service

Ever wanted to build a Slackbot, a chatbot integrated into Slack, on your own? I am going to show you how easy it is to integrate Slack or Facebook Messenger with the IBM Watson Conversation service. As a bonus, the bot is going to access a Db2 database to store and retrieve data. The code in the tutorial uses a serverless fashion with IBM Cloud Functions.

Continue reading