|
|
@@ -0,0 +1,38 @@
|
|
|
+(defun doc->point (doc)
|
|
|
+ (geo:point-deg
|
|
|
+ (/ (get-element "latitudeE7" doc) 1d7)
|
|
|
+ (/ (get-element "longitudeE7" doc) 1d7)))
|
|
|
+
|
|
|
+(defun doc->ts (doc)
|
|
|
+ (local-time:unix-to-timestamp
|
|
|
+ (floor (get-element "timestampMs" doc) 1000)))
|
|
|
+
|
|
|
+(defun day-kv (date)
|
|
|
+ (let* ((ts (local-time:parse-timestring date))
|
|
|
+ (nd (local-time:timestamp+ ts 1 :day)))
|
|
|
+ ($between "timestampMs"
|
|
|
+ (* 1000 (local-time:timestamp-to-unix ts))
|
|
|
+ (* 1000 (local-time:timestamp-to-unix nd)))))
|
|
|
+
|
|
|
+(defun extract-places (docs)
|
|
|
+ (loop
|
|
|
+ for doc in docs
|
|
|
+ for point = (doc->point doc)
|
|
|
+ with last-place and moved and need-add
|
|
|
+ when last-place do (setf moved
|
|
|
+ (geo:distance>=
|
|
|
+ (geo:distance-between
|
|
|
+ point
|
|
|
+ (doc->point last-place))
|
|
|
+ (geo:distance-meters 200)))
|
|
|
+ when moved do (setf last-place doc
|
|
|
+ need-add t)
|
|
|
+ when (and need-add
|
|
|
+ (> (local-time:timestamp-difference
|
|
|
+ (doc->ts doc)
|
|
|
+ (doc->ts last-place))
|
|
|
+ 400))
|
|
|
+ collect (cons (doc->ts last-place) (doc->point last-place))
|
|
|
+ and do (setf need-add nil)
|
|
|
+ when (not last-place) do (setf last-place doc)
|
|
|
+ ))
|