Skip to content

Commit

Permalink
refactor(Many changes to accom flex v2):
Browse files Browse the repository at this point in the history
  • Loading branch information
br648 committed Jun 24, 2024
1 parent e623aef commit 57506da
Show file tree
Hide file tree
Showing 115 changed files with 1,949 additions and 11,222 deletions.
227 changes: 49 additions & 178 deletions src/main/java/com/conveyal/gtfs/PatternBuilder.java

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions src/main/java/com/conveyal/gtfs/TripPatternKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
public class TripPatternKey {

public String routeId;
public List<Boolean> isFlexStop = new ArrayList<>();
public List<String> stops = new ArrayList<>();
public TIntList pickupTypes = new TIntArrayList();
public TIntList dropoffTypes = new TIntArrayList();
Expand All @@ -37,6 +38,8 @@ public class TripPatternKey {
public TDoubleList shapeDistances = new TDoubleArrayList();

// Flex additions
public List<String> locationGroupIds = new ArrayList<>();
public List<String> locationIds = new ArrayList<>();
public List<String> pickup_booking_rule_id = new ArrayList<>();
public List<String> drop_off_booking_rule_id = new ArrayList<>();

Expand All @@ -45,9 +48,14 @@ public TripPatternKey (String routeId) {
}

public void addStopTime (StopTime st) {
isFlexStop.add((st.stop_id == null));
stops.add(st.stop_id);
locationGroupIds.add(st.location_group_id);
locationIds.add(st.location_id);
pickupTypes.add(resolvePickupOrDropOffType(st.pickup_type));
dropoffTypes.add(resolvePickupOrDropOffType(st.drop_off_type));
start_pickup_drop_off_window.add(st.start_pickup_drop_off_window);
end_pickup_drop_off_window.add(st.end_pickup_drop_off_window);
// Note, the items listed below are not used in the equality check.
arrivalTimes.add(st.arrival_time);
departureTimes.add(st.departure_time);
Expand All @@ -58,9 +66,6 @@ public void addStopTime (StopTime st) {
continuous_drop_off.add(st.continuous_drop_off);
pickup_booking_rule_id.add(st.pickup_booking_rule_id);
drop_off_booking_rule_id.add(st.drop_off_booking_rule_id);

start_pickup_drop_off_window.add(st.start_pickup_drop_off_window);
end_pickup_drop_off_window.add(st.end_pickup_drop_off_window);
}

/**
Expand All @@ -84,6 +89,8 @@ public boolean equals(Object o) {
if (!Objects.equals(pickupTypes, that.pickupTypes)) return false;
if (!Objects.equals(routeId, that.routeId)) return false;
if (!Objects.equals(stops, that.stops)) return false;
if (!Objects.equals(locationGroupIds, that.locationGroupIds)) return false;
if (!Objects.equals(locationIds, that.locationIds)) return false;
if (!Objects.equals(start_pickup_drop_off_window, that.start_pickup_drop_off_window)) return false;
if (!Objects.equals(end_pickup_drop_off_window, that.end_pickup_drop_off_window)) return false;

Expand All @@ -92,6 +99,8 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(routeId, stops, pickupTypes, dropoffTypes, start_pickup_drop_off_window, end_pickup_drop_off_window);
return Objects.hash(
routeId, stops, locationGroupIds, locationIds, pickupTypes, dropoffTypes, start_pickup_drop_off_window, end_pickup_drop_off_window
);
}
}
24 changes: 15 additions & 9 deletions src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ public enum NewGTFSErrorType {
DUPLICATE_TRIP(Priority.MEDIUM, "More than one trip had an identical schedule and stops."),
FARE_TRANSFER_MISMATCH(Priority.MEDIUM, "A fare that does not permit transfers has a non-zero transfer duration."),
FEED_TRAVEL_TIMES_ROUNDED(Priority.LOW, "All travel times in the feed are rounded to the minute, which may cause unexpected results in routing applications where travel times are zero."),
FLEX_FORBIDDEN_ARRIVAL_TIME(Priority.HIGH, "It is forbidden to define an arrival time when either start pickup drop off window or end pickup drop off window are defined."),
FLEX_FORBIDDEN_DEPARTURE_TIME(Priority.HIGH, "It is forbidden to define a departure time when either start pickup drop off window or end pickup drop off window are defined."),
FLEX_FORBIDDEN_DROP_OFF_TYPE(Priority.HIGH, "It is forbidden to define a drop off type of 0 (Regularly scheduled pickup) when a stop id refers to a stop area or location."),
FLEX_FORBIDDEN_LOCATION_GROUP_ID(Priority.HIGH, "It is forbidden to define a stop area area id with the same value as a stop id or location id."),
FLEX_FORBIDDEN_LOCATION_ID(Priority.HIGH, "It is forbidden to define a location id with the same value as a stop id."),
FLEX_FORBIDDEN_ARRIVAL_TIME(Priority.HIGH, "It is forbidden to define an arrival time when either start pickup drop off window or end pickup drop off windows are defined."),
FLEX_FORBIDDEN_CONTINUOUS_DROP_OFF(Priority.HIGH, "It is forbidden to define a continuous drop off if start/end pick up drop off windows are defined."),
FLEX_FORBIDDEN_CONTINUOUS_PICKUP(Priority.HIGH, "It is forbidden to define a continuous pickup if start/end pick up drop off windows are defined."),
FLEX_FORBIDDEN_DEPARTURE_TIME(Priority.HIGH, "It is forbidden to define a departure time when either start pickup drop off window or end pickup drop off windows are defined."),
FLEX_FORBIDDEN_DROP_OFF_TYPE(Priority.HIGH, "It is forbidden to define a drop off type of 0 (Regularly scheduled pickup) if start/end pick up drop off windows are defined."),
FLEX_FORBIDDEN_DUPLICATE_LOCATION_GROUP_ID(Priority.HIGH, "It is forbidden to define a location group id that matches a stop id or location id."),
FLEX_FORBIDDEN_LOCATION_GROUP_ID(Priority.HIGH, "It is forbidden to define a location group id if a stop id or location id are defined."),
FLEX_FORBIDDEN_DUPLICATE_LOCATION_ID(Priority.HIGH, "It is forbidden to define a location id that matches a stop id or location group id."),
FLEX_FORBIDDEN_LOCATION_ID(Priority.HIGH, "It is forbidden to define a location id if a stop id or location group id are defined."),
FLEX_FORBIDDEN_START_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "It is forbidden to define a start pickup drop off window when either an arrive time or departure time are defined."),
FLEX_FORBIDDEN_END_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "It is forbidden to define a end pickup drop off window when either an arrive time or departure time are defined."),
FLEX_FORBIDDEN_PICKUP_TYPE(Priority.HIGH, "It is forbidden to define a pickup type of 0 (Regularly scheduled pickup) when a stop id refers to a stop area or location."),
FLEX_FORBIDDEN_PICKUP_TYPE(Priority.HIGH, "It is forbidden to define a pickup type of 0 (Regularly scheduled pickup) or 3 (Must coordinate with driver to arrange pickup) are forbidden if start/end pick up drop off window are defined."),
FLEX_FORBIDDEN_PICKUP_TYPE_FOR_LOCATION(Priority.HIGH, "It is forbidden to define a pickup type of 3 (Must coordinate with driver to arrange pickup) when a stop id refers to a location."),
FLEX_FORBIDDEN_PICKUP_TYPE_FOR_STOP_AREA(Priority.HIGH, "It is forbidden to define a pickup type of 3 (Must coordinate with driver to arrange pickup) when a stop id refers to a stop area."),
FLEX_FORBIDDEN_PRIOR_NOTICE_DURATION_MIN(Priority.HIGH, "It is forbidden to define a prior notice duration min unless booking type is 1 (Up to same-day booking with advance notice)."),
Expand All @@ -41,21 +45,23 @@ public enum NewGTFSErrorType {
FLEX_FORBIDDEN_PRIOR_NOTICE_START_DAY_FOR_BOOKING_TYPE(Priority.HIGH, "It is forbidden to define a prior notice start day for booking type 0 (Real time booking)."),
FLEX_FORBIDDEN_PRIOR_NOTICE_START_DAY(Priority.HIGH, "It is forbidden to define a prior notice start day for booking type 1 (Up to same-day booking with advance notice) and if prior notice duration max is defined."),
FLEX_FORBIDDEN_PRIOR_START_TIME(Priority.HIGH, "It is forbidden to define a prior notice start time if prior notice start day is not defined."),
FLEX_REQUIRED_END_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "End pickup drop off window is required if a stop id refers to a stop area or location."),
FLEX_FORBIDDEN_STOP_ID(Priority.HIGH, "It is forbidden to define a stop id if a location group id or location id are defined."),
FLEX_REQUIRED_END_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "End pickup drop off window is required if a location group id, location id or start pickup drop off window is defined."),
FLEX_REQUIRED_PRIOR_NOTICE_DURATION_MIN(Priority.HIGH, "Prior notice duration min is required for booking type 1 (Up to same-day booking with advance notice)."),
FLEX_REQUIRED_PRIOR_NOTICE_LAST_DAY(Priority.HIGH, "Prior notice last day is required if a stop id refers to a stop area or location."),
FLEX_REQUIRED_PRIOR_NOTICE_START_TIME(Priority.HIGH, "Prior notice start time is required if prior notice start day is defined."),
FLEX_REQUIRED_START_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "Start pickup drop off window is required if stop id refers to a stop area or location."),
FLEX_REQUIRED_STOP_ID(Priority.HIGH, "A stop id is required if a location group id or location id are not defined."),
FLEX_REQUIRED_START_PICKUP_DROP_OFF_WINDOW(Priority.HIGH, "Start pickup drop off window is required if a location group id, location id or end pickup drop off window is defined."),
FLEX_MISSING_FARE_RULE(Priority.HIGH, "A location zone id must reference a fare rule. One of contains id, destination id or origin id."),
FLOATING_FORMAT(Priority.MEDIUM, "Incorrect floating point number format."),
FREQUENCY_PERIOD_OVERLAP(Priority.MEDIUM, "A frequency for a trip overlaps with another frequency defined for the same trip."),
GEO_JSON_PARSING(Priority.HIGH, "Unable to parse the locations.geojson file. Make sure the file conforms to the GeoJSON standard and supported geometry types are used."),
ILLEGAL_FIELD_VALUE(Priority.MEDIUM, "Fields may not contain tabs, carriage returns or new lines."),
INTEGER_FORMAT(Priority.MEDIUM, "Incorrect integer format."),
LANGUAGE_FORMAT(Priority.LOW, "Language should be specified with a valid BCP47 tag."),
LOCATION_GROUP_UNUSED(Priority.MEDIUM, "This location group is not referenced by any trips."),
LOCATION_UNUSED(Priority.MEDIUM, "This location is not referenced by any trips."),
STOP_AREA_PARSING(Priority.HIGH, "Unable to parse the stop_areas.txt file. Make sure the file conforms to the GTFS Flex standard."),
STOP_AREA_UNUSED(Priority.MEDIUM, "This stop area is not referenced by any trips."),
MISSING_ARRIVAL_OR_DEPARTURE(Priority.MEDIUM, "First and last stop times are required to have both an arrival and departure time."),
MISSING_COLUMN(Priority.MEDIUM, "A required column was missing from a table."),
MISSING_FIELD(Priority.MEDIUM, "A required field was missing or empty in a particular row."),
Expand Down
Loading

0 comments on commit 57506da

Please sign in to comment.