code: def _add_up_route(self, results, real_time=True, stop_at_bounds=False):
          
  
          start_bounds = self.start_coords['bounds']
          end_bounds = self.end_coords['bounds']
  
          def between(target, min, max):
              return target > min and target < max
  
          time = 0
          distance = 0
          for segment in results:
              if stop_at_bounds and segment.get('path'):
                  x = segment['path']['x']
                  y = segment['path']['y']
                  if (
                      between(x, start_bounds.get('left', 0), start_bounds.get('right', 0)) or
                      between(x, end_bounds.get('left', 0), end_bounds.get('right', 0))
                  ) and (
                      between(y, start_bounds.get('bottom', 0), start_bounds.get('top', 0)) or
                      between(y, end_bounds.get('bottom', 0), end_bounds.get('top', 0))
                  ):
                      continue
              time += segment['crossTime' if real_time else 'crossTimeWithoutRealTime']
              distance += segment['length']
          route_time = time / 60.0
          route_distance = distance / 1000.0
          return route_time, route_distance
docs: Calculate route time and distance.