Skip to content

Commit

Permalink
adding option for human readable time output, refs #11192
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertHilbrich committed Feb 21, 2024
1 parent ceae20d commit cfa464e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/import/gtfs/gtfs2pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# @file gtfs2pt.py
# @author Jakob Erdmann
# @author Michael Behrisch
# @author Robert Hilbrich
# @date 2018-08-28

"""
Expand All @@ -36,6 +37,7 @@
os.path.join(os.environ['SUMO_HOME'], 'tools', 'route')]
import route2poly # noqa
import sumolib # noqa
from sumolib.miscutils import humanReadableTime # noqa
import tracemapper # noqa

import gtfs2fcd # noqa
Expand Down Expand Up @@ -66,6 +68,8 @@ def get_options(args=None):
ap.add_argument("--sort", action="store_true", default=False, category="processing",
help="sorting the output-file")
ap.add_argument("--stops", category="input", type=ap.file, help="file with predefined stop positions to use")
ap.add_argument("-H", "--human-readable-time", category="output", dest="hrtime", default=False, action="store_true",
help="write times as h:m:s")

# ----------------------- fcd options -------------------------------------
ap.add_argument("--network-split", category="input",
Expand Down Expand Up @@ -346,6 +350,7 @@ def map_stops(options, net, routes, rout, edgeMap, fixedStops):


def filter_trips(options, routes, stops, outf, begin, end):
ft = humanReadableTime if options.hrtime else lambda x: x
numDays = int(end) // 86400
if end % 86400 != 0:
numDays += 1
Expand All @@ -363,7 +368,7 @@ def filter_trips(options, routes, stops, outf, begin, end):
# only add trimmed trips the first day
continue
line = (u' <vehicle id="%s.%s" route="%s" type="%s" depart="%s" line="%s">\n' %
(veh.id, d, veh.route, veh.type, depart, veh.line))
(veh.id, d, veh.route, veh.type, ft(depart), veh.line))
for p in veh.param:
line += u' <param key="%s" value="%s"/>\n' % p
line += u' </vehicle>\n'
Expand Down

0 comments on commit cfa464e

Please sign in to comment.