Using Geofences for Location-based Analytics

A geo fence is a virtual boundary in a real world geographical area. This virtual boundary can be used to find the object’s position or location, with respect to the geo fence.

For example, the object position can be:

Selecting a Tile Layer

Tile layer is the base map that provides immediate geographic context. Tiles are stored in the map tile server. These tile layers contains huge amount of data pertaining to:

Oracle GoldenGate Stream Analytics supports four types of tile layers.

Elocation Tile Layer

Elocation tile layer is an Oracle tile layer.

To apply the Elocation Tile Layer:

  1. Click the user name in the top right corner of the screen.

  2. Click Preferences. The Preferences page opens.

  3. Click Map.

  4. Under Tile Layer, choose Elocation Tile Layer option from the drop-down list.

    Description of the illustration elocationtilelayeroptions.png

  5. Click Save. The map looks like this:

    Description of the illustration tilelayer_4.png

Open Street Maps Tile Layer

Open Street Maps tile layer is a free map.

To apply the Open Street Maps Tile Layer:

  1. Click the user name in the top right corner of the screen.

  2. Click Preferences. The Preferences page opens.

  3. Click Map.

  4. Under Tile Layer, choose Open Street Maps Tile Layer option from the drop-down list.

    Description of the illustration tilelayer_1.png

  5. Click Save. The map looks like this:

    Description of the illustration tilelayer_2.png

Google Maps Tile Layer

Oracle Stream Analytics has added the support for Google tile layer which displays Google maps in Spatial patterns and visualizations.

To apply the Google Tile Layer:

  1. Click the user name in the top right corner of the screen.

  2. Click Preferences. The Preferences page opens.

  3. Click Map.

  4. Under Tile Layer, choose Google Maps Tile Layer option from the drop-down list.

    Google Maps Tile Layer

  5. Provide details for the following fields:

  6. Click Save.

Note: To use Google maps tile layer, the usage of the maps must meet the terms of service defined by Google (http://code.google.com/apis/maps/faq.html#tos).

Custom Tile Layer

Oracle Maps, by default, supports Elocation tile layer which has limited zoom levels. Stream Analytics Oracle Stream Analytics now allows you to customize the zoom levels for a tile layer, in specific cases where you need a detailed, higher zoom view of confined spaces such as, restaurants, airports, etc.

To apply the Custom Tile Layer:

  1. Click the user name in the top right corner of the screen.

  2. Click Preferences. The Preferences page opens.

  3. Click Map.

  4. Under Tile Layer, choose Custom Tile Layer option from the drop-down list.

    Custom Tile Layer

  5. Provide details for the following fields:

    • Map Viewer Url — http://yourmapviewer => another address where you have an Oracle map viewer running

    • Data Source — a connection to a database where you define your style. It should be an OSA data source, or a custom one which allows to define our maps via mapbuilder.

    • Tile Layer Name — name of the defined tile layer

  6. Click Save. The map looks like this:

    Custom Tile Layer Map View

Note: Once you have modified the global parameters to customize the tile layer, the map is updated to use the custom tile layer. These customizations, will then be applied to all geofences.

Managing Geofences using the Map Editor

You can create, edit, and update manual geofence using the built-in map editor. Only polygon geo fences are allowed.

Creating a Geo Fence

To create a manual geo fence:

  1. On the Catalog page, click Create New Item and select Geo Fence from the drop-down list.

  2. On the Type Properties screen, enter the following details:

    • Name

    • Description

    • Tags

    • Geo Fence Type: Select Manually Created Geo Fence from the drop-down list.

  3. Click Save.

    In the Geo Fence Editor:

    • You can create the geo fence.

    • Navigate through the map using the zoom icons

    • Zoom a specific area on the map, using the Marquee Zoom tool. Mark an area using the marquee zoom and that area in map is zoomed.

    • Mark the area around a region to create a geo fence, using the Polygon Tool.

      Description of the illustration create_geo_fence.png

    • Save the changes made to your geofence.

Deleting a Geofence

To delete a Manual Geofence:

  1. Go to the Catalog page and hover the mouse over the geofence that you want to delete.

  2. Click the delete icon that appears to your right side on the screen.

  3. On the Delete Confirmation screen, click Delete.

Importing a Geofence from a Database

To import a geo fence from a database:

  1. On the Catalog page, Create New Item and then select Geo Fence from the drop-down list.

  2. On the Type Properties screen, enter the following details:

    • Name

    • Description

    • Tags

    • Geo Fence Type: Select Geo Fence from Database from the drop-down list.

  3. Click Next.

  4. On the Geo Fence Details screen, select a Connection.

  5. Click Next.

  6. On the Shape screen, select a database table from the drop-down list. Only the database tables that contain SDO Geometry type fields are available in the drop-down list.

    You can also define or change the key fields on this screen.

  7. Click Save.

You can see all the geo fences contained in the selected database.

Note: You cannot edit or update database-based geo fences.

Using Spatial Patterns in Pipeline Stages

Spatial patterns enables analysis of streams that contain geolocation data. Use them to determine how events relate to predefined geo fences in your maps.

Clearing Objects Outside a Geo Fence

Use the Geo Filter pattern to filter out objects that are not inside the Geofence.

For example, if users move from one geographical location to another, you can send promotional messages to the users when they are inside a specified geo fence.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays Status and PlaceName as two extra columns in the output along with the incoming shape, where Status is Inside if the object is inside geo fence (else the event is not considered) and PlaceName is the name of geo fence with which status is being evaluated.

Tracking Objects using a Geo Fence

Use the Geo Fence pattern to track object relation with a virtual boundary called geo fence.

Relations can be Enter, Exit, Stay, or Near with respect to a geo fence. For example, you can trigger an alert when an object enters the geo fence. You can also analyze a stream containing geo-location data. It helps in determining how events are related to a polygon in a geo fence.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays Status and PlaceName as two extra columns in the output along with the incoming shape, where Status is one of Enter, Exit, Stay, or Near based on how the object behaves with geo fence. PlaceName is the name of geo fence with which status is being evaluated.

Getting Direction of a Moving Object

Use the Direction pattern to get the direction of a moving object.

For example, you can evaluate the direction of a moving truck.

To use this pattern, provide suitable values for the following parameters:

Note: Make sure that you do not use any names for the fields that are already part of the incoming stream.

The outgoing shape displays direction as one of the columns, which is of type String along with the incoming shape.

Obtaining Geographic Coordinates

Use the Geo Code pattern to get geographic coordinates (like latitude and longitude) for an address or a zip code.

Ensure that you have set the proxy details in System Settings.

To use this pattern, provide suitable values for the following parameters:

The output from the pattern are the latitude and longitude corresponding to the input.

Calculating Distance between Objects in a Stream

Use the Interaction: Single Stream pattern to get interaction of an object with every other object in a stream.

For example, you can see if a set of sailing ships are too close to each other.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape contains two more fields along with the incoming shape: isInteract and distance. isInteract is trueif two shapes interact with each other, i.e., any or some portion of the two objects overlap. distance between them is 0, if no overlapping is observed; isInteract is false and distance is shown between those two objects as a positive number.

Calculating Distance between Objects in Two Streams

Use the Interaction: Two Stream pattern to get interaction of an object in one stream with objects in another stream. Two shapes are said to interact with each other if any part of the shape overlaps. If two shapes interact, the distance between them is zero.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape contains two additional fields along with the incoming shape: isInteract and distance. isInteract is trueif two shapes interact with each other, i.e., any or some portion of the two objects overlap. distance between them is 0, if no overlapping is observed; isInteract is false and distance is shown between those two objects as a positive number.

Creating Geo Fence

Use the Point to Polygon pattern to create a Geo Fence using the default coordinate system, given the latitude, longitude, width, and length.

For example, if you know the length and breadth of a group of a fleet of ships, you can get the shape of a ship using the position coordinates, where the coordinates keep changing as the ship moves.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape contains derived shape (Rectangle/Polygon of type SDO_Geometry) of an event based on its coordinate (latitude,longitude) and dimension (length, width).

Monitoring Proximity between Objects in a Stream

Use the Proximity: Single Stream pattern to get proximity of each object with every other object in a stream.

For example, if there is stream of flying airplanes and the distance buffer is 1000 meters. You can raise an alert as the two planes come into a proximity of 1000 meters or less.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays distance as another column, which is the distance between two object under consideration along with the incoming shape.

Monitoring Proximity between Objects in Two Streams

Use the Proximity: Two Stream pattern to determine the proximity between object in stream 1 with all other objects in stream 2.

The distance buffer acts as a filter in this pattern stage. For example, if there is a driver and passenger stream, you can get the proximity of each passenger with every other driver using a filter criteria of within a distance of 1 km.

To use this pattern, provide suitable values for the following parameters:

Note: When a pipeline with this pattern has a database reference with cache enabled, the pattern does not display any output in the live output stream.

The outgoing shape displays distance as another column, which is the distance between two object under consideration along with the incoming shape.

Obtaining the Proximity of an Object from a Geo Fence

Use the Proximity: Stream with Geo Fence pattern to get proximity of an object with a virtual boundary or geo fence.

For example, if you have certain stores in the city of California, you can send promotional messages as soon as the customer comes into a proximity of 1000 meters from any of the stores.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays distance as another column, which is the distance between the object and geo fence under consideration along with the incoming shape.

Finding Nearest Place using the Geographical Coordinates

Use the Reverse Geo Code: Near By pattern to obtain nearest place for the specified geographical coordinates.

Ensure that you have set the proxy details in System Settings.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays PlaceName as an additional column along with the incoming shape. This column is the nearest place for specified longitude and latitude.

Finding Nearest Place Details using the Geographical Coordinates

Use the Reverse Geo Code: Near By Place pattern to obtain the near by location with granular information like city, country, street etc. for the specified latitude and longitude.

Ensure that you have set the proxy details in System Settings.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape displays additional columns for place corresponding to the coordinates (latitude,longitude)- houseNumber, street, city, region, country, and postal code.

Determining Average Speed

Use the Spatial: Speed pattern to determine the average speed using all data points from a time window. This pattern uses the default slide value. For example, to analyze the average speed of a car.

To use this pattern, provide suitable values for the following parameters:

The outgoing shape contains speed as an added field along with the incoming fields. This is a numeric field, but the speed is measured in miles per hour.