From 85beb70856203dd8edc7f4b06ef5b89a840e5908 Mon Sep 17 00:00:00 2001 From: cka-y <60586858+cka-y@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:38:50 -0400 Subject: [PATCH] fix: comments on #1587 (#1592) * fix: comments on #1587 * fix: removed unused variable * fix: formatting * fix: rollback sources for acceptance test * fix: removing source causing timeout * fix: removing source causing timeout --- .../TripAndShapeDistanceValidator.java | 61 ++++++++----------- .../harvest_latest_versions.py | 6 +- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAndShapeDistanceValidator.java b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAndShapeDistanceValidator.java index 13196dd68b..5725ef6e43 100644 --- a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAndShapeDistanceValidator.java +++ b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAndShapeDistanceValidator.java @@ -17,8 +17,6 @@ import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; -import java.util.List; -import java.util.stream.Collectors; import javax.inject.Inject; import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.FileRefs; @@ -53,38 +51,33 @@ public class TripAndShapeDistanceValidator extends FileValidator { @Override public void validate(NoticeContainer noticeContainer) { - List uniqueShapeIds = - shapeTable.getEntities().stream() - .map(GtfsShape::shapeId) - .distinct() - .collect(Collectors.toList()); - - uniqueShapeIds.forEach( - shapeId -> { - double maxShapeDist = - shapeTable.getEntities().stream() - .filter(s -> s.shapeId().equals(shapeId)) - .mapToDouble(GtfsShape::shapeDistTraveled) - .max() - .orElse(Double.NEGATIVE_INFINITY); - - tripTable - .byShapeId(shapeId) - .forEach( - trip -> { - double maxStopTimeDist = - stopTimeTable.byTripId(trip.tripId()).stream() - .mapToDouble(GtfsStopTime::shapeDistTraveled) - .max() - .orElse(Double.NEGATIVE_INFINITY); - - if (maxStopTimeDist > maxShapeDist) { - noticeContainer.addValidationNotice( - new TripDistanceExceedsShapeDistanceNotice( - trip.tripId(), shapeId, maxStopTimeDist, maxShapeDist)); - } - }); - }); + shapeTable + .byShapeIdMap() + .forEach( + (shapeId, shape) -> { + double maxShapeDist = + shapeTable.byShapeId(shapeId).stream() + .mapToDouble(GtfsShape::shapeDistTraveled) + .max() + .orElse(Double.NEGATIVE_INFINITY); + + tripTable + .byShapeId(shapeId) + .forEach( + trip -> { + double maxStopTimeDist = + stopTimeTable.byTripId(trip.tripId()).stream() + .mapToDouble(GtfsStopTime::shapeDistTraveled) + .max() + .orElse(Double.NEGATIVE_INFINITY); + + if (maxStopTimeDist > maxShapeDist) { + noticeContainer.addValidationNotice( + new TripDistanceExceedsShapeDistanceNotice( + trip.tripId(), shapeId, maxStopTimeDist, maxShapeDist)); + } + }); + }); } /** The distance traveled by a trip should be less or equal to the max length of its shape. */ diff --git a/scripts/mobility-database-harvester/harvest_latest_versions.py b/scripts/mobility-database-harvester/harvest_latest_versions.py index 81f93f031a..0ddef96fba 100644 --- a/scripts/mobility-database-harvester/harvest_latest_versions.py +++ b/scripts/mobility-database-harvester/harvest_latest_versions.py @@ -34,11 +34,7 @@ SOURCES_TO_EXCLUDE = [ "de-unknown-rursee-schifffahrt-kg-gtfs-784", "de-unknown-ulmer-eisenbahnfreunde-gtfs-1081", - "no-unknown-agder-kollektivtrafikk-as-gtfs-1078", - "hu-unknown-volanbusz-gtfs-1836", - "de-baden-wurttemberg-verkehrsverbund-rhein-neckar-gtfs-1173", - "de-baden-wurttemberg-db-zugbus-regionalverkehr-alb-bodensee-gtfs-773", - "au-new-south-wales-train-replacement-bus-operators-gtfs-1322" + "no-unknown-agder-kollektivtrafikk-as-gtfs-1078" ] # Google Cloud constants