RoadAmp.com SatNav (POC)12/09/24 PermalinkThis is a proof-of-concept SatNav application that uses real-time data from Highways England to plot routes. It's a Full Stack Java/Javascript/HTML/CSS/JSON software from server up to display icons.
Some of the features:
- JSON "tiles" that are translated from OpenStreetMap's XML format. These have the capability of being runtime modifiable rather than the traditional baked bitmap approach. The browser essentially interprets the raw data and draws it onto a HTML canvas rather than just rendering a static bitmap. It means you can alter display preferences at runtime. Turn features different colours, add new roads, new buildings etc.
- The SatNav uses real-time Highways England data to calculate where there's slower than usual traffic and auto selects an alternate route if needed.
- Plenty POIs (Places of Interest) have been added as separate API calls. Parking, shops, speed cameras, petrol stations etc.
This took a lot of work. No, seriously, a lot. The size of just the UK taken from OpenSteetMap's xml format is huge and you need significant RAM to associate the data and make sense of it. You can't just use a standard xml parser, you need to stream the input - it's essentially a huge data dump of points and areas that won't fit into memory. You need to then convert these points and areas into individual json "tiles" at various zoom levels. Big data.
Then you need to think about the front-end. The browser has the data it needs but you need to utilise caching because you don't want to be constantly re-drawing stuff. So the browser would store a previously drawn tile and pull from cache when needed.
The SatNav part also took a lot of work. The data gets sent in XML format which was parsed into Sensor and Measurement objects and these were scanned real-time to dump anomalies in traffic flow. These are then ranked in a severity list of slow roads. This data is also integrated into a GraphHopper route finder to calculate fastest routes using live data. A lot of data crunching involved.
Because the map is web-based it can be run on a mobile phone but it was ran from a http server not https, so I had to build an Android app with WebView that would call the WebView's javascript with GPS coordinates (with https you can use the navigator.geolocation.getCurrentPosition(showPosition) directly and just use your usual browser). I also wanted the map to orientate with the direction of the vehicle so bearing data was converted to radians and used to rotate the whole map's context (the map is essentially a context holding many contexts).
I could go into a lot finer detail about coding decisions based on performance and resource usage but maybe that's for another day. Anyway, here's a video of the POC that demonstrates the service:
Play the video here.
|