Skip to content

Commit

Permalink
Get travel time data in batches of 60 stations
Browse files Browse the repository at this point in the history
NS API has a max number of requests per day.
  • Loading branch information
bartromgens committed Feb 28, 2016
1 parent f2f0ddc commit 50dcc27
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions bin/create_traveltime_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,34 @@

DATA_DIR = './website/data'

MAX_STATIONS = 60


def main():
os.path
stations = nsmaps.station.Stations(DATA_DIR)
major_station_types = (
StationType.intercitystation,
StationType.knooppuntIntercitystation,
StationType.megastation,
# StationType.knooppuntSneltreinstation,
# StationType.sneltreinstation,
StationType.knooppuntSneltreinstation,
StationType.sneltreinstation,
StationType.knooppuntStoptreinstation,
StationType.stoptreinstation
)
major_stations = stations.get_stations_for_types(major_station_types)
stations.create_traveltimes_data(major_stations)
stations_options = stations.get_stations_for_types(major_station_types)

stations_todo = []

n_stations = 0
for station in stations_options:
if n_stations >= MAX_STATIONS:
break
if not station.has_travel_time_data() and station.get_country_code() == 'NL':
stations_todo.append(station)
n_stations += 1
print(station)

stations.create_traveltimes_data(stations_todo)
stations.recreate_missing_destinations(DATA_DIR, False)


Expand Down

0 comments on commit 50dcc27

Please sign in to comment.