gooby 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +48 -67
- data/bin/20050305_corporate_cup_hm_to_csv.rb +9 -0
- data/bin/20050430_nashville_marathon_to_csv.rb +9 -0
- data/bin/20060115_phoenix_marathon_to_csv.rb +9 -0
- data/bin/activity_2007_03_10_13_02_32.xml_to_csv.rb +9 -0
- data/bin/{tests_gen.rb → code_scan.rb} +6 -4
- data/bin/example_usage.rb +2 -3
- data/bin/example_usage.sh +52 -0
- data/bin/gen_gap_phx.rb +10 -0
- data/bin/gen_gmap_cc_2005.rb +10 -0
- data/bin/gen_gmap_cc_2007.rb +10 -0
- data/bin/gen_gmap_nashville.rb +10 -0
- data/bin/gen_gmap_phx.rb +10 -0
- data/bin/phx_to_csv.rb +47 -0
- data/bin/split_forerunner_logbook_2007.rb +10 -0
- data/bin/split_training_center_2007.rb +8 -0
- data/data/{2007_03_04.tcx → 2007_03_10.tcx} +11694 -0
- data/data/activity_2007_03_10_13_02_32.csv +1168 -0
- data/data/activity_2007_03_10_13_02_32.xml +11695 -0
- data/data/forerunner_2007.xml +0 -227142
- data/img/gicons/readme.txt +3 -0
- data/lib/gooby.rb +625 -552
- data/samples/20050305_corporate_cup_hm.html +271 -269
- data/samples/20050430_nashville_marathon.html +1240 -246
- data/samples/20060115_phoenix_marathon.html +1596 -0
- data/samples/20070310_corporate_cup_hm.html +1367 -0
- data/samples/phoenix_marathon.html +1312 -258
- data/tests/ts_gooby.rb +423 -551
- data/tests/ts_gooby_min.rb +550 -0
- metadata +25 -67
- data/bin/tcx_ex.rb +0 -35
- data/data/20051124_hyatt_turkey_trot_8K.csv +0 -321
- data/data/20051124_hyatt_turkey_trot_8K.xml +0 -2651
- data/data/2007_03_03.tcx +0 -6207
- data/data/activity_2007_03_04_15_22_36.xml +0 -10545
- data/data/run_2007_01_01_16_38_27.xml +0 -2020
- data/data/run_2007_02_24_15_01_35.csv +0 -484
- data/data/run_2007_02_24_15_01_35.xml +0 -3884
- data/lib/gooby/cls_counter_hash.rb +0 -78
- data/lib/gooby/cls_delim_line.rb +0 -35
- data/lib/gooby/cls_dttm.rb +0 -79
- data/lib/gooby/cls_duration.rb +0 -79
- data/lib/gooby/cls_forerunner_xml_parser.rb +0 -178
- data/lib/gooby/cls_forerunner_xml_splitter.rb +0 -109
- data/lib/gooby/cls_geo_data.rb +0 -181
- data/lib/gooby/cls_gooby_command.rb +0 -46
- data/lib/gooby/cls_gooby_object.rb +0 -18
- data/lib/gooby/cls_google_map_generator.rb +0 -363
- data/lib/gooby/cls_history.rb +0 -33
- data/lib/gooby/cls_lap.rb +0 -22
- data/lib/gooby/cls_line.rb +0 -75
- data/lib/gooby/cls_options.rb +0 -67
- data/lib/gooby/cls_position.rb +0 -44
- data/lib/gooby/cls_run.rb +0 -194
- data/lib/gooby/cls_simple_xml_parser.rb +0 -41
- data/lib/gooby/cls_test_regen.rb +0 -182
- data/lib/gooby/cls_track.rb +0 -47
- data/lib/gooby/cls_trackpoint.rb +0 -200
- data/lib/gooby/cls_training_center_parser.rb +0 -183
- data/lib/gooby/cls_training_center_splitter.rb +0 -109
- data/lib/gooby/mod_introspect.rb +0 -26
- data/lib/gooby/mod_io.rb +0 -58
- data/lib/gooby/mod_project_info.rb +0 -80
- data/lib/gooby/mod_string.rb +0 -19
- data/lib/gooby/mod_test_helper.rb +0 -15
- data/samples/20041113_richmond_marathon.html +0 -532
- data/samples/run_2007_01_10_22_44_54.html +0 -201
- data/samples/run_2007_02_24_15_01_35.html +0 -298
- data/tests/tc_cls_counter_hash.rb +0 -107
- data/tests/tc_cls_delim_line.rb +0 -74
- data/tests/tc_cls_dttm.rb +0 -131
- data/tests/tc_cls_duration.rb +0 -51
- data/tests/tc_cls_forerunner_xml_parser.rb +0 -70
- data/tests/tc_cls_geo_data.xxx +0 -71
- data/tests/tc_cls_gooby_object.rb +0 -26
- data/tests/tc_cls_google_map_generator.rb +0 -109
- data/tests/tc_cls_history.rb +0 -46
- data/tests/tc_cls_lap.rb +0 -38
- data/tests/tc_cls_line.rb +0 -110
- data/tests/tc_cls_options.rb +0 -79
- data/tests/tc_cls_position.rb +0 -66
- data/tests/tc_cls_run.rb +0 -142
- data/tests/tc_cls_simple_xml_parser.rb +0 -50
- data/tests/tc_cls_track.rb +0 -70
- data/tests/tc_cls_trackpoint.rb +0 -145
- data/tests/tc_mod_introspect.rb +0 -32
- data/tests/tc_mod_io.rb +0 -53
- data/tests/tc_mod_project_info.rb +0 -79
- data/tests/tc_mod_string.rb +0 -58
- /data/data/{phx.csv → 20060115_phoenix_marathon.csv} +0 -0
- /data/data/{phx.xml → 20060115_phoenix_marathon.xml} +0 -0
data/lib/gooby/cls_geo_data.rb
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
module Gooby
|
2
|
-
|
3
|
-
=begin rdoc
|
4
|
-
Instances of this class represent a the set of Geographic data defined in file geo.txt
|
5
|
-
=end
|
6
|
-
|
7
|
-
class GeoData < GoobyObject
|
8
|
-
|
9
|
-
attr_reader :filename, :lines, :poi_hash, :poi_array, :track_hash, :track_array, :route_hash, :route_array
|
10
|
-
|
11
|
-
def initialize(filename)
|
12
|
-
@filename = filename
|
13
|
-
@filename = 'data/geo_data.txt' if @filename == nil
|
14
|
-
@lines = read_lines(@filename, true)
|
15
|
-
@poi_hash = Hash.new
|
16
|
-
@poi_array = Array.new
|
17
|
-
@track_hash = Hash.new
|
18
|
-
@track_array = Array.new
|
19
|
-
@route_hash = Hash.new
|
20
|
-
@route_array = Array.new
|
21
|
-
parse_poi
|
22
|
-
parse_tracks
|
23
|
-
parse_routes
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def parse_poi
|
29
|
-
in_poi, poi_number = false, 0
|
30
|
-
@lines.each { |line|
|
31
|
-
line_obj = Line.new(line, nil, true)
|
32
|
-
tok_count = line_obj.token_count
|
33
|
-
is_point = line_obj.token_idx_equals(0, '.')
|
34
|
-
|
35
|
-
if line_obj.is_populated_non_comment
|
36
|
-
if line_obj.match('points_of_interest_start')
|
37
|
-
in_poi = true
|
38
|
-
elsif line_obj.match('points_of_interest_end')
|
39
|
-
in_poi = false
|
40
|
-
elsif in_poi && tok_count > 2 && is_point
|
41
|
-
poi_number = poi_number + 1
|
42
|
-
tkpt = Trackpoint.new(
|
43
|
-
poi_number, line_obj.tokens[1], line_obj.tokens[2],
|
44
|
-
'0', '', line_obj.concatinate_tokens(3))
|
45
|
-
add_poi(tkpt)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
def parse_tracks
|
52
|
-
in_track, trk_number, tkpt_number = false, 0, 0
|
53
|
-
curr_trk, curr_run = nil, nil
|
54
|
-
@lines.each { |line|
|
55
|
-
line_obj = Line.new(line, nil, true)
|
56
|
-
tok_count = line_obj.token_count
|
57
|
-
is_point = line_obj.token_idx_equals(0, '.')
|
58
|
-
|
59
|
-
if line_obj.is_populated_non_comment
|
60
|
-
if line_obj.match('track_start')
|
61
|
-
in_track = true
|
62
|
-
trk_number = trk_number + 1
|
63
|
-
tkpt_number = 0
|
64
|
-
curr_trk = Track.new(0, line_obj.concatinate_tokens(1))
|
65
|
-
curr_run = Run.new(trk_number, line_obj.concatinate_tokens(1))
|
66
|
-
curr_run.add_track(curr_trk)
|
67
|
-
elsif line_obj.match('track_end')
|
68
|
-
in_track = false
|
69
|
-
curr_run.finish
|
70
|
-
add_track(curr_trk)
|
71
|
-
add_route(curr_run)
|
72
|
-
elsif in_track && tok_count > 2 && is_point
|
73
|
-
tkpt_number = tkpt_number + 1
|
74
|
-
tkpt = Trackpoint.new(
|
75
|
-
tkpt_number, line_obj.tokens[1], line_obj.tokens[2],
|
76
|
-
'0', '', line_obj.concatinate_tokens(3))
|
77
|
-
curr_trk.add_trackpoint(tkpt)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
def parse_routes
|
84
|
-
in_route, route_number, trk_number, tkpt_number = false, 0, 0, 0
|
85
|
-
curr_trk, curr_run = nil, nil
|
86
|
-
@lines.each { |line|
|
87
|
-
line_obj = Line.new(line, nil, true)
|
88
|
-
tok_count = line_obj.token_count
|
89
|
-
is_point = line_obj.token_idx_equals(0, '.')
|
90
|
-
|
91
|
-
if line_obj.is_populated_non_comment
|
92
|
-
if line_obj.match('route_start')
|
93
|
-
in_route = true
|
94
|
-
trk_number = trk_number + 1
|
95
|
-
tkpt_number = 0
|
96
|
-
curr_trk = Track.new(0, line_obj.concatinate_tokens(1))
|
97
|
-
curr_run = Run.new(trk_number, line_obj.concatinate_tokens(1))
|
98
|
-
curr_run.add_track(curr_trk)
|
99
|
-
elsif line_obj.match('route_end')
|
100
|
-
in_route = false
|
101
|
-
curr_run.finish
|
102
|
-
add_route(curr_run)
|
103
|
-
elsif in_route && tok_count > 2 && is_point
|
104
|
-
tkpt_number = tkpt_number + 1
|
105
|
-
tkpt = Trackpoint.new(
|
106
|
-
tkpt_number, line_obj.tokens[1], line_obj.tokens[2],
|
107
|
-
'0', '', line_obj.concatinate_tokens(3))
|
108
|
-
curr_trk.add_trackpoint(tkpt)
|
109
|
-
elsif in_route && line_obj.token_idx_equals(0, 'track') && tok_count > 1
|
110
|
-
trk_desc = line_obj.concatinate_tokens(1)
|
111
|
-
trk = @track_hash[trk_desc]
|
112
|
-
if trk
|
113
|
-
trk.trackpoints.each { |tkpt| curr_trk.add_trackpoint(tkpt) }
|
114
|
-
end
|
115
|
-
elsif in_route && line_obj.token_idx_equals(0, 'track_rev') && tok_count > 1
|
116
|
-
trk_desc = line_obj.concatinate_tokens(1)
|
117
|
-
trk = @track_hash[trk_desc]
|
118
|
-
if trk
|
119
|
-
array = trk.trackpoints
|
120
|
-
trk.trackpoints.each { |tkpt| curr_trk.add_trackpoint(tkpt) }
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
}
|
125
|
-
end
|
126
|
-
|
127
|
-
def add_poi(tkpt)
|
128
|
-
if tkpt
|
129
|
-
descr = tkpt.descr
|
130
|
-
if @poi_hash.has_key? descr
|
131
|
-
puts "Duplicate POI key ignored - '#{descr}'"
|
132
|
-
else
|
133
|
-
#puts "Adding POI: #{tkpt.to_poi_csv}"
|
134
|
-
@poi_hash[descr] = tkpt
|
135
|
-
@poi_array << tkpt
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def add_track(trk)
|
141
|
-
if trk
|
142
|
-
descr = trk.descr
|
143
|
-
if @track_hash.has_key? descr
|
144
|
-
puts "Duplicate Track key ignored - '#{descr}'"
|
145
|
-
else
|
146
|
-
@track_hash[descr] = trk
|
147
|
-
@track_array << trk
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def add_route(run)
|
153
|
-
if run
|
154
|
-
descr = run.descr
|
155
|
-
if @route_hash.has_key? descr
|
156
|
-
puts "Duplicate Route key ignored - '#{descr}'"
|
157
|
-
else
|
158
|
-
@route_hash[descr] = run
|
159
|
-
@route_array << run
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
public
|
165
|
-
|
166
|
-
def to_s
|
167
|
-
return "GeoData lines: #{lines.size} poi: #{@poi_hash.size} tracks: #{@track_hash.size} routes: #{@route_hash.size} "
|
168
|
-
end
|
169
|
-
|
170
|
-
def dump
|
171
|
-
puts "#{self.class} dump:"
|
172
|
-
@poi_array.each { |tkpt| puts "POI: #{tkpt.to_geo_s}" }
|
173
|
-
@track_array.each { |trk| trk.dump }
|
174
|
-
@route_hash.keys.sort.each { |key|
|
175
|
-
puts "Route: '#{key}'"
|
176
|
-
}
|
177
|
-
end
|
178
|
-
|
179
|
-
end
|
180
|
-
|
181
|
-
end # end of module
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Gooby
|
2
|
-
|
3
|
-
=begin rdoc
|
4
|
-
This class provides "user friendly DSL" functionality for the use
|
5
|
-
of Gooby.
|
6
|
-
=end
|
7
|
-
|
8
|
-
class GoobyCommand < GoobyObject
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
end
|
12
|
-
|
13
|
-
def options(yaml_filename)
|
14
|
-
Gooby::Options.new(yaml_filename)
|
15
|
-
end
|
16
|
-
|
17
|
-
def split_garmin_forerunner_logbook_xml(xml_filename, out_dir)
|
18
|
-
splitter = Gooby::ForerunnerXmlSplitter.new(xml_filename, out_dir)
|
19
|
-
splitter.split
|
20
|
-
end
|
21
|
-
|
22
|
-
def split_garmin_training_center_xml(tcx_filename, out_dir)
|
23
|
-
splitter = Gooby::TrainingCenterXmlSplitter.new(tcx_filename, out_dir)
|
24
|
-
splitter.split
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse_garmin_forerunner_logbook_xml(xml_filename)
|
28
|
-
handler = Gooby::ForerunnerXmlParser.new
|
29
|
-
Document.parse_stream((File.new xml_filename), handler)
|
30
|
-
handler.put_all_run_tkpt_csv(true)
|
31
|
-
end
|
32
|
-
|
33
|
-
def parse_garmin_training_center_xml(tcx_filename)
|
34
|
-
handler = Gooby::TrainingCenterXmlParser.new
|
35
|
-
Document.parse_stream((File.new tcx_filename), handler)
|
36
|
-
handler.put_all_run_tkpt_csv(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
def generate_google_map(csv_filename, options_obj)
|
40
|
-
generator = Gooby::GoogleMapGenerator.new(csv_filename)
|
41
|
-
generator.generate_page(options_obj)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end # end of module
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Gooby
|
2
|
-
|
3
|
-
=begin rdoc
|
4
|
-
This is the abstract superclass of several Gooby classes.
|
5
|
-
Includes modules GoobyIO, Introspect, and GoobyProjectInfo.
|
6
|
-
=end
|
7
|
-
|
8
|
-
class GoobyObject
|
9
|
-
|
10
|
-
include Gooby::GoobyIO
|
11
|
-
include Gooby::GoobyString
|
12
|
-
include Gooby::Introspect
|
13
|
-
include Gooby::GoobyProjectInfo
|
14
|
-
include Gooby::Con
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end # end of module
|
@@ -1,363 +0,0 @@
|
|
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
|
data/lib/gooby/cls_history.rb
DELETED
@@ -1,33 +0,0 @@
|
|
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
|
data/lib/gooby/cls_lap.rb
DELETED
@@ -1,22 +0,0 @@
|
|
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
|