From 8e30fd04aab7de6f2ae58dc40b14ab7102787806 Mon Sep 17 00:00:00 2001 From: caylasavitzky Date: Tue, 2 Feb 2021 09:25:34 -0500 Subject: [PATCH 1/3] Resolving small issues that were causing kcm transformation to fail --- .../gtfs_transformer/GtfsTransformerMain.java | 2 +- .../factory/TransformFactory.java | 4 ++-- .../NoTripsWithBlockIdAndFrequenciesStrategy.java | 15 +++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/onebusaway-gtfs-transformer-cli/src/main/java/org/onebusaway/gtfs_transformer/GtfsTransformerMain.java b/onebusaway-gtfs-transformer-cli/src/main/java/org/onebusaway/gtfs_transformer/GtfsTransformerMain.java index 562d5a613..50ef6fff0 100644 --- a/onebusaway-gtfs-transformer-cli/src/main/java/org/onebusaway/gtfs_transformer/GtfsTransformerMain.java +++ b/onebusaway-gtfs-transformer-cli/src/main/java/org/onebusaway/gtfs_transformer/GtfsTransformerMain.java @@ -137,7 +137,7 @@ public void run(String[] args) throws IOException { System.err.println(ex.getMessage()); System.exit(-1); } catch (Exception ex) { - ex.printStackTrace(); + ex.printStackTrace(); System.exit(-1); } } diff --git a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java index ec053d7dd..e66d2cf50 100644 --- a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java +++ b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java @@ -325,12 +325,12 @@ else if (opType.equals("KCMSuite")){ configureStopNameUpdates(_transformer, baseUrl - + "/KingCountyMetroStopNameModifications.mediawiki"); + + "/KingCountyMetroStopNameModifications.md"); try { GtfsTransformerLibrary.configureTransformation(_transformer, baseUrl - + "/KingCountyMetroModifications.mediawiki"); + + "/KingCountyMetroModifications.md"); } catch (TransformSpecificationException e) { throw new RuntimeException(e); } diff --git a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/updates/NoTripsWithBlockIdAndFrequenciesStrategy.java b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/updates/NoTripsWithBlockIdAndFrequenciesStrategy.java index ac87bab14..328f7a18c 100644 --- a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/updates/NoTripsWithBlockIdAndFrequenciesStrategy.java +++ b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/updates/NoTripsWithBlockIdAndFrequenciesStrategy.java @@ -26,13 +26,20 @@ import org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy; import org.onebusaway.gtfs_transformer.services.TransformContext; import org.onebusaway.gtfs_transformer.updates.UpdateLibrary; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class NoTripsWithBlockIdAndFrequenciesStrategy implements - EntityTransformStrategy { +public class NoTripsWithBlockIdAndFrequenciesStrategy implements GtfsTransformStrategy { + + private static Logger _log = LoggerFactory.getLogger(org.onebusaway.gtfs_transformer.updates.DeduplicateServiceIdsStrategy.class); + + @Override + public String getName() { + return this.getClass().getSimpleName(); + } @Override - public void run(TransformContext context, GtfsMutableRelationalDao dao, - Object entity) { + public void run(TransformContext context, GtfsMutableRelationalDao dao) { for (Trip trip : dao.getAllTrips()) { List frequencies = dao.getFrequenciesForTrip(trip); From 4d078b11c49749dfd1239957cf77c07616373552 Mon Sep 17 00:00:00 2001 From: caylasavitzky Date: Tue, 2 Feb 2021 09:37:25 -0500 Subject: [PATCH 2/3] separating out transformations p1 --- .../factory/TransformFactory.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java index e66d2cf50..7c8ca93ee 100644 --- a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java +++ b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java @@ -301,28 +301,30 @@ else if (opType.equals("add_omny_bus_data")) { else if (opType.equals("verify_route_ids")) { handleTransformOperation(line, json, new VerifyRouteIds()); } + else if (opType.equals("remove_merged_trips")){ + handleTransformOperation(line, json, new RemoveMergedTripsStrategy()); + } + else if (opType.equals("deduplicate_stops")){ + handleTransformOperation(line, json, new DeduplicateStopsStrategy()); + } + else if (opType.equals("deduplicate_routes")){ + handleTransformOperation(line, json, new DeduplicateRoutesStrategy()); + } + else if (opType.equals("remove_repeated_stop_times")){ + handleTransformOperation(line, json, new RemoveRepeatedStopTimesStrategy()); + } + else if (opType.equals("remove_empty_block_trips")){ + handleTransformOperation(line, json, new RemoveEmptyBlockTripsStrategy()); + } + else if (opType.equals("ensure_stop_times_increase")){ + handleTransformOperation(line, json, new EnsureStopTimesIncreaseUpdateStrategy()); + } + else if (opType.equals("no_trips_with_block_id_and_frequencies")){ + handleTransformOperation(line, json, new NoTripsWithBlockIdAndFrequenciesStrategy()); + } else if (opType.equals("KCMSuite")){ String baseUrl = "https://raw.github.com/wiki/camsys/onebusaway-application-modules"; - handleTransformOperation(line, json, new RemoveMergedTripsStrategy()); - - - handleTransformOperation(line, json, new DeduplicateStopsStrategy()); -// EntitiesTransformStrategy strategy = getStrategy(EntitiesTransformStrategy.class); -// TypedEntityMatch match = getMatch(line, json); -// DeduplicateStopsStrategy mod = new DeduplicateStopsStrategy(); -// strategy.addModification(match, mod); - - //GenerateEntitiesTransformStrategy("DeduplicateStopsStrategy"); - //handleTransformOperation(line, json, new DeduplicateStopsStrategy()); - - - handleTransformOperation(line, json, new DeduplicateRoutesStrategy()); - handleTransformOperation(line, json, new RemoveRepeatedStopTimesStrategy()); - handleTransformOperation(line, json, new RemoveEmptyBlockTripsStrategy()); - handleTransformOperation(line, json, new EnsureStopTimesIncreaseUpdateStrategy()); - handleTransformOperation(line, json, new NoTripsWithBlockIdAndFrequenciesStrategy()); - configureStopNameUpdates(_transformer, baseUrl + "/KingCountyMetroStopNameModifications.md"); From 48f481d59f7dfe4afe373a699407e5664486f54b Mon Sep 17 00:00:00 2001 From: caylasavitzky Date: Mon, 5 Apr 2021 13:25:46 -0400 Subject: [PATCH 3/3] removing kcm suite transformation, and adding functionality of configure_stop_name_updates --- .../factory/TransformFactory.java | 45 +++---------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java index 7c8ca93ee..3b5d3799d 100644 --- a/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java +++ b/onebusaway-gtfs-transformer/src/main/java/org/onebusaway/gtfs_transformer/factory/TransformFactory.java @@ -81,6 +81,8 @@ public class TransformFactory { private static final String ARG_COLLECTION = "collection"; + private static final String ARG_PATH = "path"; + private static final Set _excludeForObjectSpec = new HashSet( Arrays.asList(ARG_FILE, ARG_CLASS)); @@ -301,43 +303,8 @@ else if (opType.equals("add_omny_bus_data")) { else if (opType.equals("verify_route_ids")) { handleTransformOperation(line, json, new VerifyRouteIds()); } - else if (opType.equals("remove_merged_trips")){ - handleTransformOperation(line, json, new RemoveMergedTripsStrategy()); - } - else if (opType.equals("deduplicate_stops")){ - handleTransformOperation(line, json, new DeduplicateStopsStrategy()); - } - else if (opType.equals("deduplicate_routes")){ - handleTransformOperation(line, json, new DeduplicateRoutesStrategy()); - } - else if (opType.equals("remove_repeated_stop_times")){ - handleTransformOperation(line, json, new RemoveRepeatedStopTimesStrategy()); - } - else if (opType.equals("remove_empty_block_trips")){ - handleTransformOperation(line, json, new RemoveEmptyBlockTripsStrategy()); - } - else if (opType.equals("ensure_stop_times_increase")){ - handleTransformOperation(line, json, new EnsureStopTimesIncreaseUpdateStrategy()); - } - else if (opType.equals("no_trips_with_block_id_and_frequencies")){ - handleTransformOperation(line, json, new NoTripsWithBlockIdAndFrequenciesStrategy()); - } - else if (opType.equals("KCMSuite")){ - String baseUrl = "https://raw.github.com/wiki/camsys/onebusaway-application-modules"; - - - configureStopNameUpdates(_transformer, baseUrl - + "/KingCountyMetroStopNameModifications.md"); - - - try { - GtfsTransformerLibrary.configureTransformation(_transformer, baseUrl - + "/KingCountyMetroModifications.md"); - } catch (TransformSpecificationException e) { - throw new RuntimeException(e); - } - - _transformer.addTransform(new LocalVsExpressUpdateStrategy()); + else if (opType.equals("configure_stop_name_updates")){ + configureStopNameUpdates(_transformer, json.getString(ARG_PATH)); } else if (opType.equals("transform")) { handleTransformOperation(line, json); @@ -884,8 +851,10 @@ public Object create() { private void configureStopNameUpdates(GtfsTransformer transformer, String path) { - if (path == null) + if (path == null) { + _log.error("missing path to configure stop names"); return; + } try { StopNameUpdateFactoryStrategy factory = new StopNameUpdateFactoryStrategy();