CUTR-at-USF / transit-feed-quality-calculator

A tool that uses the gtfs-realtime-validator to calculate the quality of a large number of GTFS-realtime feeds
Other
7 stars 1 forks source link

Analyzer - Don't rely on "-" for parsing ID and location values from region_id #24

Open barbeau opened 6 years ago

barbeau commented 6 years ago

Summary:

Originally reported in https://github.com/CUTR-at-USF/transit-feed-quality-calculator/issues/23.

If you analyze a feed from the CSVDownloader using a region_id like -1-Portland, you'll get the error:

Exception in thread "main" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:592)
    at java.lang.Integer.parseInt(Integer.java:615)
    at edu.usf.cutr.transitfeedqualitycalculator.ResultsAnalyzer.analyzeResults(ResultsAnalyzer.java:84)
    at edu.usf.cutr.transitfeedqualitycalculator.TransitFeedQualityCalculator.calculate(TransitFeedQualityCalculator.java:112)
    at edu.usf.cutr.transitfeedqualitycalculator.Main.main(Main.java:54)

The analyzer is relying on a single - to split an ID from the region name. We should update the analyzer to be more flexible and not require strict naming conventions like ID-RegionName.

Steps to reproduce:

Run java -Djsse.enableSNIExtension=false -jar target/transit-feed-quality-calculator-1.0.0-SNAPSHOT.jar -directory output -csv feeds.csv

... where feeds.csv contains:

region_id,title,gtfs_url,gtfs_rt_url
"-1-Portland, OR, USA","TriMet Trip Update",https://developer.trimet.org/schedule/gtfs.zip,http://developer.trimet.org/ws/V1/TripUpdate&appID=225D5601E7729B9ED863DCA39
"-1-Portland, OR, USA","TriMet Alerts",https://developer.trimet.org/schedule/gtfs.zip,http://developer.trimet.org/ws/V1/FeedSpecAlerts&appID=1234567
"-2-Oakland, CA, USA","AC Transit Trip Update",http://www.actransit.org/wp-content/uploads/GTFSWinter17B.zip,http://api.actransit.org/transit/gtfsrt/tripupdates?token=12365878

Expected behavior:

Validate and analyze the feeds without a problem

Observed behavior:

NumberFormatException when analyzing the feeds

Platform:

Windows 7 Enterprise SP1 with Java 64bit 9.0.1