Skip to content

Commit

Permalink
refactor(Fixed merge conflicts):
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Beer authored and Robin Beer committed Aug 21, 2023
2 parents 9ff75cc + 57e3219 commit 2baafb5
Show file tree
Hide file tree
Showing 21 changed files with 361 additions and 82 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ jobs:
with:
java-version: 1.8
# Install node 18+ for running maven-semantic-release.
- name: Use Node.js 18.x
- name: Use Node.js 18.X
uses: actions/setup-node@v1
with:
node-version: 18.x
node-version: 18
- name: Install maven-semantic-release
# FIXME: Enable cache for node packages (add package.json?)
run: |
node --version
yarn global add @conveyal/maven-semantic-release semantic-release
# Add yarn path to GITHUB_PATH so that global package is executable.
echo "$(yarn global bin)" >> $GITHUB_PATH
Expand All @@ -62,8 +63,14 @@ jobs:
# See https://github.com/conveyal/gtfs-lib/issues/193.
#
# The git commands get the commit hash of the HEAD commit and the commit just before HEAD.
# Install node 14+ for running maven-semantic-release.
- name: Use Node.js 18.X
uses: actions/setup-node@v1
with:
node-version: 18
- name: Run maven-semantic-release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release --use-conveyal-workflow --dev-branch=dev --skip-maven-deploy
node --version
semantic-release --prepare @conveyal/maven-semantic-release --publish @semantic-release/github,@conveyal/maven-semantic-release --verify-conditions @semantic-release/github,@conveyal/maven-semantic-release --verify-release @conveyal/maven-semantic-release --use-conveyal-workflow --dev-branch=dev --skip-maven-deploy
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# gtfs-lib [![Build Status](https://travis-ci.org/conveyal/gtfs-lib.svg?branch=master)](https://travis-ci.org/conveyal/gtfs-lib)
[![Join the chat at https://matrix.to/#/#transit-data-tools:gitter.im](https://badges.gitter.im/repo.png)](https://matrix.to/#/#gtfs-lib:gitter.im)


A library for loading and saving GTFS feeds of arbitrary size with disk-backed storage.

Expand All @@ -14,6 +16,10 @@ The main design goals are:

A gtfs-lib GTFSFeed object should faithfully represent the contents of a single GTFS feed file. At least during the initial load, no heuristics are applied to clean up the data. Basic syntax is verified, and any problems encountered are logged in detail. At this stage, fields or entites may be missing, and the data may be nonsensical. Then in an optional post-load validation phase, semantic checks are performed and problems are optionally repaired.

## Getting in touch

We have a [Gitter space](https://matrix.to/#/#transit-data-tools:gitter.im) for the full TRANSIT-Data-Tools project where you can post questions and comments. This includes a room dedicated to GTFS-lib discussions.

## Usage

gtfs-lib can be used as a Java library or run via the command line. If using this library with PostgreSQL for persistence, you must use at least version 9.6 of PostgreSQL.
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<version>32.0.0-jre</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
Expand Down Expand Up @@ -296,7 +296,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.18</version>
<version>1.12.261</version>
</dependency>
<!-- Very efficient collections of primitive data types for Java. -->
<dependency>
Expand All @@ -314,7 +314,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.25</version>
<version>42.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -337,7 +337,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
<version>1.10.0</version>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions src/main/java/com/conveyal/gtfs/TripPatternKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class TripPatternKey {
public TIntList arrivalTimes = new TIntArrayList();
public TIntList departureTimes = new TIntArrayList();
public TIntList timepoints = new TIntArrayList();
public List<String> stopHeadsigns = new ArrayList<>();
public TIntList continuous_pickup = new TIntArrayList();
public TIntList continuous_drop_off = new TIntArrayList();
public TDoubleList shapeDistances = new TDoubleArrayList();
Expand All @@ -42,6 +43,7 @@ public void addStopTime (StopTime st) {
arrivalTimes.add(st.arrival_time);
departureTimes.add(st.departure_time);
timepoints.add(st.timepoint);
stopHeadsigns.add(st.stop_headsign);
shapeDistances.add(st.shape_dist_traveled);
continuous_pickup.add(st.continuous_pickup);
continuous_drop_off.add(st.continuous_drop_off);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public enum NewGTFSErrorType {
// MTC-specific errors.
FIELD_VALUE_TOO_LONG(Priority.MEDIUM, "Field value has too many characters."),

// Shared Stops-specifc errors.
MULTIPLE_SHARED_STOPS_GROUPS(Priority.HIGH, "A GTFS stop belongs to more than one shared-stop group."),
SHARED_STOP_GROUP_MUTLIPLE_PRIMARY_STOPS(Priority.HIGH, "A Shared-stop group has multiple primary stops."),
SHARED_STOP_GROUP_ENTITY_DOES_NOT_EXIST(Priority.MEDIUM, "The stop referenced by a shared-stop does not exist."),

// Unknown errors.
OTHER(Priority.LOW, "Other errors.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ public class GraphQLGtfsSchema {
.field(MapFetcher.field("shape_dist_traveled", GraphQLFloat))
.field(MapFetcher.field("drop_off_type", GraphQLInt))
.field(MapFetcher.field("pickup_type", GraphQLInt))
.field(MapFetcher.field("stop_headsign"))
.field(MapFetcher.field("continuous_drop_off", GraphQLInt))
.field(MapFetcher.field("continuous_pickup", GraphQLInt))
.field(MapFetcher.field("stop_sequence", GraphQLInt))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public interface EntityPopulator<T> {
patternStop.default_travel_time = getIntIfPresent(result, "default_travel_time", columnForName);
patternStop.pattern_id = getStringIfPresent(result, "pattern_id", columnForName);
patternStop.drop_off_type = getIntIfPresent(result, "drop_off_type", columnForName);
patternStop.stop_headsign = getStringIfPresent(result, "stop_headsign", columnForName);
patternStop.pickup_type = getIntIfPresent(result, "pickup_type", columnForName);
patternStop.stop_sequence = getIntIfPresent(result, "stop_sequence", columnForName);
patternStop.timepoint = getIntIfPresent(result, "timepoint", columnForName);
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/com/conveyal/gtfs/loader/JdbcGtfsExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

Expand Down Expand Up @@ -67,6 +68,17 @@ public JdbcGtfsExporter(String feedId, String outFile, DataSource dataSource, bo
this.fromEditor = fromEditor;
}

/**
* Utility method to check if an exception uses a specific service.
*/
public Boolean exceptionInvolvesService(ScheduleException ex, String serviceId) {
return (
ex.addedService.contains(serviceId) ||
ex.removedService.contains(serviceId) ||
ex.customSchedule.contains(serviceId)
);
}

/**
* Export primary entity tables as well as Pattern and PatternStops tables.
*
Expand Down Expand Up @@ -135,7 +147,10 @@ public FeedLoadResult exportTables() {
for (Calendar cal : calendars) {
Service service = new Service(cal.service_id);
service.calendar = cal;
for (ScheduleException ex : exceptions) {
for (ScheduleException ex : exceptions.stream()
.filter(ex -> exceptionInvolvesService(ex, cal.service_id))
.collect(Collectors.toList())
) {
if (ex.exemplar.equals(ScheduleException.ExemplarServiceDescriptor.SWAP) &&
(!ex.addedService.contains(cal.service_id) && !ex.removedService.contains(cal.service_id))) {
// Skip swap exception if cal is not referenced by added or removed service.
Expand All @@ -153,7 +168,7 @@ public FeedLoadResult exportTables() {
calendarDate.date = date;
calendarDate.service_id = cal.service_id;
calendarDate.exception_type = ex.serviceRunsOn(cal) ? 1 : 2;
LOG.info("Adding exception {} (type={}) for calendar {} on date {}", ex.name, calendarDate.exception_type, cal.service_id, date.toString());
LOG.info("Adding exception {} (type={}) for calendar {} on date {}", ex.name, calendarDate.exception_type, cal.service_id, date);

if (service.calendar_dates.containsKey(date))
throw new IllegalArgumentException("Duplicate schedule exceptions on " + date.toString());
Expand Down
Loading

0 comments on commit 2baafb5

Please sign in to comment.