Skip to content

Commit c3dad34

Browse files
committed
Move stuff around in GTFS
1 parent 0af725f commit c3dad34

File tree

17 files changed

+11
-523
lines changed

17 files changed

+11
-523
lines changed

reader-gtfs/src/main/java/com/conveyal/gtfs/model/Agency.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import java.io.IOException;
3232
import java.net.URL;
33-
import java.util.Iterator;
3433

3534
public class Agency extends Entity {
3635

@@ -79,34 +78,4 @@ public void loadOneRow() throws IOException {
7978

8079
}
8180

82-
public static class Writer extends Entity.Writer<Agency> {
83-
public Writer(GTFSFeed feed) {
84-
super(feed, "agency");
85-
}
86-
87-
@Override
88-
public void writeHeaders() throws IOException {
89-
writer.writeRecord(new String[] {"agency_id", "agency_name", "agency_url", "agency_lang",
90-
"agency_phone", "agency_timezone", "agency_fare_url", "agency_branding_url"});
91-
}
92-
93-
@Override
94-
public void writeOneRow(Agency a) throws IOException {
95-
writeStringField(a.agency_id);
96-
writeStringField(a.agency_name);
97-
writeUrlField(a.agency_url);
98-
writeStringField(a.agency_lang);
99-
writeStringField(a.agency_phone);
100-
writeStringField(a.agency_timezone);
101-
writeUrlField(a.agency_fare_url);
102-
writeUrlField(a.agency_branding_url);
103-
endRecord();
104-
}
105-
106-
@Override
107-
public Iterator<Agency> iterator() {
108-
return this.feed.agency.values().iterator();
109-
}
110-
}
111-
11281
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/Calendar.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@
2828

2929
import com.conveyal.gtfs.GTFSFeed;
3030
import com.conveyal.gtfs.error.DuplicateKeyError;
31-
import com.google.common.base.Function;
32-
import com.google.common.base.Predicate;
33-
import com.google.common.collect.Iterators;
3431

3532
import java.io.IOException;
3633
import java.io.Serializable;
37-
import java.util.Iterator;
3834
import java.util.Map;
3935

4036
public class Calendar extends Entity implements Serializable {
@@ -100,50 +96,4 @@ public void loadOneRow() throws IOException {
10096
}
10197
}
10298

103-
public static class Writer extends Entity.Writer<Calendar> {
104-
public Writer(GTFSFeed feed) {
105-
super(feed, "calendar");
106-
}
107-
108-
@Override
109-
protected void writeHeaders() throws IOException {
110-
writer.writeRecord(new String[] {"service_id", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", "start_date", "end_date"});
111-
}
112-
113-
@Override
114-
protected void writeOneRow(Calendar c) throws IOException {
115-
writeStringField(c.service_id);
116-
writeIntField(c.monday);
117-
writeIntField(c.tuesday);
118-
writeIntField(c.wednesday);
119-
writeIntField(c.thursday);
120-
writeIntField(c.friday);
121-
writeIntField(c.saturday);
122-
writeIntField(c.sunday);
123-
writeIntField(c.start_date);
124-
writeIntField(c.end_date);
125-
endRecord();
126-
}
127-
128-
@Override
129-
protected Iterator<Calendar> iterator() {
130-
// wrap an iterator over services
131-
Iterator<Calendar> calIt = Iterators.transform(feed.services.values().iterator(), new Function<Service, Calendar> () {
132-
@Override
133-
public Calendar apply (Service s) {
134-
return s.calendar;
135-
}
136-
});
137-
138-
// not every service has a calendar (e.g. TriMet has no calendars, just calendar dates).
139-
// This is legal GTFS, so skip services with no calendar
140-
return Iterators.filter(calIt, new Predicate<Calendar> () {
141-
@Override
142-
public boolean apply(Calendar c) {
143-
return c != null;
144-
}
145-
});
146-
147-
}
148-
}
14999
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/CalendarDate.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@
2828

2929
import com.conveyal.gtfs.GTFSFeed;
3030
import com.conveyal.gtfs.error.DuplicateKeyError;
31-
import com.google.common.base.Function;
32-
import com.google.common.collect.Iterators;
3331

3432
import java.io.IOException;
3533
import java.io.Serializable;
3634
import java.time.LocalDate;
37-
import java.util.Iterator;
3835
import java.util.Map;
3936

4037
public class CalendarDate extends Entity implements Cloneable, Serializable {
@@ -90,33 +87,4 @@ public void loadOneRow() throws IOException {
9087
}
9188
}
9289

93-
public static class Writer extends Entity.Writer<CalendarDate> {
94-
public Writer (GTFSFeed feed) {
95-
super(feed, "calendar_dates");
96-
}
97-
98-
@Override
99-
protected void writeHeaders() throws IOException {
100-
writer.writeRecord(new String[] {"service_id", "date", "exception_type"});
101-
}
102-
103-
@Override
104-
protected void writeOneRow(CalendarDate d) throws IOException {
105-
writeStringField(d.service_id);
106-
writeDateField(d.date);
107-
writeIntField(d.exception_type);
108-
endRecord();
109-
}
110-
111-
@Override
112-
protected Iterator<CalendarDate> iterator() {
113-
Iterator<Service> serviceIterator = feed.services.values().iterator();
114-
return Iterators.concat(Iterators.transform(serviceIterator, new Function<Service, Iterator<CalendarDate>> () {
115-
@Override
116-
public Iterator<CalendarDate> apply(Service service) {
117-
return service.calendar_dates.values().iterator();
118-
}
119-
}));
120-
}
121-
}
12290
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/FareAttribute.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.conveyal.gtfs.error.DuplicateKeyError;
3131

3232
import java.io.IOException;
33-
import java.util.Iterator;
3433
import java.util.Map;
3534

3635
public class FareAttribute extends Entity {
@@ -72,8 +71,8 @@ public void loadOneRow() throws IOException {
7271
fa.price = getDoubleField("price", true, 0, Integer.MAX_VALUE);
7372
fa.currency_type = getStringField("currency_type", true);
7473
fa.payment_method = getIntField("payment_method", true, 0, 1);
75-
fa.transfers = getIntField("transfers", false, 0, 10); // TODO missing means "unlimited" in this case (rather than 0), supply default value or just use the NULL to mean unlimited
76-
fa.transfer_duration = getIntField("transfer_duration", false, 0, 24 * 60 * 60);
74+
fa.transfers = getIntField("transfers", false, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
75+
fa.transfer_duration = getIntField("transfer_duration", false, 0, 24*60*60, 24*60*60);
7776
fa.feed = feed;
7877
fa.feed_id = feed.feedId;
7978
fare.fare_attribute = fa;
@@ -83,34 +82,4 @@ public void loadOneRow() throws IOException {
8382

8483
}
8584

86-
public static class Writer extends Entity.Writer<FareAttribute> {
87-
public Writer(GTFSFeed feed) {
88-
super(feed, "fare_attributes");
89-
}
90-
91-
@Override
92-
public void writeHeaders() throws IOException {
93-
writer.writeRecord(new String[] {"fare_id", "price", "currency_type", "payment_method",
94-
"transfers", "transfer_duration"});
95-
}
96-
97-
@Override
98-
public void writeOneRow(FareAttribute fa) throws IOException {
99-
writeStringField(fa.fare_id);
100-
writeDoubleField(fa.price);
101-
writeStringField(fa.currency_type);
102-
writeIntField(fa.payment_method);
103-
writeIntField(fa.transfers);
104-
writeIntField(fa.transfer_duration);
105-
endRecord();
106-
}
107-
108-
@Override
109-
public Iterator<FareAttribute> iterator() {
110-
return feed.fares.values().stream()
111-
.map(f -> f.fare_attribute)
112-
.iterator();
113-
}
114-
}
115-
11685
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/FareRule.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.conveyal.gtfs.error.ReferentialIntegrityError;
3131

3232
import java.io.IOException;
33-
import java.util.Iterator;
3433
import java.util.Map;
3534

3635
public class FareRule extends Entity {
@@ -82,34 +81,4 @@ public void loadOneRow() throws IOException {
8281

8382
}
8483

85-
public static class Writer extends Entity.Writer<FareRule> {
86-
public Writer(GTFSFeed feed) {
87-
super(feed, "fare_rules");
88-
}
89-
90-
@Override
91-
public void writeHeaders() throws IOException {
92-
writer.writeRecord(new String[] {"fare_id", "route_id", "origin_id", "destination_id",
93-
"contains_id"});
94-
}
95-
96-
@Override
97-
public void writeOneRow(FareRule fr) throws IOException {
98-
writeStringField(fr.fare_id);
99-
writeStringField(fr.route_id);
100-
writeStringField(fr.origin_id);
101-
writeStringField(fr.destination_id);
102-
writeStringField(fr.contains_id);
103-
endRecord();
104-
}
105-
106-
@Override
107-
public Iterator<FareRule> iterator() {
108-
return feed.fares.values().stream()
109-
.map(f -> f.fare_rules)
110-
.flatMap(fr -> fr.stream())
111-
.iterator();
112-
}
113-
}
114-
11584
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/FeedInfo.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.io.IOException;
3333
import java.net.URL;
3434
import java.time.LocalDate;
35-
import java.util.Iterator;
3635

3736
public class FeedInfo extends Entity implements Cloneable {
3837

@@ -85,38 +84,4 @@ public void loadOneRow() throws IOException {
8584
}
8685
}
8786

88-
public static class Writer extends Entity.Writer<FeedInfo> {
89-
90-
public Writer(GTFSFeed feed) {
91-
super(feed, "feed_info");
92-
}
93-
94-
@Override
95-
public void writeHeaders() throws IOException {
96-
writer.writeRecord(new String[] {"feed_id", "feed_publisher_name", "feed_publisher_url", "feed_lang",
97-
"feed_start_date", "feed_end_date", "feed_version"});
98-
}
99-
100-
@Override
101-
public void writeOneRow(FeedInfo i) throws IOException {
102-
writeStringField(i.feed_id != null && i.feed_id.equals("NONE") ? "" : i.feed_id);
103-
writeStringField(i.feed_publisher_name);
104-
writeUrlField(i.feed_publisher_url);
105-
writeStringField(i.feed_lang);
106-
107-
if (i.feed_start_date != null) writeDateField(i.feed_start_date);
108-
else writeStringField("");
109-
110-
if (i.feed_end_date != null) writeDateField(i.feed_end_date);
111-
else writeStringField("");
112-
113-
writeStringField(i.feed_version);
114-
endRecord();
115-
}
116-
117-
@Override
118-
public Iterator<FeedInfo> iterator() {
119-
return feed.feedInfo.values().iterator();
120-
}
121-
}
12287
}

reader-gtfs/src/main/java/com/conveyal/gtfs/model/Frequency.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.mapdb.Fun;
3131

3232
import java.io.IOException;
33-
import java.util.Iterator;
3433
import java.util.Locale;
3534

3635
import static com.conveyal.gtfs.model.Entity.Writer.convertToGtfsTime;
@@ -95,34 +94,4 @@ public void loadOneRow() throws IOException {
9594
}
9695
}
9796

98-
public static class Writer extends Entity.Writer<Frequency> {
99-
public Writer (GTFSFeed feed) {
100-
super(feed, "frequencies");
101-
}
102-
103-
@Override
104-
public void writeHeaders() throws IOException {
105-
writer.writeRecord(new String[] {"trip_id", "start_time", "end_time", "headway_secs", "exact_times"});
106-
}
107-
108-
@Override
109-
public void writeOneRow(Frequency f) throws IOException {
110-
writeStringField(f.trip_id);
111-
writeTimeField(f.start_time);
112-
writeTimeField(f.end_time);
113-
writeIntField(f.headway_secs);
114-
writeIntField(f.exact_times);
115-
endRecord();
116-
}
117-
118-
@Override
119-
public Iterator<Frequency> iterator() {
120-
return feed.frequencies.stream()
121-
.map(t2 -> t2.b)
122-
.iterator();
123-
}
124-
125-
126-
}
127-
12897
}

0 commit comments

Comments
 (0)