Class ConnectoidHelper


  • public class ConnectoidHelper
    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,
                                                                                                     Link accessLink,
                                                                                                     Mode accessMode,
                                                                                                     double maxAllowedStopToTransferZoneDistanceMeters,
                                                                                                     MacroscopicNetworkLayer networkLayer)
                                                                                              throws PlanItException
        find a suitable connectoid location on the given link based on the constraints that it must be able to reside on a linksegment 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 possible null is returned
        Parameters:
        transferZone - to find location for
        accessLink - to find location on
        accessMode - to be compatible with
        maxAllowedStopToTransferZoneDistanceMeters - the maximum allowed distance between stop and waiting area that we allow
        networkLayer - to use
        Returns:
        found location either exisiting osm 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
        Throws:
        PlanItException - thrown if error
      • createAndRegisterDirectedConnectoidsOnTopOfTransferZone

        public Collection<DirectedConnectoid> createAndRegisterDirectedConnectoidsOnTopOfTransferZone​(TransferZone transferZone,
                                                                                                      MacroscopicNetworkLayer networkLayer,
                                                                                                      Mode planitMode,
                                                                                                      PlanitJtsCrsUtils geoUtils)
                                                                                               throws PlanItException
        Create directed connectoids for transfer zones that reside on osw 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
        planitMode - the connectoid is accessible for
        geoUtils - to use
        Returns:
        created connectoids, null if it was not possible to create any due to some reason
        Throws:
        PlanItException - thrown if error
      • extractDirectedConnectoidsForMode

        public boolean extractDirectedConnectoidsForMode​(org.locationtech.jts.geom.Point location,
                                                         TransferZone transferZone,
                                                         Mode planitMode,
                                                         Collection<Link> eligibleAccessLinks,
                                                         PlanitJtsCrsUtils geoUtils)
                                                  throws PlanItException
        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))
        transferZone - this connectoid is assumed to provide access to
        planitMode - this connectoid is allowed access for
        eligibleAccessLinks - only links in this collection are considered when compatible with provided location
        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
        Throws:
        PlanItException - thrown if error
      • extractDirectedConnectoidsForMode

        public boolean extractDirectedConnectoidsForMode​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                         TransferZone transferZone,
                                                         Mode planitMode,
                                                         PlanitJtsCrsUtils geoUtils)
                                                  throws PlanItException
        create and/or update directed connectoids for the given mode and layer based on the passed in osm node (location) where the connectoids access link segments are extracted for. Each of the connectoids is related to the passed in transfer zone.
        Parameters:
        osmNode - to relate to planit network's incoming link segments as access points
        transferZone - this connectoid is assumed to provide access to
        planitMode - this connectoid is allowed access for
        geoUtils - used to determine location of transfer zone relative to infrastructure to identify which link segment(s) are eligible for connectoids placement
        Returns:
        true when one or more connectoids have successfully been generated or existing connectoids have bee reused, false otherwise
        Throws:
        PlanItException - thrown if error
      • extractDirectedConnectoids

        public boolean extractDirectedConnectoids​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                  Map<String,​String> tags,
                                                  Collection<TransferZone> transferZones,
                                                  Collection<Mode> planitModes,
                                                  TransferZoneGroup transferZoneGroup)
                                           throws PlanItException
        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
        tags - to use
        transferZones - connectoids are assumed to provide access to
        planitModes - 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)
        Returns:
        true when at least connectoids where created for one of the transfer zones identified
        Throws:
        PlanItException - thrown if error
      • extractDirectedConnectoidsForStandAloneTransferZoneByPlanitLink

        public void extractDirectedConnectoidsForStandAloneTransferZoneByPlanitLink​(long osmWaitingAreaId,
                                                                                    org.locationtech.jts.geom.Geometry waitingAreaGeometry,
                                                                                    Link accessLink,
                                                                                    TransferZone transferZone,
                                                                                    Mode accessMode,
                                                                                    double maxAllowedStopToTransferZoneDistanceMeters,
                                                                                    MacroscopicNetworkLayer networkLayer)
                                                                             throws PlanItException
        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
        accessMode - eligible mode for the station
        maxAllowedStopToTransferZoneDistanceMeters - the maximum allowed distance between stop and waiting area that we allow
        networkLayer - the modes relate to
        Throws:
        PlanItException - thrown if error
      • getNetworkToZoningData

        protected OsmNetworkToZoningReaderData getNetworkToZoningData()
        collect network to zoning data from settings
        Returns:
        network to zoning data
      • hasNetworkLayersWithActiveOsmNode

        protected boolean hasNetworkLayersWithActiveOsmNode​(long osmNodeId)
                                                     throws PlanItException
        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
        Throws:
        PlanItException - thrown if error