Live monitoring of ski tracks in Norway
Cross-country skiing
The problem • Snow grooming • Where does it occur and when? • A spatiotemporal problem
… alreaday solved? • Google, Runkeeper, Nike etc. • Ski-specific solutions: Skisporet.no ++ • … why do it?
Solution overview Server Web Application Snow groomer + Tracking unit
The solution • GNSS unit + network connection • A server • One developer • A bunch of open source projects
1. Tracking unit • Arduino • GPS/3G shield • Serial communication between the two • Wrote “C” application for Arduino • HTTP request to server
• 3D-printed case • Only (half-)useful thing I’ve done with it
2. Tracking server • Consume, store, analyze position updates => serve ski track info • PostGIS • Apache2 • Libpq • Php Apache PostGIS
Presenting tracks and time
Presenting tracks and time • One track can consist of many Segments segments • Two tracks can share segments • Segments can be split up into an arbitrary number of sub-segments TempSegments /w sub-segment • Based on “temporal segmentation” order info Track
4D-data in PostGIS • Each position in the network has X, Y, Z and M • Spatial + Temporal dimension • But not so easy to selectively update M-dimension of MultPoint and MultiLinestring..
PostgreSQL Extension • Quite easy if you keep to PL/PgSQL “programming” • Put SQL file + Control file in: /usr/share/postgresql/9.3/extension/ • CREATE EXTENSION langeland • Voila – new functions
Skitrack Extension • LS_BuildTimeline • LS_UpdateTimelineAtPoint • LS_NForMostRecentPoint • LS_SegmentMeanTime • +++ • LS_SplitTimeline • Splits up LINESTRINGZM based on temporal aggregation
Triggers Raw positions Segment TempSegment X – Y – Z - Time X – Y – Z - Time X – Y – Z - Time On insert Trigger: On update trigger: LS_BuildTempSegment LS_UpdateTimeline on Where SID = Segment.ID Segment table
Getting the data • Simple REST API with PHP • /langeland/spatiotemporal => Returns all temporary segments as geojson • /langeland/tracks => Returns the track metadata
3. Web client • Needs to visualize • Ski tracks themselves • Their temporal status • Leaflet – easy it use
Displaying 4D segments 1. Leaflet wont let us draw linestring with varying colours 2. This is why the temporary segment table is needed 3. Tiny, old server => would rather preprocess than generate on the fly
Deployment • November 2014 • Installed and test OK! • Wait for snow
Choices… • Call back tracker • Get new part on Ebay • (possibly?) fix and reinstall • $20 • Install
TK110 • Manual makes no sense • Setup using SMS commands • Is working, but sends wierd data • Server coding again..
• Written by Anton Tananaev from New Zealand • Supports pretty much every low-cost GPS tracker out there • Connects to MySQL, H2 and PostGIS • Now also allows you to use your cellphone • http://www.traccar.org/
Server structure New tracker “H02” Port 5003 Traccar PostGIS + Old tracker Custom Extension Apache2 HTTP POST + libpq
Web application
Tracks • Segments simply dumped to map • For track objects: • Iterate over it’s temporary segments • Append track colour to time bar • Add time + name
System overview Server PostGIS Web application Apache2 Traccar Track layer + Tracking unit
To summarize • Managed to create fully automated tracking system • Also learned: Cheap, optimized hardware from China can be better than my hobby Arduino projects
All thanks to really awesome FOSS(4G) • Traccar • PostGIS • Apache2 • Leaflet • Arduino
Thank you! Kjartan Bjørset kjabjo@norkart.no @kjartanb
Recommend
More recommend