I have been playing with Cesium off and on for a couple of weeks now, mostly with success. I'd like to start building my first "real" (i.e. non-trivial) application with Cesium, although it too will be a learning exercise.
The task I have given myself is to build an application for fleet tracking via GPS devices. That is, something that would record and be able to display the location tracks for up to a thousand vehicles (rental cars, or delivery trucks, or...) collected over time. I have written a simulator (using Cesium) that allows me to generate simulated vehicle positions along a route, reporting position (w/ velocity and acceleration vectors) at some regular interval, nominally every 10 seconds. All this goes into a mongoDB instance.
Now I want to get this stuff out of the DB and onto the map.
What about new position updates (i.e. a live view of where the vehicles are now)?
What if I want to turn off the display of the vehicle tracks and just see the data points? Does that change the answer?
I'm just trying to get a feel for how to proceed before diving in.
Thanks for any advice!
So glad you’re taking the think to think about architectural decisions! The answer with time dynamic data depends heavily on your use case. Based on what you’ve mentioned, seems like the way to go is to write a web service that will read data out of your MongoDB instances and generates CZML on the fly, returning this CZML data as a single response. For 1000 vehicles, CZML should compress really well if you enable gzip responses from your server. This CZML can then be loaded in Cesium to populate the scene with Entities, which you can then continue to process however you’d like. See the CZML load method: http://cesiumjs.org/Cesium/Build/Documentation/CzmlDataSource.html?classFilter=czm#.load
Your dataset sounds like it will be fine to load all at once, but if there were performance issues, you could have your Cesium application send requests for specific ranges of time. This would be similar to the first case, just instead of generating the CZML for the entire database, your server would get entries within a certain time range upon client request and send back the CZML for just that chunk.
Finally, if on top of the historical data you also want to receive realtime updates to your data, I would look into websockets. You can have your client listen at a websocket for new CZML data (which your server streams in as it is received and processed), then load that CZML also. In order to load the new data without clearing old values, you can use the process function: http://cesiumjs.org/Cesium/Build/Documentation/CzmlDataSource.html?classFilter=czm#process
Hope that helps! We’d be happy to provide more guidance if necessary.