diff --git a/bin/sfcta.jar b/bin/sfcta.jar new file mode 100644 index 0000000..5c63c90 Binary files /dev/null and b/bin/sfcta.jar differ diff --git a/org/sfcta/quickboards/QuickBoards.java b/org/sfcta/quickboards/QuickBoards.java index 4748153..777661e 100644 --- a/org/sfcta/quickboards/QuickBoards.java +++ b/org/sfcta/quickboards/QuickBoards.java @@ -249,20 +249,37 @@ void learnFieldPositions(DBFReader dbf) { B = getPosition(table, "B"); TIME = getPosition(table, "TIME"); MODE = getPosition(table, "MODE"); + DIST = getPosition(table, "DIST"); + NAME = getPosition(table, "NAME"); + + VOL = getPosition(table, "AB_VOL"); FREQ = getPosition(table, "FREQ"); PLOT = getPosition(table, "PLOT"); COLOR = getPosition(table, "COLOR"); STOP_A = getPosition(table, "STOP_A"); STOP_B = getPosition(table, "STOP_B"); - DIST = getPosition(table, "DIST"); - NAME = getPosition(table, "NAME"); SEQ = getPosition(table, "SEQ"); OWNER = getPosition(table, "OWNER"); - VOL = getPosition(table, "AB_VOL"); BRDA = getPosition(table, "AB_BRDA"); XITA = getPosition(table, "AB_XITA"); BRDB = getPosition(table, "AB_BRDB"); XITB = getPosition(table, "AB_XITB"); + + //IF FREQ is -1 then try reading the file in the "Cube Public Transport" type output format + if(FREQ==-1){ + VOL = getPosition(table, "VOL"); + PLOT = getPosition(table, "OPERATOR"); + COLOR = getPosition(table, "OPERATOR"); + STOP_A = getPosition(table, "STOPA"); + STOP_B = getPosition(table, "STOPB"); + SEQ = getPosition(table, "LINKSEQ"); + OWNER = getPosition(table, "OPERATOR"); + BRDA = getPosition(table, "ONA"); + XITA = getPosition(table, "OFFA"); + BRDB = getPosition(table, "ONB"); + XITB = getPosition(table, "OFFB"); + FREQ = getPositionHeadway(table); + } } @@ -283,7 +300,21 @@ int getPosition (Hashtable fields, String s) { return i; } - + + /** + * Find the DBF field for Headway. + * @param fields The table of fields and their positions + * @return Field position in the array + */ + int getPositionHeadway (Hashtable fields) { + Enumeration e = fields.keys(); + while (e.hasMoreElements()){ + String tempStr = (String) e.nextElement(); + if(tempStr.substring(0,Math.min(tempStr.length(),7)).equalsIgnoreCase("Headway")) + return getPosition(fields, tempStr); + } + return -1; + } /** * MAIN LOOP! --------------------------------------- * Read the required DBF files and populate the data vectors. diff --git a/org/sfcta/quickboards/TransitLink.java b/org/sfcta/quickboards/TransitLink.java index f767a45..73c9d91 100644 --- a/org/sfcta/quickboards/TransitLink.java +++ b/org/sfcta/quickboards/TransitLink.java @@ -39,8 +39,8 @@ public class TransitLink { long mode = 0; String a = ""; String b = ""; - long dist = 0; - long time =0; + double dist = 0; + double time =0; long stopa = 0; long stopb = 0; double vol=0.0; @@ -60,7 +60,13 @@ public TransitLink(Object[] fields, int A, int B,int MODE,int DIST,int VOL,int B this.b = fields[B].toString(); this.mode = ((Long)fields[MODE]).longValue(); - this.dist = ((Long)fields[DIST]).longValue(); + try { + this.dist = (double) ((Long)fields[DIST]).longValue(); + this.time = (double) ((Long)fields[TIME]).longValue(); + } catch (ClassCastException e) { + this.dist = ((Double)fields[DIST]).doubleValue(); + this.time = ((Double)fields[TIME]).doubleValue(); + } try { this.vol = (double) ((Long)fields[VOL]).longValue(); this.brda = (double) ((Long)fields[BRDA]).longValue(); @@ -77,7 +83,6 @@ public TransitLink(Object[] fields, int A, int B,int MODE,int DIST,int VOL,int B this.stopa= ((Long)fields[STOP_A]).longValue(); this.stopb= ((Long)fields[STOP_B]).longValue(); - this.time = ((Long)fields[TIME]).longValue(); this.freq = ((Double)fields[FREQ]).doubleValue(); this.seq = ((Long)fields[SEQ]);