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
data/lib/gooby_history.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
5
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
6
|
-
|
|
7
|
-
=end
|
|
8
|
-
|
|
9
|
-
module Gooby
|
|
10
|
-
|
|
11
|
-
=begin rdoc
|
|
12
|
-
Instances of this class represent a <History> aggregate object from a
|
|
13
|
-
Forerunner XML file.
|
|
14
|
-
=end
|
|
15
|
-
|
|
16
|
-
class History < GoobyObject
|
|
17
|
-
|
|
18
|
-
attr_reader :runs
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
@runs = Array.new
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Adds a Run during XML parsing.
|
|
25
|
-
def add_run(run)
|
|
26
|
-
@runs.push(run)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def to_s
|
|
30
|
-
return "Hist: runs: #{@runs.size}"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def print_string
|
|
34
|
-
s = "History: run count=#{@runs.size} \n"
|
|
35
|
-
runs.each { | run | s << run.print_string }
|
|
36
|
-
s
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end # end of module
|
data/lib/gooby_kernel.rb
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
5
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
6
|
-
|
|
7
|
-
=end
|
|
8
|
-
|
|
9
|
-
module Gooby
|
|
10
|
-
|
|
11
|
-
=begin rdoc
|
|
12
|
-
This module is used to embed information about the Gooby project and
|
|
13
|
-
version into the codebase.
|
|
14
|
-
=end
|
|
15
|
-
|
|
16
|
-
module GoobyKernel
|
|
17
|
-
|
|
18
|
-
def project_name
|
|
19
|
-
'Gooby'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def project_version_number
|
|
23
|
-
'1.2.0'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Return a String date, like '2007/03/21'.
|
|
27
|
-
def project_date
|
|
28
|
-
'2007/07/22'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Return a String containing the project author name.
|
|
32
|
-
def project_author
|
|
33
|
-
'Chris Joakim'
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Return a String year, like '2007'.
|
|
37
|
-
def project_year
|
|
38
|
-
project_date[0...4] # start, length
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Return a String containing copyright, year, and author.
|
|
42
|
-
def project_copyright
|
|
43
|
-
"Copyright (C) #{project_year} #{project_author}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def project_embedded_comment
|
|
47
|
-
"#{project_name} #{project_version_number}"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Return a String containing GNU/GPL, and the gpl.html URL.
|
|
51
|
-
def project_license
|
|
52
|
-
'GNU General Public License (GPL). See http://www.gnu.org/copyleft/gpl.html'
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Return an Array of lines in file, optionally stripped.
|
|
56
|
-
def read_lines(filename, strip=false)
|
|
57
|
-
|
|
58
|
-
array = IO.readlines(filename)
|
|
59
|
-
if strip
|
|
60
|
-
array = strip_lines(array)
|
|
61
|
-
end
|
|
62
|
-
return array
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Return an Array of lines in file per the given delimeter, optionally stripped.
|
|
66
|
-
def read_as_ascii_lines(filename, delim=10, strip=false)
|
|
67
|
-
|
|
68
|
-
array = Array.new
|
|
69
|
-
file = File.new(filename)
|
|
70
|
-
currLine = ''
|
|
71
|
-
bytesRead = 0
|
|
72
|
-
linesRead = 0
|
|
73
|
-
|
|
74
|
-
file.each_byte { |b|
|
|
75
|
-
bytesRead = bytesRead + 1
|
|
76
|
-
if (b == delim) # delim is 13 for quicken, 10 for address book xml
|
|
77
|
-
array << currLine
|
|
78
|
-
currLine = ''
|
|
79
|
-
linesRead = linesRead + 1
|
|
80
|
-
else
|
|
81
|
-
if (b < 127)
|
|
82
|
-
currLine << "#{b.chr}"
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if currLine.size > 0
|
|
88
|
-
array << currLine
|
|
89
|
-
end
|
|
90
|
-
if strip
|
|
91
|
-
array = strip_lines(array)
|
|
92
|
-
end
|
|
93
|
-
return array
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Strip the lines/Strings; return a new Array.
|
|
97
|
-
def strip_lines(array)
|
|
98
|
-
|
|
99
|
-
newArray = Array.new
|
|
100
|
-
if (array != nil)
|
|
101
|
-
array.each { |line| line.strip! ; newArray << line }
|
|
102
|
-
end
|
|
103
|
-
return newArray
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def tokenize(string, delim=nil, strip=false)
|
|
107
|
-
if string
|
|
108
|
-
tokens = string.split(delim)
|
|
109
|
-
if strip
|
|
110
|
-
tokens.each { |tok| tok.strip! }
|
|
111
|
-
end
|
|
112
|
-
tokens
|
|
113
|
-
else
|
|
114
|
-
Array.new
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def character_align(character, number, left_length, right_length)
|
|
119
|
-
tokens = number.to_s.split("#{character}")
|
|
120
|
-
integer = tokens[0].to_s
|
|
121
|
-
fraction = tokens[1].to_s
|
|
122
|
-
lpad_size = left_length - integer.size
|
|
123
|
-
rpad_size = right_length - fraction.size
|
|
124
|
-
if lpad_size > 0
|
|
125
|
-
lpad_size.times do |i|
|
|
126
|
-
integer = " #{integer}"
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
if rpad_size > 0
|
|
130
|
-
rpad_size.times do |i|
|
|
131
|
-
fraction = "#{fraction} "
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
"#{integer}.#{fraction}"
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def default_delimiter
|
|
138
|
-
return '|'
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def invalid_time
|
|
142
|
-
return -99999999
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def invalid_latitude
|
|
146
|
-
return -1
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def invalid_longitude
|
|
150
|
-
return -1
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def invalid_altitude
|
|
154
|
-
return -1
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def invalid_heartbeat
|
|
158
|
-
return -1
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
end # end of module
|
data/lib/gooby_line.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
5
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
6
|
-
|
|
7
|
-
=end
|
|
8
|
-
|
|
9
|
-
module Gooby
|
|
10
|
-
|
|
11
|
-
class Line < GoobyObject
|
|
12
|
-
|
|
13
|
-
attr_accessor :raw_data, :tokens
|
|
14
|
-
|
|
15
|
-
def initialize(raw='', delim=nil, strip=false)
|
|
16
|
-
if strip
|
|
17
|
-
@raw_data = raw.strip
|
|
18
|
-
else
|
|
19
|
-
@raw_data = raw
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
@tokens = tokenize(@raw_data, delim, strip=false)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
public
|
|
26
|
-
|
|
27
|
-
def token(idx)
|
|
28
|
-
@tokens[idx]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def token_count
|
|
32
|
-
@tokens.size
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def token_idx_equals(idx, value)
|
|
36
|
-
if idx < token_count
|
|
37
|
-
if @tokens[idx] == value
|
|
38
|
-
return true
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
false
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def match(pattern)
|
|
45
|
-
@raw_data.match(pattern)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def is_comment
|
|
49
|
-
s = @raw_data.strip
|
|
50
|
-
(s.match('^#')) ? true : false
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def is_populated_non_comment
|
|
54
|
-
s = @raw_data.strip
|
|
55
|
-
if s.size == 0
|
|
56
|
-
return false
|
|
57
|
-
end
|
|
58
|
-
if is_comment
|
|
59
|
-
return false
|
|
60
|
-
end
|
|
61
|
-
return true
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def concatinate_tokens(start_idx = 0)
|
|
65
|
-
s = ''
|
|
66
|
-
idx = -1
|
|
67
|
-
@tokens.each { |tok|
|
|
68
|
-
idx = idx + 1
|
|
69
|
-
if idx >= start_idx
|
|
70
|
-
s << tok
|
|
71
|
-
s << ' '
|
|
72
|
-
end
|
|
73
|
-
}
|
|
74
|
-
s.strip!
|
|
75
|
-
s
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end # end of module
|
data/lib/gooby_object.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
5
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
6
|
-
|
|
7
|
-
=end
|
|
8
|
-
|
|
9
|
-
module Gooby
|
|
10
|
-
|
|
11
|
-
=begin rdoc
|
|
12
|
-
This is the abstract superclass of several Gooby classes.
|
|
13
|
-
It includes module GoobyKernel.
|
|
14
|
-
=end
|
|
15
|
-
|
|
16
|
-
class GoobyObject
|
|
17
|
-
|
|
18
|
-
include Gooby::GoobyKernel
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end # end of module
|
data/lib/gooby_point.rb
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
=begin
|
|
2
|
-
|
|
3
|
-
Gooby = Google APIs + Ruby
|
|
4
|
-
Gooby - Copyright 2007 by Chris Joakim.
|
|
5
|
-
Gooby is available under GNU General Public License (GPL) license.
|
|
6
|
-
|
|
7
|
-
=end
|
|
8
|
-
|
|
9
|
-
module Gooby
|
|
10
|
-
|
|
11
|
-
class Point < GoobyObject
|
|
12
|
-
|
|
13
|
-
attr_accessor :number, :latitude, :longitude, :altitude, :uom, :note
|
|
14
|
-
|
|
15
|
-
def initialize(*args)
|
|
16
|
-
@number, @latitude, @longitude, @altitude, @uom, @heartbeat, @note = '', '', '', '', 'm', -1, ''
|
|
17
|
-
if args
|
|
18
|
-
if args.size == 1
|
|
19
|
-
initialize_from_string(args[0]) # yaml
|
|
20
|
-
else
|
|
21
|
-
initialize_from_array(args)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def csv_delim
|
|
27
|
-
'|'
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def english_system
|
|
31
|
-
if @uom
|
|
32
|
-
(@uom == 'm') ? true : false
|
|
33
|
-
else
|
|
34
|
-
return true # english is the default
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def metric_system
|
|
39
|
-
return false if !english_system
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def initialize_from_array(args)
|
|
43
|
-
@latitude = args[0] if args.size > 0
|
|
44
|
-
@longitude = args[1] if args.size > 1
|
|
45
|
-
@altitude = args[2] if args.size > 2
|
|
46
|
-
@note = args[3] if args.size > 3
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def initialize_from_string(yaml_value_string)
|
|
50
|
-
tokens = yaml_value_string.split
|
|
51
|
-
if (tokens.size > 2)
|
|
52
|
-
@latitude = tokens[0]
|
|
53
|
-
@longitude = tokens[1]
|
|
54
|
-
@note = ''
|
|
55
|
-
count = 0
|
|
56
|
-
tokens.each { |tok|
|
|
57
|
-
count = count + 1
|
|
58
|
-
if (count > 2)
|
|
59
|
-
@note << tok
|
|
60
|
-
@note << ' '
|
|
61
|
-
end
|
|
62
|
-
}
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
public
|
|
67
|
-
|
|
68
|
-
def has_coordinates?
|
|
69
|
-
return false if @latitude == nil
|
|
70
|
-
return false if @latitude.size < 1
|
|
71
|
-
return false if @longitude == nil
|
|
72
|
-
return false if @longitude .size < 1
|
|
73
|
-
return true
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def to_s
|
|
77
|
-
return "lat: #{@latitude} lng: #{@longitude} alt: #{@altitude} note: #{@note}"
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def to_formatted_string
|
|
81
|
-
s = "lat: #{@latitude.to_s.ljust(20)}"
|
|
82
|
-
s << " lng: #{@longitude.to_s.ljust(20)}"
|
|
83
|
-
s << " poi.#{@number.to_s.ljust(12)}" if @number
|
|
84
|
-
s << " #{@note}" if @note
|
|
85
|
-
s
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def to_csv
|
|
89
|
-
return "#{@latitude}#{csv_delim}#{@longitude}#{csv_delim}#{@altitude}"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def latitude_as_float
|
|
93
|
-
@latitude ? @latitude.to_f : invalid_latitude
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def longitude_as_float
|
|
97
|
-
@longitude ? @longitude.to_f : invalid_longitude
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def altitude_as_float
|
|
101
|
-
@altitude ? @altitude.to_f : invalid_altitude
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def heartbeat_as_float
|
|
105
|
-
@heartbeat? @heartbeat.to_f : invalid_heartbeat
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def degrees_diff(another_point)
|
|
109
|
-
if (another_point)
|
|
110
|
-
puts "this: #{to_s}" if false
|
|
111
|
-
puts "other: #{another_point.to_s}" if false
|
|
112
|
-
puts "lats: #{latitude_as_float} #{another_point.latitude_as_float}" if false
|
|
113
|
-
puts "lngs: #{longitude_as_float} #{another_point.longitude_as_float}" if false
|
|
114
|
-
lat_diff = latitude_as_float - another_point.latitude_as_float
|
|
115
|
-
lng_diff = longitude_as_float - another_point.longitude_as_float
|
|
116
|
-
diff = lat_diff.abs + lng_diff.abs
|
|
117
|
-
puts "diff: #{diff} #{lat_diff} #{lng_diff}" if false
|
|
118
|
-
diff
|
|
119
|
-
else
|
|
120
|
-
360
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def proximity(another_point, uom)
|
|
125
|
-
if (another_point)
|
|
126
|
-
arg1 = latitude_as_float
|
|
127
|
-
arg2 = another_point.latitude_as_float
|
|
128
|
-
arg3 = latitude_as_float
|
|
129
|
-
arg4 = another_point.latitude_as_float
|
|
130
|
-
theta = longitude_as_float - another_point.longitude_as_float
|
|
131
|
-
res1 = Math.sin(deg2rad(arg1))
|
|
132
|
-
res2 = Math.sin(deg2rad(arg2))
|
|
133
|
-
res3 = Math.cos(deg2rad(arg3))
|
|
134
|
-
res4 = Math.cos(deg2rad(arg4))
|
|
135
|
-
res5 = Math.cos(deg2rad(theta.to_f))
|
|
136
|
-
dist = ((res1 * res2) + (res3 * res4 * res5)).to_f
|
|
137
|
-
|
|
138
|
-
if (!dist.nan?)
|
|
139
|
-
dist = Math.acos(dist.to_f)
|
|
140
|
-
if (!dist.nan?)
|
|
141
|
-
dist = rad2deg(dist)
|
|
142
|
-
if (!dist.nan?)
|
|
143
|
-
dist = dist * 60 * 1.1515;
|
|
144
|
-
if (!dist.nan?)
|
|
145
|
-
if uom == "km"
|
|
146
|
-
dist = dist * 1.609344;
|
|
147
|
-
end
|
|
148
|
-
if uom == "n"
|
|
149
|
-
dist = dist * 0.8684;
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
return dist.to_f
|
|
155
|
-
else
|
|
156
|
-
return 0
|
|
157
|
-
end
|
|
158
|
-
else
|
|
159
|
-
return 0
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def deg2rad(degrees)
|
|
164
|
-
(((0 + degrees) * Math::PI) / 180)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def rad2deg(radians)
|
|
168
|
-
(((0 + radians) * 180) / Math::PI)
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
end # end of module
|