Class OsmConnectoidHelper


  • public class OsmConnectoidHelper
    extends Object
    Class to provide functionality for parsing PLANit connectoids from OSM entities
    Author:
    markr
    • Method Detail

      • findConnectoidLocationForStandAloneTransferZoneOnLink

        public org.locationtech.jts.geom.Point findConnectoidLocationForStandAloneTransferZoneOnLink​(TransferZone transferZone,
                                                                                                     MacroscopicLink accessLink,
                                                                                                     PredefinedModeType planitModeType,
                                                                                                     double maxAllowedDistanceMeters)
        find a suitable connectoid location on the given link based on the constraints that it must be able to reside on a link segment that is in the correct relative position to the transfer zone and supports the access mode on at least one of the designated link segment(s) that is eligible (if any). If not null is returned
        Parameters:
        transferZone - to find location for
        accessLink - to find location on
        planitModeType - to be compatible with
        maxAllowedDistanceMeters - the maximum allowed distance between stop and waiting area that we allow
        Returns:
        found location either existing node or projected location that is nearest and does not exist as a shape point on the link yet, or null if no valid position could be found
      • createAndRegisterDirectedConnectoidsOnTopOfTransferZone

        public Collection<DirectedConnectoid> createAndRegisterDirectedConnectoidsOnTopOfTransferZone​(TransferZone transferZone,
                                                                                                      MacroscopicNetworkLayer networkLayer,
                                                                                                      PredefinedModeType planitModeType,
                                                                                                      PlanitJtsCrsUtils geoUtils)
        Create directed connectoids for transfer zones that reside on OSM ways. For such transfer zones, we simply create connectoids in both directions for all eligible incoming link segments. This is a special case because due to residing on the OSM way it is not possible to distinguish what intended direction of the OSM way is serviced (it is neither left nor right of the way). Therefore, any attempt to extract this information is bypassed here.
        Parameters:
        transferZone - residing on an osm way
        networkLayer - related to the mode
        planitModeType - the connectoid is accessible for
        geoUtils - to use
        Returns:
        created connectoids, null if it was not possible to create any due to some reason
      • extractDirectedConnectoidsForMode

        public boolean extractDirectedConnectoidsForMode​(org.locationtech.jts.geom.Point location,
                                                         boolean locationIsKnownOsmStopPosition,
                                                         TransferZone transferZone,
                                                         PredefinedModeType planitModeType,
                                                         boolean suppressLogging,
                                                         PlanitJtsCrsUtils geoUtils)
        create and/or update directed connectoids for the given mode and layer based on the passed in location where the connectoids access link segments are extracted for. Each of the connectoids is related to the passed in transfer zone. Generally a single connectoid is created for the most likely link segment identified, i.e., if the transfer zone is placed on the left of the infrastructure, the closest by incoming link segment to the given location is used. Since the geometry of a link applies to both link segments we define closest based on the driving position of the country, so a left-hand drive country will use the incoming link segment where the transfer zone is placed on the left, etc.
        Parameters:
        location - to create the access point for as PLANit node (one or more upstream planit link segments will act as access link segment for the created connectoid(s))
        locationIsKnownOsmStopPosition - when true the location provided is tagged explicitly, meaning we do not enforce filtering based on criteria that might not have been properly tagged, when false, we proceed applying as many filter criteria as possible to get best possible match based on available tagging, e.g., vertical layer information
        transferZone - this connectoid is assumed to provide access to
        planitModeType - mode type this connectoid is allowed access for
        suppressLogging - when true do not log anything, false otherwise
        geoUtils - used when location of transfer zone relative to infrastructure is to be determined
        Returns:
        true when one or more connectoids have successfully been generated or existing connectoids have bee reused, false otherwise
      • extractDirectedConnectoidsForMode

        public boolean extractDirectedConnectoidsForMode​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                         boolean locationIsKnownOsmStopPosition,
                                                         TransferZone transferZone,
                                                         PredefinedModeType planitModeType,
                                                         boolean suppressLogging,
                                                         PlanitJtsCrsUtils geoUtils)
      • extractDirectedConnectoids

        public boolean extractDirectedConnectoids​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                  boolean locationIsKnownOsmStopPosition,
                                                  Collection<TransferZone> transferZones,
                                                  Collection<PredefinedModeType> planitModeTypes,
                                                  TransferZoneGroup transferZoneGroup,
                                                  boolean suppressLogging)
        create and/or update directed connectoids for the transfer zones and mode combinations when eligible, based on the passed in OSM node where the connectoids access link segments are extracted from
        Parameters:
        osmNode - to relate to planit network's incoming link segments as access points
        locationIsKnownOsmStopPosition - when true the location provided is tagged explicitly, meaning we do not enforce filtering based on criteria that might not have been properly tagged, when false, we proceed applying as many filter criteria as possible to get the best possible match based on available tagging, e.g., vertical layer information
        transferZones - connectoids are assumed to provide access to
        planitModeTypes - this connectoid is allowed access for
        transferZoneGroup - it belongs to, when zone is not yet in the group the zone is added to the group (group is allowed to be null)
        suppressLogging - when true, suppress logging, otherwise do not
        Returns:
        true when at least connectoids where created for one of the transfer zones identified
      • extractDirectedConnectoidsForStandAloneTransferZoneByPlanitLink

        public void extractDirectedConnectoidsForStandAloneTransferZoneByPlanitLink​(long osmWaitingAreaId,
                                                                                    org.locationtech.jts.geom.Geometry waitingAreaGeometry,
                                                                                    MacroscopicLink accessLink,
                                                                                    TransferZone transferZone,
                                                                                    PredefinedModeType planitAccessModeType,
                                                                                    double maxAllowedStopToTransferZoneDistanceMeters,
                                                                                    MacroscopicNetworkLayer networkLayer,
                                                                                    boolean suppressLogging)
        create connectoids not based on OSM node location but based on auto-generated geographic location on the provided link's link segments by finding either a close enough existing coordinate (OSM node), or if not close enough a newly created coordinate at the appropriate position. then create connectoids accordingly by breaking the link in these locations
        Parameters:
        osmWaitingAreaId - the waiting area pertains to
        waitingAreaGeometry - geometry of the waiting area
        accessLink - to create connectoids on by breaking it
        transferZone - to register connectoids on
        planitAccessModeType - eligible mode type for the station
        maxAllowedStopToTransferZoneDistanceMeters - the maximum allowed distance between stop and waiting area that we allow
        networkLayer - the modes relate to
        suppressLogging - when true suppress logging, false otherwise
      • 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 for
        layer - 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