use estimate_location in via_home.get_location
This commit is contained in:
parent
c9c2415771
commit
b7d1012bf5
1 changed files with 3 additions and 9 deletions
|
@ -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?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue