Calculates statistics on the driving travel time of cities.
When run as a script, will save statistics for all cities listed in settings.py to the data directory listed in settings.py (../data/ by default) in .json format. To use another settings file, pass it as the first command line argument:
python cityspeed.py /path/to/settings.py
You will need to edit settings.py to provide a Google Maps API Key and Referrer URL.
Orchestrates the process retrieving data about cities, computing and writing out statistics.
Implements some checkpoint-restart facilities for doing long runs. Basically, for each city:
Parameters: |
|
---|---|
Raises MapperError: | |
If no points or routes could be retrieved |
Compute statistics from route data.
Parameters: |
|
---|---|
Returns: | Dictionary of statistics for the given routes. |
Return type: | dict(string: numeric) with (at least) the following keys: numroutes, meters_avg, meters_std, seconds_avg, seconds_std, meters_per_sec_avg, meters_per_sec_std, steps_avg, steps_std, steps_per_meter_avg, steps_per_meter_std. ‘avg’ means average, ‘std’ means standard deviation. |
You can add your own statistics by subclassing stats.Keeper and adding your class to statskeepers. The key you use will be appended to each of the five measured quantites (meters, seconds, steps, meters per second, and steps per meter) returned from compute_route_stats(), and it will map to the value returned by the get() method of your stats.Keeper.
Example: say you want to see medians. Define a Median(stats.Keeper) and pass the keyword argument statskeepers={'med': Median} to this function. Then the dictionary returned from this function will contain keys ‘meters_med’, ‘seconds_med’, etc., mapping to the medians of the samples.
Prints message to stdout.
For tracking the progress of long runs.