Ejemplo n.º 1
0
def load_cached_track_file(cache_file_name: str, file_name: str) -> Track:
    """Load an individual track from cache files"""
    try:
        t = Track()
        t.load_cache(cache_file_name)
        t.file_names = [os.path.basename(file_name)]
        log.info(f"Loaded track {file_name} from cache file {cache_file_name}")
        return t
    except Exception as e:
        raise TrackLoadError("Failed to load track from cache.") from e
Ejemplo n.º 2
0
 def _strava_cache_to_track(data: typing.Dict[str, Any]) -> "Track":
     t = Track()
     t.file_names = [data["name"]]
     t.set_start_time(datetime.datetime.strptime(data["start"], "%Y-%m-%d %H:%M:%S"))
     t.set_end_time(datetime.datetime.strptime(data["end"], "%Y-%m-%d %H:%M:%S"))
     t.length_meters = float(data["length"])
     t.polylines = []
     for data_line in data["segments"]:
         t.polylines.append([s2sphere.LatLng.from_degrees(float(d["lat"]), float(d["lng"])) for d in data_line])
     return t