A solution for ingesting, enriching, storing, and retrieving live location data
What does this solution do?
Logistics providers need to continuously improve safety, efficiency and satisfaction for their customers. To achieve these goals, providers need to overcome three major problems:
- Operational visibility - A trucking company needs to respond to a mechanical problem with a vehicle. The company’s legacy system only describes the vehicle location at specific barcode checkpoints. Without an asset tracking solution, service operators must get on the phone to determine the exact vehicle location and dispatch a technician.
- Customer experience - A grocery delivery company needs to show customers exactly where their delivery is. Providing accurate and real-time ETA updates to customers reduces churn and increases adoption.
- Compliance and reporting - A rental car company has parking lots where vehicles are returned and restricted areas where they cannot operate. Without an asset tracking solution, they don’t know if a customer enters a restricted area or abandons a vehicle until they get fined by law enforcement.
The Mapbox asset tracking solution solves these problems by determining whether assets are on task, on time, and on location.
This solution deploys a pipeline using AWS infrastructure to ingest, enrich, store, and retrieve live location data. Data flows through the solution in four phases:
Phase 1: Data ingestion
Data is ingested into the pipeline from any device that measures and transmits location, such as an Automotive Vehicle Location (AVL) sensor or a mobile device with GPS. After AWS IoT Core ingests the data, it is forwarded to AWS Kinesis for processing.
This solution comes with a test IoT harness for sending sample messages into the pipeline. You can create your own asset application to measure and transmit location using the Mapbox Navigation SDKs for Android and iOS.
Phase 2: Data enrichment
Once the data has entered the Kinesis stream, an AWS Lambda function enriches each data point with geofence status and elevation. Geofences define areas of interest for your business that you want to track, such as no-park zones defined by the city government for a bike share application. Elevation data allows you to create route profiles from historical data for route planning, fuel optimization, and vehicle simulation.
Geofence status is added by querying the Mapbox Tilequery API, and polygon geofences are defined using the Mapbox Datasets Editor. High-precision elevation information is added by querying the Mapbox Terrain-RGB dataset from the Mapbox Raster Tiles API.
You can customize how your data is enriched in the AWS Lambda function. For example, you can call a third-party service such as the Mapbox Directions API to calculate traffic-aware ETAs. You can also retrieve business-specific information from a database, such as delivery time SLA's or package contents.
Phase 3: Data storage
Once enrichment is complete, the data is written to an AWS DynamoDB table and simultaneously archived to AWS S3. DynamoDB stores the current state of all assets, while S3 serves as a low cost, long-term archive for all historical data.
You can move data from S3 into a data warehouse for historical analysis. For example, you could identify frequent truck idling locations and the impact on fleet fuel efficiency in the past quarter.
Phase 4: Data retrieval
The data in DynamoDB can be consumed via a REST API powered by AWS API Gateway and AWS Lambda. The API transforms the data into GeoJSON using TurfJS for use with Mapbox GL JS.
You can build a live asset tracking dashboard or customer delivery status map using the API to retrieve data from DynamoDB. This solution includes a sample web dashboard which connects directly to the API and visualizes live asset location and state.
Source code can be found in the GitHub repository.
What you’ll need:
To deploy this solution you will need the following:
- Current Mapbox account and valid token:
You will need a public token to access Mapbox API services.
- AWS account:
You will need basic familiarity with Amazon Web Services (AWS). You will need an active AWS account with valid Access and Secret keys to deploy your infrastructure. If you do not have an AWS account, you will need to create an account and consult the AWS documentation for configuring CLI access.
You will be consuming services from Mapbox and AWS. You are responsible for any associated costs.
- Mapbox usage
Each message ingested into the pipeline will make a single call to the Raster Tiles API for elevation, and the Tilequery API for geofencing. The sample dashboard visualization consumes map loads. All services used in the solution are available on free tier. For more pricing details, consult the Mapbox pricing documentation.
- AWS usage
All infrastructure, except for Kinesis, is billed per request and is AWS Free Tier eligible. For more pricing details, consult the AWS Pricing documentation.
There is no charge for Pulumi usage.