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
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ private static String getROUTE_ID_CLEANUP_REGEX(@NonNull Context context) {
return routeIdCleanupRegex;
}

@Nullable
private static String tripIdCleanupRegex = null;

/**
* Override if multiple {@link GTFSRealTimeProvider} implementations in same app.
*/
@NonNull
private static String getTRIP_ID_CLEANUP_REGEX(@NonNull Context context) {
if (tripIdCleanupRegex == null) {
tripIdCleanupRegex = context.getResources().getString(R.string.gtfs_rts_trip_id_cleanup_regex);
}
return tripIdCleanupRegex;
}

@Nullable
private static String stopIdCleanupRegex = null;

Expand Down Expand Up @@ -1041,6 +1055,20 @@ private Pattern getRouteIdCleanupPattern(@NonNull Context context) {
return this.routeIdCleanupPattern;
}

@Nullable
private Pattern tripIdCleanupPattern = null;

private boolean tripIdCleanupPatternSet = false;

@Nullable
private Pattern getTripIdCleanupPattern(@NonNull Context context) {
if (this.tripIdCleanupPattern == null && !tripIdCleanupPatternSet) {
this.tripIdCleanupPattern = GTFSCommons.makeIdCleanupPattern(getTRIP_ID_CLEANUP_REGEX(context));
this.tripIdCleanupPatternSet = true;
}
return this.tripIdCleanupPattern;
}

@Nullable
private Pattern stopIdCleanupPattern = null;

Expand Down Expand Up @@ -1074,7 +1102,11 @@ private String parseTargetUUID(@NonNull Context context, String agencyTag, @NonN
} else if (gEntitySelector.hasAgencyId()) {
return getAgencyTargetUUID(agencyTag);
} else if (gEntitySelector.hasTrip()) {
MTLog.w(this, "parseTargetUUID() > unsupported TRIP entity selector: %s (IGNORED)", GtfsRealtimeExt.toStringExt(gEntitySelector.getTrip()));
final String tripIdHash = GtfsRealtimeExt.getTripIdHash(gEntitySelector, getTripIdCleanupPattern(context));
MTLog.w(this, "parseTargetUUID() > unsupported TRIP entity selector: %s (%s) (IGNORED)",
GtfsRealtimeExt.toStringExt(gEntitySelector.getTrip()),
tripIdHash
);
return null;
}
MTLog.w(this, "parseTargetUUID() > unexpected entity selector: %s (IGNORED)", GtfsRealtimeExt.toStringExt(gEntitySelector));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ object GtfsRealtimeExt {
return this.routeId.originalIdToHash(idCleanupRegex)
}

@JvmStatic
fun GtfsRealtime.EntitySelector.getTripIdHash(idCleanupRegex: Pattern?): String {
if (!FeatureFlags.F_USE_GTFS_ID_HASH_INT) {
return this.trip.tripId
}
return this.trip.tripId.originalIdToHash(idCleanupRegex)
}

@JvmStatic
fun GtfsRealtime.EntitySelector.getStopIdHash(idCleanupRegex: Pattern?): String {
if (!FeatureFlags.F_USE_GTFS_ID_HASH_INT) {
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/gtfs_rts_values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<string name="gtfs_rts_area_max_lng" /> <!-- empty: set in module app -->
<string name="gtfs_rts_color" /> <!-- empty: set in module app -->
<string name="gtfs_rts_route_id_cleanup_regex" /> <!-- empty: set in module app -->
<string name="gtfs_rts_trip_id_cleanup_regex" /> <!-- empty: set in module app -->
<string name="gtfs_rts_stop_id_cleanup_regex" /> <!-- empty: set in module app -->
<integer name="gtfs_rts_first_departure_in_sec">-1</integer> <!-- -1: set in module app -->
<integer name="gtfs_rts_last_departure_in_sec">-1</integer> <!-- -1: set in module app -->
Expand Down
Loading