Changeset c555386 in OpenWorkouts-current for ow/fit.py


Ignore:
Timestamp:
Jan 11, 2019, 11:56:20 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
d17dffe
Parents:
b73ae09
Message:

(#26) Several bugfixes when loading data from fit, then generating gpx code

from it:

  • Ensure track points are added to a generated gpx (from a fit file) if they exist.
  • Ensure ascent (uphill), descent (downhill) and distance data is added to the Workout object if there is any in the fit file (fixes loading fit files for indoor training without gps data on them)
  • Load the "sport" property from the fit file when loading data from fit into a Workout object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/fit.py

    rb73ae09 rc555386  
    116116        # The schema namespaces info is very important, in order to support
    117117        # all the data we will extract from the fit file.
     118
    118119        gpx = gpxpy.gpx.GPX()
    119120        gpx.creator = 'OpenWorkouts'
     
    202203                    latitude=semicircles_to_degrees(values['position_lat']),
    203204                    longitude=semicircles_to_degrees(values['position_long']),
    204                     elevation=values['enhanced_altitude'],
    205                     speed=values['enhanced_speed'],
    206205                    time=values['timestamp']
    207206                )
    208207
    209             track_point.extensions.append(extensions_root)
    210 
    211             gpx_segment.points.append(track_point)
     208                if 'enhanced_altitude' in values.keys():
     209                    track_point.elevation = values['enhanced_altitude']
     210
     211                if 'enhanced_speed' in values.keys():
     212                    track_point.speed = values['enhanced_speed']
     213
     214                track_point.extensions.append(extensions_root)
     215
     216                gpx_segment.points.append(track_point)
    212217
    213218        # if the fit file has temperature data, calculate the avg
Note: See TracChangeset for help on using the changeset viewer.