File tree Expand file tree Collapse file tree 3 files changed +31
-18
lines changed Expand file tree Collapse file tree 3 files changed +31
-18
lines changed Original file line number Diff line number Diff line change 57
57
; ; strategies for covering the distance effectively.
58
58
59
59
60
- ; ; This page has been composed with Clerk and rando-planner
60
+ ; ; This page was composed with Clerk and rando-planner
61
61
62
62
; ; You can see the code for the project [on
63
63
; ; github.com](https://github.com/larsen/rando-planner).
@@ -239,6 +239,12 @@ be morale-crushing."]])
239
239
{:nextjournal/width :full }
240
240
(clerk/with-viewer leaflet/leaflet-gpx-viewer equally-split-plan-with-pauses))
241
241
242
+ ; ; Additionally, you can focus the map on the portion of map
243
+ ; ; corresponding to a single day
244
+
245
+ (clerk/with-viewer leaflet/leaflet-gpx-viewer
246
+ (assoc equally-split-plan-with-pauses :focus-on " Second day" ))
247
+
242
248
; ; ## How plans are defined
243
249
244
250
; ; Examining an example, we'll provide a more formal definition of
Original file line number Diff line number Diff line change 5
5
6
6
(defn add-center-and-bounds [plan]
7
7
(if (:gpx plan)
8
- (let [points (gpx/points (:gpx plan))]
8
+ (let [points (gpx/points (:gpx plan))
9
+ grouped-by-day (plan/group-points-by-day plan)
10
+ points-to-focus-on (if (:focus-on plan)
11
+ (get grouped-by-day (:focus-on plan))
12
+ points)
13
+ center (gpx/center points-to-focus-on)
14
+ bounds (gpx/bounds points-to-focus-on)]
9
15
(assoc plan
10
16
:points points
11
- :grouped-by-day (plan/group-points- by-day plan )
12
- :center ( gpx/ center points)
13
- :bounds ( gpx/ bounds points) ))
17
+ :grouped-by-day (vals grouped- by-day)
18
+ :center center
19
+ :bounds bounds))
14
20
plan))
15
21
16
22
(defn add-plan-markers [plan]
Original file line number Diff line number Diff line change 98
98
(defn group-points-by-day [plan]
99
99
(let [points-with-cumulative-distance (gpx/with-cumulative-distance
100
100
(gpx/points (:gpx plan)))]
101
- (map (fn [d]
102
- (filter #(and (>= (:cumulative-distance %)
103
- (:covered d))
104
- (< (:cumulative-distance %)
105
- (+ (:covered d)
106
- (:kilometers d))))
107
- points-with-cumulative-distance))
108
- (daily-distance plan))))
101
+ (into {} (map (fn [d]
102
+ [(:label d)
103
+ (filter #(and (>= (:cumulative-distance %)
104
+ (:covered d))
105
+ (< (:cumulative-distance %)
106
+ (+ (:covered d)
107
+ (:kilometers d))))
108
+ points-with-cumulative-distance)])
109
+ (daily-distance plan)))))
109
110
110
111
(defn daily-stats
111
112
" Given a plan, it returns a list of dictionaries with info and
128
129
gpx/with-cumulative-distance)
129
130
daily-distance (daily-distance plan)
130
131
points-at-end-of-days (for [dk daily-distance]
131
- (first (filter (fn [p]
132
- (> (:cumulative-distance p)
133
- (+ (:covered dk)
134
- (:kilometers dk))))
135
- points-with-cumulative-distance)))
132
+ (first (filter (fn [p]
133
+ (> (:cumulative-distance p)
134
+ (+ (:covered dk)
135
+ (:kilometers dk))))
136
+ points-with-cumulative-distance)))
136
137
daily-pauses (vec (map
137
138
(fn [pauses]
138
139
{:pauses pauses})
You can’t perform that action at this time.
0 commit comments