diff --git a/mpwo_api/mpwo_api/activities/utils.py b/mpwo_api/mpwo_api/activities/utils.py index 3b3a4833..e79363c5 100644 --- a/mpwo_api/mpwo_api/activities/utils.py +++ b/mpwo_api/mpwo_api/activities/utils.py @@ -144,18 +144,16 @@ def get_gpx_info(gpx_file): start = 0 for segment_idx, segment in enumerate(gpx.tracks[0].segments): - segment_max_speed = 0 segment_start = 0 for point_idx, point in enumerate(segment.points): - if point_idx == 0: - segment_start = point.time - if start == 0: - start = segment_start - segment_speed = segment.get_speed(point_idx) - if segment_speed > segment_max_speed: - segment_max_speed = segment_speed - if segment_max_speed > max_speed: - max_speed = segment_max_speed + if point_idx == 0 and start == 0: + start = point.time + segment_max_speed = (segment.get_moving_data().max_speed + if segment.get_moving_data().max_speed + else 0) + + if segment_max_speed > max_speed: + max_speed = segment_max_speed segment_data = get_gpx_data( segment, segment_max_speed, segment_start @@ -163,8 +161,8 @@ def get_gpx_info(gpx_file): segment_data['idx'] = segment_idx gpx_data['segments'].append(segment_data) - gull_gpx_data = get_gpx_data(gpx, max_speed, start) - gpx_data = {**gpx_data, **gull_gpx_data} + full_gpx_data = get_gpx_data(gpx, max_speed, start) + gpx_data = {**gpx_data, **full_gpx_data} bounds = gpx.get_bounds() gpx_data['bounds'] = [ bounds.min_latitude, diff --git a/mpwo_api/mpwo_api/tests/test_activities_api_1_post.py b/mpwo_api/mpwo_api/tests/test_activities_api_1_post.py index 229d2fa9..2cb00beb 100644 --- a/mpwo_api/mpwo_api/tests/test_activities_api_1_post.py +++ b/mpwo_api/mpwo_api/tests/test_activities_api_1_post.py @@ -13,7 +13,7 @@ def assert_activity_data_with_gpx(data): assert data['data']['activities'][0]['descent'] == 23.4 assert data['data']['activities'][0]['distance'] == 0.32 assert data['data']['activities'][0]['max_alt'] == 998.0 - assert data['data']['activities'][0]['max_speed'] == 5.09 + assert data['data']['activities'][0]['max_speed'] == 5.11 assert data['data']['activities'][0]['min_alt'] == 975.0 assert data['data']['activities'][0]['moving'] == '0:04:10' assert data['data']['activities'][0]['pauses'] is None @@ -29,7 +29,7 @@ def assert_activity_data_with_gpx(data): assert segment['descent'] == 23.4 assert segment['distance'] == 0.32 assert segment['max_alt'] == 998.0 - assert segment['max_speed'] == 5.09 + assert segment['max_speed'] == 5.11 assert segment['min_alt'] == 975.0 assert segment['moving'] == '0:04:10' assert segment['pauses'] is None @@ -40,7 +40,7 @@ def assert_activity_data_with_gpx(data): assert records[0]['activity_id'] == 1 assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Tue, 13 Mar 2018 12:44:45 GMT' - assert records[0]['value'] == 5.09 + assert records[0]['value'] == 5.11 assert records[1]['sport_id'] == 1 assert records[1]['activity_id'] == 1 assert records[1]['record_type'] == 'LD' diff --git a/mpwo_api/mpwo_api/tests/test_activities_api_2_patch.py b/mpwo_api/mpwo_api/tests/test_activities_api_2_patch.py index 10039548..4cdb7196 100644 --- a/mpwo_api/mpwo_api/tests/test_activities_api_2_patch.py +++ b/mpwo_api/mpwo_api/tests/test_activities_api_2_patch.py @@ -12,7 +12,7 @@ def assert_activity_data_with_gpx(data): assert data['data']['activities'][0]['descent'] == 23.4 assert data['data']['activities'][0]['distance'] == 0.32 assert data['data']['activities'][0]['max_alt'] == 998.0 - assert data['data']['activities'][0]['max_speed'] == 5.09 + assert data['data']['activities'][0]['max_speed'] == 5.11 assert data['data']['activities'][0]['min_alt'] == 975.0 assert data['data']['activities'][0]['moving'] == '0:04:10' assert data['data']['activities'][0]['pauses'] is None @@ -24,7 +24,7 @@ def assert_activity_data_with_gpx(data): assert records[0]['activity_id'] == 1 assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Tue, 13 Mar 2018 12:44:45 GMT' - assert records[0]['value'] == 5.09 + assert records[0]['value'] == 5.11 assert records[1]['sport_id'] == 2 assert records[1]['activity_id'] == 1 assert records[1]['record_type'] == 'LD'