tcx_reader 0.2.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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/lib/tcx_reader.rb +34 -0
- data/lib/tcx_reader/activity.rb +37 -0
- data/lib/tcx_reader/lap.rb +44 -0
- data/lib/tcx_reader/point.rb +37 -0
- data/lib/tcx_reader/tcx.rb +43 -0
- data/lib/tcx_reader/track.rb +35 -0
- data/lib/tcx_reader/version.rb +3 -0
- data/tcx_reader.gemspec +28 -0
- data/tests/big_file.rb +62 -0
- data/tests/tcx_file1.rb +50 -0
- data/tests/tcx_files/big_file.tcx +59287 -0
- data/tests/tcx_files/tcx_file1.tcx +3251 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1308f81eb3c67bf9031b93bbb16bc47b6669f332
|
4
|
+
data.tar.gz: 04e6c79ab0b2e032e01a07119fcb719c1227dcc0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30fa0551cddf922fe542503cb7f2c787974517d14820762e9c7ff45becf5131371444c949c3e02bebfe498df0e236c17341eb07c9d586fd4c110ac6980cd9ebf
|
7
|
+
data.tar.gz: 7e91eabad55eedef4a439cf0d5460b2c736d9366ead3bc159d73281bc4facc87d8373f7d374b2d52ce1023abf633579740eafe5541c778b53df7371359a5b0e3
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Nicolas Aguttes
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# TcxReader
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tcx_reader'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tcx_reader
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
tcx_reader accept a file as argument or a string.
|
22
|
+
|
23
|
+
To read a tcx file just call @tcx = TCXReader::Tcx.new(file) or @tcx = TCXReader::Tcx.new(string)
|
24
|
+
|
25
|
+
Then use it as follow:
|
26
|
+
|
27
|
+
- @tcx.activities => activities in the tcx
|
28
|
+
- activity.sport => activity type
|
29
|
+
- activity.activity_id => activity id (usually the time)
|
30
|
+
- activity.laps => array of laps
|
31
|
+
- lap.start_time => start time of the lap
|
32
|
+
- lap.time_seconds => time in seconds for the lap
|
33
|
+
- lap.distance_meter => distance of the lap
|
34
|
+
- lap.max_speed => max speed of the lap
|
35
|
+
|
36
|
+
## Notes
|
37
|
+
|
38
|
+
This gem has been written for my own needs, if you feel something is missing don't hesitate to ask
|
39
|
+
|
40
|
+
|
41
|
+
## TODO
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/tcx_reader/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/tcx_reader.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
$:.unshift(File.dirname(__FILE__))
|
24
|
+
require "tcx_reader/version"
|
25
|
+
require "nokogiri"
|
26
|
+
|
27
|
+
require 'date'
|
28
|
+
require 'time'
|
29
|
+
require 'tcx_reader/tcx'
|
30
|
+
require 'tcx_reader/activity'
|
31
|
+
require 'tcx_reader/lap'
|
32
|
+
require 'tcx_reader/track'
|
33
|
+
require 'tcx_reader/point'
|
34
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module TCXReader
|
24
|
+
class Activity
|
25
|
+
attr_accessor :sport, :laps, :activity_id
|
26
|
+
|
27
|
+
def initialize(activity)
|
28
|
+
@sport = activity["Sport"] rescue ""
|
29
|
+
@activity_id = activity.at_css("Id")
|
30
|
+
@laps = []
|
31
|
+
activity.css("Lap").each do |lap|
|
32
|
+
lap = Lap.new(lap)
|
33
|
+
@laps << lap
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module TCXReader
|
24
|
+
class Lap
|
25
|
+
attr_accessor :tracks,:start_time, :time_seconds, :distance_meter, :max_speed, :calories, :avg_hr, :max_hr, :intensity, :trigger_method
|
26
|
+
|
27
|
+
def initialize(lap)
|
28
|
+
@start_time = Time.parse(lap["StartTime"])
|
29
|
+
@time_seconds = lap.at_css("TotalTimeSeconds").text.to_f rescue nil
|
30
|
+
@distance_meter = lap.at_css("DistanceMeters").text.to_f rescue nil
|
31
|
+
@max_speed = lap.at_css("MaximumSpeed").text.to_f rescue nil
|
32
|
+
@calories = lap.at_css("Calories").text.to_i rescue nil
|
33
|
+
@avg_hr = lap.at_css("AverageHeartRateBpm Value").text.to_i rescue nil
|
34
|
+
@max_hr = lap.at_css("MaximumHeartRateBpm Value").text.to_i rescue nil
|
35
|
+
@intensity = lap.at_css("Intensity").text rescue nil
|
36
|
+
@trigger_method = lap.at_css("TriggerMethod").text rescue nil
|
37
|
+
@tracks = []
|
38
|
+
lap.css("Track").each do |trk|
|
39
|
+
trk = Track.new(trk)
|
40
|
+
@tracks << trk
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module TCXReader
|
24
|
+
class Point
|
25
|
+
attr_accessor :time,:lat, :lon, :hr, :distance, :speed, :cadence
|
26
|
+
|
27
|
+
def initialize(point)
|
28
|
+
@time = Time.parse(point.at_css("Time"))
|
29
|
+
@lat = point.at_css("Position LatitudeDegrees").text.to_f rescue nil
|
30
|
+
@lon = point.at_css("Position LongitudeDegrees").text.to_f rescue nil
|
31
|
+
@hr = point.at_css("HeartRateBpm Value").text.to_i rescue nil
|
32
|
+
@distance = point.at_css("DistanceMeters").text.to_f rescue nil
|
33
|
+
@speed = point.at_css("Speed").text.to_f rescue nil
|
34
|
+
@cadence = point.at_css("RunCadence").text.to_i rescue nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module TCXReader
|
24
|
+
class Tcx
|
25
|
+
attr_accessor :activities
|
26
|
+
# read the file containing the tracks
|
27
|
+
# get the different information of the file
|
28
|
+
# get the tracks
|
29
|
+
# NOTE: removing name space may lead to some ambiguities
|
30
|
+
def initialize(file)
|
31
|
+
if file.is_a?(File)
|
32
|
+
@tcx=Nokogiri::XML(File.open(file)).remove_namespaces!
|
33
|
+
else
|
34
|
+
@tcx=Nokogiri::XML(file).remove_namespaces!
|
35
|
+
end
|
36
|
+
@activities = []
|
37
|
+
@tcx.css("Activity").each do |act|
|
38
|
+
act = Activity.new(act)
|
39
|
+
@activities << act
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Nicolas Aguttes
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
module TCXReader
|
24
|
+
class Track
|
25
|
+
attr_accessor :points
|
26
|
+
|
27
|
+
def initialize(trk)
|
28
|
+
@points = []
|
29
|
+
trk.css("Trackpoint").each do |pt|
|
30
|
+
point = Point.new(pt)
|
31
|
+
@points << point
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/tcx_reader.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tcx_reader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tcx_reader"
|
8
|
+
spec.version = TcxReader::VERSION
|
9
|
+
spec.authors = ["Nicolas Aguttes"]
|
10
|
+
spec.email = ["nicolas.aguttes@gmail.com"]
|
11
|
+
spec.name = "tcx_reader"
|
12
|
+
spec.version = TcxReader::VERSION
|
13
|
+
spec.authors = ["Nicolas Aguttes"]
|
14
|
+
spec.email = ["nicolas.aguttes@gmail.com"]
|
15
|
+
spec.description = %q{Gem to parse a tcx file or string}
|
16
|
+
spec.summary = %q{tcx (garmin) reader}
|
17
|
+
spec.homepage = "https://github.com/tranquiliste/tcx_reader"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split($/)
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_dependency "nokogiri", "1.6.1"
|
28
|
+
end
|
data/tests/big_file.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.expand_path('../.') + '/tcx_reader/lib/tcx_reader'
|
3
|
+
|
4
|
+
class TCXBigFileTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
BIG_FILE = File.join(File.dirname(__FILE__), "tcx_files/big_file.tcx")
|
7
|
+
|
8
|
+
def test_big_file
|
9
|
+
tcx = TCXReader::Tcx.new(File.open(BIG_FILE))
|
10
|
+
assert_equal(1, tcx.activities.size)
|
11
|
+
assert_equal(3, tcx.activities.first.laps.size)
|
12
|
+
assert_equal("Other", tcx.activities.first.sport)
|
13
|
+
# first lap
|
14
|
+
assert_equal(9700.825, tcx.activities.first.laps[0].time_seconds)
|
15
|
+
assert_equal(Time.parse("2014-02-20 08:42:59 UTC"), tcx.activities.first.laps[0].start_time)
|
16
|
+
assert_equal(5201.66, tcx.activities.first.laps[0].distance_meter)
|
17
|
+
assert_equal(3.7309999465942383, tcx.activities.first.laps[0].max_speed)
|
18
|
+
assert_equal(1094, tcx.activities.first.laps[0].calories)
|
19
|
+
assert_equal(124, tcx.activities.first.laps[0].avg_hr)
|
20
|
+
assert_equal(148, tcx.activities.first.laps[0].max_hr)
|
21
|
+
assert_equal(1, tcx.activities.first.laps[0].tracks.size)
|
22
|
+
assert_equal(2619, tcx.activities.first.laps[0].tracks[0].points.size)
|
23
|
+
# first track
|
24
|
+
# points
|
25
|
+
assert_equal(Time.parse("2014-02-20 08:42:59 UTC"), tcx.activities.first.laps[0].tracks[0].points[0].time)
|
26
|
+
assert_equal(46.03442206978798, tcx.activities.first.laps[0].tracks[0].points[0].lat)
|
27
|
+
assert_equal(6.934360396116972, tcx.activities.first.laps[0].tracks[0].points[0].lon)
|
28
|
+
assert_equal(91, tcx.activities.first.laps[0].tracks[0].points[0].hr)
|
29
|
+
assert_equal(2.609999895095825, tcx.activities.first.laps[0].tracks[0].points[0].distance)
|
30
|
+
assert_equal(2.385999917984009, tcx.activities.first.laps[0].tracks[0].points[0].speed)
|
31
|
+
assert_equal(nil, tcx.activities.first.laps[0].tracks[0].points[0].cadence)
|
32
|
+
assert_equal(Time.parse("2014-02-20 08:43:00 UTC"), tcx.activities.first.laps[0].tracks[0].points[1].time)
|
33
|
+
assert_equal(46.03444067761302, tcx.activities.first.laps[0].tracks[0].points[1].lat)
|
34
|
+
assert_equal(6.93439643830061, tcx.activities.first.laps[0].tracks[0].points[1].lon)
|
35
|
+
assert_equal(91, tcx.activities.first.laps[0].tracks[0].points[1].hr)
|
36
|
+
assert_equal(5.920000076293945, tcx.activities.first.laps[0].tracks[0].points[1].distance)
|
37
|
+
assert_equal(2.6510000228881836, tcx.activities.first.laps[0].tracks[0].points[1].speed)
|
38
|
+
assert_equal(nil, tcx.activities.first.laps[0].tracks[0].points[1].cadence)
|
39
|
+
# second lap
|
40
|
+
assert_equal(1, tcx.activities.first.laps[1].tracks.size)
|
41
|
+
assert_equal(224, tcx.activities.first.laps[1].tracks[0].points.size)
|
42
|
+
assert_equal(569.351, tcx.activities.first.laps[1].time_seconds)
|
43
|
+
assert_equal(Time.parse("2014-02-20 11:24:39 UTC"), tcx.activities.first.laps[1].start_time)
|
44
|
+
assert_equal(1096.79, tcx.activities.first.laps[1].distance_meter)
|
45
|
+
assert_equal(10.222000122070312, tcx.activities.first.laps[1].max_speed)
|
46
|
+
assert_equal(21, tcx.activities.first.laps[1].calories)
|
47
|
+
assert_equal(98, tcx.activities.first.laps[1].avg_hr)
|
48
|
+
assert_equal(124, tcx.activities.first.laps[1].max_hr)
|
49
|
+
# third lap
|
50
|
+
assert_equal(1, tcx.activities.first.laps[2].tracks.size)
|
51
|
+
assert_equal(646, tcx.activities.first.laps[2].tracks[0].points.size)
|
52
|
+
assert_equal(1135.273, tcx.activities.first.laps[2].time_seconds)
|
53
|
+
assert_equal(Time.parse("2014-02-20 11:34:08 UTC"), tcx.activities.first.laps[2].start_time)
|
54
|
+
assert_equal(4942.11, tcx.activities.first.laps[2].distance_meter)
|
55
|
+
assert_equal(10.625, tcx.activities.first.laps[2].max_speed)
|
56
|
+
assert_equal(41, tcx.activities.first.laps[2].calories)
|
57
|
+
assert_equal(95, tcx.activities.first.laps[2].avg_hr)
|
58
|
+
assert_equal(114, tcx.activities.first.laps[2].max_hr)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|