Skip to content

Commit

Permalink
Merge pull request #244 from conveyal/dev
Browse files Browse the repository at this point in the history
Patch release
  • Loading branch information
landonreed authored Jul 30, 2019
2 parents 30f0ad0 + 6f9a967 commit 6d5e228
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/conveyal/gtfs/model/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Locale;
Expand Down Expand Up @@ -213,7 +214,7 @@ protected LocalDate getDateField(String column, boolean required) throws IOExcep
if (str != null) try {
dateTime = LocalDate.parse(str, DateField.GTFS_DATE_FORMATTER);
checkRangeInclusive(2000, 2100, dateTime.getYear());
} catch (IllegalArgumentException iae) {
} catch (IllegalArgumentException | DateTimeParseException e) {
feed.errors.add(new DateParseError(tableName, row, column));
}
return dateTime;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/conveyal/gtfs/model/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public void loadOneRow() throws IOException {
r.route_branding_url = getUrlField("route_branding_url", false);
r.feed = feed;
r.feed_id = feed.feedId;
feed.routes.put(r.route_id, r);
// Attempting to put a null key or value will cause an NPE in BTreeMap
if (r.route_id != null) feed.routes.put(r.route_id, r);
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/conveyal/gtfs/model/Stop.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void loadOneRow() throws IOException {
s.feed = feed;
s.feed_id = feed.feedId;
/* TODO check ref integrity later, this table self-references via parent_station */

feed.stops.put(s.stop_id, s);
// Attempting to put a null key or value will cause an NPE in BTreeMap
if (s.stop_id != null) feed.stops.put(s.stop_id, s);
}

}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/conveyal/gtfs/model/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public void loadOneRow() throws IOException {
t.wheelchair_accessible = getIntField("wheelchair_accessible", false, 0, 2);
t.feed = feed;
t.feed_id = feed.feedId;
feed.trips.put(t.trip_id, t);
// Attempting to put a null key or value will cause an NPE in BTreeMap
if (t.trip_id != null) feed.trips.put(t.trip_id, t);

/*
Check referential integrity without storing references. Trip cannot directly reference Services or
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/conveyal/gtfs/GTFSMainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
public class GTFSMainTest {
private static String simpleGtfsZipFileName;
private static String badGtfsZipFileName;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();

// this is used so that it is possible to test code that calls System.exit()
Expand All @@ -30,6 +31,7 @@ public static void setUpClass() {
simpleGtfsZipFileName = null;
try {
simpleGtfsZipFileName = TestUtils.zipFolderFiles("fake-agency", true);
badGtfsZipFileName = TestUtils.zipFolderFiles("fake-agency-bad-calendar-date", true);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -76,4 +78,15 @@ public void canValidateSimpleAgency() throws Exception {
String[] args = {simpleGtfsZipFileName, "-validate"};
GTFSMain.main(args);
}

/**
* Verify that a simple GTFS Zip file can be loaded with the GTFSMain class.
*
* @throws Exception
*/
@Test
public void canValidateFeedWithErrors() throws Exception {
String[] args = {badGtfsZipFileName, "-validate"};
GTFSMain.main(args);
}
}
5 changes: 5 additions & 0 deletions src/test/resources/fake-agency-bad-calendar-date/routes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
agency_id,route_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color,route_branding_url
1,1,1,Route 1,,3,,7CE6E7,FFFFFF,





0 comments on commit 6d5e228

Please sign in to comment.