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.
- data/README +133 -341
- data/config/ballantyne.yaml +11 -0
- data/config/big_sur_marathon.yaml +11 -0
- data/config/crowders_mtn_hike.yaml +11 -0
- data/config/davidson1.yaml +16 -0
- data/config/gooby_config.yaml +28 -135
- data/cucumber.yml +1 -0
- data/features/build_gem.feature +88 -0
- data/features/gooby.feature +300 -0
- data/features/install.feature +78 -0
- data/features/steps/gooby_steps.rb +245 -0
- data/features/support/env.rb +4 -0
- data/lib/gooby.rb +24 -30
- data/lib/gooby_activity.rb +63 -0
- data/lib/gooby_base_object.rb +46 -0
- data/lib/gooby_base_sax_parser.rb +95 -0
- data/lib/gooby_configuration.rb +33 -115
- data/lib/gooby_counter_hash.rb +28 -87
- data/lib/gooby_dttm.rb +88 -66
- data/lib/gooby_environment.rb +48 -0
- data/lib/gooby_garmin_tcx_parser.rb +92 -0
- data/lib/gooby_google_kml_generator.rb +168 -0
- data/lib/gooby_google_map_generator.rb +284 -349
- data/lib/gooby_gpx_parser.rb +97 -0
- data/lib/gooby_help_producer.rb +40 -0
- data/lib/gooby_introspection.rb +25 -0
- data/lib/gooby_io.rb +30 -0
- data/lib/gooby_lap.rb +27 -18
- data/lib/gooby_process.rb +281 -0
- data/lib/gooby_sax_path_parser.rb +43 -0
- data/lib/gooby_tcx_extractor.rb +71 -0
- data/lib/gooby_track_log_parser.rb +114 -0
- data/lib/gooby_trackpoint.rb +276 -0
- data/lib/gooby_xml_object.rb +40 -0
- data/{img/gicons → out/images}/blank.png +0 -0
- data/{img/gicons → out/images}/dd-end.png +0 -0
- data/{img/gicons → out/images}/dd-start.png +0 -0
- data/{img/gicons → out/images}/marker.png +0 -0
- data/{img/gicons → out/images}/marker0.png +0 -0
- data/{img/gicons → out/images}/marker00.png +0 -0
- data/{img/gicons → out/images}/marker01.png +0 -0
- data/{img/gicons → out/images}/marker02.png +0 -0
- data/{img/gicons → out/images}/marker03.png +0 -0
- data/{img/gicons → out/images}/marker04.png +0 -0
- data/{img/gicons → out/images}/marker05.png +0 -0
- data/{img/gicons → out/images}/marker06.png +0 -0
- data/{img/gicons → out/images}/marker07.png +0 -0
- data/{img/gicons → out/images}/marker08.png +0 -0
- data/{img/gicons → out/images}/marker09.png +0 -0
- data/{img/gicons → out/images}/marker1.png +0 -0
- data/{img/gicons → out/images}/marker10.png +0 -0
- data/{img/gicons → out/images}/marker11.png +0 -0
- data/{img/gicons → out/images}/marker12.png +0 -0
- data/{img/gicons → out/images}/marker13.png +0 -0
- data/{img/gicons → out/images}/marker14.png +0 -0
- data/{img/gicons → out/images}/marker15.png +0 -0
- data/{img/gicons → out/images}/marker16.png +0 -0
- data/{img/gicons → out/images}/marker17.png +0 -0
- data/{img/gicons → out/images}/marker18.png +0 -0
- data/{img/gicons → out/images}/marker19.png +0 -0
- data/{img/gicons → out/images}/marker2.png +0 -0
- data/{img/gicons → out/images}/marker20.png +0 -0
- data/{img/gicons → out/images}/marker21.png +0 -0
- data/{img/gicons → out/images}/marker22.png +0 -0
- data/{img/gicons → out/images}/marker23.png +0 -0
- data/{img/gicons → out/images}/marker24.png +0 -0
- data/{img/gicons → out/images}/marker25.png +0 -0
- data/{img/gicons → out/images}/marker26.png +0 -0
- data/{img/gicons → out/images}/marker27.png +0 -0
- data/{img/gicons → out/images}/marker28.png +0 -0
- data/{img/gicons → out/images}/marker29.png +0 -0
- data/{img/gicons → out/images}/marker3.png +0 -0
- data/{img/gicons → out/images}/marker30.png +0 -0
- data/{img/gicons → out/images}/marker31.png +0 -0
- data/{img/gicons → out/images}/marker32.png +0 -0
- data/{img/gicons → out/images}/marker33.png +0 -0
- data/{img/gicons → out/images}/marker34.png +0 -0
- data/{img/gicons → out/images}/marker35.png +0 -0
- data/{img/gicons → out/images}/marker36.png +0 -0
- data/{img/gicons → out/images}/marker37.png +0 -0
- data/{img/gicons → out/images}/marker38.png +0 -0
- data/{img/gicons → out/images}/marker39.png +0 -0
- data/{img/gicons → out/images}/marker4.png +0 -0
- data/{img/gicons → out/images}/marker40.png +0 -0
- data/{img/gicons → out/images}/marker41.png +0 -0
- data/{img/gicons → out/images}/marker42.png +0 -0
- data/{img/gicons → out/images}/marker43.png +0 -0
- data/{img/gicons → out/images}/marker44.png +0 -0
- data/{img/gicons → out/images}/marker45.png +0 -0
- data/{img/gicons → out/images}/marker46.png +0 -0
- data/{img/gicons → out/images}/marker47.png +0 -0
- data/{img/gicons → out/images}/marker48.png +0 -0
- data/{img/gicons → out/images}/marker49.png +0 -0
- data/{img/gicons → out/images}/marker5.png +0 -0
- data/{img/gicons → out/images}/marker50.png +0 -0
- data/{img/gicons → out/images}/marker51.png +0 -0
- data/{img/gicons → out/images}/marker52.png +0 -0
- data/{img/gicons → out/images}/marker53.png +0 -0
- data/{img/gicons → out/images}/marker54.png +0 -0
- data/{img/gicons → out/images}/marker55.png +0 -0
- data/{img/gicons → out/images}/marker56.png +0 -0
- data/{img/gicons → out/images}/marker57.png +0 -0
- data/{img/gicons → out/images}/marker58.png +0 -0
- data/{img/gicons → out/images}/marker59.png +0 -0
- data/{img/gicons → out/images}/marker6.png +0 -0
- data/{img/gicons → out/images}/marker60.png +0 -0
- data/{img/gicons → out/images}/marker61.png +0 -0
- data/{img/gicons → out/images}/marker62.png +0 -0
- data/{img/gicons → out/images}/marker63.png +0 -0
- data/{img/gicons → out/images}/marker64.png +0 -0
- data/{img/gicons → out/images}/marker65.png +0 -0
- data/{img/gicons → out/images}/marker66.png +0 -0
- data/{img/gicons → out/images}/marker67.png +0 -0
- data/{img/gicons → out/images}/marker68.png +0 -0
- data/{img/gicons → out/images}/marker69.png +0 -0
- data/{img/gicons → out/images}/marker7.png +0 -0
- data/{img/gicons → out/images}/marker70.png +0 -0
- data/{img/gicons → out/images}/marker71.png +0 -0
- data/{img/gicons → out/images}/marker72.png +0 -0
- data/{img/gicons → out/images}/marker73.png +0 -0
- data/{img/gicons → out/images}/marker74.png +0 -0
- data/{img/gicons → out/images}/marker75.png +0 -0
- data/{img/gicons → out/images}/marker76.png +0 -0
- data/{img/gicons → out/images}/marker77.png +0 -0
- data/{img/gicons → out/images}/marker78.png +0 -0
- data/{img/gicons → out/images}/marker79.png +0 -0
- data/{img/gicons → out/images}/marker8.png +0 -0
- data/{img/gicons → out/images}/marker80.png +0 -0
- data/{img/gicons → out/images}/marker81.png +0 -0
- data/{img/gicons → out/images}/marker82.png +0 -0
- data/{img/gicons → out/images}/marker83.png +0 -0
- data/{img/gicons → out/images}/marker84.png +0 -0
- data/{img/gicons → out/images}/marker85.png +0 -0
- data/{img/gicons → out/images}/marker86.png +0 -0
- data/{img/gicons → out/images}/marker87.png +0 -0
- data/{img/gicons → out/images}/marker88.png +0 -0
- data/{img/gicons → out/images}/marker89.png +0 -0
- data/{img/gicons → out/images}/marker9.png +0 -0
- data/{img/gicons → out/images}/marker90.png +0 -0
- data/{img/gicons → out/images}/marker91.png +0 -0
- data/{img/gicons → out/images}/marker92.png +0 -0
- data/{img/gicons → out/images}/marker93.png +0 -0
- data/{img/gicons → out/images}/marker94.png +0 -0
- data/{img/gicons → out/images}/marker95.png +0 -0
- data/{img/gicons → out/images}/marker96.png +0 -0
- data/{img/gicons → out/images}/marker97.png +0 -0
- data/{img/gicons → out/images}/marker98.png +0 -0
- data/{img/gicons → out/images}/marker99.png +0 -0
- data/{img/gicons → out/images}/markerA.png +0 -0
- data/{img/gicons → out/images}/markerB.png +0 -0
- data/{img/gicons → out/images}/markerC.png +0 -0
- data/{img/gicons → out/images}/markerD.png +0 -0
- data/{img/gicons → out/images}/markerE.png +0 -0
- data/{img/gicons → out/images}/markerF.png +0 -0
- data/{img/gicons → out/images}/markerG.png +0 -0
- data/{img/gicons → out/images}/markerH.png +0 -0
- data/{img/gicons → out/images}/markerI.png +0 -0
- data/{img/gicons → out/images}/markerJ.png +0 -0
- data/{img/gicons → out/images}/mm_20_red.png +0 -0
- data/{img/gicons → out/images}/mm_20_shadow.png +0 -0
- data/{img/gicons → out/images}/shadow50.png +0 -0
- data/rakefile.rb +79 -0
- data/samples.sh +21 -0
- data/samples/2008_04_27_13_49_50_tcx.csv +2449 -0
- data/samples/2008_04_27_13_49_50_tcx.xml +24560 -0
- data/samples/2009_01_01_14_45_00_tcx.xml +10630 -0
- data/samples/ballantyne.csv +27 -0
- data/samples/ballantyne.gpx +117 -0
- data/samples/ballantyne.kml +91 -0
- data/samples/big_sur_marathon.html +2766 -0
- data/samples/big_sur_marathon.kml +685 -0
- data/samples/build_gem_test_results.txt +6 -0
- data/samples/crowders_mtn_hike.csv +1065 -0
- data/samples/crowders_mtn_hike.html +1283 -0
- data/samples/crowders_mtn_hike.log +1 -0
- data/samples/cucumber_test_results.txt +302 -0
- data/samples/davidson1.csv +1 -0
- data/samples/davidson1.html +75 -0
- data/samples/davidson_1_point_tcx.csv +0 -0
- data/samples/doc.kml +49 -0
- data/samples/gps_track_log_asheville_mt_pisgah.txt +1 -0
- data/samples/gps_track_logs.txt +1 -0
- data/samples/install_test_results.txt +81 -0
- data/samples/mt_pisgah.txt +1 -0
- data/samples/rspec_test_results.txt +5 -0
- data/setup.rb +66 -0
- data/spec/gooby_base_object_spec.rb +116 -0
- data/spec/gooby_counter_hash_spec.rb +34 -0
- data/spec/gooby_dttm_spec.rb +40 -0
- data/spec/gooby_spec_helper.rb +9 -0
- data/spec/gooby_xml_object_spec.rb +32 -0
- metadata +225 -226
- data/bin/code_scan.rb +0 -16
- data/bin/gooby_been_there.rb +0 -33
- data/bin/gooby_config.rb +0 -24
- data/bin/gooby_csv_validation.rb +0 -50
- data/bin/gooby_first_trackpoints_as_poi.rb +0 -31
- data/bin/gooby_gen_gmap.rb +0 -20
- data/bin/gooby_parser.rb +0 -21
- data/bin/gooby_splitter.rb +0 -21
- data/bin/gooby_version.rb +0 -20
- data/bin/run_all.sh +0 -33
- data/bin/run_been_there.sh +0 -19
- data/bin/run_config.sh +0 -12
- data/bin/run_csv_validation.sh +0 -15
- data/bin/run_db_gen.sh +0 -11
- data/bin/run_db_load.sh +0 -11
- data/bin/run_first_trackpoints_as_poi.sh +0 -16
- data/bin/run_gen_gmaps.sh +0 -21
- data/bin/run_parse_full.sh +0 -45
- data/bin/run_parse_samples.sh +0 -21
- data/bin/run_split.sh +0 -24
- data/bin/run_version.sh +0 -12
- data/data/20050305_corporate_cup_hm.csv +0 -251
- data/data/20050305_corporate_cup_hm.xml +0 -2208
- data/data/20050430_nashville_marathon.xml +0 -10043
- data/data/20050430_nashville_marathon_km.csv +0 -1208
- data/data/20060115_phoenix_marathon.csv +0 -1280
- data/data/20060115_phoenix_marathon.xml +0 -10620
- data/data/20070101_davidson_11m.csv +0 -251
- data/data/20070101_davidson_11m.xml +0 -2020
- data/data/20070505_davidson_5k.xml +0 -2875
- data/data/20070505_davidson_5k_km.csv +0 -286
- data/data/hrm1.csv +0 -5
- data/img/gicons/readme.txt +0 -14
- data/lib/gooby_code_scanner.rb +0 -288
- data/lib/gooby_command.rb +0 -210
- data/lib/gooby_course.rb +0 -117
- data/lib/gooby_csv_point.rb +0 -71
- data/lib/gooby_csv_reader.rb +0 -71
- data/lib/gooby_csv_run.rb +0 -28
- data/lib/gooby_delim_line.rb +0 -42
- data/lib/gooby_duration.rb +0 -86
- data/lib/gooby_forerunner_xml_parser.rb +0 -191
- data/lib/gooby_forerunner_xml_splitter.rb +0 -115
- data/lib/gooby_history.rb +0 -41
- data/lib/gooby_kernel.rb +0 -163
- data/lib/gooby_line.rb +0 -80
- data/lib/gooby_object.rb +0 -22
- data/lib/gooby_point.rb +0 -172
- data/lib/gooby_run.rb +0 -213
- data/lib/gooby_simple_xml_parser.rb +0 -50
- data/lib/gooby_test_helper.rb +0 -23
- data/lib/gooby_track.rb +0 -47
- data/lib/gooby_track_point.rb +0 -229
- data/lib/gooby_training_center_xml_parser.rb +0 -224
- data/lib/gooby_training_center_xml_splitter.rb +0 -116
- data/lib/split_code.sh +0 -29
- data/samples/20050305_corporate_cup_hm.html +0 -450
- data/samples/20050430_nashville_marathon.html +0 -1668
- data/samples/20060115_phoenix_marathon.html +0 -1596
- data/samples/20070101_davidson_11m.html +0 -432
- data/samples/20070505_davidson_5k.html +0 -413
- data/samples/been_there.txt +0 -92
- data/samples/hrm1.html +0 -87
- data/sql/gooby.ddl +0 -60
- data/sql/gooby_load.dml +0 -62
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
This class is used to parse a gpx xml file, such as from MotionX GPS software on an iPhone.
|
|
9
|
+
|
|
10
|
+
This implementation, based on one sample file, handles a gpx file with one 'trk'.
|
|
11
|
+
A future implementation may handle multiple 'trk' elements per document, as well as
|
|
12
|
+
'trkseg' aggregates. The observed structure of a gpx document is:
|
|
13
|
+
|
|
14
|
+
gpx
|
|
15
|
+
gpx|trk
|
|
16
|
+
gpx|trk|name
|
|
17
|
+
gpx|trk|desc
|
|
18
|
+
gpx|trk|trkseg
|
|
19
|
+
gpx|trk|trkseg|trkpt
|
|
20
|
+
gpx|trk|trkseg|trkpt|ele
|
|
21
|
+
gpx|trk|trkseg|trkpt|time
|
|
22
|
+
|
|
23
|
+
=end
|
|
24
|
+
|
|
25
|
+
class GoobyGpxParser < GoobyBaseSaxParser
|
|
26
|
+
|
|
27
|
+
def subclass_initialize
|
|
28
|
+
@tags, @trackpoints, @mappings, = [], [], {},
|
|
29
|
+
@name, @desc = '', ''
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def on_start_element(name, attributes, prefix=nil, uri=nil, namespaces=nil)
|
|
33
|
+
@tags.push(name)
|
|
34
|
+
@current_text = ''
|
|
35
|
+
path = current_path
|
|
36
|
+
if path == 'gpx|trk|trkseg|trkpt'
|
|
37
|
+
@current_trackpoint = GoobyTrackpoint.new
|
|
38
|
+
@current_trackpoint.set('LatitudeDegrees', attributes['lat'])
|
|
39
|
+
@current_trackpoint.set('LongitudeDegrees', attributes['lon'])
|
|
40
|
+
@current_trackpoint.set('Time', get_current_text)
|
|
41
|
+
@trackpoints << @current_trackpoint
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def on_end_element(name, prefix=nil, uri=nil)
|
|
46
|
+
path = current_path
|
|
47
|
+
if path == 'gpx|trk|name'
|
|
48
|
+
@name = get_current_text
|
|
49
|
+
elsif path == 'gpx|trk|desc'
|
|
50
|
+
@desc = get_current_text
|
|
51
|
+
elsif path == 'gpx|trk|trkseg|trkpt|ele'
|
|
52
|
+
@current_trackpoint.set('AltitudeMeters', get_current_text)
|
|
53
|
+
elsif path == 'gpx|trk|trkseg|trkpt|time'
|
|
54
|
+
@current_trackpoint.set('Time', get_current_text)
|
|
55
|
+
end
|
|
56
|
+
@current_text = ''
|
|
57
|
+
@tags.pop
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def current_path
|
|
61
|
+
@tags.join('|')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Coumpute the elapsed time and distance of each Trackpoint within the Activity.
|
|
65
|
+
def post_process
|
|
66
|
+
cumulative_distance, first_tkpt_dttm, prev_tkpt, activ_id = 0.0, nil, nil, @name
|
|
67
|
+
@trackpoints.each_with_index { | tkpt, idx |
|
|
68
|
+
if prev_tkpt
|
|
69
|
+
incremental_distance = tkpt.proximity(prev_tkpt)
|
|
70
|
+
cumulative_distance = cumulative_distance + incremental_distance
|
|
71
|
+
tkpt.set('Distance', cumulative_distance)
|
|
72
|
+
else
|
|
73
|
+
first_tkpt_dttm = tkpt.dttm
|
|
74
|
+
tkpt.set('Distance', 0.0)
|
|
75
|
+
if activ_id.size < 1
|
|
76
|
+
activ_id = first_tkpt_dttm
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
tkpt.set('Seq', idx + 1)
|
|
80
|
+
tkpt.set('LapSeq', 1)
|
|
81
|
+
tkpt.set('ActivityId', activ_id)
|
|
82
|
+
tkpt.set('LapStartTime', first_tkpt_dttm)
|
|
83
|
+
tkpt.compute_elapsed_time(first_tkpt_dttm)
|
|
84
|
+
tkpt.compute_cumulative_pace_and_mph(first_tkpt_dttm)
|
|
85
|
+
prev_tkpt = tkpt
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def trackpoints_to_csv
|
|
90
|
+
lines = []
|
|
91
|
+
@trackpoints.each { | tkpt |
|
|
92
|
+
lines << tkpt.to_csv
|
|
93
|
+
}
|
|
94
|
+
lines
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The help information is obtained here by "grepping" the given source code
|
|
9
|
+
filename, and selecting the lines which contain three consecutive hash symbols.
|
|
10
|
+
This enables the documentation to reside with the actual code.
|
|
11
|
+
|
|
12
|
+
=end
|
|
13
|
+
|
|
14
|
+
module GoobyHelpProducer
|
|
15
|
+
|
|
16
|
+
def produce_help_page(source_filename, print_it=false)
|
|
17
|
+
help_content, marker, lines = [], '###', IO.readlines(source_filename)
|
|
18
|
+
lines.each { | line |
|
|
19
|
+
if line.match(marker)
|
|
20
|
+
if line.strip == marker
|
|
21
|
+
help_content << "\n"
|
|
22
|
+
else
|
|
23
|
+
help_content << line.strip[4..999]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
}
|
|
27
|
+
help_content << ''
|
|
28
|
+
if ENV['GOOBY_HOME']
|
|
29
|
+
help_content << "Your GOOBY_HOME directory is currently set to #{ENV['GOOBY_HOME']}"
|
|
30
|
+
else
|
|
31
|
+
help_content << "Your GOOBY_HOME directory environment variable has not been set; please do so."
|
|
32
|
+
end
|
|
33
|
+
help_content << ''
|
|
34
|
+
if print_it
|
|
35
|
+
help_content.each { | line | puts line }
|
|
36
|
+
end
|
|
37
|
+
help_content
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
|
5
|
+
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
module GoobyIntrospection
|
|
9
|
+
|
|
10
|
+
def self.included(base)
|
|
11
|
+
base.extend ClassMethods
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def classname
|
|
15
|
+
self.class.name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module ClassMethods
|
|
19
|
+
|
|
20
|
+
def classname
|
|
21
|
+
self.name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/gooby_io.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
|
5
|
+
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
module GoobyIO
|
|
9
|
+
|
|
10
|
+
def read_file_as_lines(filename)
|
|
11
|
+
IO.readlines(filename)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def write_lines(out_name, lines)
|
|
15
|
+
s = ''
|
|
16
|
+
lines.each { | line |
|
|
17
|
+
s << line
|
|
18
|
+
s << "\n"
|
|
19
|
+
}
|
|
20
|
+
write_file(out_name, s)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def write_file(out_name, content, mode='w+')
|
|
24
|
+
out = File.new out_name, mode
|
|
25
|
+
out.write content
|
|
26
|
+
out.flush
|
|
27
|
+
out.close
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
data/lib/gooby_lap.rb
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
5
4
|
Gooby is available under GNU General Public License (GPL) license.
|
|
6
5
|
|
|
7
6
|
=end
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
=begin rdoc
|
|
12
|
-
Instances of this class represent a <Lap> aggregate object from a
|
|
13
|
-
Forerunner XML file.
|
|
14
|
-
=end
|
|
8
|
+
class GoobyLap < GoobyXmlObject
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
def initialize(attrs=nil)
|
|
11
|
+
base_initialize
|
|
12
|
+
if attrs
|
|
13
|
+
attrs.keys.each { | name | set(name, attrs[name]) }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
def start_time
|
|
18
|
+
get('StartTime')
|
|
19
|
+
end
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
def seconds
|
|
22
|
+
get('TotalTimeSeconds').to_f
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def distance_in_meters
|
|
26
|
+
get('DistanceMeters').to_f
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def max_speed
|
|
30
|
+
get('MaximumSpeed').to_f
|
|
31
|
+
end
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
def dump
|
|
34
|
+
puts "Lap: #{id}, #{sequence}, #{start_time}, #{distance_in_meters}, #{max_speed}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
27
38
|
|
|
28
|
-
end
|
|
29
39
|
|
|
30
|
-
end # end of module
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
4
|
+
Gooby is available under GNU General Public License (GPL) license.
|
|
5
|
+
|
|
6
|
+
=end
|
|
7
|
+
|
|
8
|
+
class GoobyProcess
|
|
9
|
+
|
|
10
|
+
include GoobyConfiguration
|
|
11
|
+
include GoobyEnvironment
|
|
12
|
+
include GoobyHelpProducer
|
|
13
|
+
include GoobyIO
|
|
14
|
+
|
|
15
|
+
attr_reader :method_name, :subsystem, :tmp_dir, :start_time, :exception
|
|
16
|
+
attr_reader :dispatch, :help_content, :system_test_commands
|
|
17
|
+
|
|
18
|
+
def initialize(method_name_symbol, opts={})
|
|
19
|
+
begin
|
|
20
|
+
@start_time, @method_name = Time.now, method_name_symbol.to_s
|
|
21
|
+
if opts
|
|
22
|
+
opts.keys.each { | key | ENV[key.to_s] = opts[key].to_s }
|
|
23
|
+
end
|
|
24
|
+
if @method_name != 'help'
|
|
25
|
+
puts "---"
|
|
26
|
+
puts "Beginning of Gooby process: '#{method_name_symbol}'"
|
|
27
|
+
end
|
|
28
|
+
self.send(method_name_symbol.to_s) # "dynamic dispatch" to the implementation method
|
|
29
|
+
rescue Exception => e
|
|
30
|
+
@exception = e
|
|
31
|
+
puts "Exception in process #{process_info}"
|
|
32
|
+
puts "class: #{e.class.name}"
|
|
33
|
+
puts "exception: #{e.inspect}"
|
|
34
|
+
if e.backtrace && e.backtrace.class == Array
|
|
35
|
+
e.backtrace.each { | line | puts line }
|
|
36
|
+
else
|
|
37
|
+
puts e.backtrace
|
|
38
|
+
end
|
|
39
|
+
ensure
|
|
40
|
+
if @method_name != 'help'
|
|
41
|
+
end_time = Time.now
|
|
42
|
+
elapsed = end_time - start_time
|
|
43
|
+
minutes = elapsed.to_f / 60.0
|
|
44
|
+
hours = elapsed.to_f / 3600.0
|
|
45
|
+
puts "Process completed #{Time.now.to_s}."
|
|
46
|
+
puts sprintf("Elapsed seconds %6.6f = %5.6f minutes = %2.6f hours", elapsed, minutes, hours)
|
|
47
|
+
puts "---"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def classname
|
|
53
|
+
self.class.name
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def process_info
|
|
57
|
+
"'#{classname}.#{method_name.to_s}'"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def gooby_home
|
|
61
|
+
ENV['GOOBY_HOME']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
###
|
|
65
|
+
### Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim.
|
|
66
|
+
### Gooby is available under GNU General Public License (GPL) license.
|
|
67
|
+
### Version 2.0.0
|
|
68
|
+
###
|
|
69
|
+
### Directory Structure:
|
|
70
|
+
### {GOOBY_HOME} Your chosen directory on your computer in which to store Gooby files.
|
|
71
|
+
### You must set the "GOOBY_HOME" environment variable on your computer to this
|
|
72
|
+
### chosen directory name.
|
|
73
|
+
### {GOOBY_HOME}/config Contains configuration files in yaml format.
|
|
74
|
+
### File /config/gooby_config.yaml is the "base" configuration file, and is read first.
|
|
75
|
+
### This file typically remains unchanged after your intial edits to it. Be sure to
|
|
76
|
+
### set "gmap_key" to your Google Maps key, and "gmap_icon_url_base" to the URL on
|
|
77
|
+
### your site where the map icon images are located.
|
|
78
|
+
### You should create one "map-specific" yaml file for each map you wish to create.
|
|
79
|
+
### It "inherits" all entries from the base configuration file, gooby_config.yaml.
|
|
80
|
+
### So just specify the additions or overrides in your map-specific yaml files.
|
|
81
|
+
### This design allows you generate your various maps, without having to frequently
|
|
82
|
+
### reset the values the the base configuration file.
|
|
83
|
+
### {GOOBY_HOME}/csv Gooby places CSV data files in this directory. All Gooby parsers create a
|
|
84
|
+
### standard CSV format that you can use to generate either Google maps or Google Earth
|
|
85
|
+
### maps with.
|
|
86
|
+
### {GOOBY_HOME}/data You place data files from your desktop GPS software here.
|
|
87
|
+
### {GOOBY_HOME}/out Gooby places generated Google Map html files and Google Earth kml files here.
|
|
88
|
+
### {GOOBY_HOME}/out/images Standard set of images here which are used in the generated html & kml files.
|
|
89
|
+
### Add your own images here, or replace the existing ones, as necessary.
|
|
90
|
+
### {GOOBY_HOME}/samples Contains a set of sample files for your reference.
|
|
91
|
+
### {GOOBY_HOME}/splits Gooby places individual 'activity xml files' here, split-out from a large tcx file.
|
|
92
|
+
### {GOOBY_HOME}/tmp Temporary files.
|
|
93
|
+
###
|
|
94
|
+
### List of Gooby commands (in order of typical usage):
|
|
95
|
+
### rake # Default task; same as 'rake gooby:help'.
|
|
96
|
+
### rake gooby:help # Display Gooby usage instructions.
|
|
97
|
+
### rake gooby:extract_activities_from_tcx # Extract individual Activity xml files from a Garmin tcx file
|
|
98
|
+
### rake gooby:parse_activity_xml_to_csv # Parse an extracted Activity xml file to a corresponding csv file.
|
|
99
|
+
### rake gooby:parse_track_log_to_csv # Parse a GPS Track Log file a corresponding csv file.
|
|
100
|
+
### rake gooby:parse_gpx_to_csv # Parse a *.gpx file into a corresponding csv file.
|
|
101
|
+
### rake gooby:generate_google_map # Generate a Google Map from a csv file.
|
|
102
|
+
### rake gooby:generate_google_earth_map # Generate a Google Earth kml file from a csv file, with optional
|
|
103
|
+
### kmz file generation.
|
|
104
|
+
###
|
|
105
|
+
### Gooby Command Detail:
|
|
106
|
+
###
|
|
107
|
+
### command: rake gooby:help
|
|
108
|
+
### description: Displays help information for each Gooby command.
|
|
109
|
+
### parameters: none
|
|
110
|
+
def help
|
|
111
|
+
produce_help_page(__FILE__, true)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
###
|
|
115
|
+
### ---
|
|
116
|
+
###
|
|
117
|
+
### command: rake gooby:extract_activities_from_tcx
|
|
118
|
+
### description: Splits the potentially huge Garmin Training Center tcx file into individual
|
|
119
|
+
### Activity xml files, and places these in the /splits directory. Each has a filename
|
|
120
|
+
### based on the starting date/time of the activity.
|
|
121
|
+
### parameters: tcx_file - The input file, created by exporting from Garmin Training Center.
|
|
122
|
+
### Defaults to 'data/current.tcx' in your GOOBY_HOME directory.
|
|
123
|
+
## example: rake gooby:extract_activities_from_tcx tcx_file=data/current.tcx
|
|
124
|
+
def extract_activities_from_tcx
|
|
125
|
+
tcx_file = command_line_arg('tcx_file', "#{gooby_home}/data/current.tcx")
|
|
126
|
+
if File.exist?(tcx_file)
|
|
127
|
+
puts "processing file: #{tcx_file}"
|
|
128
|
+
extractor = GoobyTcxExtractor.new
|
|
129
|
+
extractor.extract(tcx_file, "#{gooby_home}/splits")
|
|
130
|
+
else
|
|
131
|
+
puts "file does not exist: #{tcx_file} GOOBY_HOME is #{gooby_home}"
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
###
|
|
136
|
+
### ---
|
|
137
|
+
###
|
|
138
|
+
### command: rake gooby:parse_activity_xml_to_csv
|
|
139
|
+
### description: Parse an extracted Activity xml 'split' file to a corresponding csv file.
|
|
140
|
+
### parameters: config_file - Your yaml configuration file in /config.
|
|
141
|
+
### Defaults to 'config/gooby_config.yaml' in your GOOBY_HOME directory.
|
|
142
|
+
### note 1: The configuration file entry 'activity_xml_file' specifies the xml file that
|
|
143
|
+
### will be read and parsed into csv.
|
|
144
|
+
### note 2: The configuration file entry 'csv_file' specifies the csv file that will be created.
|
|
145
|
+
### example: rake gooby:parse_activity_xml_to_csv config_file=config/big_sur_marathon.yaml
|
|
146
|
+
def parse_activity_xml_to_csv
|
|
147
|
+
config_file = command_line_arg('config_file', nil)
|
|
148
|
+
read_configuration(config_file)
|
|
149
|
+
file = @configuration['activity_xml_file']
|
|
150
|
+
csv_file = @configuration['csv_file']
|
|
151
|
+
if File.exist?(file)
|
|
152
|
+
puts "processing file: #{file}"
|
|
153
|
+
parser = GoobyGarminTcxParser.new
|
|
154
|
+
parser.process_file(file)
|
|
155
|
+
puts "parser.error #{parser.error}" if parser.error
|
|
156
|
+
puts "parser.exception #{parser.exception}" if parser.exception
|
|
157
|
+
parser.post_process
|
|
158
|
+
csv_lines = parser.trackpoints_to_csv
|
|
159
|
+
# basename = File.basename(file)
|
|
160
|
+
# basename.gsub!('.xml', '.csv')
|
|
161
|
+
csv_filename = "#{gooby_home}/#{csv_file}"
|
|
162
|
+
# csv_filename.gsub!('.xml', '.csv')
|
|
163
|
+
write_lines(csv_filename, csv_lines)
|
|
164
|
+
puts "file written; #{csv_filename}"
|
|
165
|
+
else
|
|
166
|
+
puts "file does not exist: #{file}"
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
###
|
|
171
|
+
### ---
|
|
172
|
+
###
|
|
173
|
+
### command: rake gooby:parse_gpx_to_csv
|
|
174
|
+
### description: Parse a *.gpx file into a corresponding csv file.
|
|
175
|
+
### parameters: config_file - Your yaml configuration file in /config.
|
|
176
|
+
### Defaults to 'config/gooby_config.yaml' in your GOOBY_HOME directory.
|
|
177
|
+
### note 1: The configuration file entry 'gpx_file' specifies the gpx file that
|
|
178
|
+
### will be read and parsed into csv.
|
|
179
|
+
### note 2: The configuration file entry 'csv_file' specifies the csv file that will be created.
|
|
180
|
+
### example: rake gooby:parse_gpx_to_csv config_file=config/ballantyne.yaml
|
|
181
|
+
def parse_gpx_to_csv
|
|
182
|
+
config_file = command_line_arg('config_file', nil)
|
|
183
|
+
read_configuration(config_file)
|
|
184
|
+
file = @configuration['gpx_file']
|
|
185
|
+
csv_file = @configuration['csv_file']
|
|
186
|
+
if File.exist?(file)
|
|
187
|
+
puts "processing file: #{file}"
|
|
188
|
+
parser = GoobyGpxParser.new
|
|
189
|
+
parser.process_file(file)
|
|
190
|
+
puts "parser.error #{parser.error}" if parser.error
|
|
191
|
+
puts "parser.exception #{parser.exception}" if parser.exception
|
|
192
|
+
parser.post_process
|
|
193
|
+
csv_lines = parser.trackpoints_to_csv
|
|
194
|
+
# basename = File.basename(file)
|
|
195
|
+
# basename.gsub!('.gpx', '.csv')
|
|
196
|
+
csv_filename = "#{gooby_home}/#{csv_file}"
|
|
197
|
+
#csv_filename.gsub!('.gpx', '.csv')
|
|
198
|
+
write_lines(csv_filename, csv_lines)
|
|
199
|
+
puts "file written; #{csv_filename}"
|
|
200
|
+
else
|
|
201
|
+
puts "file does not exist: #{file}"
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
###
|
|
206
|
+
### ---
|
|
207
|
+
###
|
|
208
|
+
### command: rake gooby:parse_track_log_to_csv
|
|
209
|
+
### description: Parse an extracted 'GPS Tracks Log' file from MacGpsPro into csv format.
|
|
210
|
+
### parameters: config_file - Your yaml configuration file in /config.
|
|
211
|
+
### Defaults to 'config/gooby_config.yaml' in your GOOBY_HOME directory.
|
|
212
|
+
### note 1: The configuration file entry 'track_log_file' specifies the track log file that
|
|
213
|
+
### will be read and parsed into csv. The filename suffix should be '.txt'.
|
|
214
|
+
### note 2: It is strongly recommended that you manually copy the 'GPS Tracks Log' file
|
|
215
|
+
### from your MacGpsPro installation to the GOOBY_HOME/data directory, and rename it to
|
|
216
|
+
### 'gps_track_logs.txt', before running this command. Then manually edit out the lines
|
|
217
|
+
### not pertinent to the map you want to generate.
|
|
218
|
+
### note 3: I use MacGpsPro to read the GPS data from my Garmin eTrex Venture device, since the
|
|
219
|
+
### Garmin Training Center software does not support this device.
|
|
220
|
+
### example: rake gooby:parse_track_log_to_csv config_file=config/crowders_mtn_hike.yaml
|
|
221
|
+
def parse_track_log_to_csv
|
|
222
|
+
config_file = command_line_arg('config_file', nil)
|
|
223
|
+
read_configuration(config_file)
|
|
224
|
+
logs_file = @configuration['track_log_file']
|
|
225
|
+
logs_file = "#{gooby_home}/data/gps_track_logs.txt" if logs_file.nil?
|
|
226
|
+
csv_file = @configuration['csv_file']
|
|
227
|
+
if File.exist?(logs_file)
|
|
228
|
+
puts "processing file: #{logs_file}"
|
|
229
|
+
parser = GoobyTracksLogParser.new
|
|
230
|
+
parser.parse(logs_file)
|
|
231
|
+
csv_lines = parser.trackpoints_to_csv
|
|
232
|
+
csv_filename = "#{gooby_home}/#{csv_file}"
|
|
233
|
+
write_lines(csv_filename, csv_lines)
|
|
234
|
+
puts "file written; #{csv_filename}"
|
|
235
|
+
else
|
|
236
|
+
puts "file does not exist: #{logs_file}"
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
###
|
|
241
|
+
### ---
|
|
242
|
+
###
|
|
243
|
+
### command: rake gooby:generate_google_map
|
|
244
|
+
### description: Generate a Google Map html file from a csv file.
|
|
245
|
+
### parameters: config_file - Your yaml configuration file in /config.
|
|
246
|
+
### Defaults to 'config/gooby_config.yaml' in your GOOBY_HOME directory.
|
|
247
|
+
### note 1: The configuration file entry 'csv_file' specifies the csv data file that
|
|
248
|
+
### will be read and used to generate the map.
|
|
249
|
+
### example: rake gooby:generate_google_map config_file=config/big_sur_marathon.yaml
|
|
250
|
+
def generate_google_map
|
|
251
|
+
config_file = command_line_arg('config_file', "#{gooby_home}/config/gooby_config.yaml")
|
|
252
|
+
generator = GoobyGoogleMapGenerator.new
|
|
253
|
+
generator.generate(config_file)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
###
|
|
257
|
+
### ---
|
|
258
|
+
###
|
|
259
|
+
### command: rake gooby:generate_google_earth_map
|
|
260
|
+
### description: Generate a Google Earth kml file from a csv file.
|
|
261
|
+
### parameters: config_file - Your yaml configuration file in /config.
|
|
262
|
+
### Defaults to 'config/gooby_config.yaml' in your GOOBY_HOME directory.
|
|
263
|
+
### note 1: The configuration file entry 'csv_file' specifies the csv data file that
|
|
264
|
+
### will be read and used to generate the map.
|
|
265
|
+
### note 2: Gooby will optionally create a kmz file for you. A kmz file is essentially a
|
|
266
|
+
### zip file, which contains your kml file(s), as well as any associated files such
|
|
267
|
+
### as images. Two parameters are required in your yaml config file for kmz generation:
|
|
268
|
+
### 'kmz_build' must be set to true, and 'kmz_build_command' must be the appropriate
|
|
269
|
+
### zip-creating command for your operating system and set of installed software.
|
|
270
|
+
### A Mac OS/X example command is: zip -r gooby_big_sur.kmz .
|
|
271
|
+
### example: rake gooby:generate_google_earth_map config_file=config/big_sur_marathon.yaml
|
|
272
|
+
def generate_google_earth_map
|
|
273
|
+
config_file = command_line_arg('config_file', "#{gooby_home}/config/gooby_config.yaml")
|
|
274
|
+
generator = GoobyGoogleKmlGenerator.new
|
|
275
|
+
generator.generate(config_file)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
###
|
|
279
|
+
### ---
|
|
280
|
+
|
|
281
|
+
end
|