use estimate_location in via_home.get_location

This commit is contained in:
Sean Breckenridge 2023-02-22 04:56:15 -08:00
parent c9c2415771
commit b7d1012bf5

View file

@ -68,15 +68,9 @@ def get_location(dt: datetime) -> LatLon:
''' '''
Interpolates the location at dt Interpolates the location at dt
''' '''
if dt.tzinfo is None: loc = list(estimate_location(dt))
dt = dt.replace(tzinfo=timezone.utc) assert len(loc) == 1
hist = list(reversed(config._history)) return loc[0].lat, loc[0].lon
for pdt, loc in hist:
if dt >= pdt:
return loc
else:
# I guess the most reasonable is to fallback on the first location
return hist[-1][1]
# TODO: in python3.9, use functools.cached_property instead? # TODO: in python3.9, use functools.cached_property instead?