56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
Reading a set of gpx files
|
|
==========================
|
|
|
|
# get all file names from some directory
|
|
|
|
query getDirectory('/home/ralf/Tracks', 2) transformstream filter[not(isDirectory(.Elem))] consume
|
|
|
|
let Raw = getDirectory('/home/ralf/Tracks') transformstream
|
|
filter[not(isDirectory(.Elem))]
|
|
addcounter[TrackId, 1]
|
|
loopsel[fun(t: TUPLE) gpximport(attr(t, Elem))
|
|
projectextend[Time, Lon, Lat, Ele; TrackId: attr(t, TrackId), Pos: makepoint(.Lon, .Lat)]]
|
|
consume
|
|
|
|
# create Trip and Altitude for each day. Filter out very long connections of two successive
|
|
# points from the raw data.
|
|
|
|
let twohours = [const duration value (0 7200000)]
|
|
|
|
let DayTrips = Raw feed
|
|
filter[.Lat > 50.0]
|
|
extend_last[Seg: makeline(.Pos, ..Pos)::[const line value undef]]
|
|
extend[Length: size(.Seg)]
|
|
filter[.Length < 0.001]
|
|
extend[
|
|
I: .Time + twohours,
|
|
Alt: .Ele]
|
|
sortby[TrackId, I asc]
|
|
groupby[TrackId
|
|
; DayTrip: group feed approximate[I, Pos, [const duration value (0 300000)]],
|
|
DayAlt: group feed approximate[I, Alt, [const duration value (0 300000)]] ]
|
|
consume
|
|
|
|
|
|
# alternative representation: split by trips
|
|
|
|
let Trips = DayTrips feed
|
|
projectextendstream[TrackId
|
|
; Trip: .DayTrip sim_trips[ [const duration value (0 300000)]] ]
|
|
extend[Traj: trajectory(.Trip)]
|
|
consume
|
|
|
|
|
|
|
|
# Match all trips
|
|
|
|
let MatchedTrips = Trips feed addcounter[No, 1]
|
|
extend[Matched: omapmatchmht(Edges, EdgeIndex_Box_rtree, EdgeIndex, .Trip) aconsume]
|
|
consume
|
|
|
|
# 407 seconds
|
|
# 169 Trips matched with 41294 units
|
|
|
|
# 2.4 secs per trip with 244 units per trip
|
|
|