Usually, geofences are all about drawing geometrics on a map using OpenLayers or Leaflet (open-source libraries to load, display and render maps). However, this can be really time consuming as you have to trace geofences manually. This can lead to errors and irregularities at different zoom levels of the map.

We thought we would simplify the process of creating an accurate geofence to help our clients search, customise, save and export geofences easily. We’ve made it possible to do a simple database search for a geofences based on existing OSM points of interest such as roads and buildings. This information can then be added to the map as a geofence, customised and saved for future use. To do this, we downloaded OSM data extract, imported it in PostgreSQL, and using imposm3 we made it possible to use POIs as geofences.

The Geofence API also makes it possible to create custom geofences drawn as points, lines or polygons. Users can set a buffer around the shape. You can then attach alert messages to geofences to notify you if an asset is in, out or near a marked area. This can be set up so that the geofence is only active at certain times of day.

The video below shows an asset in green moving along a set route with geofences shown in red acting as checkpoints along the way. As an asset moves in and out of the geofences, a notification appears at the bottom left.

Technically, we did this by using:

    • OpenStreetmap to collect data for a specific region
    • IMPOSM3 to import OSM data
    • Recently released Openlayers3 to draw geofences
    • PostgreSQL, PostGIS to store geofences
    • PostgreSQL & PostGIS queries to trigger alerts when an asset is in, out or close to geofence
    • Turf.js to simulate movement of assets on the map passing through different geofences