gooby 0.9.3

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 (224) hide show
  1. data/README +242 -0
  2. data/bin/example_usage.rb +38 -0
  3. data/bin/tests_gen.rb +16 -0
  4. data/data/20050305_corporate_cup_hm.csv +251 -0
  5. data/data/20050305_corporate_cup_hm.xml +2208 -0
  6. data/data/20050430_nashville_marathon.csv +1208 -0
  7. data/data/20050430_nashville_marathon.xml +10043 -0
  8. data/data/20051119_dowd_ymca_hm.csv +251 -0
  9. data/data/20051119_dowd_ymca_hm.xml +2210 -0
  10. data/data/20051124_hyatt_turkey_trot_8K.csv +321 -0
  11. data/data/20051124_hyatt_turkey_trot_8K.xml +2651 -0
  12. data/data/2007_03_03.tcx +6207 -0
  13. data/data/forerunner_2007.xml +259014 -0
  14. data/data/geo_data.txt +171 -0
  15. data/data/phx.csv +1280 -0
  16. data/data/phx.xml +10620 -0
  17. data/data/run_2007_01_01_16_38_27.xml +2020 -0
  18. data/data/run_2007_01_06_15_27_31.xml +2020 -0
  19. data/data/run_2007_01_10_12_25_47.xml +820 -0
  20. data/data/run_2007_01_10_22_44_54.csv +112 -0
  21. data/data/run_2007_01_10_22_44_54.xml +908 -0
  22. data/data/run_2007_01_11_10_48_45.xml +1292 -0
  23. data/data/run_2007_01_13_15_37_06.xml +1964 -0
  24. data/data/run_2007_01_14_15_46_02.xml +1368 -0
  25. data/data/run_2007_01_15_14_01_48.xml +1868 -0
  26. data/data/run_2007_01_20_16_22_05.xml +1702 -0
  27. data/data/run_2007_01_27_17_32_13.xml +3626 -0
  28. data/data/run_2007_01_28_19_14_52.xml +2538 -0
  29. data/data/run_2007_02_03_14_30_20.xml +2016 -0
  30. data/data/run_2007_02_04_18_02_30.xml +1476 -0
  31. data/data/run_2007_02_17_16_29_35.xml +1236 -0
  32. data/data/run_2007_02_19_14_44_33.xml +1816 -0
  33. data/data/run_2007_02_23_15_53_55.xml +36 -0
  34. data/data/run_2007_02_23_15_55_20.xml +1296 -0
  35. data/data/run_2007_02_24_15_01_35.csv +484 -0
  36. data/data/run_2007_02_24_15_01_35.xml +3884 -0
  37. data/data/test1.txt +4 -0
  38. data/img/gicons/blank.png +0 -0
  39. data/img/gicons/dd-end.png +0 -0
  40. data/img/gicons/dd-start.png +0 -0
  41. data/img/gicons/marker.png +0 -0
  42. data/img/gicons/marker0.png +0 -0
  43. data/img/gicons/marker00.png +0 -0
  44. data/img/gicons/marker01.png +0 -0
  45. data/img/gicons/marker02.png +0 -0
  46. data/img/gicons/marker03.png +0 -0
  47. data/img/gicons/marker04.png +0 -0
  48. data/img/gicons/marker05.png +0 -0
  49. data/img/gicons/marker06.png +0 -0
  50. data/img/gicons/marker07.png +0 -0
  51. data/img/gicons/marker08.png +0 -0
  52. data/img/gicons/marker09.png +0 -0
  53. data/img/gicons/marker1.png +0 -0
  54. data/img/gicons/marker10.png +0 -0
  55. data/img/gicons/marker11.png +0 -0
  56. data/img/gicons/marker12.png +0 -0
  57. data/img/gicons/marker13.png +0 -0
  58. data/img/gicons/marker14.png +0 -0
  59. data/img/gicons/marker15.png +0 -0
  60. data/img/gicons/marker16.png +0 -0
  61. data/img/gicons/marker17.png +0 -0
  62. data/img/gicons/marker18.png +0 -0
  63. data/img/gicons/marker19.png +0 -0
  64. data/img/gicons/marker2.png +0 -0
  65. data/img/gicons/marker20.png +0 -0
  66. data/img/gicons/marker21.png +0 -0
  67. data/img/gicons/marker22.png +0 -0
  68. data/img/gicons/marker23.png +0 -0
  69. data/img/gicons/marker24.png +0 -0
  70. data/img/gicons/marker25.png +0 -0
  71. data/img/gicons/marker26.png +0 -0
  72. data/img/gicons/marker27.png +0 -0
  73. data/img/gicons/marker28.png +0 -0
  74. data/img/gicons/marker29.png +0 -0
  75. data/img/gicons/marker3.png +0 -0
  76. data/img/gicons/marker30.png +0 -0
  77. data/img/gicons/marker31.png +0 -0
  78. data/img/gicons/marker32.png +0 -0
  79. data/img/gicons/marker33.png +0 -0
  80. data/img/gicons/marker34.png +0 -0
  81. data/img/gicons/marker35.png +0 -0
  82. data/img/gicons/marker36.png +0 -0
  83. data/img/gicons/marker37.png +0 -0
  84. data/img/gicons/marker38.png +0 -0
  85. data/img/gicons/marker39.png +0 -0
  86. data/img/gicons/marker4.png +0 -0
  87. data/img/gicons/marker40.png +0 -0
  88. data/img/gicons/marker41.png +0 -0
  89. data/img/gicons/marker42.png +0 -0
  90. data/img/gicons/marker43.png +0 -0
  91. data/img/gicons/marker44.png +0 -0
  92. data/img/gicons/marker45.png +0 -0
  93. data/img/gicons/marker46.png +0 -0
  94. data/img/gicons/marker47.png +0 -0
  95. data/img/gicons/marker48.png +0 -0
  96. data/img/gicons/marker49.png +0 -0
  97. data/img/gicons/marker5.png +0 -0
  98. data/img/gicons/marker50.png +0 -0
  99. data/img/gicons/marker51.png +0 -0
  100. data/img/gicons/marker52.png +0 -0
  101. data/img/gicons/marker53.png +0 -0
  102. data/img/gicons/marker54.png +0 -0
  103. data/img/gicons/marker55.png +0 -0
  104. data/img/gicons/marker56.png +0 -0
  105. data/img/gicons/marker57.png +0 -0
  106. data/img/gicons/marker58.png +0 -0
  107. data/img/gicons/marker59.png +0 -0
  108. data/img/gicons/marker6.png +0 -0
  109. data/img/gicons/marker60.png +0 -0
  110. data/img/gicons/marker61.png +0 -0
  111. data/img/gicons/marker62.png +0 -0
  112. data/img/gicons/marker63.png +0 -0
  113. data/img/gicons/marker64.png +0 -0
  114. data/img/gicons/marker65.png +0 -0
  115. data/img/gicons/marker66.png +0 -0
  116. data/img/gicons/marker67.png +0 -0
  117. data/img/gicons/marker68.png +0 -0
  118. data/img/gicons/marker69.png +0 -0
  119. data/img/gicons/marker7.png +0 -0
  120. data/img/gicons/marker70.png +0 -0
  121. data/img/gicons/marker71.png +0 -0
  122. data/img/gicons/marker72.png +0 -0
  123. data/img/gicons/marker73.png +0 -0
  124. data/img/gicons/marker74.png +0 -0
  125. data/img/gicons/marker75.png +0 -0
  126. data/img/gicons/marker76.png +0 -0
  127. data/img/gicons/marker77.png +0 -0
  128. data/img/gicons/marker78.png +0 -0
  129. data/img/gicons/marker79.png +0 -0
  130. data/img/gicons/marker8.png +0 -0
  131. data/img/gicons/marker80.png +0 -0
  132. data/img/gicons/marker81.png +0 -0
  133. data/img/gicons/marker82.png +0 -0
  134. data/img/gicons/marker83.png +0 -0
  135. data/img/gicons/marker84.png +0 -0
  136. data/img/gicons/marker85.png +0 -0
  137. data/img/gicons/marker86.png +0 -0
  138. data/img/gicons/marker87.png +0 -0
  139. data/img/gicons/marker88.png +0 -0
  140. data/img/gicons/marker89.png +0 -0
  141. data/img/gicons/marker9.png +0 -0
  142. data/img/gicons/marker90.png +0 -0
  143. data/img/gicons/marker91.png +0 -0
  144. data/img/gicons/marker92.png +0 -0
  145. data/img/gicons/marker93.png +0 -0
  146. data/img/gicons/marker94.png +0 -0
  147. data/img/gicons/marker95.png +0 -0
  148. data/img/gicons/marker96.png +0 -0
  149. data/img/gicons/marker97.png +0 -0
  150. data/img/gicons/marker98.png +0 -0
  151. data/img/gicons/marker99.png +0 -0
  152. data/img/gicons/markerA.png +0 -0
  153. data/img/gicons/markerB.png +0 -0
  154. data/img/gicons/markerC.png +0 -0
  155. data/img/gicons/markerD.png +0 -0
  156. data/img/gicons/markerE.png +0 -0
  157. data/img/gicons/markerF.png +0 -0
  158. data/img/gicons/markerG.png +0 -0
  159. data/img/gicons/markerH.png +0 -0
  160. data/img/gicons/markerI.png +0 -0
  161. data/img/gicons/markerJ.png +0 -0
  162. data/img/gicons/mm_20_red.png +0 -0
  163. data/img/gicons/mm_20_shadow.png +0 -0
  164. data/img/gicons/readme.txt +11 -0
  165. data/img/gicons/shadow50.png +0 -0
  166. data/lib/gooby/cls_counter_hash.rb +78 -0
  167. data/lib/gooby/cls_delim_line.rb +35 -0
  168. data/lib/gooby/cls_dttm.rb +79 -0
  169. data/lib/gooby/cls_duration.rb +79 -0
  170. data/lib/gooby/cls_forerunner_xml_parser.rb +178 -0
  171. data/lib/gooby/cls_forerunner_xml_splitter.rb +109 -0
  172. data/lib/gooby/cls_geo_data.rb +181 -0
  173. data/lib/gooby/cls_gooby_command.rb +35 -0
  174. data/lib/gooby/cls_gooby_object.rb +18 -0
  175. data/lib/gooby/cls_google_map_generator.rb +363 -0
  176. data/lib/gooby/cls_history.rb +33 -0
  177. data/lib/gooby/cls_lap.rb +22 -0
  178. data/lib/gooby/cls_line.rb +75 -0
  179. data/lib/gooby/cls_options.rb +67 -0
  180. data/lib/gooby/cls_position.rb +44 -0
  181. data/lib/gooby/cls_run.rb +194 -0
  182. data/lib/gooby/cls_simple_xml_parser.rb +41 -0
  183. data/lib/gooby/cls_test_regen.rb +182 -0
  184. data/lib/gooby/cls_track.rb +47 -0
  185. data/lib/gooby/cls_trackpoint.rb +200 -0
  186. data/lib/gooby/mod_introspect.rb +26 -0
  187. data/lib/gooby/mod_io.rb +58 -0
  188. data/lib/gooby/mod_project_info.rb +80 -0
  189. data/lib/gooby/mod_string.rb +19 -0
  190. data/lib/gooby/mod_test_helper.rb +15 -0
  191. data/lib/gooby.rb +2265 -0
  192. data/pkg/code_header.txt +21 -0
  193. data/pkg/pkg.rb +236 -0
  194. data/pkg/test_header.txt +19 -0
  195. data/samples/20041113_richmond_marathon.html +532 -0
  196. data/samples/20050305_corporate_cup_hm.html +448 -0
  197. data/samples/20050430_nashville_marathon.html +530 -0
  198. data/samples/gps_point_capture.html +54 -0
  199. data/samples/phoenix_marathon.html +542 -0
  200. data/samples/run_2007_01_10_22_44_54.html +201 -0
  201. data/samples/run_2007_02_24_15_01_35.html +298 -0
  202. data/tests/tc_cls_counter_hash.rb +107 -0
  203. data/tests/tc_cls_delim_line.rb +74 -0
  204. data/tests/tc_cls_dttm.rb +131 -0
  205. data/tests/tc_cls_duration.rb +51 -0
  206. data/tests/tc_cls_forerunner_xml_parser.rb +70 -0
  207. data/tests/tc_cls_geo_data.xxx +71 -0
  208. data/tests/tc_cls_gooby_object.rb +26 -0
  209. data/tests/tc_cls_google_map_generator.rb +109 -0
  210. data/tests/tc_cls_history.rb +46 -0
  211. data/tests/tc_cls_lap.rb +38 -0
  212. data/tests/tc_cls_line.rb +110 -0
  213. data/tests/tc_cls_options.rb +79 -0
  214. data/tests/tc_cls_position.rb +66 -0
  215. data/tests/tc_cls_run.rb +142 -0
  216. data/tests/tc_cls_simple_xml_parser.rb +50 -0
  217. data/tests/tc_cls_track.rb +70 -0
  218. data/tests/tc_cls_trackpoint.rb +145 -0
  219. data/tests/tc_mod_introspect.rb +32 -0
  220. data/tests/tc_mod_io.rb +53 -0
  221. data/tests/tc_mod_project_info.rb +79 -0
  222. data/tests/tc_mod_string.rb +58 -0
  223. data/tests/ts_gooby.rb +1237 -0
  224. metadata +270 -0
@@ -0,0 +1,363 @@
1
+ module Gooby
2
+
3
+ =begin rdoc
4
+ Instances of this class represent a <Run> aggregate object from a
5
+ Forerunner XML file.
6
+
7
+ Additionally, there is distance, pace, and Google Map generation logic
8
+ in this class.
9
+ =end
10
+
11
+ class GoogleMapGenerator < GoobyObject
12
+
13
+ attr_reader :csv_file, :csv_lines, :dttm_idx, :num_idx, :lat_idx, :lng_idx, :alt_idx, :cdist_idx
14
+ attr_reader :run, :tkpts, :content_hash, :center_longitude, :center_latitude, :gpoint_array, :overlay_points, :notes
15
+ attr_reader :center_longitude, :center_latitude
16
+
17
+ # The default csv input file format is as follows:
18
+ # 1 | 2006-01-15T18:31:10Z | 1279 | 33.42601 | -111.92927 | 347.654 | 26.3514930151813
19
+ # 1 | 2004-11-13T13:05:20Z | 2 | 37.54318 | -77.43636 | -58.022 | 0.00297286231747969
20
+
21
+ def initialize(csv_file, dttm_idx=1, num_idx=2, lat_idx=3, lng_idx=4, alt_idx=5, cdist_idx=6)
22
+ @csv_file = csv_file
23
+ @dttm_idx = dttm_idx
24
+ @num_idx = num_idx
25
+ @lat_idx = lat_idx
26
+ @lng_idx = lng_idx
27
+ @alt_idx = alt_idx
28
+ @cdist_idx = cdist_idx
29
+ @options = Gooby::Options.new(nil)
30
+ @content_hash = Hash.new('')
31
+ @run = Gooby::Run.new(1)
32
+ @track = Gooby::Track.new(1)
33
+ @run.add_track(@track)
34
+ @tkpts = Array.new
35
+
36
+ @csv_lines = read_as_ascii_lines(@csv_file, 10, true)
37
+ @csv_lines.each { | line |
38
+ dline = Gooby::DelimLine.new(line)
39
+ if (!dline.is_comment?)
40
+ tkpt = dline.as_trackpoint(@num_idx, @lat_idx, @lng_idx, @alt_idx, @dttm_idx)
41
+ if tkpt
42
+ @track.add_trackpoint(tkpt)
43
+ end
44
+ end
45
+ }
46
+ @run.finish
47
+ end
48
+
49
+ =begin
50
+ Returns a Hash with specific generated content at the following keys:
51
+ =end
52
+ def generate(options)
53
+ if (options == nil)
54
+ @options = Gooby::Options.new(nil)
55
+ else
56
+ @options = options
57
+ end
58
+ @content_hash['when_generated'] = Time.now
59
+ @content_hash['title'] = @options.get('gmap_title')
60
+ filter_trackpoints
61
+ compute_center_point
62
+ generate_key_js
63
+ generate_map_div
64
+ generate_messages_div
65
+ generate_main_js_start
66
+ generate_main_js_route_overlay
67
+ generate_main_js_checkpoint_overlays
68
+ generate_main_js_map_clicked_listeners
69
+ generate_main_js_end
70
+ @content_hash
71
+ end
72
+
73
+ def filter_trackpoints
74
+ count, @tkpts = 0, Array.new
75
+ firstTkpt = @options.get('gmap_first_tkpt_number')
76
+ lastTkpt = @options.get('gmap_last_tkpt_number')
77
+ @run.tracks.each { |trk|
78
+ trk.trackpoints.each { |tkpt|
79
+ count = count + 1
80
+ if ((count >= firstTkpt) && (count <= lastTkpt))
81
+ @tkpts.push(tkpt)
82
+ end
83
+ }
84
+ }
85
+ end
86
+
87
+ =begin
88
+ Returns a Hash with specific generated content at the following keys:
89
+ =end
90
+ def generate_page(options)
91
+
92
+ # puts "generate_page #{@csv_file} #{@csv_lines.size}"
93
+ content_hash = generate(nil)
94
+ s = String.new(@csv_file)
95
+ s.gsub("/", " ")
96
+ tokens = tokenize(s, nil)
97
+ out_file = "#{tokens[-2]}.html"
98
+ #content_hash.keys.sort.each { | key | puts key }
99
+
100
+ s = <<HERE
101
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
102
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
103
+ <html xmlns="http://www.w3.org/1999/xhtml">
104
+ <head>
105
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
106
+ <title> Google Map by Gooby </title>
107
+ #{content_hash['key_js']}
108
+ #{content_hash['main_js_start']}
109
+ #{content_hash['main_js_route_overlay']}
110
+ #{content_hash['main_js_checkpoint_overlays']}
111
+ #{content_hash['main_js_map_clicked_listeners']}
112
+ #{content_hash['main_js_end']}
113
+ </head>
114
+ <body onload="load()" onunload="GUnload()">
115
+ <center>
116
+ <h3> #{content_hash['title']} </h3>
117
+ <h5> Generated by Gooby #{content_hash['when_generated']} <br> Gooby = Google APIs + Ruby </h5>
118
+ #{content_hash['map_div']}
119
+ #{content_hash['messages_div']}
120
+ </center>
121
+ </body>
122
+ </html>
123
+ HERE
124
+
125
+ # html_file = File.new(out_file, "w+")
126
+ # html_file.write(s)
127
+ # html_file.flush
128
+ # html_file.close
129
+ puts s # Output is redirected by shell.
130
+ end
131
+
132
+ private
133
+
134
+ def compute_center_point
135
+ highLat = -999.0
136
+ highLong = -999.0
137
+ lowLat = 999.0
138
+ lowLong = 999.0
139
+ @tkpts.each { |tkpt|
140
+ highLat = tkpt.latitude_as_float if tkpt.latitude_as_float > highLat
141
+ lowLat = tkpt.latitude_as_float if tkpt.latitude_as_float < lowLat
142
+ highLong = tkpt.longitude_as_float if tkpt.longitude_as_float > highLong
143
+ lowLong = tkpt.longitude_as_float if tkpt.longitude_as_float < lowLong
144
+ }
145
+ @center_longitude = (highLong + lowLong) / 2
146
+ @center_latitude = (highLat + lowLat) / 2
147
+ @content_hash['center_longitude'] = @center_longitude
148
+ @content_hash['center_latitude'] = @center_latitude
149
+ end
150
+
151
+ def generate_key_js
152
+ key = @options.get('gmap_key')
153
+ key.strip!
154
+ s = '<script src="http://maps.google.com/maps?file=api&v=2&key='
155
+ s << key
156
+ s << '" type="text/javascript"></script>'
157
+ @content_hash['key_js'] = s
158
+ end
159
+
160
+ def generate_map_div
161
+ width = @options.get('gmap_width')
162
+ height = @options.get('gmap_height')
163
+ id = @options.get('gmap_map_element_id')
164
+ s = '<div id="'
165
+ s << id
166
+ s << '" style="width: '
167
+ s << width
168
+ s << '; height: '
169
+ s << height
170
+ s << '"></div>'
171
+ @content_hash['map_width'] = width
172
+ @content_hash['map_height'] = height
173
+ @content_hash['map_div'] = s
174
+ end
175
+
176
+ def generate_messages_div
177
+ s = "<div id=\"messages\"></div>"
178
+ @content_hash['messages_div'] = s
179
+ end
180
+
181
+ def generate_main_js_start
182
+ id = @options.get('gmap_map_element_id')
183
+ size = @options.get('gmap_size_control')
184
+ type = @options.get('gmap_type')
185
+ zoom = @options.get('gmap_zoom_level')
186
+ title = @options.get('gmap_title')
187
+ if size
188
+ if size == 'smallmap'
189
+ size = 'GSmallMapControl'
190
+ elsif size == 'smallzoom'
191
+ size = 'GSmallMapControl'
192
+ else
193
+ size = 'GLargeMapControl'
194
+ end
195
+ end
196
+
197
+ if type
198
+ if type == 'satellite'
199
+ type = 'G_SATELLITE_MAP'
200
+ elsif type == 'hybrid'
201
+ type = 'G_HYBRID_MAP'
202
+ else
203
+ type = 'G_NORMAL_MAP'
204
+ end
205
+ else
206
+ type = 'G_NORMAL_MAP'
207
+ end
208
+
209
+ s = '<script type="text/javascript">'
210
+ s << "\n"
211
+ s << "//<![CDATA[ \n"
212
+ s << " function load() { \n"
213
+ s << " if (GBrowserIsCompatible()) { \n"
214
+ s << ' var map = new GMap2(document.getElementById("'
215
+ s << id
216
+ s << '")); '
217
+ s << "\n"
218
+
219
+ if size
220
+ s << ' map.addControl(new '
221
+ s << size
222
+ s << '());'
223
+ s << "\n"
224
+ end
225
+
226
+ if type
227
+ s << ' map.addControl(new GMapTypeControl());'
228
+ s << "\n"
229
+ # s << ' map.setMapType('
230
+ # s << type
231
+ # s << ');'
232
+ s << "\n"
233
+ end
234
+ s << " var centerPoint = new GLatLng(#{@center_latitude}, #{@center_longitude}); \n"
235
+ s << " map.setCenter(centerPoint, #{zoom}); \n"
236
+ s << "\n"
237
+ @content_hash['main_js_start'] = s
238
+ @content_hash['title'] = title
239
+ end
240
+
241
+ def generate_main_js_route_overlay
242
+ tkpt_count = @tkpts.size.to_f
243
+ app_max = @options.get('gmap_approx_max_points').to_f
244
+ comments = @options.get('gmap_gen_comments')
245
+ ratio = tkpt_count / app_max
246
+ @start_dttm = nil
247
+ if ratio > 1.0
248
+ increment = (tkpt_count / app_max).to_i
249
+ else
250
+ increment = 1
251
+ end
252
+ curr_idx, next_idx, gpoint_count, last_idx = -1, 0, 0, @tkpts.size - 1
253
+ s = " var points = new Array(); "
254
+ @tkpts.each { |tkpt|
255
+ curr_idx = curr_idx + 1
256
+ if curr_idx == 0
257
+ @start_dttm = tkpt.dttm
258
+ @start_pos = tkpt.position
259
+ time = Time.parse(@start_dttm.dateTime().to_s)
260
+ end
261
+ if ((curr_idx == next_idx) || (curr_idx == last_idx) || (tkpt.is_split()))
262
+ gpoint_count = gpoint_count + 1
263
+ s << tkpt.as_glatlng(comments, tkpt_count, curr_idx, gpoint_count, @start_dttm)
264
+ next_idx = curr_idx + increment
265
+ end
266
+ }
267
+ s << "\n"
268
+ s << "\n var routePolyline = new GPolyline(points); "
269
+ s << "\n map.addOverlay(routePolyline); "
270
+ @content_hash['main_js_route_overlay'] = s
271
+ @content_hash['main_js_route_overlay_increment'] = increment
272
+ end
273
+
274
+ def generate_main_js_checkpoint_overlays
275
+ s = "\n // Create a base icon for all of our markers that specifies the "
276
+ s << "\n // shadow, icon dimensions, etc."
277
+ s << "\n var baseIcon = new GIcon();"
278
+ s << "\n baseIcon.shadow = \"http://www.joakim-systems.com/gicons/shadow50.png\";"
279
+ s << "\n baseIcon.iconSize = new GSize(20, 34);"
280
+ s << "\n baseIcon.shadowSize = new GSize(37, 34);"
281
+ s << "\n baseIcon.iconAnchor = new GPoint(9, 34);"
282
+ s << "\n baseIcon.infoWindowAnchor = new GPoint(9, 2);"
283
+ s << "\n baseIcon.infoShadowAnchor = new GPoint(18, 25);"
284
+ s << "\n"
285
+
286
+ curr_idx = -1
287
+ last_idx = @tkpts.size - 1
288
+ next_checkpoint = 0.0
289
+ @start_dttm = nil
290
+ @tkpts.each { | tkpt |
291
+ curr_idx = curr_idx + 1
292
+ if curr_idx == 0
293
+ @start_dttm = tkpt.dttm
294
+ info_window_html = tkpt.as_info_window_html('Start', @start_dttm)
295
+ s << "\n var iconStart = new GIcon(baseIcon); "
296
+ s << "\n iconStart.image = \"http://www.joakim-systems.com/gicons/dd-start.png\";"
297
+ s << "\n var pStart = new GPoint(#{tkpt.longitude_as_float}, #{tkpt.latitude_as_float});"
298
+ s << "\n var mStart = new GMarker(pStart, iconStart);"
299
+ s << "\n GEvent.addListener(mStart, \"click\", function() { "
300
+ s << "\n mStart.openInfoWindowHtml(#{info_window_html});"
301
+ s << "\n }); "
302
+ s << "\n map.addOverlay(mStart);"
303
+ s << "\n "
304
+ next_checkpoint = 1.0
305
+ elsif curr_idx == last_idx
306
+ info_window_html = tkpt.as_info_window_html('Finish', @start_dttm)
307
+ s << "\n var iconFinish = new GIcon(baseIcon); "
308
+ s << "\n iconFinish.image = \"http://www.joakim-systems.com/gicons/dd-end.png\";"
309
+ s << "\n var pFinish = new GPoint(#{tkpt.longitude_as_float}, #{tkpt.latitude_as_float});"
310
+ s << "\n var mFinish = new GMarker(pFinish, iconFinish);"
311
+ s << "\n GEvent.addListener(mFinish, \"click\", function() { "
312
+ s << "\n mFinish.openInfoWindowHtml(#{info_window_html});"
313
+ s << "\n }); "
314
+ s << "\n map.addOverlay(mFinish);"
315
+ s << "\n "
316
+ next_checkpoint = 999999
317
+ else
318
+ if (tkpt.cumulativeDistance >= next_checkpoint)
319
+ integer = next_checkpoint.to_i
320
+ info_window_html = tkpt.as_info_window_html("#{integer}", @start_dttm)
321
+ s << "\n var icon#{integer} = new GIcon(baseIcon); "
322
+ s << "\n icon#{integer}.image = \"http://www.joakim-systems.com/gicons/marker#{integer}.png\";"
323
+ s << "\n var p#{integer} = new GPoint(#{tkpt.longitude_as_float}, #{tkpt.latitude_as_float});"
324
+ s << "\n var m#{integer} = new GMarker(p#{integer}, icon#{integer});"
325
+ s << "\n GEvent.addListener(m#{integer}, \"click\", function() { "
326
+ s << "\n m#{integer}.openInfoWindowHtml(#{info_window_html});"
327
+ s << "\n }); "
328
+ s << "\n map.addOverlay(m#{integer});"
329
+ s << "\n "
330
+ next_checkpoint = next_checkpoint + 1.0
331
+ end
332
+ end
333
+ }
334
+ s << "\n"
335
+ @content_hash['main_js_checkpoint_overlays'] = s
336
+
337
+ end
338
+
339
+ def generate_main_js_map_clicked_listeners
340
+ s = "\n"
341
+ s << "\n GEvent.addListener(map, \"click\", function() { "
342
+ s << "\n var center = map.getCenter(); \n"
343
+ s << "\n document.getElementById(\"messages\").innerHTML = 'click: ' + center.toString(); "
344
+ s << "\n });"
345
+ s << "\n GEvent.addListener(map, \"moveend\", function() { "
346
+ s << "\n var center = map.getCenter(); \n"
347
+ s << "\n document.getElementById(\"messages\").innerHTML = 'moveend: ' + center.toString(); "
348
+ s << "\n });"
349
+ @content_hash['main_js_map_clicked_listeners'] = s
350
+ end
351
+
352
+ def generate_main_js_end
353
+ s = "\n } "
354
+ s << "\n } "
355
+ s << "\n//]]> \n"
356
+ s << "\n</script>"
357
+
358
+ @content_hash['main_js_end'] = s
359
+ end
360
+
361
+ end
362
+
363
+ end # end of module
@@ -0,0 +1,33 @@
1
+ module Gooby
2
+
3
+ =begin rdoc
4
+ Instances of this class represent a <History> aggregate object from a
5
+ Forerunner XML file.
6
+ =end
7
+
8
+ class History < GoobyObject
9
+
10
+ attr_reader :runs
11
+
12
+ def initialize
13
+ @runs = Array.new
14
+ end
15
+
16
+ # Adds a Run during XML parsing.
17
+ def add_run(run)
18
+ @runs.push(run)
19
+ end
20
+
21
+ def to_s
22
+ return "Hist: runs: #{@runs.size}"
23
+ end
24
+
25
+ def print_string
26
+ s = "History: run count=#{@runs.size} \n"
27
+ runs.each { | run | s << run.print_string }
28
+ s
29
+ end
30
+
31
+ end
32
+
33
+ end # end of module
@@ -0,0 +1,22 @@
1
+ module Gooby
2
+
3
+ =begin rdoc
4
+ Instances of this class represent a <Lap> aggregate object from a
5
+ Forerunner XML file.
6
+ =end
7
+
8
+ class Lap < GoobyObject
9
+
10
+ attr_accessor :number, :startTime, :duration, :length, :beginPosition, :endPosition
11
+
12
+ def initialize(num)
13
+ @number = num
14
+ end
15
+
16
+ def to_s
17
+ return "Lap: num: #{@number} start: #{@startTime} dur: #{@duration} len: #{@length} begin: #{@beginPosition.to_s} end: #{@endPosition.to_s}"
18
+ end
19
+
20
+ end
21
+
22
+ end # end of module
@@ -0,0 +1,75 @@
1
+ module Gooby
2
+
3
+ =begin rdoc
4
+
5
+ =end
6
+
7
+ class Line < GoobyObject
8
+
9
+ attr_accessor :raw_data, :tokens
10
+
11
+ def initialize(raw='', delim=nil, strip=false)
12
+ if strip
13
+ @raw_data = raw.strip
14
+ else
15
+ @raw_data = raw
16
+ end
17
+
18
+ @tokens = tokenize(@raw_data, delim, strip=false)
19
+ end
20
+
21
+ public
22
+
23
+ def token(idx)
24
+ @tokens[idx]
25
+ end
26
+
27
+ def token_count
28
+ @tokens.size
29
+ end
30
+
31
+ def token_idx_equals(idx, value)
32
+ if idx < token_count
33
+ if @tokens[idx] == value
34
+ return true
35
+ end
36
+ end
37
+ false
38
+ end
39
+
40
+ def match(pattern)
41
+ @raw_data.match(pattern)
42
+ end
43
+
44
+ def is_comment
45
+ s = @raw_data.strip
46
+ (s.match('^#')) ? true : false
47
+ end
48
+
49
+ def is_populated_non_comment
50
+ s = @raw_data.strip
51
+ if s.size == 0
52
+ return false
53
+ end
54
+ if is_comment
55
+ return false
56
+ end
57
+ return true
58
+ end
59
+
60
+ def concatinate_tokens(start_idx = 0)
61
+ s = ''
62
+ idx = -1
63
+ @tokens.each { |tok|
64
+ idx = idx + 1
65
+ if idx >= start_idx
66
+ s << tok
67
+ s << ' '
68
+ end
69
+ }
70
+ s.strip!
71
+ s
72
+ end
73
+ end
74
+
75
+ end # end of module
@@ -0,0 +1,67 @@
1
+ module Gooby
2
+
3
+ class Options < GoobyObject
4
+
5
+ attr_reader :yamlFilename, :options
6
+
7
+ def initialize(filename) # Constructor.
8
+ filename ? @yamlFilename = filename : @yamlFilename = 'gooby_options.yaml'
9
+ loadFile()
10
+ end
11
+
12
+ public
13
+
14
+ # Load the @yamlFilename
15
+ def loadFile
16
+ File.open("#{@yamlFilename}") { |fn|
17
+ @options = YAML::load(fn)
18
+ }
19
+ end
20
+
21
+ def get(name)
22
+ if name == nil
23
+ return ''
24
+ end
25
+ s = @options["#{name}"]
26
+
27
+ # Provide "sensible defaults".
28
+ if s == nil
29
+ if (name == '')
30
+ return ''
31
+ elsif (name == 'gmap_first_tkpt_number')
32
+ return 1
33
+ elsif (name == 'gmap_last_tkpt_number')
34
+ return 5000
35
+ elsif (name == 'gmap_map_element_id')
36
+ return 'map'
37
+ elsif (name == 'gmap_height')
38
+ return '600'
39
+ elsif (name == 'gmap_key')
40
+ return 'enter your Google Map Key here'
41
+ elsif (name == 'gmap_type_control')
42
+ return true
43
+ elsif (name == 'gmap_approx_max_points')
44
+ return '200'
45
+ elsif (name == 'gmap_gen_comments')
46
+ return true
47
+ elsif (name == 'gmap_size_control')
48
+ return nil
49
+ elsif (name == 'gmap_type')
50
+ return 'G_NORMAL_MAP'
51
+ elsif (name == 'gmap_zoom_level')
52
+ return 5
53
+ else
54
+ return ''
55
+ end
56
+ end
57
+ s
58
+ end
59
+
60
+ # Return a String containing yaml filename and entry count.
61
+ def to_s
62
+ return "Options: filename: #{@yamlFilename} entries: #{@options.size}"
63
+ end
64
+
65
+ end
66
+
67
+ end # end of module
@@ -0,0 +1,44 @@
1
+ module Gooby
2
+
3
+ =begin rdoc
4
+ Instances of this class represent a <Position> aggregate object from a
5
+ Forerunner XML file. Each contains a latitude and longitude.
6
+ Instances within a Trackpoint will also contain an altitude.
7
+ =end
8
+
9
+ class Position < GoobyObject
10
+
11
+ attr_accessor :latitude, :longitude, :altitude, :note
12
+
13
+ def initialize(lat, lng, alt='0', note='')
14
+ @latitude = lat.to_s
15
+ @longitude = lng.to_s
16
+ @altitude = alt.to_s
17
+ @note = note.to_s
18
+ end
19
+
20
+ public
21
+
22
+ def to_s
23
+ return "lat: #{@latitude} lng: #{@longitude} alt: #{@altitude} note: #{@note}"
24
+ end
25
+
26
+ def to_csv
27
+ return "#{@latitude} | #{@longitude} | #{@altitude}"
28
+ end
29
+
30
+ def latitude_as_float
31
+ @latitude ? @latitude.to_f : invalid_latitude
32
+ end
33
+
34
+ def longitude_as_float
35
+ @longitude ? @longitude.to_f : invalid_longitude
36
+ end
37
+
38
+ def altitude_as_float
39
+ @altitude ? @altitude.to_f : invalid_altitude
40
+ end
41
+
42
+ end
43
+
44
+ end # end of module