Skip to content

Commit

Permalink
refactor: Explicit default-value for StopTransferPriority
Browse files Browse the repository at this point in the history
  • Loading branch information
t2gran committed Jul 3, 2024
1 parent 76e9139 commit 3e0c482
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public record GtfsFeedParameters(
implements DataSourceConfig {
public static final boolean DEFAULT_REMOVE_REPEATED_STOPS = true;

public static final StopTransferPriority DEFAULT_STATION_TRANSFER_PREFERENCE =
StopTransferPriority.ALLOWED;

public static final boolean DEFAULT_DISCARD_MIN_TRANSFER_TIMES = false;

public static final boolean DEFAULT_BLOCK_BASED_INTERLINING = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GtfsFeedParametersBuilder {

public GtfsFeedParametersBuilder() {
this.removeRepeatedStops = GtfsFeedParameters.DEFAULT_REMOVE_REPEATED_STOPS;
this.stationTransferPreference = GtfsFeedParameters.DEFAULT_STATION_TRANSFER_PREFERENCE;
this.stationTransferPreference = StopTransferPriority.defaultValue();
this.discardMinTransferTimes = GtfsFeedParameters.DEFAULT_DISCARD_MIN_TRANSFER_TIMES;
this.blockBasedInterlining = GtfsFeedParameters.DEFAULT_BLOCK_BASED_INTERLINING;
this.maxInterlineDistance = GtfsFeedParameters.DEFAULT_MAX_INTERLINE_DISTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int[] createStopBoardAlightTransferCosts(
return null;
}
int defaultCost = RaptorCostConverter.toRaptorCost(
tuningParams.stopBoardAlightDuringTransferCost(StopTransferPriority.ALLOWED)
tuningParams.stopBoardAlightDuringTransferCost(StopTransferPriority.defaultValue())
);
int[] stopBoardAlightTransferCosts = new int[stops.stopIndexSize()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public Point getGeometry() {
@Override
@Nonnull
public StopTransferPriority getPriority() {
return isPartOfStation() ? getParentStation().getPriority() : StopTransferPriority.ALLOWED;
return isPartOfStation()
? getParentStation().getPriority()
: StopTransferPriority.defaultValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public class Station
extends AbstractTransitEntity<Station, StationBuilder>
implements StopLocationsGroup, LogInfo {

public static final StopTransferPriority DEFAULT_PRIORITY = StopTransferPriority.ALLOWED;

private final I18NString name;
private final String code;
private final I18NString description;
Expand All @@ -52,7 +50,8 @@ public class Station
// Required fields
this.name = Objects.requireNonNull(builder.getName());
this.coordinate = Objects.requireNonNull(builder.getCoordinate());
this.priority = Objects.requireNonNullElse(builder.getPriority(), DEFAULT_PRIORITY);
this.priority =
Objects.requireNonNullElse(builder.getPriority(), StopTransferPriority.defaultValue());
this.transfersNotAllowed = builder.isTransfersNotAllowed();

// Optional fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ default ZoneId getTimeZone() {

@Nonnull
default StopTransferPriority getPriority() {
return StopTransferPriority.ALLOWED;
return StopTransferPriority.defaultValue();
}

boolean isPartOfSameStationAs(StopLocation alternativeStop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,35 @@
*/
public enum StopTransferPriority {
/**
* Block transfers from/to this stop. In OTP this is not a definitive block, just a huge penalty
* is added to the cost function.
* Preferred place to transfer, strongly recommended.
* <p>
* NeTEx equivalent is NO_INTERCHANGE.
* NeTEx equivalent is PREFERRED_INTERCHANGE.
*/
DISCOURAGED,

PREFERRED,
/**
* Recommended stop place.
* <p>
* NeTEx equivalent is RECOMMENDED_INTERCHANGE.
*/
RECOMMENDED,
/**
* Allow transfers from/to this stop. This is the default.
* <p>
* NeTEx equivalent is INTERCHANGE_ALLOWED.
*/
ALLOWED,

/**
* Recommended stop place.
* Block transfers from/to this stop. In OTP this is not a definitive block, just a huge penalty
* is added to the cost function.
* <p>
* NeTEx equivalent is RECOMMENDED_INTERCHANGE.
* NeTEx equivalent is NO_INTERCHANGE.
*/
RECOMMENDED,
DISCOURAGED;

/**
* Preferred place to transfer, strongly recommended.
* <p>
* NeTEx equivalent is PREFERRED_INTERCHANGE.
* The {@link #ALLOWED} is used as default value in cases where the value is not set.
*/
PREFERRED,
public static StopTransferPriority defaultValue() {
return ALLOWED;
}
}

0 comments on commit 3e0c482

Please sign in to comment.