From f2ec482603238ccbd7bc04e7140a86d9458eb40b Mon Sep 17 00:00:00 2001 From: "dkeen@dkeen-laptop" Date: Mon, 30 Apr 2012 15:02:14 -0700 Subject: [PATCH] Fixed route direction bug for transfer routes --- src/com/dougkeen/bart/model/Station.java | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/com/dougkeen/bart/model/Station.java b/src/com/dougkeen/bart/model/Station.java index fc21e85..4daefb9 100644 --- a/src/com/dougkeen/bart/model/Station.java +++ b/src/com/dougkeen/bart/model/Station.java @@ -152,13 +152,28 @@ public enum Station { List returnList = new ArrayList(); final Collection applicableLines = Line.getLinesWithStations( this, dest); - for (Line line : applicableLines) { - int origIndex = line.stations.indexOf(this); - int destIndex = line.stations.indexOf(dest); + if (transferLines != null && !transferLines.isEmpty()) { + for (Line transferLine : transferLines) { + int origIndex = transferLine.stations.indexOf(origin); + int destIndex = transferLine.stations.indexOf(origin + .getOutboundTransferStation()); - isNorth = (origIndex < destIndex); - if (line.directionMayInvert && this.invertDirection) { - isNorth = !isNorth; + isNorth = (origIndex < destIndex); + if (origin.invertDirection && transferLine.directionMayInvert) { + isNorth = !isNorth; + break; + } + } + } + for (Line line : applicableLines) { + if (transferLines == null || transferLines.isEmpty()) { + int origIndex = line.stations.indexOf(this); + int destIndex = line.stations.indexOf(dest); + + isNorth = (origIndex < destIndex); + if (line.directionMayInvert && this.invertDirection) { + isNorth = !isNorth; + } } Route route = new Route(); route.setOrigin(origin);