Skip to content

Commit

Permalink
Minor update: Reading speed for average speed
Browse files Browse the repository at this point in the history
  • Loading branch information
HlisTilen committed Aug 20, 2024
1 parent 42cd2a5 commit 6551691
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/tcxread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def parse_tracks(lap)
heart_rate: trackpoint.xpath('xmlns:HeartRateBpm/xmlns:Value').text.to_i,
cadence: trackpoint.xpath('xmlns:Cadence').text.to_i,
sensor_state: trackpoint.xpath('xmlns:SensorState').text,
watts: trackpoint.xpath('xmlns:Extensions/ns3:TPX/ns3:Watts').text.to_f
watts: trackpoint.xpath('xmlns:Extensions/ns3:TPX/ns3:Watts').text.to_f,
speed: trackpoint.xpath('xmlns:Extensions/ns3:TPX/ns3:Speed').text.to_f
}
end
tracks << trackpoints
Expand Down Expand Up @@ -276,9 +277,7 @@ def calculate_average_speed_from_activities(activities)
activities.each do |activity|
activity[:laps].each do |lap|
lap[:tracks].flatten.each do |trackpoint|
distance = trackpoint[:distance_meters]
time_seconds = lap[:total_time_seconds]
speed = distance / time_seconds if time_seconds > 0
speed = trackpoint[:speed]

if speed
total_speed_all += speed
Expand Down

0 comments on commit 6551691

Please sign in to comment.