For the past 3 years we have had several instances of our customers wanting to monitor transit assets from shipping vessels to transportation vehicles. Traditionally, we had monitored only fixed assets. However, large corporations would like to keep track of specific fixed and moving assets.
Currently, any asset's location can be updated through WeatherOps Commander. Making manual updates though for assets that move does not make sense for a company with a large number of assets to track, such as real-time location updates for vehicles or vessels. WDT built WeatherOps Commander for frictionless setup of assets whether they are in transit or stationary.
Introducing WeatherOps Asset Update API! Most transit tracking systems utilize a unique identifier. We now provide an interface to add your own unique identifier to any asset in WeatherOps Commander. After you sign up for our External Commander API, you will have access to an endpoint to send location updates for any of your asset locations. As an asset location updates within your infrastructure, you will be able to call our API and keep all asset locations synced.
To test this out, we worked with long term client, Oceaneering. They provided us access to a web socket that outputs real-time updates for fleets of vessels across the globe. Anytime we receive an event from the web socket, we will automatically update the location in commander. We have been running the application in real-time for the past month and have been receiving thousands of email notifications.
In our proof of concept, we used ws for the connection to the Oceaneering WebSocket. We also used hapi and nes to serve a WebSocket from which a client map will listen.
javascript //when we receive a message from the WebSocket function on_message_received(data, flags) { 'use strict'; try { var vessel = JSON.parse(data); if (vessel !== null) { //this is where we call the asset update API return update_vessel(vessel).then(function (res) { console.log(res.name + ' updated'); server.publish('/updates', vessel); }).catch(function (err) { console.error(err.stack); }); } } catch (err) { console.error(err); } }
While the entirety of the application can be internal and transparent to a client, we decided to build a small display. This map, built using LeafletJS, adds all of the vessels to the map and connects to our internal socket. From there, whenever an update occurs we will move the marker and change the color for a few seconds to show that an update happened.
javascript //when we receive a message from the internal socket function socket_handler(message) { if (message) { //lets see if this is on the map if (vessel_structure[message.properties.imo]) { var latlng = L.latLng(message.geometry.coordinates[1], message.geometry.coordinates[0]); vessel_structure[message.properties.imo].featureData = message; vessel_structure[message.properties.imo].layer.setLatLng(latlng); vessel_structure[message.properties.imo].layer.setStyle({ fillColor: "#fd3529" }); setTimeout(function () { vessel_structure[message.properties.imo].layer.setStyle({ fillColor: "#fd9f29" }); }, 1000); setTimeout(function () { vessel_structure[message.properties.imo].layer.setStyle({ fillColor: "#29F1FD" }); }, 2000); } else { //new vessel, time to add it to the data structure var new_vessel_geojson = L.geoJson(message, { onEachFeature: onEachFeature, pointToLayer: pointToLayer }); new_vessel_geojson.addTo(map); console.log("NEW VESSEL"); console.log(JSON.stringify(message)); console.log("/NEW VESSEL"); } console.log(message.properties.shipName + ' UPDATED'); } }
Here is a small animation of what our map looks like in action:
On-shift meteorologists can monitor their fleet as they are moving around the globe. Daily Planners and Weather Checks will be generated using the most up-to-date location. NWS Watches and Warnings, Halo, and Lightning Alerts will follow wherever the asset moves. And soon, we will tie in the Alerting Engine's powerful moving-into alerts. If a vehicle or vessel location moves into an active alert, you will receive notification.