Class PlanitTransferZoneUtils


  • public class PlanitTransferZoneUtils
    extends Object
    Static helper methods to support parsing/functionality of PLANit TransferZones
    Author:
    markr
    • Constructor Detail

      • PlanitTransferZoneUtils

        public PlanitTransferZoneUtils()
    • Method Detail

      • findTransferZoneClosestByTransferGroup

        public static TransferZone findTransferZoneClosestByTransferGroup​(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity,
                                                                          Collection<? extends TransferZoneGroup> transferZoneGroups,
                                                                          Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                                          PlanitJtsCrsUtils geoUtils)
                                                                   throws PlanItException
        Find the zone (within any of the transfer zone groups) closest to the passed in OSM Entity
        Parameters:
        osmEntity - to find closest zone for
        transferZoneGroups - to check against
        osmNodes - to extract geo information from if needed
        geoUtils - used to compute distances
        Returns:
        closest zone found
        Throws:
        PlanItException - thrown if error
      • isTransferZoneAtLocation

        public static boolean isTransferZoneAtLocation​(TransferZone transferZone,
                                                       org.locationtech.jts.geom.Point location)
                                                throws PlanItException
        Verify if the geometry of the transfer zone equates to the provided location
        Parameters:
        transferZone - to verify
        location - to verify against
        Returns:
        true when residing at the exact same location at the reference location, false otherwise
        Throws:
        PlanItException - thrown if error
      • isTransferZoneLeftOf

        public static boolean isTransferZoneLeftOf​(TransferZone transferZone,
                                                   org.locationtech.jts.geom.Coordinate coordA,
                                                   org.locationtech.jts.geom.Coordinate coordB,
                                                   PlanitJtsCrsUtils geoUtils)
                                            throws PlanItException
        Verify of the transfer zone resides left of the line coordA to coordB
        Parameters:
        transferZone - to check
        coordA - of line
        coordB - of line
        geoUtils - to use
        Returns:
        true when left, false otherwise
        Throws:
        PlanItException - thrown if error
      • identifyInvalidTransferZoneAccessLinkSegmentsBasedOnRelativeLocationToInfrastructure

        public static Collection<EdgeSegment> identifyInvalidTransferZoneAccessLinkSegmentsBasedOnRelativeLocationToInfrastructure​(Collection<EdgeSegment> accessLinkSegments,
                                                                                                                                   TransferZone transferZone,
                                                                                                                                   Mode planitMode,
                                                                                                                                   boolean leftHandDrive,
                                                                                                                                   PlanitJtsCrsUtils geoUtils)
                                                                                                                            throws PlanItException
        Find the access link segments ineligible given the intended location of the to be created connectoid, the transfer zone provided, and the access mode. When transfer zone location differs from the connectoid location determine on which side of the infrastructure it exists and based on the country's driving direction and access mode determine the access link segments
        Parameters:
        accessLinkSegments - to filter
        transferZone - to create connectoid(s) for
        planitMode - that is accessible
        leftHandDrive - is infrastructure left hand drive or not
        geoUtils - to use for determining geographic eligibility
        Returns:
        ineligible link segments to be access link segments for connectoid at this location
        Throws:
        PlanItException - thrown if error
      • updateTransferZoneStationName

        public static void updateTransferZoneStationName​(TransferZone transferZone,
                                                         Map<String,​String> tags)
        process an osm entity that is classified as a (train) station. For this to register on the transfer zone, we try to utilise its name and use it for the zone name if it is empty. We also record it as an input property for future reference, e.g. key=station and value the name of the osm station
        Parameters:
        transferZone - the osm station relates to
        tags - of the osm entity representation a station
      • registerOsmModesOnTransferZone

        public static void registerOsmModesOnTransferZone​(TransferZone transferZone,
                                                          Collection<String> eligibleOsmModes)
        While PLANit does not require access modes on transfer zones because it is handled by connectoids, OSM stop_positions (connectoids) might lack the required tagging to identify their mode access in which case we revert to the related transfer zone to deduce it. Therefore, we store OSM mode information on a transfer zone via the generic input properties to be able to retrieve it if needed later
        Parameters:
        transferZone - to use
        eligibleOsmModes - to add
      • getRegisteredOsmModesForTransferZone

        public static Collection<String> getRegisteredOsmModesForTransferZone​(TransferZone transferZone)
        Collect any prior registered eligible OSM modes on a PLANit transfer zone (unmodifiable)
        Parameters:
        transferZone - to collect from
        Returns:
        eligible OSM modes, null if none
      • getTransferZoneStationName

        public static String getTransferZoneStationName​(TransferZone transferZone)
        Collect the station name for a transfer zone (if any)
        Parameters:
        transferZone - to collect for
        Returns:
        station name
      • extractOsmEntityType

        public static de.topobyte.osm4j.core.model.iface.EntityType extractOsmEntityType​(TransferZone transferZone)
                                                                                  throws PlanItException
        Extract the OSM entity type from a PLANit Transfer zone
        Parameters:
        transferZone - to identify entity type for
        Returns:
        the entity type
        Throws:
        PlanItException - thrown if error
      • extractClosestProjectedLinearLocationOnEdgeForTransferZone

        public static org.locationtech.jts.linearref.LinearLocation extractClosestProjectedLinearLocationOnEdgeForTransferZone​(TransferZone transferZone,
                                                                                                                               Edge accessEdge,
                                                                                                                               PlanitJtsCrsUtils geoUtils)
                                                                                                                        throws PlanItException
        Find the linear location reflecting the closest projected location between the transfer zone and link geometries. For the transfer zone geometry we use existing coordinates rather than projected ones
        Parameters:
        transferZone - to use
        accessEdge - to use
        geoUtils - to use
        Returns:
        closest projected linear location on link geometry
        Throws:
        PlanItException - thrown if error
      • extractTransferZoneTypeFromPtv1Tags

        public static TransferZoneType extractTransferZoneTypeFromPtv1Tags​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                                           Map<String,​String> tags)
        Collect the transfer zone type based on the tags
        Parameters:
        osmNode - node
        tags - tags of the node
        Returns:
        transfer zone type, unknown if not able to map