Using flags.map_importing to handle map importing control. Updating RPi 4 map import estimate using create import tests, rather than slower append import tests.

This commit is contained in:
Roland 2023-08-17 08:27:49 -06:00
parent 6405188a98
commit 6376e6539b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
9 changed files with 130 additions and 94 deletions

View file

@ -1,23 +1,10 @@
from pathlib import Path
from sqlalchemy import Column, Integer, Boolean, BigInteger
from modules.map import lib
from wrolpi import dates
from wrolpi.common import Base, ModelHelper
from wrolpi.media_path import MediaPathType
# Bps calculated using many tests on a well-cooled RPi4.
RPI4_PBF_BYTES_PER_SECOND = 3943
def seconds_to_import(path: Path, size: int) -> int:
"""Attempt to predict how long it will take an RPi4 to import a given PBF file."""
if str(path).endswith('.osm.pbf'):
return max(int(size // RPI4_PBF_BYTES_PER_SECOND), 0)
# Can't calculate an unknown file.
return 0
class MapFile(Base, ModelHelper):
__tablename__ = 'map_file'
@ -35,7 +22,7 @@ class MapFile(Base, ModelHelper):
'id': self.id,
'imported': self.imported,
'path': self.path,
'seconds_to_import': (seconds := seconds_to_import(self.path, self.size)),
'seconds_to_import': (seconds := lib.seconds_to_import(self.size)),
'size': self.size,
'time_to_import': dates.seconds_to_timestamp(seconds),
}