Skip to content

Commit

Permalink
Merge pull request #184 from conveyal/dev
Browse files Browse the repository at this point in the history
Add missing fields route_route_sort_order and fare_attribute#agency_id
  • Loading branch information
Landon Reed authored Jan 7, 2019
2 parents b476deb + b15744f commit 21f4563
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/conveyal/gtfs/model/FareAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FareAttribute extends Entity {
private static final long serialVersionUID = 2157859372072056891L;
public static final int UNLIMITED_TRANSFERS = Integer.MAX_VALUE;
public String fare_id;
public String agency_id;
public double price;
public String currency_type;
public int payment_method;
Expand All @@ -40,6 +41,7 @@ public void setStatementParameters(PreparedStatement statement, boolean setDefau
setIntParameter(statement, oneBasedIndex++, payment_method);
// FIXME Entity.INT_MISSING causing out of range error on small int
setIntParameter(statement, oneBasedIndex++, transfers);
statement.setString(oneBasedIndex++, agency_id);
setIntParameter(statement, oneBasedIndex++, transfer_duration);
}

Expand Down Expand Up @@ -72,6 +74,7 @@ public void loadOneRow() throws IOException {
fa.currency_type = getStringField("currency_type", true);
fa.payment_method = getIntField("payment_method", true, 0, 1);
fa.transfers = getIntField("transfers", false, 0, 10, UNLIMITED_TRANSFERS); // in the GTFS spec, a missing value means "unlimited", so we default to UNLIMITED_TRANSFERS (or MAX_INT) when no value is found
fa.agency_id = getStringField("agency_id", false);
fa.transfer_duration = getIntField("transfer_duration", false, 0, 24 * 60 * 60);
fa.feed = feed;
fa.feed_id = feed.feedId;
Expand All @@ -89,13 +92,14 @@ public Writer(GTFSFeed feed) {

@Override
public void writeHeaders() throws IOException {
writer.writeRecord(new String[] {"fare_id", "price", "currency_type", "payment_method",
writer.writeRecord(new String[] {"fare_id", "agency_id", "price", "currency_type", "payment_method",
"transfers", "transfer_duration"});
}

@Override
public void writeOneRow(FareAttribute fa) throws IOException {
writeStringField(fa.fare_id);
writeStringField(fa.agency_id);
writeDoubleField(fa.price);
writeStringField(fa.currency_type);
writeIntField(fa.payment_method);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/conveyal/gtfs/model/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Route extends Entity { // implements Entity.Factory<Route>
public int route_type;
public URL route_url;
public String route_color;
public int route_sort_order;
public String route_text_color;
public URL route_branding_url;
public String feed_id;
Expand Down Expand Up @@ -60,7 +61,8 @@ public void setStatementParameters(PreparedStatement statement, boolean setDefau
// Editor-specific fields publicly_visible, wheelchair_accessible, route_sort_order, and status.
setIntParameter(statement, oneBasedIndex++, 0);
setIntParameter(statement, oneBasedIndex++, 0);
setIntParameter(statement, oneBasedIndex++, INT_MISSING);
// route_sort_order
setIntParameter(statement, oneBasedIndex++, route_sort_order);
setIntParameter(statement, oneBasedIndex++, 0);
}

Expand Down Expand Up @@ -97,6 +99,7 @@ public void loadOneRow() throws IOException {
r.route_long_name = getStringField("route_long_name", false);
r.route_desc = getStringField("route_desc", false);
r.route_type = getIntField("route_type", true, 0, 7);
r.route_sort_order = getIntField("route_type", false, 0, Integer.MAX_VALUE);
r.route_url = getUrlField("route_url", false);
r.route_color = getStringField("route_color", false);
r.route_text_color = getStringField("route_text_color", false);
Expand Down Expand Up @@ -125,6 +128,7 @@ public void writeHeaders() throws IOException {
writeStringField("route_color");
writeStringField("route_text_color");
writeStringField("route_branding_url");
writeStringField("route_sort_order");
endRecord();
}

Expand All @@ -140,6 +144,7 @@ public void writeOneRow(Route r) throws IOException {
writeStringField(r.route_color);
writeStringField(r.route_text_color);
writeUrlField(r.route_branding_url);
writeIntField(r.route_sort_order);
endRecord();
}

Expand Down

0 comments on commit 21f4563

Please sign in to comment.