Skip to content

Commit

Permalink
refactor(Updates to include location groups and location group stops):
Browse files Browse the repository at this point in the history
  • Loading branch information
br648 committed May 15, 2024
1 parent 11e6ef8 commit 6a764ff
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 52 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
<dependency>
<groupId>com.github.ibi-group</groupId>
<artifactId>gtfs-lib</artifactId>
<version>2bd924c6e5f5244a279c9d94298c14c0b3d47b35</version>
<version>e623aef54deba8c95d34e2f7c6760bc055612193</version>
<!-- Latest dev-flex build on jitpack.io -->
<!-- Exclusions added in order to silence SLF4J warnings about multiple bindings:
http://www.slf4j.org/codes.html#multiple_bindings
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/conveyal/datatools/manager/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,11 @@ static void registerRoutes() throws IOException {
// NOTE: fare_attributes controller handles updates to nested table fare_rules.
new EditorControllerImpl(EDITOR_API_PREFIX, Table.FARE_ATTRIBUTES, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.FEED_INFO, DataManager.GTFS_DATA_SOURCE);
// NOTE: AREA and STOP_AREAS are additions for GTFS Flex but belong to the Fares v2 specification:
new EditorControllerImpl(EDITOR_API_PREFIX, Table.STOP_AREAS, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.AREA, DataManager.GTFS_DATA_SOURCE);
// NOTE: Booking rules, locations and location shapes are GTFS Flex additions.
new EditorControllerImpl(EDITOR_API_PREFIX, Table.BOOKING_RULES, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.LOCATIONS, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.LOCATION_GROUP, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.LOCATION_GROUP_STOPS, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.LOCATION_SHAPES, DataManager.GTFS_DATA_SOURCE);
new EditorControllerImpl(EDITOR_API_PREFIX, Table.ROUTES, DataManager.GTFS_DATA_SOURCE);
// NOTE: Patterns controller handles updates to nested tables shapes, pattern stops, and frequencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MergeFeedsResult implements Serializable {
* Track various table ids for resolving foreign references.
*/
public Set<String> stopIds = new HashSet<>();
public Set<String> stopAreaIds = new HashSet<>();
public Set<String> locationGroupStopIds = new HashSet<>();

/**
* Track the set of route IDs to end up in the merged feed in order to determine which route_attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ private void setForeignReferenceKeyValues() {
case "stops":
mergeFeedsResult.stopIds.add(getIdWithScope(keyValue));
break;
case "stop_areas":
mergeFeedsResult.stopAreaIds.add(getIdWithScope(keyValue));
case "location_group_stops":
mergeFeedsResult.locationGroupStopIds.add(getIdWithScope(keyValue));
break;
default:
// nothing.
Expand All @@ -272,16 +272,15 @@ private Table getReferenceTable(FieldContext fieldContext, Field field) {
getTableScopedValue(Table.CALENDAR_DATES, fieldContext.getValue())
);
case STOP_TIMES_STOP_ID_KEY:
return ReferenceTableDiscovery.getStopTimeStopIdReferenceTable(
return ReferenceTableDiscovery.getStopTimeReferenceTable(
fieldContext.getValueToWrite(),
mergeFeedsResult,
feedMergeContext.locationIds
);
case STOP_AREA_STOP_ID_KEY:
return ReferenceTableDiscovery.getStopAreaAreaIdReferenceTable(
case LOCATION_GROUP_STOPS_STOP_ID_KEY:
return ReferenceTableDiscovery.getLocationGroupStopReferenceTable(
fieldContext.getValueToWrite(),
mergeFeedsResult,
feedMergeContext.locationIds
mergeFeedsResult
);
default:
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public enum ReferenceTableKey {
Table.SCHEDULE_EXCEPTIONS.name
)
),
STOP_AREA_STOP_ID_KEY(
LOCATION_GROUP_STOPS_STOP_ID_KEY(
String.join(
REF_TABLE_SEPARATOR,
Table.STOP_AREAS.name,
Table.LOCATION_GROUP_STOPS.name,
"stop_id",
Table.STOPS.name,
Table.LOCATIONS.name
Expand All @@ -43,7 +43,7 @@ public enum ReferenceTableKey {
"stop_id",
Table.STOPS.name,
Table.LOCATIONS.name,
Table.STOP_AREAS.name
Table.LOCATION_GROUP_STOPS.name
)
);

Expand Down Expand Up @@ -112,25 +112,23 @@ public static Table getTripServiceIdReferenceTable(
}

/**
* Define the reference table for a stop area's area id. This will either be a stop or location.
* Define the reference table for a location group stop: stop id. This will either be a stop or null.
*/
public static Table getStopAreaAreaIdReferenceTable(
public static Table getLocationGroupStopReferenceTable(
String fieldValue,
MergeFeedsResult mergeFeedsResult,
Set<String> locationIds
MergeFeedsResult mergeFeedsResult
) {
if (mergeFeedsResult.stopIds.contains(fieldValue)) {
return Table.STOPS;
} else if (locationIds.contains(fieldValue)) {
return Table.LOCATIONS;
}
return null;
}

/**
* Define the reference table for a stop time's stop id. This will either be a stop, location or stop area.
* Define the reference table for a stop time's stop id. This will either be a stop, location or location group.
* TODO: In later PR's this will be redundant as a stop time: stop id will only reference a stop.
*/
public static Table getStopTimeStopIdReferenceTable(
public static Table getStopTimeReferenceTable(
String fieldValue,
MergeFeedsResult mergeFeedsResult,
Set<String> locationIds
Expand All @@ -139,8 +137,8 @@ public static Table getStopTimeStopIdReferenceTable(
return Table.STOPS;
} else if (locationIds.contains(fieldValue)) {
return Table.LOCATIONS;
} else if (mergeFeedsResult.stopAreaIds.contains(fieldValue)) {
return Table.STOP_AREAS;
} else if (mergeFeedsResult.locationGroupStopIds.contains(fieldValue)) {
return Table.LOCATION_GROUP_STOPS;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void canMergeRegional() throws SQLException {

// Ensure the feed has the row counts we expect.
assertRowCount(r1.agency, r2.agency, merged.agency, "Agency");
assertRowCount(r1.area, r2.area, merged.area, "Area");
assertRowCount(r1.attributions, r2.attributions, merged.attributions, "Attributions");
assertRowCount(r1.bookingRules, r2.bookingRules, merged.bookingRules, "Booking rules");
assertRowCount(r1.calendar, r2.calendar, merged.calendar, "Calendar");
Expand All @@ -106,11 +105,12 @@ void canMergeRegional() throws SQLException {
assertRowCount(r1.fareRules, r2.fareRules, merged.fareRules, "Fare rules");
assertRowCount(r1.frequencies, r2.frequencies, merged.frequencies, "Frequencies");
assertRowCount(r1.locations, r2.locations, merged.locations, "Locations");
assertRowCount(r1.locationGroup, r2.locationGroup, merged.locationGroup, "Location Groups");
assertRowCount(r1.locationGroupStops, r2.locationGroupStops, merged.locationGroupStops, "Location Group Stops");
assertRowCount(r1.locationShapes, r2.locationShapes, merged.locationShapes, "Location shapes");
assertRowCount(r1.routes, r2.routes, merged.routes, "Routes");
assertRowCount(r1.shapes, r2.shapes, merged.shapes, "Shapes");
assertRowCount(r1.stops, r2.stops, merged.stops, "Stops");
assertRowCount(r1.stopAreas, r2.stopAreas, merged.stopAreas, "Stop areas");
assertRowCount(r1.stopTimes, r2.stopTimes, merged.stopTimes, "Stop times");
assertRowCount(r1.trips, r2.trips, merged.trips, "Trips");
assertRowCount(r1.translations, r2.translations, merged.translations, "Translations");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
area_id,area_name
Area One,"This is area one"
Area One,"This is locationGroup one"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
location_group_id,stop_id
1,123
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
location_group_id,location_group_name
1,"Area referencing a stop"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "area_1469-2",
"properties": {
"stop_name": "Templeboy to Ballisodare",
"stop_desc": "Templeboy to Ballisodare Door-to-door pickup area"
"stop_desc": "Templeboy to Ballisodare Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand All @@ -25,7 +25,7 @@
"id": "area_1469-1",
"properties": {
"stop_name": "Dromore West to Templeboy",
"stop_desc": "Dromore West to Templeboy Door-to-door pickup area"
"stop_desc": "Dromore West to Templeboy Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand Down Expand Up @@ -172,7 +172,7 @@
"id": "area_246",
"properties": {
"stop_name": "Moville to Letterkenny",
"stop_desc": "Moville to Letterkenny Door-to-door pickup area"
"stop_desc": "Moville to Letterkenny Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand All @@ -187,7 +187,7 @@
"id": "area_251",
"properties": {
"stop_name": "Muff to Moville",
"stop_desc": "Muff to Moville Door-to-door pickup area"
"stop_desc": "Muff to Moville Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
location_group_id,stop_id
1,123
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
location_group_id,location_group_name
1,"Area referencing a stop"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "area_1469-2",
"properties": {
"stop_name": "Templeboy to Ballisodare",
"stop_desc": "Templeboy to Ballisodare Door-to-door pickup area"
"stop_desc": "Templeboy to Ballisodare Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand All @@ -25,7 +25,7 @@
"id": "area_1469-1",
"properties": {
"stop_name": "Dromore West to Templeboy",
"stop_desc": "Dromore West to Templeboy Door-to-door pickup area"
"stop_desc": "Dromore West to Templeboy Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand Down Expand Up @@ -172,7 +172,7 @@
"id": "area_246",
"properties": {
"stop_name": "Moville to Letterkenny",
"stop_desc": "Moville to Letterkenny Door-to-door pickup area"
"stop_desc": "Moville to Letterkenny Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand All @@ -187,7 +187,7 @@
"id": "area_251",
"properties": {
"stop_name": "Muff to Moville",
"stop_desc": "Muff to Moville Door-to-door pickup area"
"stop_desc": "Muff to Moville Door-to-door pickup locationGroup"
},
"type": "Feature",
"geometry": {
Expand Down

This file was deleted.

0 comments on commit 6a764ff

Please sign in to comment.