From d20f2d228bec55ed85fdb3419909278ee214cc1a Mon Sep 17 00:00:00 2001 From: Jakob Erdmann Date: Fri, 20 Dec 2024 15:30:29 +0100 Subject: [PATCH] supporting random departpos and arrivalpos for persons. refs #15946 --- tools/randomTrips.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tools/randomTrips.py b/tools/randomTrips.py index 8566d9517e4b..c8a44cb970db 100755 --- a/tools/randomTrips.py +++ b/tools/randomTrips.py @@ -680,13 +680,19 @@ def generate_origin_destination(trip_generator, options): def generate_attributes(idx, departureTime, arrivalTime, origin, destination, intermediate, options): label = "%s%s" % (options.tripprefix, idx) - combined_attrs = options.tripattrs + if options.pedestrians: + combined_attrs = "" + else: + combined_attrs = options.tripattrs + arrivalPos = "" if options.randomDepartPos: randomPosition = samplePosition(origin) combined_attrs += ' departPos="%.2f"' % randomPosition if options.randomArrivalPos: randomPosition = samplePosition(destination) - combined_attrs += ' arrivalPos="%.2f"' % randomPosition + arrivalPos = ' arrivalPos="%.2f"' % randomPosition + if not options.pedestrians: + combined_attrs += arrivalPos if options.fringeattrs and origin.is_fringe( origin._incoming, checkJunctions=options.fringeJunctions): combined_attrs += " " + options.fringeattrs @@ -706,11 +712,11 @@ def generate_attributes(idx, departureTime, arrivalTime, origin, destination, in [e.getID() for e in intermediate]) if options.validate: vias[label] = via - return label, combined_attrs, attrFrom, attrTo, via + return label, combined_attrs, attrFrom, attrTo, via, arrivalPos - def generate_one_plan(combined_attrs, attrFrom, attrTo, intermediate, options): + def generate_one_plan(combined_attrs, attrFrom, attrTo, arrivalPos, intermediate, options): element = "walk" - attrs = otherattrs + attrs = otherattrs + arrivalPos if options.fromStops: fouttrips.write(' \n' % attrFrom) attrFrom = '' @@ -727,10 +733,10 @@ def generate_one_plan(combined_attrs, attrFrom, attrTo, intermediate, options): else: fouttrips.write(' <%s%s%s%s/>\n' % (element, attrFrom, attrTo, attrs)) - def generate_one_person(label, combined_attrs, attrFrom, attrTo, departureTime, intermediate, options): + def generate_one_person(label, combined_attrs, attrFrom, attrTo, arrivalPos, departureTime, intermediate, options): fouttrips.write( - ' \n' % (label, departureTime, personattrs)) - generate_one_plan(combined_attrs, attrFrom, attrTo, intermediate, options) + ' \n' % (label, departureTime, personattrs, combined_attrs)) + generate_one_plan(combined_attrs, attrFrom, attrTo, arrivalPos, intermediate, options) fouttrips.write(' \n') def generate_one_flow(label, combined_attrs, departureTime, arrivalTime, period, options, timeIdx): @@ -745,7 +751,7 @@ def generate_one_flow(label, combined_attrs, departureTime, arrivalTime, period, fouttrips.write((' \n') % ( label, departureTime, arrivalTime, intIfPossible(period * options.flows), combined_attrs)) - def generate_one_personflow(label, combined_attrs, attrFrom, attrTo, departureTime, arrivalTime, period, options, timeIdx): + def generate_one_personflow(label, combined_attrs, attrFrom, attrTo, arrivalPos, departureTime, arrivalTime, period, options, timeIdx): if len(options.period) > 1: label = label + "#%s" % timeIdx if options.binomial: @@ -753,12 +759,12 @@ def generate_one_personflow(label, combined_attrs, attrFrom, attrTo, departureTi fouttrips.write((' \n') % ( label, j, departureTime, arrivalTime, 1.0 / period / options.binomial, combined_attrs)) - generate_one_plan(combined_attrs, attrFrom, attrTo, intermediate, options) + generate_one_plan(combined_attrs, attrFrom, attrTo, arrivalPos, intermediate, options) fouttrips.write(' \n') else: fouttrips.write((' \n') % ( label, departureTime, arrivalTime, intIfPossible(period * options.flows), combined_attrs)) - generate_one_plan(combined_attrs, attrFrom, attrTo, intermediate, options) + generate_one_plan(combined_attrs, attrFrom, attrTo, arrivalPos, intermediate, options) fouttrips.write(' \n') def generate_one_trip(label, combined_attrs, departureTime): @@ -767,14 +773,16 @@ def generate_one_trip(label, combined_attrs, departureTime): def generate_one(idx, departureTime, arrivalTime, period, origin, destination, intermediate, timeIdx=None): try: - label, combined_attrs, attrFrom, attrTo, via = generate_attributes( + label, combined_attrs, attrFrom, attrTo, via, arrivalPos = generate_attributes( idx, departureTime, arrivalTime, origin, destination, intermediate, options) if options.pedestrians: if options.flows > 0: - generate_one_personflow(label, combined_attrs, attrFrom, attrTo, departureTime, arrivalTime, period, options, timeIdx) + generate_one_personflow(label, combined_attrs, attrFrom, attrTo, arrivalPos, + departureTime, arrivalTime, period, options, timeIdx) else: - generate_one_person(label, combined_attrs, attrFrom, attrTo, departureTime, intermediate, options) + generate_one_person(label, combined_attrs, attrFrom, attrTo, arrivalPos, + departureTime, intermediate, options) else: if options.jtrrouter: attrTo = ''