gooby 0.9.4 → 0.9.5
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.
- 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_trackpoint.rb
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
=begin rdoc
|
|
4
|
-
Instances of this class represent a <Trackpoint> aggregate from a Forerunner
|
|
5
|
-
XML file. Additionally, there is distance, pace, and Google Map generation
|
|
6
|
-
logic in this class.
|
|
7
|
-
|
|
8
|
-
<Trackpoint>
|
|
9
|
-
<Position>
|
|
10
|
-
<Latitude>35.49577</Latitude>
|
|
11
|
-
<Longitude>-80.83281</Longitude>
|
|
12
|
-
<Altitude>232.296</Altitude>
|
|
13
|
-
</Position>
|
|
14
|
-
<Time>2007-01-06T15:27:51Z</Time>
|
|
15
|
-
</Trackpoint>
|
|
16
|
-
=end
|
|
17
|
-
|
|
18
|
-
class Trackpoint < Position
|
|
19
|
-
|
|
20
|
-
attr_reader :first, :last, :number, :runNumber, :dttm, :prevTkpt, :descr
|
|
21
|
-
attr_reader :cumulativeDistance, :cumulativePace, :incrementalDistance, :split, :prevSplit
|
|
22
|
-
attr_writer :first, :last, :runNumber
|
|
23
|
-
|
|
24
|
-
def initialize(num, lat, lng, alt, time_string, descr='')
|
|
25
|
-
@number = num
|
|
26
|
-
@runNumber = 0
|
|
27
|
-
|
|
28
|
-
# initialize superclass variables:
|
|
29
|
-
@latitude = lat.to_s
|
|
30
|
-
@longitude = lng.to_s
|
|
31
|
-
@altitude = alt.to_s
|
|
32
|
-
@note = note.to_s
|
|
33
|
-
@dttm = DtTm.new(time_string)
|
|
34
|
-
@first = false
|
|
35
|
-
@last = false
|
|
36
|
-
@prevTkpt = nil
|
|
37
|
-
@cumulativeDistance, @split = 0.0, 0.0
|
|
38
|
-
@cumulativePace = ""
|
|
39
|
-
@descr = descr
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
public
|
|
43
|
-
|
|
44
|
-
def position
|
|
45
|
-
Position.new(@latitude, @longitude, @altitude, @note)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def to_s
|
|
49
|
-
"Tkpt: #{@number} #{super.to_s} date: #{@dttm.to_s} cdist: #{@cumulativeDistance}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def to_csv
|
|
53
|
-
ss = position.to_csv
|
|
54
|
-
"#{@runNumber} | #{@dttm.to_s} | #{@number} | #{ss} | #{@cumulativeDistance} "
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def to_geo_s
|
|
58
|
-
ss = position.to_csv
|
|
59
|
-
"Tkpt: #{@number} | #{ss} | #{@descr}"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def compute_distance_and_pace(curr_index, start_dttm, prev_cumulative_dist, prev_trackpoint, units)
|
|
63
|
-
@prev_tkpt = prev_trackpoint
|
|
64
|
-
@cumulativeDistance = prev_cumulative_dist.to_f
|
|
65
|
-
|
|
66
|
-
if @prev_tkpt
|
|
67
|
-
arg1 = latitude().to_f
|
|
68
|
-
arg2 = @prev_tkpt.latitude().to_f
|
|
69
|
-
arg3 = latitude().to_f
|
|
70
|
-
arg4 = @prev_tkpt.latitude().to_f
|
|
71
|
-
theta = longitude().to_f - @prev_tkpt.longitude().to_f
|
|
72
|
-
|
|
73
|
-
res1 = Math.sin(deg2rad(arg1))
|
|
74
|
-
res2 = Math.sin(deg2rad(arg2))
|
|
75
|
-
res3 = Math.cos(deg2rad(arg3))
|
|
76
|
-
res4 = Math.cos(deg2rad(arg4))
|
|
77
|
-
res5 = Math.cos(deg2rad(theta.to_f))
|
|
78
|
-
|
|
79
|
-
incremental_distance = ((res1 * res2) + (res3 * res4 * res5)).to_f
|
|
80
|
-
|
|
81
|
-
if (!incremental_distance.nan?)
|
|
82
|
-
incremental_distance = Math.acos(incremental_distance.to_f)
|
|
83
|
-
if (!incremental_distance.nan?)
|
|
84
|
-
incremental_distance = rad2deg(incremental_distance)
|
|
85
|
-
if (!incremental_distance.nan?)
|
|
86
|
-
incremental_distance = incremental_distance * 60 * 1.1515;
|
|
87
|
-
if (!incremental_distance.nan?)
|
|
88
|
-
if units == "K"
|
|
89
|
-
incremental_distance = incremental_distance * 1.609344;
|
|
90
|
-
end
|
|
91
|
-
if units == "N"
|
|
92
|
-
incremental_distance = incremental_distance * 0.8684;
|
|
93
|
-
end
|
|
94
|
-
@cumulativeDistance = @cumulativeDistance + incremental_distance.to_f
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
compute_cumulative_pace(start_dttm)
|
|
100
|
-
@cumulativeDistance
|
|
101
|
-
else
|
|
102
|
-
0
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def compute_cumulative_pace(start_dttm)
|
|
107
|
-
if @cumulativeDistance > 0
|
|
108
|
-
secsDiff = @dttm.seconds_diff(start_dttm)
|
|
109
|
-
secsMile = ((secsDiff.to_f) / (@cumulativeDistance.to_f))
|
|
110
|
-
minsMile = (secsMile / 60)
|
|
111
|
-
wholeMins = minsMile.floor
|
|
112
|
-
secsBal = secsMile - (wholeMins * 60)
|
|
113
|
-
s1 = "#{secsDiff} #{secsMile} #{minsMile} #{wholeMins} #{secsBal} #{@cumulativeDistance} | "
|
|
114
|
-
s2 = sprintf("%d:%2.1f", minsMile, secsBal)
|
|
115
|
-
@cumulativePace = "#{s2}"
|
|
116
|
-
else
|
|
117
|
-
@cumulativePace = ""
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def set_split(n, tkpt)
|
|
122
|
-
@split, @prevSplit = n, tkpt
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def is_split()
|
|
126
|
-
(@split >= 1)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def is_first()
|
|
130
|
-
@first
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def is_last()
|
|
134
|
-
@last
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def split_info(dtTm)
|
|
138
|
-
if is_split
|
|
139
|
-
hhmmss = ''
|
|
140
|
-
if @prevSplit
|
|
141
|
-
return "#{@split} #{@dttm.hhmmss_diff(@prevSplit.dttm())}"
|
|
142
|
-
else
|
|
143
|
-
return "#{@split} #{@dttm.hhmmss_diff(dtTm)}"
|
|
144
|
-
end
|
|
145
|
-
else
|
|
146
|
-
""
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
private
|
|
151
|
-
|
|
152
|
-
def deg2rad(degrees)
|
|
153
|
-
(((0 + degrees) * Math::PI) / 180)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def rad2deg(radians)
|
|
157
|
-
(((0 + radians) * 180) / Math::PI)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
public
|
|
161
|
-
|
|
162
|
-
def as_glatlng(comments, tkpt_count, curr_idx, gpoint_count, start_dttm)
|
|
163
|
-
if comments
|
|
164
|
-
secs_diff = @dttm.seconds_diff(start_dttm)
|
|
165
|
-
fmt_time = @dttm.hhmmss_diff(start_dttm)
|
|
166
|
-
"\n points.push(new GLatLng(#{latitude_as_float},#{longitude_as_float})); " +
|
|
167
|
-
"// #{gpoint_count} (#{curr_idx + 1} of #{tkpt_count}) #{@dttm.to_s} #{secs_diff} #{fmt_time} #{@cumulativeDistance} #{split_info(start_dttm)} "
|
|
168
|
-
else
|
|
169
|
-
"\n points.push(new GLatLng(#{latitude_as_float},#{longitude_as_float})); "
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def as_info_window_html(checkpoint, start_dttm)
|
|
174
|
-
s = "\"<table align='left'>"
|
|
175
|
-
if checkpoint
|
|
176
|
-
secs_diff = @dttm.seconds_diff(start_dttm)
|
|
177
|
-
fmt_time = @dttm.hhmmss_diff(start_dttm)
|
|
178
|
-
|
|
179
|
-
if checkpoint == 'Start'
|
|
180
|
-
s << "<tr><td colspan='2'><b>Start!</b></td></tr>"
|
|
181
|
-
elsif checkpoint == 'Finish'
|
|
182
|
-
s << "<tr><td colspan='2'><b>Finish!</b></td></tr>"
|
|
183
|
-
else
|
|
184
|
-
s << "<tr><td colspan='2'><b>Checkpoint #{checkpoint}</b></td></tr>"
|
|
185
|
-
end
|
|
186
|
-
s << "<tr><td>Distance: </td><td>#{@cumulativeDistance}</td></tr>"
|
|
187
|
-
s << "<tr><td>Time of Day: </td><td>#{@dttm.to_s} </td></tr>"
|
|
188
|
-
s << "<tr><td>Elapsed Time: </td><td>#{fmt_time} </td></tr>"
|
|
189
|
-
s << "<tr><td>Average Pace: </td><td>#{@cumulativePace} </td></tr>"
|
|
190
|
-
s << "<tr><td>Lat/Lng: </td><td>#{latitude_as_float} , #{longitude_as_float} </td></tr>"
|
|
191
|
-
s << "<tr><td>Altitude: </td><td>#{altitude_as_float}m </td></tr>"
|
|
192
|
-
s
|
|
193
|
-
end
|
|
194
|
-
s << "</table>\""
|
|
195
|
-
s
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
end # end of module
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
=begin rdoc
|
|
4
|
-
Instances of this class are used to parse a Garmin TrainingCenter XML file
|
|
5
|
-
in a SAX-like manner. Instances of the model classes - History, Run, Track,
|
|
6
|
-
Trackpoint, etc. are created in this parsing process.
|
|
7
|
-
|
|
8
|
-
See http://www.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd for the XML
|
|
9
|
-
Schema Definition for Garmin TrainingCenter XML.
|
|
10
|
-
=end
|
|
11
|
-
|
|
12
|
-
class TrainingCenterXmlParser
|
|
13
|
-
|
|
14
|
-
DETAIL_TAGS = %w( Notes StartTime Duration Length Time
|
|
15
|
-
TotalTimeSeconds DistanceMeters
|
|
16
|
-
LatitudeDegrees LongitudeDegrees AltitudeMeters BeginPosition EndPosition )
|
|
17
|
-
|
|
18
|
-
include REXML::StreamListener
|
|
19
|
-
|
|
20
|
-
attr_reader :history, :cvHash, :tagCount
|
|
21
|
-
|
|
22
|
-
def initialize
|
|
23
|
-
@cvHash = Hash.new("")
|
|
24
|
-
@tagCount = 0
|
|
25
|
-
@runCount = 0
|
|
26
|
-
@lapCount = 0
|
|
27
|
-
@trackCount = 0
|
|
28
|
-
@trackpoint_count = 0
|
|
29
|
-
@currText = "";
|
|
30
|
-
@history = History.new
|
|
31
|
-
@currRun = nil
|
|
32
|
-
@currLap = nil
|
|
33
|
-
@currTrack = nil
|
|
34
|
-
@currBeginPosition = nil
|
|
35
|
-
@currEndPosition = nil
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
public
|
|
39
|
-
|
|
40
|
-
# SAX API method; handles 'Activity', 'Lap', 'Track'.
|
|
41
|
-
def tag_start(tagname, attrs)
|
|
42
|
-
@tagCount += 1
|
|
43
|
-
@currTag = tagname
|
|
44
|
-
@cvHash[tagname] = ''
|
|
45
|
-
|
|
46
|
-
if detail_tag?(tagname)
|
|
47
|
-
@inDetail = true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
if is_tag?('Activity', tagname)
|
|
51
|
-
@runCount = @runCount + 1
|
|
52
|
-
@lapCount = 0
|
|
53
|
-
@trackCount = 0
|
|
54
|
-
@currRun = Run.new(@runCount)
|
|
55
|
-
@history.add_run(@currRun)
|
|
56
|
-
@cvHash['Notes'] = ''
|
|
57
|
-
return
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
if is_tag?('Lap', tagname)
|
|
61
|
-
@lapCount = @lapCount + 1
|
|
62
|
-
@currLap = Lap.new(@lapCount)
|
|
63
|
-
# TODO - capture value of 'StartTime' attribute.
|
|
64
|
-
return
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
if is_tag?('Track', tagname)
|
|
68
|
-
@trackCount = @trackCount + 1
|
|
69
|
-
@currTrack = Track.new(@trackCount)
|
|
70
|
-
@trackpoint_count = 0
|
|
71
|
-
return
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# SAX API method; handles 'Position', 'Trackpoint', 'Track', 'Lap', 'Run'.
|
|
77
|
-
def tag_end(tagname)
|
|
78
|
-
if @inDetail
|
|
79
|
-
@cvHash[tagname] = @currText
|
|
80
|
-
else
|
|
81
|
-
if is_tag?('Position', tagname)
|
|
82
|
-
lat = @cvHash['LatitudeDegrees']
|
|
83
|
-
long = @cvHash['LongitudeDegrees']
|
|
84
|
-
@currBeginPosition = Position.new(lat.strip, long.strip, '')
|
|
85
|
-
@currEndPosition = Position.new(lat.strip, long.strip, '')
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
if is_tag?('BeginPosition', tagname)
|
|
89
|
-
lat = @cvHash['LatitudeDegrees']
|
|
90
|
-
long = @cvHash['LongitudeDegrees']
|
|
91
|
-
@currBeginPosition = Position.new(lat.strip, long.strip, '')
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
if is_tag?('EndPosition', tagname)
|
|
95
|
-
lat = @cvHash['LatitudeDegrees']
|
|
96
|
-
long = @cvHash['LongitudeDegrees']
|
|
97
|
-
@currEndPosition = Position.new(lat.strip, long.strip, '')
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
if is_tag?('Trackpoint', tagname)
|
|
101
|
-
@trackpoint_count = @trackpoint_count + 1
|
|
102
|
-
lat = @cvHash['LatitudeDegrees']
|
|
103
|
-
long = @cvHash['LongitudeDegrees']
|
|
104
|
-
alt = @cvHash['AltitudeMeters']
|
|
105
|
-
time = @cvHash['Time']
|
|
106
|
-
tp = Trackpoint.new(@trackpoint_count, lat, long, alt, time)
|
|
107
|
-
@currTrack.add_trackpoint(tp)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
if is_tag?('Track', tagname)
|
|
111
|
-
if @currRun != nil
|
|
112
|
-
@currRun.add_track(@currTrack)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
if is_tag?('Lap', tagname)
|
|
117
|
-
# TotalTimeSeconds DistanceMeters
|
|
118
|
-
# TODO - rework tnd of Lap for tcx
|
|
119
|
-
# @currLap.startTime = @cvHash['StartTime']
|
|
120
|
-
# @currLap.duration = Duration.new(@cvHash['Duration'])
|
|
121
|
-
# @currLap.length = @cvHash['Length']
|
|
122
|
-
# @currLap.beginPosition = @currBeginPosition
|
|
123
|
-
# @currLap.endPosition = @currEndPosition
|
|
124
|
-
@currRun.add_lap(@currLap)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
if is_tag?('Activity', tagname)
|
|
128
|
-
@currRun.notes = @cvHash['Notes']
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
@inDetail = false
|
|
133
|
-
@currText = ""
|
|
134
|
-
@currTag = ""
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# SAX API method.
|
|
138
|
-
def text(txt)
|
|
139
|
-
if @inDetail
|
|
140
|
-
@currText = @currText + txt
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# Iterate all parsed Run objects and print each with to_s.
|
|
145
|
-
def gdump()
|
|
146
|
-
@history.runs().each { |run| puts run.to_s }
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
# Iterate all parsed Run objects and print each with to_s.
|
|
150
|
-
def dump()
|
|
151
|
-
@history.runs().each { |run| puts run.to_s }
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# Iterate all parsed Run objects and print each with put_csv.
|
|
155
|
-
def put_run_csv()
|
|
156
|
-
@history.runs().each { |run| run.put_csv() }
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Iterate all parsed Run objects and print each with put_tkpt_csv.
|
|
160
|
-
def put_all_run_tkpt_csv(with_header_comment)
|
|
161
|
-
@history.runs.each { |run|
|
|
162
|
-
run.put_tkpt_csv(with_header_comment)
|
|
163
|
-
}
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
private
|
|
167
|
-
|
|
168
|
-
def is_tag?(tagname, value)
|
|
169
|
-
tagname == value
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def detail_tag?(tagname)
|
|
173
|
-
DETAIL_TAGS.each { |typ|
|
|
174
|
-
if typ == tagname
|
|
175
|
-
return true
|
|
176
|
-
end
|
|
177
|
-
}
|
|
178
|
-
return false
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
end # end of module
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
=begin rdoc
|
|
4
|
-
Instances of this class are used to split a large Garmin TrainingCenter
|
|
5
|
-
*.tcx file into individual 'activity_' files.
|
|
6
|
-
=end
|
|
7
|
-
|
|
8
|
-
class TrainingCenterXmlSplitter < GoobyObject
|
|
9
|
-
|
|
10
|
-
attr_reader :out_dir, :training_center_files, :out_files_hash
|
|
11
|
-
|
|
12
|
-
def initialize(tcx_file, out_dir)
|
|
13
|
-
@out_dir = out_dir
|
|
14
|
-
@training_center_files = Array.new
|
|
15
|
-
@training_center_files << tcx_file
|
|
16
|
-
@out_files_hash = Hash.new
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def split
|
|
20
|
-
@training_center_files.each { |f| process_file(f) }
|
|
21
|
-
write_files
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def process_file(training_center_tcx_file)
|
|
27
|
-
@file_name = training_center_tcx_file
|
|
28
|
-
@tcx_lines = read_lines(@file_name, false)
|
|
29
|
-
@line_num = 0
|
|
30
|
-
@activity_num = 0
|
|
31
|
-
@curr_activity_lines = Array.new
|
|
32
|
-
@curr_activity_tkpts = 0
|
|
33
|
-
@start_line_num = 0
|
|
34
|
-
@end_line_num = 0
|
|
35
|
-
@activity_start_time = nil
|
|
36
|
-
|
|
37
|
-
@tcx_lines.each { |line|
|
|
38
|
-
@line_num = @line_num + 1
|
|
39
|
-
if (line.match(/<Activity /))
|
|
40
|
-
@activity_num = @activity_num + 1
|
|
41
|
-
@start_line_num = @line_num
|
|
42
|
-
@curr_activity_lines = Array.new
|
|
43
|
-
@curr_activity_lines << line
|
|
44
|
-
elsif (line.match(/<Id>/)) # <Id>2007-03-03T15:58:57Z</Id> <StartTime>2007-01-13T15:37:06Z</StartTime>
|
|
45
|
-
@curr_activity_lines << line
|
|
46
|
-
if @activity_start_time == nil
|
|
47
|
-
clone = String.new(line)
|
|
48
|
-
clone.gsub!(/[<>]/, ' ')
|
|
49
|
-
clone.gsub!(/[-:T]/, '_')
|
|
50
|
-
clone.gsub!(/[Z]/, '')
|
|
51
|
-
tokens = clone.split
|
|
52
|
-
@activity_start_time = tokens[1]
|
|
53
|
-
end
|
|
54
|
-
elsif (line.match(/<Trackpoint>/))
|
|
55
|
-
@curr_activity_tkpts = @curr_activity_tkpts + 1
|
|
56
|
-
@curr_activity_lines << line
|
|
57
|
-
elsif (line.match(/<\/Activity/))
|
|
58
|
-
@end_line_num = @line_num
|
|
59
|
-
@curr_activity_lines << line
|
|
60
|
-
end_run
|
|
61
|
-
elsif (@curr_activity_lines.size > 0)
|
|
62
|
-
@curr_activity_lines << line
|
|
63
|
-
end
|
|
64
|
-
}
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def end_run
|
|
68
|
-
out_file = "#{@out_dir}/activity_#{@activity_start_time}.xml"
|
|
69
|
-
comment = "<!-- file: #{out_file} lines: #{@curr_activity_lines.size} (#{@start_line_num} to #{@end_line_num}) tkpts: #{@curr_activity_tkpts} --> \n"
|
|
70
|
-
@curr_activity_lines.insert(0, comment)
|
|
71
|
-
|
|
72
|
-
prev_entry = @out_files_hash[out_file]
|
|
73
|
-
if prev_entry
|
|
74
|
-
if (@curr_activity_lines.size >= prev_entry.size)
|
|
75
|
-
puts "previous entry overlaid for #{out_file}. curr=#{@curr_activity_lines.size} prev=#{prev_entry.size}"
|
|
76
|
-
@out_files_hash[out_file] = @curr_activity_lines
|
|
77
|
-
else
|
|
78
|
-
puts "previous entry retained for #{out_file}. curr=#{@curr_activity_lines.size} prev=#{prev_entry.size}"
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
puts "new entry for #{out_file}. curr=#{@curr_activity_lines.size}"
|
|
82
|
-
@out_files_hash[out_file] = @curr_activity_lines
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
@curr_activity_lines = Array.new
|
|
86
|
-
@curr_activity_tkpts = 0
|
|
87
|
-
@start_line_num = 0
|
|
88
|
-
@end_line_num = 0
|
|
89
|
-
@activity_start_time = nil
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def write_files
|
|
93
|
-
out_names = @out_files_hash.keys.sort
|
|
94
|
-
puts "Writing #{out_names.size} extract files..."
|
|
95
|
-
out_names.each { |out_name|
|
|
96
|
-
lines = @out_files_hash[out_name]
|
|
97
|
-
out = File.new out_name, "w+"
|
|
98
|
-
lines.each { |line| out.write line }
|
|
99
|
-
out.flush
|
|
100
|
-
out.close
|
|
101
|
-
puts "File written: #{out_name}"
|
|
102
|
-
}
|
|
103
|
-
puts "output files written."
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end # end of module
|
|
109
|
-
|
data/lib/gooby/mod_introspect.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
module Introspect
|
|
4
|
-
|
|
5
|
-
# Return a String w/instance variable and method info.
|
|
6
|
-
def introspect
|
|
7
|
-
c = self.class
|
|
8
|
-
s = "Class: #{c} "
|
|
9
|
-
iv = self.instance_variables.sort
|
|
10
|
-
s << " ivc=#{iv.size}"
|
|
11
|
-
iv.each { |v| s << " #{v}" }
|
|
12
|
-
meth = self.methods.sort
|
|
13
|
-
s << " mc=#{meth.size}"
|
|
14
|
-
meth.each { |m| s << " #{m}" }
|
|
15
|
-
s << ""
|
|
16
|
-
s
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Return 'self.instance_variables'.
|
|
20
|
-
def to_yaml_properties
|
|
21
|
-
self.instance_variables
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end # end of module
|
data/lib/gooby/mod_io.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
module GoobyIO
|
|
4
|
-
|
|
5
|
-
# Return an Array of lines in file, optionally stripped.
|
|
6
|
-
def read_lines(filename, strip=false)
|
|
7
|
-
|
|
8
|
-
array = IO.readlines(filename)
|
|
9
|
-
if strip
|
|
10
|
-
array = strip_lines(array)
|
|
11
|
-
end
|
|
12
|
-
return array
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Return an Array of lines in file per the given delimeter, optionally stripped.
|
|
16
|
-
def read_as_ascii_lines(filename, delim=10, strip=false)
|
|
17
|
-
|
|
18
|
-
array = Array.new
|
|
19
|
-
file = File.new(filename)
|
|
20
|
-
currLine = ''
|
|
21
|
-
bytesRead = 0
|
|
22
|
-
linesRead = 0
|
|
23
|
-
|
|
24
|
-
file.each_byte { |b|
|
|
25
|
-
bytesRead = bytesRead + 1
|
|
26
|
-
if (b == delim) # delim is 13 for quicken, 10 for address book xml
|
|
27
|
-
array << currLine
|
|
28
|
-
currLine = ''
|
|
29
|
-
linesRead = linesRead + 1
|
|
30
|
-
else
|
|
31
|
-
if (b < 127)
|
|
32
|
-
currLine << "#{b.chr}"
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if currLine.size > 0
|
|
38
|
-
array << currLine
|
|
39
|
-
end
|
|
40
|
-
if strip
|
|
41
|
-
array = strip_lines(array)
|
|
42
|
-
end
|
|
43
|
-
return array
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Strip the lines/Strings; return a new Array.
|
|
47
|
-
def strip_lines(array)
|
|
48
|
-
|
|
49
|
-
newArray = Array.new
|
|
50
|
-
if (array != nil)
|
|
51
|
-
array.each { |line| line.strip! ; newArray << line }
|
|
52
|
-
end
|
|
53
|
-
return newArray
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end # end of module
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
=begin rdoc
|
|
4
|
-
This module is used to embed information about the Gooby project and
|
|
5
|
-
version into the codebase.
|
|
6
|
-
|
|
7
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
8
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
module GoobyProjectInfo
|
|
12
|
-
|
|
13
|
-
# Return a String version number, like '1.0.0'.
|
|
14
|
-
def project_version_number
|
|
15
|
-
'0.9.4'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Return a String date, like '2007/02/25'.
|
|
19
|
-
def project_date
|
|
20
|
-
'2007/03/03'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Return a String year, like '2007'.
|
|
24
|
-
def project_year
|
|
25
|
-
project_date[0...4] # start, length
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Return a String containing copyright, year, and author.
|
|
29
|
-
def project_copyright
|
|
30
|
-
"Copyright (C) #{project_year} #{project_author}"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Return a String containing GNU/GPL, and the gpl.html URL.
|
|
34
|
-
def project_license
|
|
35
|
-
'GNU General Public License (GPL). See http://www.gnu.org/copyleft/gpl.html'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Return a String containing the project author name.
|
|
39
|
-
def project_author
|
|
40
|
-
'Chris Joakim'
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def google_maps_api_level
|
|
44
|
-
'2'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def some_new_thing
|
|
48
|
-
'2'
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def tested_files
|
|
52
|
-
array = Array.new
|
|
53
|
-
array << 'cls_counter_hash.rb'
|
|
54
|
-
array << 'cls_delim_line.rb'
|
|
55
|
-
array << 'cls_dttm.rb'
|
|
56
|
-
array << 'cls_duration.rb'
|
|
57
|
-
array << 'cls_forerunner_xml_parser.rb'
|
|
58
|
-
array << 'cls_geo_data.rb'
|
|
59
|
-
array << 'cls_gooby_object.rb'
|
|
60
|
-
array << 'cls_google_map_generator.rb'
|
|
61
|
-
array << 'cls_history.rb'
|
|
62
|
-
array << 'cls_lap.rb'
|
|
63
|
-
array << 'cls_line.rb'
|
|
64
|
-
array << 'cls_options.rb'
|
|
65
|
-
array << 'cls_position.rb'
|
|
66
|
-
array << 'cls_run.rb'
|
|
67
|
-
array << 'cls_simple_xml_parser.rb'
|
|
68
|
-
array << 'cls_track.rb'
|
|
69
|
-
array << 'cls_trackpoint.rb'
|
|
70
|
-
array << 'mod_constants.rb'
|
|
71
|
-
array << 'mod_introspect.rb'
|
|
72
|
-
array << 'mod_io.rb'
|
|
73
|
-
array << 'mod_project_info.rb'
|
|
74
|
-
array << 'mod_string.rb'
|
|
75
|
-
array
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end # end of module
|
data/lib/gooby/mod_string.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Gooby
|
|
2
|
-
|
|
3
|
-
module GoobyString
|
|
4
|
-
|
|
5
|
-
def tokenize(string, delim, strip=false)
|
|
6
|
-
if string
|
|
7
|
-
tokens = string.split(delim)
|
|
8
|
-
if strip
|
|
9
|
-
tokens.each { |tok| tok.strip! }
|
|
10
|
-
end
|
|
11
|
-
tokens
|
|
12
|
-
else
|
|
13
|
-
Array.new
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end # end of module
|