Trasu z GPX nahravat do DB

This commit is contained in:
Michal Kváček
2024-07-25 19:50:09 +02:00
parent e541508f75
commit 10bc0847b6
10 changed files with 231 additions and 81 deletions
+10 -1
View File
@@ -1,5 +1,5 @@
from collections import defaultdict
from datetime import datetime
from datetime import datetime, timedelta
from typing import List, Dict, Any
from aiocache import cached
from lxml import etree
@@ -78,6 +78,11 @@ class GPXParser:
times = await self.get_times_all()
return await self.sample_times(times)
@cached()
async def get_total_duration(self) -> timedelta:
times = await self.get_times_all()
return times[-1] - times[0]
@cached()
async def get_coordinates(self) -> List[Dict[str, float]]:
return await self.average_coordinates(await self.get_coordinates_all())
@@ -111,6 +116,10 @@ class GPXParser:
async def get_max_speed(self):
return max(await self.get_speed()) or 0
@cached()
async def get_min_speed(self):
return min(await self.get_speed()) or 0
@cached()
async def get_avg_speed(self):
speeds = await self.get_speed()