Merge branch 'dev' into oauth2

This commit is contained in:
Sam
2022-07-13 15:58:28 +02:00
84 changed files with 1114 additions and 773 deletions

View File

@ -104,7 +104,9 @@ def get_gpx_info(
# if a previous segment exists, calculate stopped time between
# the two segments
if prev_seg_last_point:
stopped_time_between_seg = point.time - prev_seg_last_point
stopped_time_between_seg += (
point.time - prev_seg_last_point
)
# last segment point
if point_idx == (segment_points_nb - 1):

View File

@ -1,20 +1,32 @@
import hashlib
from typing import List
import random
from typing import Dict, List
from flask import current_app
from staticmap import Line, StaticMap
from fittrackee import VERSION
from fittrackee.files import get_absolute_file_path
def get_static_map_tile_server_url(tile_server_config: Dict) -> str:
if tile_server_config['STATICMAP_SUBDOMAINS']:
subdomains = tile_server_config['STATICMAP_SUBDOMAINS'].split(',')
subdomain = f'{random.choice(subdomains)}.' # nosec
else:
subdomain = ''
return tile_server_config['URL'].replace('{s}.', subdomain)
def generate_map(map_filepath: str, map_data: List) -> None:
"""
Generate and save map image from map data
"""
m = StaticMap(400, 225, 10)
m.headers = {'User-Agent': f'FitTrackee v{VERSION}'}
if not current_app.config['TILE_SERVER']['DEFAULT_STATICMAP']:
m.url_template = current_app.config['TILE_SERVER']['URL'].replace(
'{s}.', ''
m.url_template = get_static_map_tile_server_url(
current_app.config['TILE_SERVER']
)
line = Line(map_data, '#3388FF', 4)
m.add_line(line)

View File

@ -307,9 +307,9 @@ def process_one_gpx_file(
absolute_map_filepath = get_absolute_file_path(map_filepath)
generate_map(absolute_map_filepath, map_data)
except (gpxpy.gpx.GPXXMLSyntaxException, TypeError) as e:
raise WorkoutException('error', 'Error during gpx file parsing.', e)
raise WorkoutException('error', 'error during gpx file parsing', e)
except Exception as e:
raise WorkoutException('error', 'Error during gpx processing.', e)
raise WorkoutException('error', 'error during gpx processing', e)
try:
new_workout = create_workout(