(self, cache_file_name: str)
Cache the current track
Cache the current track
Cache the current track
def store_cache(self, cache_file_name: str) -> None:
        """Cache the current track"""
        dir_name = os.path.dirname(cache_file_name)
        if not os.path.isdir(dir_name):
            os.makedirs(dir_name)
        with open(cache_file_name, "w", encoding="utf8") as json_file:
            lines_data = []
            for line in self.polylines:
                lines_data.append([{"lat": latlng.lat().degrees, "lng": latlng.lng().degrees} for latlng in line])
            json.dump(
                {
                    "start": self.start_time().strftime("%Y-%m-%d %H:%M:%S"),
                    "end": self.end_time().strftime("%Y-%m-%d %H:%M:%S"),
                    "length": self._length_meters,
                    "segments": lines_data,
                },
                json_file,
            )
def store_cache ( self , cache_file_name : str ) -> None : dir_name = os . path . dirname ( cache_file_name ) if not os . path . isdir ( dir_name ) : os . makedirs ( dir_name ) with open ( cache_file_name , "w" , encoding = "utf8" ) as json_file : lines_data = [ ] for line in self . polylines : lines_data . append ( [ { "lat" : latlng . lat ( ) . degrees , "lng" : latlng . lng ( ) . degrees } for latlng in line ] ) json . dump ( { "start" : self . start_time ( ) . strftime ( "%Y-%m-%d %H:%M:%S" ) , "end" : self . end_time ( ) . strftime ( "%Y-%m-%d %H:%M:%S" ) , "length" : self . _length_meters , "segments" : lines_data , } , json_file , )