Adding initial walking time and identifier to the information
This commit is contained in:
parent
ce632c795d
commit
47f7b2b672
2 changed files with 8 additions and 1 deletions
|
|
@ -11,7 +11,6 @@ _DATA_DIR = pathlib.Path('data/rs/')
|
|||
class Listing():
|
||||
identifier: int
|
||||
_cached: Dict = None
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_all_listings() -> List['Listing']:
|
||||
|
|
@ -187,6 +186,7 @@ class Listing():
|
|||
|
||||
def dict_nicely(self):
|
||||
return {
|
||||
'identifier': self.identifier,
|
||||
'sqm_ocr': self.sqm_ocr,
|
||||
'price': self.price,
|
||||
'price_per_sqm': self.price_per_sqm,
|
||||
|
|
|
|||
|
|
@ -59,11 +59,17 @@ def extract_time(d, limit:int=2):
|
|||
duration_static = int(route['staticDuration'].strip('s'))
|
||||
|
||||
steps = route['legs'][0]['steps']
|
||||
initial_walk_duration = 0
|
||||
used_transit = False
|
||||
duration_per_transit = defaultdict(lambda: 0)
|
||||
distance_per_transit = defaultdict(lambda: 0)
|
||||
number_of_transit_stops = 0
|
||||
|
||||
for step in steps:
|
||||
if used_transit == False and step['travelMode'] == 'WALK':
|
||||
initial_walk_duration += int(step['staticDuration'].strip('s'))
|
||||
else:
|
||||
used_transit = True
|
||||
duration_per_transit[step['travelMode']] += int(step['staticDuration'].strip('s'))
|
||||
distance_per_transit[step['travelMode']] += step.get('distanceMeters', 0)
|
||||
if step['travelMode'] == 'TRANSIT':
|
||||
|
|
@ -73,6 +79,7 @@ def extract_time(d, limit:int=2):
|
|||
'duration': duration,
|
||||
'distance': distance,
|
||||
'duration_static': duration_static,
|
||||
'initial_walk_duration': initial_walk_duration,
|
||||
'duration_per_transit': dict(duration_per_transit),
|
||||
'distance_per_transit': dict(distance_per_transit),
|
||||
'number_of_transit_stops': number_of_transit_stops,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue