Package org.goplanit.gtfs.converter
Class GtfsConverterReaderSettingsWithModeMapping
- java.lang.Object
-
- org.goplanit.gtfs.converter.GtfsConverterReaderSettingsImpl
-
- org.goplanit.gtfs.converter.GtfsConverterReaderSettingsWithModeMapping
-
- All Implemented Interfaces:
ConverterReaderSettings
,GtfsConverterReaderSettings
- Direct Known Subclasses:
GtfsServicesReaderSettings
,GtfsZoningReaderSettings
public class GtfsConverterReaderSettingsWithModeMapping extends GtfsConverterReaderSettingsImpl
Capture the mode mapping aspect of GTFS converter readers for raw (static) GTFS feeds. To be used as base class not as actual settings class to be exposed.- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<RouteType>
activatedGtfsModes
Activated GTFS modes.protected Map<RouteType,List<PredefinedModeType>>
defaultGtfsMode2PrefinedModeTypeMap
Default mapping (specific to this (services) network) from each supported GTFS mode to PLANit predefined mode.protected RouteTypeChoice
routeTypeChoice
Indicates what route types are applied, e.g.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GtfsConverterReaderSettingsWithModeMapping(String inputSource, String countryName, RouteTypeChoice routeTypeChoice)
Constructor with user defined source localeprotected
GtfsConverterReaderSettingsWithModeMapping(URL inputSource, String countryName, RouteTypeChoice routeTypeChoice)
Constructor with user defined source localeprotected
GtfsConverterReaderSettingsWithModeMapping(GtfsConverterReaderSettingsWithModeMapping other)
Copy constructor (reference copy because we use it to share the same mode mapping across multiple instance) todo not great because technically this is a hack and we do not create a shallow copy but simply assign references...
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activateGtfsRouteTypeMode(RouteType gtfsMode)
Activate an GTFS mode, i.e., route type, based on its default mapping to a PLANit modevoid
deactivateAllModesExcept(List<RouteType> remainingGtfsModes)
remove all GTFS modes from mapping except for the passed in onesvoid
deactivateGtfsMode(RouteType gtfsMode)
Deactivate an OSM mode.void
deactivateGtfsModes(Collection<RouteType> GtfsModes)
Remove all provided GTFS modes from active mappingSet<RouteType>
findGtfsModesFor(PredefinedModeType predefinedModeType)
Find the GTFS mode that is mapped to the given predefined PLANit modeCollection<RouteType>
getAcivatedGtfsModes()
Convenience method that provides access to all the currently active GTFS modes (unmodifiable)List<RouteType>
getAcivatedGtfsModes(PredefinedModeType planitModeType)
Find the currently mapped GTFS modes for a given PLANit predefined mode typeSet<PredefinedModeType>
getAcivatedPlanitPredefinedModes()
Currently activated mapped PLANit modes as a new set, i.e., modifying this set does not impact the configurationList<PredefinedModeType>
getAcivatedPlanitPredefinedModes(RouteType gtfsMode)
Find the currently mapped PLANit predefined modes for a given gtfsModeRouteTypeChoice
getRouteTypeChoice()
The route type choice used for identifying the GTFS route modes and mapping them to PLANit modesprotected void
initialiseDefaultModeMappings()
Conduct general initialisation for any instance of this classboolean
isGtfsModeActivated(RouteType gtfsMode)
Verify if Gtfs Mode has been activated or notvoid
logSettings()
Log settings usedvoid
reset()
be able to reset all settings if neededprotected void
setDefaultGtfs2PredefinedModeTypeMapping(RouteType gtfsRouteType, List<PredefinedModeType> planitModes)
Set mapping from GTFS mode to PLANit modeprotected void
setDefaultGtfs2PredefinedModeTypeMapping(RouteType gtfsRouteType, PredefinedModeType planitMode)
Set mapping from GTFS mode to PLANit mode-
Methods inherited from class org.goplanit.gtfs.converter.GtfsConverterReaderSettingsImpl
getCountryName, getInputSource, setInputFile, setInputSource
-
-
-
-
Field Detail
-
routeTypeChoice
protected final RouteTypeChoice routeTypeChoice
Indicates what route types are applied, e.g. the default or the extended
-
defaultGtfsMode2PrefinedModeTypeMap
protected final Map<RouteType,List<PredefinedModeType>> defaultGtfsMode2PrefinedModeTypeMap
Default mapping (specific to this (services) network) from each supported GTFS mode to PLANit predefined mode. Not each mapping is necessarily activated. Multiple mappings per GTFS mode may exist indicating a primary mapping (first) and fallback mappings where the latter indicate a GTFS mode may access pre-existing stops/transfer zones of the seconday type in case the primary type is not present, e.g. trams using available lightrail tagged stops for instance
-
-
Constructor Detail
-
GtfsConverterReaderSettingsWithModeMapping
protected GtfsConverterReaderSettingsWithModeMapping(String inputSource, String countryName, RouteTypeChoice routeTypeChoice)
Constructor with user defined source locale- Parameters:
inputSource
- to usecountryName
- to base source locale onrouteTypeChoice
- to apply
-
GtfsConverterReaderSettingsWithModeMapping
protected GtfsConverterReaderSettingsWithModeMapping(URL inputSource, String countryName, RouteTypeChoice routeTypeChoice)
Constructor with user defined source locale- Parameters:
inputSource
- to usecountryName
- to base source locale onrouteTypeChoice
- to apply
-
GtfsConverterReaderSettingsWithModeMapping
protected GtfsConverterReaderSettingsWithModeMapping(GtfsConverterReaderSettingsWithModeMapping other)
Copy constructor (reference copy because we use it to share the same mode mapping across multiple instance) todo not great because technically this is a hack and we do not create a shallow copy but simply assign references...- Parameters:
other
- to use
-
-
Method Detail
-
initialiseDefaultModeMappings
protected void initialiseDefaultModeMappings()
Conduct general initialisation for any instance of this class
-
setDefaultGtfs2PredefinedModeTypeMapping
protected void setDefaultGtfs2PredefinedModeTypeMapping(RouteType gtfsRouteType, PredefinedModeType planitMode)
Set mapping from GTFS mode to PLANit mode- Parameters:
gtfsRouteType
- to map fromplanitMode
- mode type to map to
-
setDefaultGtfs2PredefinedModeTypeMapping
protected void setDefaultGtfs2PredefinedModeTypeMapping(RouteType gtfsRouteType, List<PredefinedModeType> planitModes)
Set mapping from GTFS mode to PLANit mode- Parameters:
gtfsRouteType
- to map fromplanitModes
- mode types to map to
-
activateGtfsRouteTypeMode
protected void activateGtfsRouteTypeMode(RouteType gtfsMode)
Activate an GTFS mode, i.e., route type, based on its default mapping to a PLANit mode- Parameters:
gtfsMode
- to map from
-
deactivateGtfsMode
public void deactivateGtfsMode(RouteType gtfsMode)
Deactivate an OSM mode. This means that the osmMode will not be added to the PLANit network You can only remove a mode when it is already added.- Parameters:
gtfsMode
- to remove
-
isGtfsModeActivated
public boolean isGtfsModeActivated(RouteType gtfsMode)
Verify if Gtfs Mode has been activated or not- Parameters:
gtfsMode
- to verify- Returns:
- true when activate, false otherwise
-
deactivateGtfsModes
public void deactivateGtfsModes(Collection<RouteType> GtfsModes)
Remove all provided GTFS modes from active mapping- Parameters:
GtfsModes
- to deactivate
-
deactivateAllModesExcept
public void deactivateAllModesExcept(List<RouteType> remainingGtfsModes)
remove all GTFS modes from mapping except for the passed in ones- Parameters:
remainingGtfsModes
- to explicitly keep from the GTFSModesToRemove
-
getAcivatedGtfsModes
public Collection<RouteType> getAcivatedGtfsModes()
Convenience method that provides access to all the currently active GTFS modes (unmodifiable)- Returns:
- mapped GTFS modes, if not available (due to lack of mapping or inactive parser) empty collection is returned
-
getAcivatedPlanitPredefinedModes
public Set<PredefinedModeType> getAcivatedPlanitPredefinedModes()
Currently activated mapped PLANit modes as a new set, i.e., modifying this set does not impact the configuration- Returns:
- activated, i.e., mapped PLANit predefined mode types
-
getAcivatedPlanitPredefinedModes
public List<PredefinedModeType> getAcivatedPlanitPredefinedModes(RouteType gtfsMode)
Find the currently mapped PLANit predefined modes for a given gtfsMode- Parameters:
gtfsMode
- to find modes for- Returns:
- found mapped PLANit modes starting with primary mapping (if GTFS mode is activated), otherwise null
-
getAcivatedGtfsModes
public List<RouteType> getAcivatedGtfsModes(PredefinedModeType planitModeType)
Find the currently mapped GTFS modes for a given PLANit predefined mode type- Parameters:
planitModeType
- to find modes for- Returns:
- found mapped GTFS modes (may be empty)
-
findGtfsModesFor
public Set<RouteType> findGtfsModesFor(PredefinedModeType predefinedModeType)
Find the GTFS mode that is mapped to the given predefined PLANit mode- Parameters:
predefinedModeType
- to collect Gtfs route types for- Returns:
- found mappings
-
getRouteTypeChoice
public RouteTypeChoice getRouteTypeChoice()
The route type choice used for identifying the GTFS route modes and mapping them to PLANit modes- Returns:
- chosen route type choice
-
logSettings
public void logSettings()
Log settings used- Specified by:
logSettings
in interfaceConverterReaderSettings
- Specified by:
logSettings
in interfaceGtfsConverterReaderSettings
- Overrides:
logSettings
in classGtfsConverterReaderSettingsImpl
-
reset
public void reset()
be able to reset all settings if needed- Specified by:
reset
in interfaceConverterReaderSettings
- Overrides:
reset
in classGtfsConverterReaderSettingsImpl
-
-