Class TransferZoneHelper
- java.lang.Object
-
- org.goplanit.osm.converter.zoning.handler.helper.TransferZoneHelper
-
public class TransferZoneHelper extends Object
Class to provide functionality for parsing transfer zones from OSM entities- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description TransferZoneHelper(PlanitOsmNetwork referenceNetwork, Zoning zoning, OsmZoningReaderData zoningReaderData, OsmNetworkToZoningReaderData network2ZoningData, OsmPublicTransportReaderSettings transferSettings, OsmZoningHandlerProfiler profiler)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TransferZone
createAndRegisterTransferZoneWithConnectoidsAtOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, String defaultOsmMode, TransferZoneType defaultTransferZoneType, PlanitJtsCrsUtils geoUtils)
Method that will attempt to create both a transfer zone and its connectoids at the location of the OSM node.TransferZone
createAndRegisterTransferZoneWithoutConnectoidsFindAccessModes(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<String,String> tags, TransferZoneType transferZoneType, String defaultOsmMode, PlanitJtsCrsUtils geoUtils)
Attempt to create a new transfer zone and register it, do not yet create connectoids for it.TransferZone
createAndRegisterTransferZoneWithoutConnectoidsSetAccessModes(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<String,String> tags, TransferZoneType transferZoneType, SortedSet<String> eligibleOsmModes, PlanitJtsCrsUtils geoUtils)
Attempt to create a new transfer zone and register it, do not create connectoids for it.Set<TransferZone>
filterModeCompatibleTransferZones(Collection<String> eligibleOsmModes, Collection<TransferZone> potentialTransferZones, boolean allowPseudoModeMatches, boolean allowModelessTransferZoneMatches)
Find all transfer zones with at least one compatible mode (and PLANit mode mapped) based on the passed in reference osm modes In case no eligible modes are provided (null), we allow any transfer zone with at least one valid mapped modeCollection<MacroscopicLink>
filterVerticalLayerCompatibleLinks(TransferZone transferZone, Collection<MacroscopicLink> linksToFilter, boolean assumeDefaultLayerForZoneIfAbsent)
Filter (retain) only the links that are vertical layer index compatible, i.e., have the same vertical layer index (or both adopt the default).protected Pair<Integer,Boolean>
findOsmVerticalLayerIndexByStopPositionPlanitLinks(org.locationtech.jts.geom.Point stopPositionLocation, NetworkLayer layer)
Based on the location of the stop position, determine if the PLANit links that it resides on, or borders or reside in a particular layer.Collection<TransferZone>
findTransferZonesForStopPosition(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, SortedSet<String> eligibleOsmModes, boolean suppressLogging)
Identical to the one with transfer zone group parameter, only here no stop_position is not part of transfer zone group and therefore we only can find matches spatiallyCollection<TransferZone>
findTransferZonesForStopPosition(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, SortedSet<String> eligibleOsmModes, TransferZoneGroup transferZoneGroup, boolean suppressLogging)
Find the transfer zone(s) for a given stop_position, either the user overwritten mapping, or conditioned on mode,reference/name/spatially, or just the closest one in absence of eligible modes.protected OsmNetworkToZoningReaderData
getNetworkToZoningData()
protected PlanitOsmNetwork
getReferenceNetwork()
protected OsmPublicTransportReaderSettings
getSettings()
Collect the pt settingsprotected boolean
hasNetworkLayersWithActiveOsmNode(long osmNodeId)
Verify if there exist any layers where the node is active either as an extreme node or internal to a PLANit link
-
-
-
Constructor Detail
-
TransferZoneHelper
public TransferZoneHelper(PlanitOsmNetwork referenceNetwork, Zoning zoning, OsmZoningReaderData zoningReaderData, OsmNetworkToZoningReaderData network2ZoningData, OsmPublicTransportReaderSettings transferSettings, OsmZoningHandlerProfiler profiler)
Constructor- Parameters:
referenceNetwork
- to usezoning
- to usezoningReaderData
- to usenetwork2ZoningData
- data transferred from parsing network to be used by zoning reader.transferSettings
- to useprofiler
- to use
-
-
Method Detail
-
filterModeCompatibleTransferZones
public Set<TransferZone> filterModeCompatibleTransferZones(Collection<String> eligibleOsmModes, Collection<TransferZone> potentialTransferZones, boolean allowPseudoModeMatches, boolean allowModelessTransferZoneMatches)
Find all transfer zones with at least one compatible mode (and PLANit mode mapped) based on the passed in reference osm modes In case no eligible modes are provided (null), we allow any transfer zone with at least one valid mapped mode- Parameters:
eligibleOsmModes
- to map against (may be null)potentialTransferZones
- to extract mode compatible transfer zonesallowPseudoModeMatches
- , when true only broad category needs to match, i.e., both have a road/rail/water mode, when false only exact matches are allowedallowModelessTransferZoneMatches
- , when true transfer zones that do not have any known mode are also considered. If such a match is found, user is requested to verify correctness- Returns:
- matched transfer zones
-
createAndRegisterTransferZoneWithoutConnectoidsFindAccessModes
public TransferZone createAndRegisterTransferZoneWithoutConnectoidsFindAccessModes(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<String,String> tags, TransferZoneType transferZoneType, String defaultOsmMode, PlanitJtsCrsUtils geoUtils)
Attempt to create a new transfer zone and register it, do not yet create connectoids for it. This is postponed because likely at this point in time it is not possible to best determine where they should reside. Find eligible access modes as input properties as well which can be used later to map stop_positions more easily. Note that one can provide a default osm mode that is deemed eligible in case no tags are provided on the osm entity. In case no mode information can be extracted a warning is issued but the transfer zone is still created because this is a tagging error and we might be able to salvage later on. If there are osm modes but none of them are mapped, then we should not create the zone since it will not be of use.- Parameters:
osmEntity
- to extract transfer zone fortags
- to usetransferZoneType
- to applydefaultOsmMode
- to apply (may be null)geoUtils
- to use- Returns:
- transfer zone created, null if something happened making it impossible or not useful to create the zone
-
createAndRegisterTransferZoneWithoutConnectoidsSetAccessModes
public TransferZone createAndRegisterTransferZoneWithoutConnectoidsSetAccessModes(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, Map<String,String> tags, TransferZoneType transferZoneType, SortedSet<String> eligibleOsmModes, PlanitJtsCrsUtils geoUtils)
Attempt to create a new transfer zone and register it, do not create connectoids for it. Register the provided access modes as eligible by setting them on the input properties which can be used later to map stop_positions more easily.- Parameters:
osmEntity
- to extract transfer zone fortags
- to usetransferZoneType
- to applyeligibleOsmModes
- the eligible osm modes consideredgeoUtils
- to use- Returns:
- transfer zone created, null if something happened making it impossible to create the zone
-
createAndRegisterTransferZoneWithConnectoidsAtOsmNode
public TransferZone createAndRegisterTransferZoneWithConnectoidsAtOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, String defaultOsmMode, TransferZoneType defaultTransferZoneType, PlanitJtsCrsUtils geoUtils)
Method that will attempt to create both a transfer zone and its connectoids at the location of the OSM node. This is only relevant for very specific types of OSM pt nodes, such as tram_stop, some bus_stops that are tagged on the road, and potentially halts and/or stations. In case no existing transfer zone in this location exists, we create one first using the default transfer zone type provided, otherwise we utilise the existing transfer zone- Parameters:
osmNode
- for the location to create both a transfer zone and connectoid(s)tags
- of the nodedefaultOsmMode
- that is to be expected heredefaultTransferZoneType
- in case a transfer zone needs to be created in this locationgeoUtils
- to use- Returns:
- created transfer zone (if not already in existence)
-
findTransferZonesForStopPosition
public Collection<TransferZone> findTransferZonesForStopPosition(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, SortedSet<String> eligibleOsmModes, TransferZoneGroup transferZoneGroup, boolean suppressLogging)
Find the transfer zone(s) for a given stop_position, either the user overwritten mapping, or conditioned on mode,reference/name/spatially, or just the closest one in absence of eligible modes. In the special case the stop_position is in fact also the transfer zone and none is present we create a new TransferZone- Parameters:
osmNode
- representing the stop_locationtags
- of the nodeeligibleOsmModes
- eligible modes for the stop_location, may be nulltransferZoneGroup
- the node belongs to, may be nullsuppressLogging
- when true suppress logging, false otherwise- Returns:
- found transfer zone matches, can be multiple if multiple are serviced by the same stop position
-
findTransferZonesForStopPosition
public Collection<TransferZone> findTransferZonesForStopPosition(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, Map<String,String> tags, SortedSet<String> eligibleOsmModes, boolean suppressLogging)
Identical to the one with transfer zone group parameter, only here no stop_position is not part of transfer zone group and therefore we only can find matches spatially- Parameters:
osmNode
- representing the stop_locationtags
- of the nodeeligibleOsmModes
- eligible modes for the stop_location, may be nullsuppressLogging
- when true suppress logging, false otherwise- Returns:
- found transfer zone matches
-
filterVerticalLayerCompatibleLinks
public Collection<MacroscopicLink> filterVerticalLayerCompatibleLinks(TransferZone transferZone, Collection<MacroscopicLink> linksToFilter, boolean assumeDefaultLayerForZoneIfAbsent)
Filter (retain) only the links that are vertical layer index compatible, i.e., have the same vertical layer index (or both adopt the default). In case the transfer zone has no explicit layer specified, it depends on the user whether we would assume the default layer or we assume the layer is in fact unknown- Parameters:
transferZone
- to match againstlinksToFilter
- the links to filterassumeDefaultLayerForZoneIfAbsent
- when true, we assume a transfer zone without an explicitly tagged layer is given default layer, when false we assume it is unknown and links will not be filtered- Returns:
- remaining links, which is the same collection as passed in, only without the ineligible links removed
-
getSettings
protected OsmPublicTransportReaderSettings getSettings()
Collect the pt settings- Returns:
- public transport settings
-
getReferenceNetwork
protected PlanitOsmNetwork getReferenceNetwork()
-
getNetworkToZoningData
protected OsmNetworkToZoningReaderData getNetworkToZoningData()
-
hasNetworkLayersWithActiveOsmNode
protected boolean hasNetworkLayersWithActiveOsmNode(long osmNodeId)
Verify if there exist any layers where the node is active either as an extreme node or internal to a PLANit link- Parameters:
osmNodeId
- to use- Returns:
- true when one or more layers are found, false otherwise
-
findOsmVerticalLayerIndexByStopPositionPlanitLinks
protected Pair<Integer,Boolean> findOsmVerticalLayerIndexByStopPositionPlanitLinks(org.locationtech.jts.geom.Point stopPositionLocation, NetworkLayer layer)
Based on the location of the stop position, determine if the PLANit links that it resides on, or borders or reside in a particular layer. If so, the OSM vertical layer index is retrieved and provided. If inconsistent indices are found across the links the user is warned, if no matching links are known on the layer null is returned.- Parameters:
stopPositionLocation
- to find layer index forlayer
- to check- Returns:
- OSM vertical layer index found, and boolean indicating if the found layer index was the same across all eligible links (true), false otherwise
-
-