Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/java/org/mtransit/parser/DefaultAgencyTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -1452,8 +1452,9 @@ public int getStopId(@NotNull GStop gStop) {
//noinspection DiscouragedApi
final String stopIdS =
useStopCodeForStopId() ? stopCode
: useStopCodeForStopIdDigitsOnly() && CharUtils.isDigitsOnly(stopCode, true) ? stopCode
: gStopId;
: Configs.getRouteConfig().getUseStopCodeForStopIdIfAvailable() && !stopCode.isBlank() ? stopCode
: useStopCodeForStopIdDigitsOnly() && CharUtils.isDigitsOnly(stopCode, true) ? stopCode
: gStopId;
Comment thread
mmathieum marked this conversation as resolved.
Comment thread
mmathieum marked this conversation as resolved.
if (stopIdS.isBlank() || !CharUtils.isDigitsOnly(stopIdS)) {
Integer stopIdSInt = convertStopIdNotSupported(stopIdS);
if (stopIdSInt != null) return stopIdSInt;
Expand All @@ -1466,7 +1467,15 @@ public int getStopId(@NotNull GStop gStop) {
this::convertStopIdPreviousChars
);
}
return Integer.parseInt(stopIdS);
try {
return Integer.parseInt(stopIdS);
} catch (NumberFormatException nfe) {
Integer stopIdSInt = convertStopIdNotSupported(stopIdS);
if (stopIdSInt != null) return stopIdSInt;
stopIdSInt = Configs.getRouteConfig().convertStopIdFromOriginalNotSupported(gStopId);
if (stopIdSInt != null) return stopIdSInt;
throw nfe;
Comment thread
mmathieum marked this conversation as resolved.
}
} catch (Exception e) {
throw new MTLog.Fatal(e, "Error while extracting stop ID from %s!", gStop.toStringPlus(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ data class RouteConfig(
val stopIdNotUniqueAllowed: Boolean = false, // OPT-IN feature
@SerialName("use_stop_code_for_stop_id")
val useStopCodeForStopId: Boolean = false, // OPT-IN feature
@SerialName("use_stop_code_for_stop_id_if_available")
val useStopCodeForStopIdIfAvailable: Boolean = false, // OPT-IN feature
@SerialName("use_stop_code_for_stop_id_digits_only")
@get:Discouraged("only for backward compat w/ old Java config")
val useStopCodeForStopIdDigitsOnly: Boolean = false, // OPT-IN feature
Expand Down