def distance_matrix(client, origins, destinations, mode=None, language=None, avoid=None, units=None, departure_time=None, arrival_time=None, transit_mode=None, transit_routing_preference=None, traffic_model=None):
 params = {'origins': convert.location_list(origins), 'destinations': convert.location_list(destinations)}
 if mode:
  if (mode not in ['driving', 'walking', 'bicycling', 'transit']):
   raise ValueError('Invalid travel mode.')
  params['mode'] = mode
 if language:
  params['language'] = language
 if avoid:
  if (avoid not in ['tolls', 'highways', 'ferries']):
   raise ValueError('Invalid route restriction.')
  params['avoid'] = avoid
 if units:
  params['units'] = units
 if departure_time:
  params['departure_time'] = convert.time(departure_time)
 if arrival_time:
  params['arrival_time'] = convert.time(arrival_time)
 if (departure_time and arrival_time):
  raise ValueError('Should not specify both departure_time andarrival_time.')
 if transit_mode:
  params['transit_mode'] = convert.join_list('|', transit_mode)
 if transit_routing_preference:
  params['transit_routing_preference'] = transit_routing_preference
 if traffic_model:
  params['traffic_model'] = traffic_model
 return client._get('/maps/api/distancematrix/json', params)

def distance_matrix ( client , origins , destinations , mode = None , language = None , avoid = None , units = None , departure_time = None , arrival_time = None , transit_mode = None , transit_routing_preference = None , traffic_model = None ) : params = { 'origins' : convert . location_list ( origins ) , 'destinations' : convert . location_list ( destinations ) } if mode : if ( mode not in [ 'driving' , 'walking' , 'bicycling' , 'transit' ] ) : raise ValueError ( 'Invalid travel mode.' ) params [ 'mode' ] = mode if language : params [ 'language' ] = language if avoid : if ( avoid not in [ 'tolls' , 'highways' , 'ferries' ] ) : raise ValueError ( 'Invalid route restriction.' ) params [ 'avoid' ] = avoid if units : params [ 'units' ] = units if departure_time : params [ 'departure_time' ] = convert . time ( departure_time ) if arrival_time : params [ 'arrival_time' ] = convert . time ( arrival_time ) if ( departure_time and arrival_time ) : raise ValueError ( 'Should not specify both departure_time andarrival_time.' ) if transit_mode : params [ 'transit_mode' ] = convert . join_list ( '|' , transit_mode ) if transit_routing_preference : params [ 'transit_routing_preference' ] = transit_routing_preference if traffic_model : params [ 'traffic_model' ] = traffic_model return client . _get ( '/maps/api/distancematrix/json' , params )
compute the distance matrix .