Class BusHub

    • Field Detail

      • busStops

        protected final List<BusStop> busStops
        List of bus stops in this hub.
    • Constructor Detail

      • BusHub

        BusHub​(BusNetwork network,
               String name)
        Create bus hub with attributes in memory.
        Parameters:
        network - is the bus network in which this hub is located.
        name - is the name of the bus hub.
      • BusHub

        BusHub​(BusNetwork network,
               String name,
               AttributeCollection attributeProvider)
        Create bus hub.
        Parameters:
        network - is the bus network in which this hub is located.
        name - is the name of the bus hub.
        attributeProvider - the attribute provider.
    • Method Detail

      • getFirstFreeBusHubName

        @Pure
        public static String getFirstFreeBusHubName​(BusNetwork busnetwork)
        Replies a bus hub name that was not exist in the specified bus network.
        Parameters:
        busnetwork - is the bus network from which a free bus hub name may be computed.
        Returns:
        a name suitable for a bus hub.
      • getGeoPosition

        @Pure
        public GeoLocationPoint getGeoPosition()
        Replies the position of the bus hub.
        Returns:
        the position or null if never set before.
      • getPosition2D

        @Pure
        public Point2d getPosition2D()
        Replies the position of the bus hub.
        Returns:
        the position
      • isEmpty

        @Pure
        public boolean isEmpty()
        Replies if this hub is empty.
        Returns:
        true if the hub is empty, otherwise false
      • isSignificant

        @Pure
        public boolean isSignificant()
        Replies if this hub contains at least two bus stops.
        Returns:
        true if the hub contains at least 2 bus stops, otherwise false
      • distance

        @Pure
        public double distance​(double x,
                               double y)
        Replies the distance between the given point and this bus hub.

        The distance to the hub is the distance to the nearest bus stop located in the hub.

        Parameters:
        x - x coordinate.
        y - y coordinate.
        Returns:
        the distance to this bus hub
      • distance

        @Pure
        public double distance​(Point2D<?,​?> point)
        Replies the distance between the given point and this bus hub.

        The distance to the hub is the distance to the nearest bus stop located in the hub.

        Parameters:
        point - the point
        Returns:
        the distance to this bus hub
      • distance

        @Pure
        public final double distance​(GeoLocationPoint point)
        Replies the distance between the given point and this bus hub.

        The distance to the hub is the distance to the nearest bus stop located in the hub.

        Parameters:
        point - the point
        Returns:
        the distance to this bus hub
      • addBusStop

        public boolean addBusStop​(BusStop busStop)
        Add a bus stop inside the bus hub.
        Parameters:
        busStop - is the bus stop to insert.
        Returns:
        true if the bus stop was added, otherwise false
      • addBusStop

        boolean addBusStop​(BusStop busStop,
                           boolean fireEvents)
        Add a bus stop inside the bus hub.
        Parameters:
        busStop - is the bus stop to insert.
        fireEvents - indicates if the events should be fired and the validity checked.
        Returns:
        true if the bus stop was added, otherwise false
      • removeAllBusStops

        public void removeAllBusStops()
        Remove all the bus stops from the current hub.
      • removeBusStop

        public boolean removeBusStop​(BusStop busStop)
        Remove a bus stop from this hub.
        Parameters:
        busStop - is the bus stop to remove.
        Returns:
        true if the bus stop was successfully removed, otherwise false
      • removeBusStop

        public boolean removeBusStop​(int index)
        Remove the bus stop at the specified index.
        Parameters:
        index - is the index of the bus stop to remove.
        Returns:
        true if the bus stop was successfully removed, otherwise false
      • getBusStopCount

        @Pure
        public int getBusStopCount()
        Replies the count of bus stops into this hub.
        Returns:
        the count of bus stops into this hub.
      • indexOf

        @Pure
        public int indexOf​(BusStop busStop)
        Replies the index of the specified bus stop.
        Parameters:
        busStop - is the bus stop to search for.
        Returns:
        the index or -1 if it was not found.
      • contains

        @Pure
        public boolean contains​(BusStop busStop)
        Replies if the given bus stop is inside this hub.
        Parameters:
        busStop - is the bus stop to search for.
        Returns:
        true if the bus stop is inside the hub, false otherwise.
      • getBusStopAt

        @Pure
        public BusStop getBusStopAt​(int index)
        Replies the bus stop at the specified index.
        Parameters:
        index - the index.
        Returns:
        a bus stop
      • busStopIterator

        @Pure
        public Iterator<BusStop> busStopIterator()
        Replies the list of the bus stops of the bus hub.
        Returns:
        a list of bus stops
      • busStops

        @Pure
        public Iterable<BusStop> busStops()
        Replies the list of the bus stops of the bus hub.
        Returns:
        a list of bus stops
      • busStopsArray

        @Pure
        public BusStop[] busStopsArray()
        Replies the array of the bus stops. This function copies the bus stops in an array.
        Returns:
        the array of bus stops.