gooby 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. data/README +133 -341
  2. data/config/ballantyne.yaml +11 -0
  3. data/config/big_sur_marathon.yaml +11 -0
  4. data/config/crowders_mtn_hike.yaml +11 -0
  5. data/config/davidson1.yaml +16 -0
  6. data/config/gooby_config.yaml +28 -135
  7. data/cucumber.yml +1 -0
  8. data/features/build_gem.feature +88 -0
  9. data/features/gooby.feature +300 -0
  10. data/features/install.feature +78 -0
  11. data/features/steps/gooby_steps.rb +245 -0
  12. data/features/support/env.rb +4 -0
  13. data/lib/gooby.rb +24 -30
  14. data/lib/gooby_activity.rb +63 -0
  15. data/lib/gooby_base_object.rb +46 -0
  16. data/lib/gooby_base_sax_parser.rb +95 -0
  17. data/lib/gooby_configuration.rb +33 -115
  18. data/lib/gooby_counter_hash.rb +28 -87
  19. data/lib/gooby_dttm.rb +88 -66
  20. data/lib/gooby_environment.rb +48 -0
  21. data/lib/gooby_garmin_tcx_parser.rb +92 -0
  22. data/lib/gooby_google_kml_generator.rb +168 -0
  23. data/lib/gooby_google_map_generator.rb +284 -349
  24. data/lib/gooby_gpx_parser.rb +97 -0
  25. data/lib/gooby_help_producer.rb +40 -0
  26. data/lib/gooby_introspection.rb +25 -0
  27. data/lib/gooby_io.rb +30 -0
  28. data/lib/gooby_lap.rb +27 -18
  29. data/lib/gooby_process.rb +281 -0
  30. data/lib/gooby_sax_path_parser.rb +43 -0
  31. data/lib/gooby_tcx_extractor.rb +71 -0
  32. data/lib/gooby_track_log_parser.rb +114 -0
  33. data/lib/gooby_trackpoint.rb +276 -0
  34. data/lib/gooby_xml_object.rb +40 -0
  35. data/{img/gicons → out/images}/blank.png +0 -0
  36. data/{img/gicons → out/images}/dd-end.png +0 -0
  37. data/{img/gicons → out/images}/dd-start.png +0 -0
  38. data/{img/gicons → out/images}/marker.png +0 -0
  39. data/{img/gicons → out/images}/marker0.png +0 -0
  40. data/{img/gicons → out/images}/marker00.png +0 -0
  41. data/{img/gicons → out/images}/marker01.png +0 -0
  42. data/{img/gicons → out/images}/marker02.png +0 -0
  43. data/{img/gicons → out/images}/marker03.png +0 -0
  44. data/{img/gicons → out/images}/marker04.png +0 -0
  45. data/{img/gicons → out/images}/marker05.png +0 -0
  46. data/{img/gicons → out/images}/marker06.png +0 -0
  47. data/{img/gicons → out/images}/marker07.png +0 -0
  48. data/{img/gicons → out/images}/marker08.png +0 -0
  49. data/{img/gicons → out/images}/marker09.png +0 -0
  50. data/{img/gicons → out/images}/marker1.png +0 -0
  51. data/{img/gicons → out/images}/marker10.png +0 -0
  52. data/{img/gicons → out/images}/marker11.png +0 -0
  53. data/{img/gicons → out/images}/marker12.png +0 -0
  54. data/{img/gicons → out/images}/marker13.png +0 -0
  55. data/{img/gicons → out/images}/marker14.png +0 -0
  56. data/{img/gicons → out/images}/marker15.png +0 -0
  57. data/{img/gicons → out/images}/marker16.png +0 -0
  58. data/{img/gicons → out/images}/marker17.png +0 -0
  59. data/{img/gicons → out/images}/marker18.png +0 -0
  60. data/{img/gicons → out/images}/marker19.png +0 -0
  61. data/{img/gicons → out/images}/marker2.png +0 -0
  62. data/{img/gicons → out/images}/marker20.png +0 -0
  63. data/{img/gicons → out/images}/marker21.png +0 -0
  64. data/{img/gicons → out/images}/marker22.png +0 -0
  65. data/{img/gicons → out/images}/marker23.png +0 -0
  66. data/{img/gicons → out/images}/marker24.png +0 -0
  67. data/{img/gicons → out/images}/marker25.png +0 -0
  68. data/{img/gicons → out/images}/marker26.png +0 -0
  69. data/{img/gicons → out/images}/marker27.png +0 -0
  70. data/{img/gicons → out/images}/marker28.png +0 -0
  71. data/{img/gicons → out/images}/marker29.png +0 -0
  72. data/{img/gicons → out/images}/marker3.png +0 -0
  73. data/{img/gicons → out/images}/marker30.png +0 -0
  74. data/{img/gicons → out/images}/marker31.png +0 -0
  75. data/{img/gicons → out/images}/marker32.png +0 -0
  76. data/{img/gicons → out/images}/marker33.png +0 -0
  77. data/{img/gicons → out/images}/marker34.png +0 -0
  78. data/{img/gicons → out/images}/marker35.png +0 -0
  79. data/{img/gicons → out/images}/marker36.png +0 -0
  80. data/{img/gicons → out/images}/marker37.png +0 -0
  81. data/{img/gicons → out/images}/marker38.png +0 -0
  82. data/{img/gicons → out/images}/marker39.png +0 -0
  83. data/{img/gicons → out/images}/marker4.png +0 -0
  84. data/{img/gicons → out/images}/marker40.png +0 -0
  85. data/{img/gicons → out/images}/marker41.png +0 -0
  86. data/{img/gicons → out/images}/marker42.png +0 -0
  87. data/{img/gicons → out/images}/marker43.png +0 -0
  88. data/{img/gicons → out/images}/marker44.png +0 -0
  89. data/{img/gicons → out/images}/marker45.png +0 -0
  90. data/{img/gicons → out/images}/marker46.png +0 -0
  91. data/{img/gicons → out/images}/marker47.png +0 -0
  92. data/{img/gicons → out/images}/marker48.png +0 -0
  93. data/{img/gicons → out/images}/marker49.png +0 -0
  94. data/{img/gicons → out/images}/marker5.png +0 -0
  95. data/{img/gicons → out/images}/marker50.png +0 -0
  96. data/{img/gicons → out/images}/marker51.png +0 -0
  97. data/{img/gicons → out/images}/marker52.png +0 -0
  98. data/{img/gicons → out/images}/marker53.png +0 -0
  99. data/{img/gicons → out/images}/marker54.png +0 -0
  100. data/{img/gicons → out/images}/marker55.png +0 -0
  101. data/{img/gicons → out/images}/marker56.png +0 -0
  102. data/{img/gicons → out/images}/marker57.png +0 -0
  103. data/{img/gicons → out/images}/marker58.png +0 -0
  104. data/{img/gicons → out/images}/marker59.png +0 -0
  105. data/{img/gicons → out/images}/marker6.png +0 -0
  106. data/{img/gicons → out/images}/marker60.png +0 -0
  107. data/{img/gicons → out/images}/marker61.png +0 -0
  108. data/{img/gicons → out/images}/marker62.png +0 -0
  109. data/{img/gicons → out/images}/marker63.png +0 -0
  110. data/{img/gicons → out/images}/marker64.png +0 -0
  111. data/{img/gicons → out/images}/marker65.png +0 -0
  112. data/{img/gicons → out/images}/marker66.png +0 -0
  113. data/{img/gicons → out/images}/marker67.png +0 -0
  114. data/{img/gicons → out/images}/marker68.png +0 -0
  115. data/{img/gicons → out/images}/marker69.png +0 -0
  116. data/{img/gicons → out/images}/marker7.png +0 -0
  117. data/{img/gicons → out/images}/marker70.png +0 -0
  118. data/{img/gicons → out/images}/marker71.png +0 -0
  119. data/{img/gicons → out/images}/marker72.png +0 -0
  120. data/{img/gicons → out/images}/marker73.png +0 -0
  121. data/{img/gicons → out/images}/marker74.png +0 -0
  122. data/{img/gicons → out/images}/marker75.png +0 -0
  123. data/{img/gicons → out/images}/marker76.png +0 -0
  124. data/{img/gicons → out/images}/marker77.png +0 -0
  125. data/{img/gicons → out/images}/marker78.png +0 -0
  126. data/{img/gicons → out/images}/marker79.png +0 -0
  127. data/{img/gicons → out/images}/marker8.png +0 -0
  128. data/{img/gicons → out/images}/marker80.png +0 -0
  129. data/{img/gicons → out/images}/marker81.png +0 -0
  130. data/{img/gicons → out/images}/marker82.png +0 -0
  131. data/{img/gicons → out/images}/marker83.png +0 -0
  132. data/{img/gicons → out/images}/marker84.png +0 -0
  133. data/{img/gicons → out/images}/marker85.png +0 -0
  134. data/{img/gicons → out/images}/marker86.png +0 -0
  135. data/{img/gicons → out/images}/marker87.png +0 -0
  136. data/{img/gicons → out/images}/marker88.png +0 -0
  137. data/{img/gicons → out/images}/marker89.png +0 -0
  138. data/{img/gicons → out/images}/marker9.png +0 -0
  139. data/{img/gicons → out/images}/marker90.png +0 -0
  140. data/{img/gicons → out/images}/marker91.png +0 -0
  141. data/{img/gicons → out/images}/marker92.png +0 -0
  142. data/{img/gicons → out/images}/marker93.png +0 -0
  143. data/{img/gicons → out/images}/marker94.png +0 -0
  144. data/{img/gicons → out/images}/marker95.png +0 -0
  145. data/{img/gicons → out/images}/marker96.png +0 -0
  146. data/{img/gicons → out/images}/marker97.png +0 -0
  147. data/{img/gicons → out/images}/marker98.png +0 -0
  148. data/{img/gicons → out/images}/marker99.png +0 -0
  149. data/{img/gicons → out/images}/markerA.png +0 -0
  150. data/{img/gicons → out/images}/markerB.png +0 -0
  151. data/{img/gicons → out/images}/markerC.png +0 -0
  152. data/{img/gicons → out/images}/markerD.png +0 -0
  153. data/{img/gicons → out/images}/markerE.png +0 -0
  154. data/{img/gicons → out/images}/markerF.png +0 -0
  155. data/{img/gicons → out/images}/markerG.png +0 -0
  156. data/{img/gicons → out/images}/markerH.png +0 -0
  157. data/{img/gicons → out/images}/markerI.png +0 -0
  158. data/{img/gicons → out/images}/markerJ.png +0 -0
  159. data/{img/gicons → out/images}/mm_20_red.png +0 -0
  160. data/{img/gicons → out/images}/mm_20_shadow.png +0 -0
  161. data/{img/gicons → out/images}/shadow50.png +0 -0
  162. data/rakefile.rb +79 -0
  163. data/samples.sh +21 -0
  164. data/samples/2008_04_27_13_49_50_tcx.csv +2449 -0
  165. data/samples/2008_04_27_13_49_50_tcx.xml +24560 -0
  166. data/samples/2009_01_01_14_45_00_tcx.xml +10630 -0
  167. data/samples/ballantyne.csv +27 -0
  168. data/samples/ballantyne.gpx +117 -0
  169. data/samples/ballantyne.kml +91 -0
  170. data/samples/big_sur_marathon.html +2766 -0
  171. data/samples/big_sur_marathon.kml +685 -0
  172. data/samples/build_gem_test_results.txt +6 -0
  173. data/samples/crowders_mtn_hike.csv +1065 -0
  174. data/samples/crowders_mtn_hike.html +1283 -0
  175. data/samples/crowders_mtn_hike.log +1 -0
  176. data/samples/cucumber_test_results.txt +302 -0
  177. data/samples/davidson1.csv +1 -0
  178. data/samples/davidson1.html +75 -0
  179. data/samples/davidson_1_point_tcx.csv +0 -0
  180. data/samples/doc.kml +49 -0
  181. data/samples/gps_track_log_asheville_mt_pisgah.txt +1 -0
  182. data/samples/gps_track_logs.txt +1 -0
  183. data/samples/install_test_results.txt +81 -0
  184. data/samples/mt_pisgah.txt +1 -0
  185. data/samples/rspec_test_results.txt +5 -0
  186. data/setup.rb +66 -0
  187. data/spec/gooby_base_object_spec.rb +116 -0
  188. data/spec/gooby_counter_hash_spec.rb +34 -0
  189. data/spec/gooby_dttm_spec.rb +40 -0
  190. data/spec/gooby_spec_helper.rb +9 -0
  191. data/spec/gooby_xml_object_spec.rb +32 -0
  192. metadata +225 -226
  193. data/bin/code_scan.rb +0 -16
  194. data/bin/gooby_been_there.rb +0 -33
  195. data/bin/gooby_config.rb +0 -24
  196. data/bin/gooby_csv_validation.rb +0 -50
  197. data/bin/gooby_first_trackpoints_as_poi.rb +0 -31
  198. data/bin/gooby_gen_gmap.rb +0 -20
  199. data/bin/gooby_parser.rb +0 -21
  200. data/bin/gooby_splitter.rb +0 -21
  201. data/bin/gooby_version.rb +0 -20
  202. data/bin/run_all.sh +0 -33
  203. data/bin/run_been_there.sh +0 -19
  204. data/bin/run_config.sh +0 -12
  205. data/bin/run_csv_validation.sh +0 -15
  206. data/bin/run_db_gen.sh +0 -11
  207. data/bin/run_db_load.sh +0 -11
  208. data/bin/run_first_trackpoints_as_poi.sh +0 -16
  209. data/bin/run_gen_gmaps.sh +0 -21
  210. data/bin/run_parse_full.sh +0 -45
  211. data/bin/run_parse_samples.sh +0 -21
  212. data/bin/run_split.sh +0 -24
  213. data/bin/run_version.sh +0 -12
  214. data/data/20050305_corporate_cup_hm.csv +0 -251
  215. data/data/20050305_corporate_cup_hm.xml +0 -2208
  216. data/data/20050430_nashville_marathon.xml +0 -10043
  217. data/data/20050430_nashville_marathon_km.csv +0 -1208
  218. data/data/20060115_phoenix_marathon.csv +0 -1280
  219. data/data/20060115_phoenix_marathon.xml +0 -10620
  220. data/data/20070101_davidson_11m.csv +0 -251
  221. data/data/20070101_davidson_11m.xml +0 -2020
  222. data/data/20070505_davidson_5k.xml +0 -2875
  223. data/data/20070505_davidson_5k_km.csv +0 -286
  224. data/data/hrm1.csv +0 -5
  225. data/img/gicons/readme.txt +0 -14
  226. data/lib/gooby_code_scanner.rb +0 -288
  227. data/lib/gooby_command.rb +0 -210
  228. data/lib/gooby_course.rb +0 -117
  229. data/lib/gooby_csv_point.rb +0 -71
  230. data/lib/gooby_csv_reader.rb +0 -71
  231. data/lib/gooby_csv_run.rb +0 -28
  232. data/lib/gooby_delim_line.rb +0 -42
  233. data/lib/gooby_duration.rb +0 -86
  234. data/lib/gooby_forerunner_xml_parser.rb +0 -191
  235. data/lib/gooby_forerunner_xml_splitter.rb +0 -115
  236. data/lib/gooby_history.rb +0 -41
  237. data/lib/gooby_kernel.rb +0 -163
  238. data/lib/gooby_line.rb +0 -80
  239. data/lib/gooby_object.rb +0 -22
  240. data/lib/gooby_point.rb +0 -172
  241. data/lib/gooby_run.rb +0 -213
  242. data/lib/gooby_simple_xml_parser.rb +0 -50
  243. data/lib/gooby_test_helper.rb +0 -23
  244. data/lib/gooby_track.rb +0 -47
  245. data/lib/gooby_track_point.rb +0 -229
  246. data/lib/gooby_training_center_xml_parser.rb +0 -224
  247. data/lib/gooby_training_center_xml_splitter.rb +0 -116
  248. data/lib/split_code.sh +0 -29
  249. data/samples/20050305_corporate_cup_hm.html +0 -450
  250. data/samples/20050430_nashville_marathon.html +0 -1668
  251. data/samples/20060115_phoenix_marathon.html +0 -1596
  252. data/samples/20070101_davidson_11m.html +0 -432
  253. data/samples/20070505_davidson_5k.html +0 -413
  254. data/samples/been_there.txt +0 -92
  255. data/samples/hrm1.html +0 -87
  256. data/sql/gooby.ddl +0 -60
  257. data/sql/gooby_load.dml +0 -62
@@ -1,213 +0,0 @@
1
- =begin
2
-
3
- Gooby = Google APIs + Ruby
4
- Gooby - Copyright 2007 by Chris Joakim.
5
- Gooby is available under GNU General Public License (GPL) license.
6
-
7
- =end
8
-
9
- module Gooby
10
-
11
- =begin rdoc
12
- Instances of this class represent a <Run> aggregate object from a
13
- Forerunner XML file.
14
-
15
- Additionally, there is distance, pace, and Google Map generation logic
16
- in this class.
17
- =end
18
-
19
- class Run < GoobyObject
20
-
21
- attr_accessor :number, :run_id, :descr, :notes, :tracks, :tkpts, :laps, :distance
22
-
23
- def initialize(number=0, descr='')
24
- @number = number
25
- @run_id = nil
26
- @descr = descr
27
- @notes = ''
28
- @tracks = Array.new
29
- @tkpts = Array.new
30
- @laps = Array.new
31
- @distance = 0
32
- @configuration = Hash.new
33
- @logProgress = true
34
- @finished = false
35
- end
36
-
37
- public
38
-
39
- # This method is invoked at end-of-parsing.
40
- def finish()
41
- @logProgress = false
42
- unless @finished
43
- @tracks.each { |trk|
44
- trk.trackpoints().each { |tkpt|
45
- tkpt.run_number = @number
46
- @tkpts.push(tkpt)
47
- }
48
- }
49
- compute_distance_and_pace
50
- compute_splits
51
- set_run_ids
52
- @finished = true
53
- end
54
- end
55
-
56
- public
57
-
58
- def add_track(trk)
59
- if trk != nil
60
- @tracks.push(trk)
61
- end
62
- end
63
-
64
- def trackpoint_count()
65
- @tkpts.size()
66
- end
67
-
68
- def add_lap(lap)
69
- @laps.push(lap)
70
- end
71
-
72
- def lap_count()
73
- @laps.size
74
- end
75
-
76
- def start_dttm()
77
- count = 0
78
- @tracks.each { |trk|
79
- trk.trackpoints().each { |tkpt|
80
- return tkpt.dttm()
81
- }
82
- }
83
- return nil
84
- end
85
-
86
- def end_dttm()
87
- lastOne = nil
88
- @tracks.each { |trk|
89
- trk.trackpoints().each { |tkpt|
90
- lastOne = tkpt.dttm()
91
- }
92
- }
93
- lastOne
94
- end
95
-
96
- def duration()
97
- first = start_dttm()
98
- last = end_dttm()
99
- if first
100
- if last
101
- return last.hhmmss_diff(first)
102
- end
103
- end
104
- return "00:00:00"
105
- end
106
-
107
- def start_yyyy_mm_dd
108
- if start_dttm()
109
- start_dttm().yyyy_mm_dd()
110
- else
111
- ""
112
- end
113
- end
114
-
115
- def start_hh_mm_ss
116
- if start_dttm()
117
- start_dttm().hh_mm_ss()
118
- else
119
- ""
120
- end
121
- end
122
-
123
- def end_hh_mm_ss
124
- if end_dttm()
125
- end_dttm().hh_mm_ss()
126
- else
127
- ""
128
- end
129
- end
130
-
131
- def to_s
132
- finish() unless @finished
133
- s = "Run: #{@number} date: #{start_yyyy_mm_dd} distance: #{distance} duration: #{duration} "
134
- s << " tracks: #{@tracks.size} tkpts: #{trackpoint_count} laps: #{lap_count} "
135
- s << " notes: #{@notes} "
136
- s
137
- end
138
-
139
- def print_string
140
- finish() unless @finished
141
- "Run number=#{@number} tracks=#{@tracks.size} tkpts=#{@tkpts.size} laps=#{@laps.size} distance=#{@distance} "
142
- end
143
-
144
- def put_csv()
145
- finish() unless @finished
146
- puts "#{@number}|#{}|#{start_yyyy_mm_dd()}|#{start_hh_mm_ss()}|#{end_hh_mm_ss}|#{duration()}|#{@distance}|#{@tracks.size}|#{trackpoint_count()}|#{lap_count}|#{@notes.strip}"
147
- end
148
-
149
- def put_tkpt_csv()
150
- finish() unless @finished
151
- @tkpts.each { | tkpt |
152
- @prev_tkpt = tkpt if (@prev_tkpt == nil)
153
- puts tkpt.to_csv(@prev_tkpt)
154
- }
155
- end
156
-
157
- def put_laps
158
- @laps.each { | lap | puts lap.to_s }
159
- end
160
-
161
- private
162
-
163
- def compute_distance_and_pace
164
- cumulative_dist = 0.to_f;
165
- curr_index = -1
166
- prev_tkpt = nil
167
- start_dttm = nil
168
- @tkpts.each { | tkpt |
169
- curr_index = curr_index + 1
170
- if curr_index == 0
171
- start_dttm = tkpt.dttm()
172
- prev_tkpt = tkpt
173
- else
174
- cumulative_dist = tkpt.compute_distance_and_pace(curr_index, start_dttm, cumulative_dist, prev_tkpt)
175
- prev_tkpt = tkpt
176
- end
177
- }
178
- @distance = cumulative_dist
179
- end
180
-
181
- def compute_splits
182
- nextSplitDist = 1.00
183
- prev_splitTkpt = nil
184
- loop1Count = 0;
185
- @tkpts.each { |tkpt|
186
- loop1Count = loop1Count + 1
187
- if tkpt.cumulative_distance() >= nextSplitDist
188
- tkpt.set_split(0 + nextSplitDist, prev_splitTkpt)
189
- nextSplitDist = nextSplitDist + 1.00
190
- prev_splitTkpt = tkpt
191
- end
192
- }
193
- # set first and last booleans
194
- count = 0
195
- @tkpts.each { |tkpt|
196
- count = count + 1
197
- tkpt.first = true if count == 1
198
- tkpt.last = true if count == loop1Count
199
- }
200
- end
201
-
202
- def set_run_ids
203
- @tkpts.each { |tkpt|
204
- if (@run_id == nil)
205
- @run_id = tkpt.dttm.rawdata
206
- end
207
- tkpt.run_id = @run_id
208
- }
209
- end
210
-
211
- end
212
-
213
- end # end of module
@@ -1,50 +0,0 @@
1
- =begin
2
-
3
- Gooby = Google APIs + Ruby
4
- Gooby - Copyright 2007 by Chris Joakim.
5
- Gooby is available under GNU General Public License (GPL) license.
6
-
7
- =end
8
-
9
- module Gooby
10
-
11
- =begin rdoc
12
- Sample implementation of a REXML::StreamListener SAX parser.
13
- This class isn't actually used in Gooby, but is retained for future use.
14
- =end
15
-
16
- class SimpleXmlParser
17
-
18
- include REXML::StreamListener
19
-
20
- attr_accessor :tag_count, :watched_tags
21
-
22
- def initialize
23
- @tag_count = 0
24
- @counter_hash = CounterHash.new
25
- end
26
-
27
- public
28
-
29
- # SAX API method. Increments the tagname in the counter hash.
30
- def tag_start(tag_name, attrs)
31
- @tag_count = @tag_count + 1
32
- @counter_hash.increment(tag_name)
33
- end
34
-
35
- # SAX API method. No impl.
36
- def tag_end(tagname)
37
- end
38
-
39
- # SAX API method. No impl.
40
- def text(txt)
41
- end
42
-
43
- # Prints the state of this object (the counter hash).
44
- def dump
45
- puts @counter_hash.to_s
46
- end
47
-
48
- end
49
-
50
- end # end of module
@@ -1,23 +0,0 @@
1
- =begin
2
-
3
- Gooby = Google APIs + Ruby
4
- Gooby - Copyright 2007 by Chris Joakim.
5
- Gooby is available under GNU General Public License (GPL) license.
6
-
7
- =end
8
-
9
- module Gooby
10
-
11
- module TestHelper
12
-
13
- def setup
14
- puts "test: #{name}"
15
- end
16
-
17
- def teardown
18
- @debug = false
19
- end
20
-
21
- end
22
-
23
- end # end of module
@@ -1,47 +0,0 @@
1
- =begin
2
-
3
- Gooby = Google APIs + Ruby
4
- Gooby - Copyright 2007 by Chris Joakim.
5
- Gooby is available under GNU General Public License (GPL) license.
6
-
7
- =end
8
-
9
- module Gooby
10
-
11
- =begin rdoc
12
- Instances of this class represent a <Track> aggregate object from a Forerunner
13
- XML file. Note that a <Run> may contain more than one <Track> aggregates.
14
- =end
15
-
16
- class Track < GoobyObject
17
-
18
- attr_reader :number, :descr, :trackpoints
19
-
20
- def initialize(num=0, descr='')
21
- @number = num
22
- @descr = descr
23
- @trackpoints = Array.new
24
- end
25
-
26
- public
27
-
28
- def add_trackpoint(tkpt)
29
- @trackpoints.push(tkpt)
30
- end
31
-
32
- def size
33
- @trackpoints.size
34
- end
35
-
36
- def to_s
37
- return "Trk: #{@descr} tkpts: #{size}"
38
- end
39
-
40
- def dump
41
- puts "Track: '#{@descr}' tkpts: #{size}"
42
- @trackpoints.each { |tkpt| puts tkpt.to_csv }
43
- end
44
-
45
- end
46
-
47
- end # end of module
@@ -1,229 +0,0 @@
1
- =begin
2
-
3
- Gooby = Google APIs + Ruby
4
- Gooby - Copyright 2007 by Chris Joakim.
5
- Gooby is available under GNU General Public License (GPL) license.
6
-
7
- =end
8
-
9
- module Gooby
10
-
11
- class Trackpoint < Point
12
-
13
- attr_accessor :first, :last, :number, :run_number, :dttm, :prev_tkpt, :lap_number, :lap_seq, :lap_distance, :lap_elapsed
14
- attr_accessor :cumulative_distance, :cumulative_pace, :incremental_distance, :split, :prev_split
15
- attr_accessor :first, :last, :run_id, :run_number
16
- attr_accessor :run_start_dttm
17
-
18
- def initialize(num, lat, lng, alt, hb, time_string, uom, auxInfoHash=Hash.new(''))
19
- @number = num
20
- @run_number = 0
21
- @auxInfoHash = auxInfoHash
22
- @lap_seq = 1
23
- @lap_distance = 0
24
- lap_num = @auxInfoHash['lap_number']
25
- if (lap_num && lap_num.size > 0)
26
- @lap_number = lap_num.to_i
27
- else
28
- @lap_number = 0
29
- end
30
- # initialize superclass variables:
31
- @latitude = lat.to_s
32
- @longitude = lng.to_s
33
- @altitude = alt.to_f
34
- @uom = uom
35
- @altitude = @altitude * 3.2736 if (@uom == 'm')
36
- @heartbeat = hb.to_s
37
- if ((@heartbeat == nil) || (@heartbeat == ''))
38
- @heartbeat = -1
39
- end
40
- @note = note.to_s
41
- @dttm = DtTm.new(time_string)
42
- @first = false
43
- @last = false
44
- @prev_tkpt = nil
45
- @cumulative_distance, @incremental_distance, @split = 0.0, 0.0, 0.0
46
- @cumulative_pace = ""
47
- end
48
-
49
- public
50
-
51
- def point
52
- Point.new(@latitude, @longitude, @altitude, @note)
53
- end
54
-
55
- def position
56
- Point.new(@latitude, @longitude, @altitude, @note)
57
- end
58
-
59
- def to_s
60
- "Tkpt: #{@number} #{super.to_s} date: #{@dttm.to_s} cdist: #{@cumulative_distance}"
61
- end
62
-
63
- def to_csv(prev_tkpt=nil)
64
- first_lap_start_time_s = @auxInfoHash['first_lap_start_time']
65
- curr_lap_start_time_s = @auxInfoHash['curr_lap_start_time']
66
- lap_elapsed = ''
67
- total_elapsed = ''
68
-
69
- if (first_lap_start_time_s && (first_lap_start_time_s.size > 0) &&
70
- curr_lap_start_time_s && (curr_lap_start_time_s.size > 0)) # garmin205 & 305
71
- first_lap_start_time = DtTm.new(first_lap_start_time_s)
72
- first_lap_start_time = @run_start_dttm
73
- curr_lap_start_time = DtTm.new(curr_lap_start_time_s)
74
- lap_elapsed = @dttm.hhmmss_diff(curr_lap_start_time)
75
- total_elapsed = @dttm.hhmmss_diff(first_lap_start_time)
76
- else # garmin 201
77
- total_elapsed = @dttm.hhmmss_diff(@run_start_dttm)
78
- lap_elapsed = total_elapsed
79
- end
80
-
81
- delim = csv_delim
82
- csv = "#{@run_id}.#{@number}" # <-- primary key
83
- csv << "#{delim}#{@run_id}"
84
- csv << "#{delim}#{@dttm.yyyy_mm_dd_hh_mm_ss('|')}"
85
- csv << "#{delim}#{@number}"
86
- csv << "#{delim}#{position.to_csv}"
87
- csv << "#{delim}#{@heartbeat}"
88
- csv << "#{delim}#{@cumulative_distance}"
89
- csv << "#{delim}#{uom}"
90
- csv << "#{delim}#{total_elapsed}"
91
- csv << "#{delim}#{@lap_seq}"
92
- csv << "#{delim}#{@lap_distance}"
93
- csv << "#{delim}#{lap_elapsed}"
94
- csv
95
- end
96
-
97
- def self.csv_header
98
- "#cols: primary_key|run_id|date|time|tkpt_num|latitude|longitude|altitude|heartbeat|run_distance|uom|run_elapsed|lap_tkpt_number|lap_distance|lap_elapsed"
99
- end
100
-
101
- def to_geo_s
102
- ss = position.to_csv
103
- "Tkpt: #{@number} | #{ss} | #{@descr}"
104
- end
105
-
106
- def compute_distance_and_pace(curr_index, start_dttm, prev_cumulative_dist, prev_trackpoint)
107
- @prev_tkpt = prev_trackpoint
108
- @cumulative_distance = prev_cumulative_dist.to_f
109
- @run_start_dttm = start_dttm
110
-
111
- if @prev_tkpt
112
- @incremental_distance = proximity(@prev_tkpt, @uom)
113
- if (!@incremental_distance.nan?)
114
- @cumulative_distance = @cumulative_distance + @incremental_distance.to_f
115
- if (@lap_number == prev_trackpoint.lap_number)
116
- @lap_seq = prev_trackpoint.lap_seq + 1
117
- @lap_distance = prev_trackpoint.lap_distance + @incremental_distance
118
- else
119
- @lap_seq = 1
120
- @lap_distance = @incremental_distance
121
- end
122
- end
123
- compute_cumulative_pace(start_dttm)
124
- @cumulative_distance
125
- else
126
- @lap_seq = 1
127
- 0
128
- end
129
- end
130
-
131
- def compute_cumulative_pace(start_dttm)
132
- if @cumulative_distance > 0
133
- secsDiff = @dttm.seconds_diff(start_dttm)
134
- secsMile = ((secsDiff.to_f) / (@cumulative_distance.to_f))
135
- minsMile = (secsMile / 60)
136
- wholeMins = minsMile.floor
137
- fractMins = minsMile - (wholeMins.to_f)
138
- fractSecs = fractMins * 60
139
- secsStr = fractSecs.to_s
140
- tokens = secsStr.split('.')
141
- whole, fract = '', ''
142
- if tokens.size > 1
143
- whole = tokens[0]
144
- fract = tokens[1]
145
- fract = fract[0,3] if fract.size > 3
146
- if (whole.to_f < 10)
147
- secsStr = "0#{whole}.#{fract}"
148
- else
149
- secsStr = "#{whole}.#{fract}"
150
- end
151
- end
152
- #s1 = " | #{secsDiff} #{secsMile} #{minsMile} #{wholeMins} #{fractMins} #{fractSecs} #{whole} #{fract} #{@cumulative_distance} "
153
- s2 = sprintf("%d:%5s", minsMile, secsStr)
154
- @cumulative_pace = "#{s2} per #{@uom}"
155
- else
156
- @cumulative_pace = ""
157
- end
158
- end
159
-
160
- def set_split(n, tkpt)
161
- @split, @prev_split = n, tkpt
162
- end
163
-
164
- def is_split()
165
- (@split >= 1)
166
- end
167
-
168
- def split_info(dtTm)
169
- if is_split
170
- hhmmss = ''
171
- if @prev_split
172
- return "#{@split} #{@dttm.hhmmss_diff(@prev_split.dttm())}"
173
- else
174
- return "#{@split} #{@dttm.hhmmss_diff(dtTm)}"
175
- end
176
- else
177
- ""
178
- end
179
- end
180
-
181
- public
182
-
183
- def as_glatlng(comment_out, gen_comments, tkpt_count, curr_idx, start_dttm)
184
- comment_out ? comment = '// ' : comment = ''
185
- if gen_comments
186
- secs_diff = @dttm.seconds_diff(start_dttm)
187
- fmt_time = @dttm.hhmmss_diff(start_dttm)
188
- "\n #{comment}points.push(new GLatLng(#{latitude_as_float},#{longitude_as_float})); " +
189
- "// (#{curr_idx + 1} of #{tkpt_count}) #{@dttm.to_s} #{secs_diff} #{fmt_time} #{@cumulative_distance} #{split_info(start_dttm)} #{project_embedded_comment} "
190
- else
191
- "\n #{comment}points.push(new GLatLng(#{latitude_as_float},#{longitude_as_float})); // #{project_embedded_comment} "
192
- end
193
- end
194
-
195
- def as_info_window_html(checkpoint, start_dttm)
196
- s = "\"<table align='left'>"
197
- if checkpoint
198
- secs_diff = @dttm.seconds_diff(start_dttm)
199
- fmt_time = @dttm.hhmmss_diff(start_dttm)
200
-
201
- if checkpoint == 'Start'
202
- s << "<tr><td colspan='2'><b>Start!</b></td></tr>"
203
- elsif checkpoint == 'Finish'
204
- s << "<tr><td colspan='2'><b>Finish!</b></td></tr>"
205
- else
206
- if (@uom == 'km')
207
- s << "<tr><td colspan='2'><b>Kilometer #{checkpoint}</b></td></tr>"
208
- else
209
- s << "<tr><td colspan='2'><b>Mile #{checkpoint}</b></td></tr>"
210
- end
211
- end
212
- s << "<tr><td>Distance:</td><td>#{@cumulative_distance} #{@uom}</td></tr>"
213
- s << "<tr><td>Time of Day:</td><td>#{@dttm.to_s}</td></tr>"
214
- s << "<tr><td>Elapsed Time:</td><td>#{fmt_time}</td></tr>"
215
- s << "<tr><td>Average Pace:</td><td>#{@cumulative_pace}</td></tr>"
216
- s << "<tr><td>Lat/Lng:</td><td>#{latitude_as_float} , #{longitude_as_float}</td></tr>"
217
- s << "<tr><td>Altitude:</td><td>#{altitude_as_float}</td></tr>"
218
- if (@heartbeat && (@heartbeat.size > 1) && (@heartbeat.to_i > 0))
219
- s << "<tr><td>Heartbeat:</td><td>#{@heartbeat}</td></tr>"
220
- end
221
- s
222
- end
223
- s << "</table>\""
224
- s
225
- end
226
-
227
- end
228
-
229
- end # end of module