Class GtfsServicesHandlerData
- java.lang.Object
-
- org.goplanit.gtfs.converter.GtfsConverterHandlerData
-
- org.goplanit.gtfs.converter.service.handler.GtfsServicesHandlerData
-
public class GtfsServicesHandlerData extends GtfsConverterHandlerData
Track data used during handling/parsing of GTFS routes
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GtfsServicesHandlerData.RouteRemovalType
reason for discarding routes, used during registering themstatic class
GtfsServicesHandlerData.TripRemovalType
reason for discarding trips, used during registering them
-
Constructor Summary
Constructors Constructor Description GtfsServicesHandlerData(GtfsServicesReaderSettings settings, ServiceNetwork serviceNetwork, RoutedServices routedServices, GtfsServicesHandlerProfiler handlerProfiler)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GtfsServicesHandlerData.RouteRemovalType
getGtfsRemovedRouteRemovalType(String gtfsRouteId)
Identify route removal type for a given GTFS route id, if the route is not marked for removal UNKNOWN is returned, otherwise the registered cause of removal is providedGtfsTrip
getGtfsTripByGtfsTripId(String gtfsTripId)
Collect GTFS trip by GTFS trip idRoutedTripSchedule
getPlanitScheduleBasedTripByExternalId(String externalId)
Collect Planit scheduled trip by its external idGtfsServicesHandlerProfiler
getProfiler()
Access to profilerRoutedService
getRoutedServiceByExternalId(String externalId)
Collect routed service by external id indexRoutedServices
getRoutedServices()
Access to the routed services containerMode
getServiceLegMode(ServiceLeg serviceLeg)
find mode attributed to the given service leg if anyServiceNode
getServiceNodeByExternalId(String externalId)
Collect routed service by external id indexstatic Function<ServiceNode,String>
getServiceNodeToGtfsStopIdMapping()
GTFS Services are ingested and lead to PLANit service nodes to be created based on GTFS stop ids.GtfsServicesReaderSettings
getSettings()
Access to GTFS services reader settingsboolean
hasActiveServiceIds()
Verify if any service ids have been activatedvoid
indexByExternalId(ServiceNode planitServiceNode)
Index the service node by its external id (GTFS_STOP_ID)void
indexByExternalId(RoutedService planitRoutedService)
Index the routed service by its external id (GTFS_ROUTE_ID)void
indexByExternalId(RoutedTripSchedule planitScheduleBasedTrip)
Index the PLANit schedule based trip by its external id (GTFS_TRIP_ID)void
indexByGtfsTripId(GtfsTrip gtfsTrip)
Index the GTFS trip by its trip id (GTFS_TRIP_ID)boolean
isDepartureTimeOfServiceIdWithinEligibleTimePeriod(String serviceId, ExtendedLocalTime departureTime)
Verify if a service id is active AND the given departure time for that service id falls within an active time periodboolean
isGtfsRouteRemoved(String gtfsRouteId)
Verify if GTFS route has been discarded based on its mode (route type) not being supported in this runboolean
isGtfsTripRemoved(String gtfsTripId)
Verify if GTFS trip has been discarded based on some reason in this runboolean
isServiceIdActivated(String serviceId)
Verify if a service id has been activated, i.e., it occurs on a day with an active time period (note that the filtering for the time period has to be done separately, so it is possible a service is active on the day, but it falls outside of the chosen time period) in which case this method still returns truevoid
registeredRemovedGtfsTrip(GtfsTrip gtfsTrip, GtfsServicesHandlerData.TripRemovalType type)
Register GTFS trip as discarded for a reason, e.g.void
registeredRemovedRoute(GtfsRoute gtfsRoute, GtfsServicesHandlerData.RouteRemovalType reason)
Register GTFS route as discarded based on its route type (mode), which is a valid reason to ignore it from further processing.void
registerServiceIdCalendarAsActive(GtfsCalendar gtfsCalendar)
Register all active service ids, which will be cross-referenced with parsed trips.void
registerServiceLegMode(ServiceLeg parentLeg, Mode serviceLegMode)
Mark the service leg as compatible with the given mode, and this given mode only.-
Methods inherited from class org.goplanit.gtfs.converter.GtfsConverterHandlerData
expandWithCompatibleModes, getActivatedPlanitModesByGtfsMode, getCompatiblePlanitModesIfActivated, getCompatiblePlanitModesIfActivated, getPrimaryPlanitModeIfActivated, getServiceNetwork
-
-
-
-
Constructor Detail
-
GtfsServicesHandlerData
public GtfsServicesHandlerData(GtfsServicesReaderSettings settings, ServiceNetwork serviceNetwork, RoutedServices routedServices, GtfsServicesHandlerProfiler handlerProfiler)
Constructor- Parameters:
settings
- to useserviceNetwork
- to useroutedServices
- to usehandlerProfiler
- to use
-
-
Method Detail
-
indexByExternalId
public void indexByExternalId(RoutedService planitRoutedService)
Index the routed service by its external id (GTFS_ROUTE_ID)- Parameters:
planitRoutedService
- to register
-
getRoutedServiceByExternalId
public RoutedService getRoutedServiceByExternalId(String externalId)
Collect routed service by external id index- Parameters:
externalId
- to collect by- Returns:
- found routed service
-
registeredRemovedRoute
public void registeredRemovedRoute(GtfsRoute gtfsRoute, GtfsServicesHandlerData.RouteRemovalType reason)
Register GTFS route as discarded based on its route type (mode), which is a valid reason to ignore it from further processing.- Parameters:
gtfsRoute
- to mark as discardedreason
- reason for removal
-
isGtfsRouteRemoved
public boolean isGtfsRouteRemoved(String gtfsRouteId)
Verify if GTFS route has been discarded based on its mode (route type) not being supported in this run- Parameters:
gtfsRouteId
- to verify- Returns:
- true when discarded, false otherwise
-
getGtfsRemovedRouteRemovalType
public GtfsServicesHandlerData.RouteRemovalType getGtfsRemovedRouteRemovalType(String gtfsRouteId)
Identify route removal type for a given GTFS route id, if the route is not marked for removal UNKNOWN is returned, otherwise the registered cause of removal is provided- Parameters:
gtfsRouteId
- to collect reason for removal for (if it is removed)- Returns:
- reason for removal
-
registeredRemovedGtfsTrip
public void registeredRemovedGtfsTrip(GtfsTrip gtfsTrip, GtfsServicesHandlerData.TripRemovalType type)
Register GTFS trip as discarded for a reason, e.g. because it route is discarded, seeregisteredRemovedRoute(GtfsRoute, RouteRemovalType)
, or because its service is not registered for inclusion, which are valid reasonsto ignore it from further processing without warning- Parameters:
gtfsTrip
- to mark as discardedtype
- reason for discarding
-
isGtfsTripRemoved
public boolean isGtfsTripRemoved(String gtfsTripId)
Verify if GTFS trip has been discarded based on some reason in this run- Parameters:
gtfsTripId
- to verify- Returns:
- true when discarded, false otherwise
-
registerServiceLegMode
public void registerServiceLegMode(ServiceLeg parentLeg, Mode serviceLegMode)
Mark the service leg as compatible with the given mode, and this given mode only.- Parameters:
parentLeg
- to attribute mode toserviceLegMode
- to use
-
getServiceLegMode
public Mode getServiceLegMode(ServiceLeg serviceLeg)
find mode attributed to the given service leg if any- Parameters:
serviceLeg
- to check- Returns:
- mode that is attached to it, or null if not mapped (yet)
-
registerServiceIdCalendarAsActive
public void registerServiceIdCalendarAsActive(GtfsCalendar gtfsCalendar)
Register all active service ids, which will be cross-referenced with parsed trips. Only trips with an active service id should be parsed. Active relates to the fact that the service occurs on a day for which an eligible time period filter has registered (or all times on that day are deemed eligible)- Parameters:
gtfsCalendar
- to register
-
hasActiveServiceIds
public boolean hasActiveServiceIds()
Verify if any service ids have been activated- Returns:
- true when present, false otherwise
-
isServiceIdActivated
public boolean isServiceIdActivated(String serviceId)
Verify if a service id has been activated, i.e., it occurs on a day with an active time period (note that the filtering for the time period has to be done separately, so it is possible a service is active on the day, but it falls outside of the chosen time period) in which case this method still returns true- Parameters:
serviceId
- to check- Returns:
- true when deemed active on a date serviced by this service id, false otherwise
-
isDepartureTimeOfServiceIdWithinEligibleTimePeriod
public boolean isDepartureTimeOfServiceIdWithinEligibleTimePeriod(String serviceId, ExtendedLocalTime departureTime)
Verify if a service id is active AND the given departure time for that service id falls within an active time period- Parameters:
serviceId
- to checkdepartureTime
- to check- Returns:
- true when deemed active on a date serviced by this service id, false otherwise
-
indexByExternalId
public void indexByExternalId(ServiceNode planitServiceNode)
Index the service node by its external id (GTFS_STOP_ID)- Parameters:
planitServiceNode
- to register
-
getServiceNodeByExternalId
public ServiceNode getServiceNodeByExternalId(String externalId)
Collect routed service by external id index- Parameters:
externalId
- to collect by- Returns:
- found routed service
-
indexByGtfsTripId
public void indexByGtfsTripId(GtfsTrip gtfsTrip)
Index the GTFS trip by its trip id (GTFS_TRIP_ID)- Parameters:
gtfsTrip
- to register
-
getGtfsTripByGtfsTripId
public GtfsTrip getGtfsTripByGtfsTripId(String gtfsTripId)
Collect GTFS trip by GTFS trip id- Parameters:
gtfsTripId
- to collect by- Returns:
- found GTFS trip entity
-
indexByExternalId
public void indexByExternalId(RoutedTripSchedule planitScheduleBasedTrip)
Index the PLANit schedule based trip by its external id (GTFS_TRIP_ID)- Parameters:
planitScheduleBasedTrip
- to register
-
getPlanitScheduleBasedTripByExternalId
public RoutedTripSchedule getPlanitScheduleBasedTripByExternalId(String externalId)
Collect Planit scheduled trip by its external id- Parameters:
externalId
- to collect PLANit trip for- Returns:
- found schedule based PLANit trip (null if not present)
-
getServiceNodeToGtfsStopIdMapping
public static Function<ServiceNode,String> getServiceNodeToGtfsStopIdMapping()
GTFS Services are ingested and lead to PLANit service nodes to be created based on GTFS stop ids. When at some later point in time these PLANit service nodes are to be linked to PLANit transfer zones (which in turn have an association with a GTFS stop) the mapping between PLANit service node and its underlying GTFS stop needs to remain available. This function provides this mapping.For now this mapping is purely based on the external id, but if this changes using this explicit functional approach allows us to change this without having to change the process flow itself
- Returns:
- mapping from PLANit service node to underlying source GTFS stop id
-
getRoutedServices
public RoutedServices getRoutedServices()
Access to the routed services container- Returns:
- the routed services being populated
-
getProfiler
public GtfsServicesHandlerProfiler getProfiler()
Access to profiler- Returns:
- profiler
-
getSettings
public GtfsServicesReaderSettings getSettings()
Access to GTFS services reader settings- Overrides:
getSettings
in classGtfsConverterHandlerData
- Returns:
- user configuration settings
-
-