Skip to content

Commit

Permalink
Fix the order for batch lines (#240)
Browse files Browse the repository at this point in the history
This patch fixes the order that the batch line edits are applied.  It also fixes
the case where a line filter could be applied twice.
  • Loading branch information
JamesVaughan authored Jul 22, 2024
1 parent 8415fda commit 8326175
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions TMGToolbox/src/XTMF_internal/apply_batch_line_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,41 +175,36 @@ def _LoadFile(self, fileName):
print(msg)
return

instructionData = {}
instructionData = []

for num, line in enumerate(reader):
cells = line.strip().split(self.COMMA)

filter = cells[filterCol]
if cells[headwayCol]:
hdw = cells[headwayCol]
else:
hdw = 1 # if the headway column is left blank, carry forward a factor of 1
if cells[speedCol]:
spd = cells[speedCol]
else:
spd = 1
instructionData[filter] = (float(hdw),float(spd))
line_filter = cells[filterCol]
# if the column is left blank, carry forward a factor of 1
headway = cells[headwayCol] if cells[headwayCol] else 1.0
speed = cells[speedCol] if cells[speedCol] else 1.0
instructionData.append((str(line_filter),float(headway),float(speed)))

return instructionData

def _ApplyLineChanges(self, inputData):
for filter, factors in six.iteritems(inputData):
if factors[0] != 1:
for (line_filter, headway, speed) in inputData:
if headway != 1:
spec = {
"type": "NETWORK_CALCULATION",
"expression": str(factors[0]) + "*hdw",
"expression": str(headway) + "*hdw",
"result": "hdw",
"selections": {
"transit_line": filter}}
"transit_line": line_filter}}
netCalc(spec, self.Scenario)
if factors[1] != 1:
if speed != 1:
spec = {
"type": "NETWORK_CALCULATION",
"expression": str(factors[1]) + "*speed",
"expression": str(speed) + "*speed",
"result": "speed",
"selections": {
"transit_line": filter}}
"transit_line": line_filter}}
netCalc(spec, self.Scenario)

@_m.method(return_type=_m.TupleType)
Expand Down

0 comments on commit 8326175

Please sign in to comment.