Build a Node-RED Dashboard which overlays TWC weather maps on a HERE truck routing map
This example might be useful for a package logistics company who wants to build logistics applications using TWC APIs that can help improve route planning, driver safety and equipment safety. Using The Weather Company APIs to alert drivers of storm warnings and forecasts, wind advisories, winter conditions, and real time driving updates can improve package delivery times and protect drivers.
It uses The Weather Company APIs to display a near real-time North America Satellite / Radar Weather map on a Node-RED Dashboard. It could be extended to display TWC forecast map tiles of winter advisories, hail alerts, wind conditions, etc.
This Node-RED flow retrieves map tiles from the TWC Current Conditions package and, specifically, the Current Conditions Gridded Tiler APIs. There are many TWC weather map tile layers available. One of the APIs returns satellite and weather radar tiles. See the Node-RED-TWC-Weather-Radar-Map repository for additional examples.
It also uses the HERE.com Routing APIs to build a map navigation dashboard and plots the truck route on a Node-RED Dashboard.
To assist the driver during hazardous driving conditions, it uses the Watson Text to Speech service to narrate the route.
This example flow and Node-RED Dashboard might be useful as part of a Call for Code solution that uses TWC and HERE Technologies APIs. Natural disaster applications could guide someone to safety.
- Install Node-RED on your system or in the cloud
- This flow can be deployed to IBM Cloud by creating a Node-RED Starter Application
- This flow requires Node-RED v1.3 or higher
- Add the following nodes to your Node-RED palette
- Signup for a HERE Developer account
- Signup for an IBM Cloud account
- Create a (free) instance of Watson Text to Speech
- If you are participating in the 2021 Call for Code you can register for a time limited TWC API key.
- Learn more about the TWC APIs used in this Node-RED flow by reading the TWC Current Conditions API documentation
Set your TWC API, HERE API and Watson Text to Speech keys as environment variables before starting Node-RED
export TWCAPIKEY=<TWC API KEY>
export HEREAPIKEY=<HERE API KEY>
export WATSON_TTS=<Watson Text to Speech API KEY>
Get the Code: Node-RED flow for Weather Logistics Routing / Navigation
This flow has four sections:
- The Starting and Destination Locations / Geocode section displays a Node-RED Dashboard form which prompts the navigator to enter their starting location and ending destination. The flow then calls the HERE Geocode Search API to determine the latitude and longitude of the two waypoints.
- The Request Driving Navigation Instructions section calls the HERE Routing API to calculate the route between the two locations. It builds a table of these driving instructions and displays a summary of the route distance and driving duration.
- The Draw Map and Route section moves the truck on the node-red-contrib-web-worldmap as the navigator clicks on the Navigation Preview button. It loads the TWC Weather Satellite Radar tile overlays onto the worldmap to warn the driver of impending weather conditions.
- The Read the Driving Instructions section determines if the mute slider is on / off and uses the Watson Text to Speech service to read the driving instructions aloud. Paste your Watson Text to Speech credentials into the node.
You might want to deploy this Node-RED flow to IBM Cloud Code Engine. The first step is to build a container. This repository includes a Makefile
and a Dockerfile
to assist in building a container.
-
Log into your Docker Hub account so the container can be hosted for Cloud deployment.
docker login
-
Edit the variable at the top of the Makefile, if necessary. If you plan to push it to a Docker registry, make sure you enter your docker ID.
-
Change the following
Makefile
line:DOCKERHUB_ID:=<your docker registry account>
-
-
Enter the TWC, HERE, Watson TTS API Keys in the .env file (see .env.example for formatting)
-
Build the container, run the container, test the Node-RED Dashboard in the container, push the container to the Docker registry.
make build make run make test make ui make push
Enjoy! Give us feedback if you have suggestions on how to improve this tutorial.
This tutorial is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.