Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Sep 2, 2024
1 parent 1f8cea0 commit 1551ea4
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package org.opentripplanner.netex.validation;

import java.util.function.Predicate;
import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.rutebanken.netex.model.JourneyPattern_VersionStructure;
import org.rutebanken.netex.model.PointInLinkSequence_VersionedChildStructure;
import org.rutebanken.netex.model.ServiceJourney;
import org.rutebanken.netex.model.StopPointInJourneyPattern;
import org.rutebanken.netex.model.StopUseEnumeration;

/**
* Validates that the number of passing times in the journey and the number of stop points in the
* pattern are equal.
* It also takes into account that some points in the pattern can be set to stopUse=passthrough
* which means that those must not be referenced in the journey.
*/
class JourneyPatternSJMismatch extends AbstractHMapValidationRule<String, ServiceJourney> {

@Override
Expand All @@ -19,19 +26,23 @@ public Status validate(ServiceJourney sj) {
.getPointsInSequence()
.getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern()
.stream()
.filter(JourneyPatternSJMismatch::stopsAtQuay)
.filter(Predicate.not(JourneyPatternSJMismatch::isPassThrough))
.count();

int nTimetablePassingTimes = sj.getPassingTimes().getTimetabledPassingTime().size();

return nStopPointsInJourneyPattern != nTimetablePassingTimes ? Status.DISCARD : Status.OK;
}

private static boolean stopsAtQuay(PointInLinkSequence_VersionedChildStructure point) {
return switch (point) {
case StopPointInJourneyPattern spijp -> spijp.getStopUse() != StopUseEnumeration.PASSTHROUGH;
default -> true;
};
/**
* Does the stop point in the sequence represent a stop where the vehicle passes through without
* stopping?
*/
private static boolean isPassThrough(PointInLinkSequence_VersionedChildStructure point) {
return (
point instanceof StopPointInJourneyPattern spijp &&
spijp.getStopUse() == StopUseEnumeration.PASSTHROUGH
);
}

@Override
Expand Down

0 comments on commit 1551ea4

Please sign in to comment.