mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-24 17:06:18 -05:00
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:
parent
6405188a98
commit
6376e6539b
9 changed files with 130 additions and 94 deletions
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue