Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/data/gtfs/GtfsAlertsDBConverter.kt
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | ): MappedAlert { | ||||
| Triple(null, null, null) | Triple(null, null, null) | ||||
| } | } | ||||
| GtfsAlertInformedEntity( | GtfsAlertInformedEntity( | ||||
| alertId = alertId, | alertId = alertId, | ||||
| //agencyId = if (e.hasAgencyId()) e.agencyId else null, | //agencyId = if (e.hasAgencyId()) e.agencyId else null, | ||||
| routeId = if (e.hasRouteId()) "gtt:${e.routeId}" else null, | routeId = if (e.hasRouteId()) "gtt:${e.routeId}" else null, | ||||
| routeType = if (e.hasRouteType()) e.routeType else null, | routeType = if (e.hasRouteType()) e.routeType else null, | ||||
| stopId = if (e.hasStopId()) e.stopId else null, | stopId = if (e.hasStopId()) "gtt:${e.stopId}" else null, | ||||
| tripId = tripId, | tripId = tripId, | ||||
| tripRouteId = tripRouteId, | tripRouteId = tripRouteId, | ||||
| directionId = directionId | directionId = directionId | ||||
| ) | ) | ||||
| } | } | ||||
| return MappedAlert(alert, translations, activePeriods, informedEntities) | return MappedAlert(alert, translations, activePeriods, informedEntities) | ||||
| } | } | ||||
| /** | /** | ||||
| * Comodità: prende un intero FeedMessage e mappa solo i FeedEntity che sono alert, | * Comodità: prende un intero FeedMessage e mappa solo i FeedEntity che sono alert, | ||||
| * ignorando TripUpdate e VehiclePosition. | * ignorando TripUpdate e VehiclePosition. | ||||
| */ | */ | ||||
| fun fromFeedMessage( | fun fromFeedMessage( | ||||
| feed: GtfsRealtime.FeedMessage, | feed: GtfsRealtime.FeedMessage, | ||||
| fetchedAtMillis: Long = System.currentTimeMillis() | fetchedAtMillis: Long = System.currentTimeMillis() | ||||
| ): List<MappedAlert> { | ): List<MappedAlert> { | ||||
| return feed.entityList.mapNotNull { fe -> | return feed.entityList.mapNotNull { fe -> | ||||
| // Salta gli entity marcati come deleted | // Salta gli entity marcati come deleted | ||||
| if (fe.isDeleted || !fe.hasAlert()) null | if (fe.isDeleted || !fe.hasAlert()) null | ||||
| else fromFeedEntity(fe, fetchedAtMillis) | else fromFeedEntity(fe, fetchedAtMillis) | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| No newline at end of file | No newline at end of file | ||||
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register