Class GtfsServicesHandlerData


  • public class GtfsServicesHandlerData
    extends GtfsConverterHandlerData
    Track data used during handling/parsing of GTFS routes
    • 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 discarded
        reason - 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
      • 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 to
        serviceLegMode - 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 check
        departureTime - 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