diff --git a/README.md b/README.md index 1788992..c114ef3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GTFS-examples -Here you can find scripts written in Python and PHP, as an example on how you can use GTFS, and what's possible with it. +Here you can find scripts written in Python and PHP, as an example on how you can use GTFS, and what's possible with it. ## Contributing @@ -10,6 +10,6 @@ If you would like to see a new feature added, you can also create a feature requ ## Help If you're stuck with a question, feel free to ask help through the Issue tracker. -- Need help with API keys? Please read [www.trafiklab.se/api-nycklar](https://www.trafiklab.se/api-nycklar) first. +- Need help with API keys? Please read [Getting Started](https://www.trafiklab.se/docs/getting-started/using-trafiklab) first. - Do you want to check the current systems status? Service disruptions are published on the [Trafiklab homepage](https://www.trafiklab.se/) diff --git a/python/README.md b/python/README.md index 2722814..c870de8 100644 --- a/python/README.md +++ b/python/README.md @@ -25,6 +25,6 @@ see a new feature added, you can also create a feature request by creating an is If you're stuck with a question, feel free to ask help through the Issue tracker. -- Need help with API keys? Please read [www.trafiklab.se/api-nycklar](https://www.trafiklab.se/api-nycklar) first. +- Need help with API keys? Please read [Getting Started](https://www.trafiklab.se/docs/getting-started/using-trafiklab) first. - Do you want to check the current systems status? Service disruptions are published on - the [Trafiklab homepage](https://www.trafiklab.se/) \ No newline at end of file + the [Trafiklab homepage](https://www.trafiklab.se/) diff --git a/python/gtfsToTimetableApi/GtfsTimeTable.py b/python/gtfsToTimetableApi/GtfsTimeTable.py index a1ebbd1..ee1d74c 100644 --- a/python/gtfsToTimetableApi/GtfsTimeTable.py +++ b/python/gtfsToTimetableApi/GtfsTimeTable.py @@ -72,7 +72,7 @@ def is_archive_outdated(directory): if is_outdated: logging.info("GTFS archive is older than 1 day") else: - logging.info("GTFS archive is less than 1 day old") + logging.debug("GTFS archive is less than 1 day old") # Since we check this on every call loglevel is set to DEBUG when the archive is up to date return is_outdated @@ -350,7 +350,7 @@ def get_seconds_since_midnight(self, time_str: str) -> int: required.add_argument("--vehicle-positions", help="the url to the vehiclepositions.pb file. Include an API key if the realtime feed requires this.", dest="vehicle_positions", required=True) - required.add_argument("--stop-id", help="the id of the stop to create a timetable for", dest="stop-id", + required.add_argument("--stop-id", help="the id of the stop to create a timetable for", dest="stop_id", required=True) args = parser.parse_args() @@ -362,5 +362,5 @@ def get_seconds_since_midnight(self, time_str: str) -> int: # will be offset by the reduced startup time. query_engine = TimeTableQueryEngine(gtfs_path, realtime_data_fetcher, reduce_memory_usage=True) # Run a sample query and print the result - result = query_engine.create_departures_timetable('9021012080000000') + result = query_engine.create_departures_timetable(args.stop_id) print(result) diff --git a/python/gtfsToTimetableApi/TimeTableApi.py b/python/gtfsToTimetableApi/TimeTableApi.py index 8fd153c..0c913ae 100644 --- a/python/gtfsToTimetableApi/TimeTableApi.py +++ b/python/gtfsToTimetableApi/TimeTableApi.py @@ -6,6 +6,7 @@ import json import logging import sys +from datetime import datetime, timedelta import flask @@ -28,7 +29,10 @@ @app.route('/departures/', methods=['GET']) def departures(stop_id): - resp = flask.Response(json.dumps(query_engine.create_departures_timetable(stop_id))) + gtfs_path = GtfsArchiveFetcher.fetch_and_extract(args.gtfs_url, "gtfs/") + window_start = datetime.now() - timedelta(minutes=10) + window_end = datetime.now() + timedelta(hours=2) + resp = flask.Response(json.dumps(query_engine.create_departures_timetable(stop_id, window_start, window_end))) resp.headers['Content-encoding'] = 'UTF-8' resp.headers['Content-type'] = 'Application/json' return resp @@ -36,6 +40,7 @@ def departures(stop_id): @app.route('/stops/', methods=['GET']) def stops(): + gtfs_path = GtfsArchiveFetcher.fetch_and_extract(args.gtfs_url, "gtfs/") resp = flask.Response(json.dumps(query_engine.list_queryable_stops())) resp.headers['Content-encoding'] = 'UTF-8' resp.headers['Content-type'] = 'Application/json' diff --git a/python/gtfsToTimetableApi/requirements.txt b/python/gtfsToTimetableApi/requirements.txt index 724d568..59b6ec3 100644 --- a/python/gtfsToTimetableApi/requirements.txt +++ b/python/gtfsToTimetableApi/requirements.txt @@ -1,4 +1,4 @@ -Flask==1.1.2 -gtfs-realtime-bindings==0.0.7 -urllib3==1.26.5 -requests==2.31.0 \ No newline at end of file +Flask==3.0.3 +gtfs-realtime-bindings==1.0.0 +urllib3==2.2.2 +requests==2.31.0