Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bin/sfcta.jar
Binary file not shown.
39 changes: 35 additions & 4 deletions org/sfcta/quickboards/QuickBoards.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand All @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions org/sfcta/quickboards/TransitLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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]);
Expand Down