- java.lang.Object
-
- org.arakhne.afc.gis.primitive.AbstractGISElement<C,T>
-
- org.arakhne.afc.gis.primitive.AbstractBoundedGISElement<CONTAINER,AbstractBusPrimitive<CONTAINER>>
-
- org.arakhne.afc.gis.bus.network.AbstractBusPrimitive<BusNetwork>
-
- org.arakhne.afc.gis.bus.network.BusHub
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<BusStop>
,EventListener
,AttributeChangeListener
,AttributeCollection
,AttributeProvider
,BusPrimitive<BusNetwork>
,BoundedGISElement
,FlagContainer
,GISCloneable<AbstractBusPrimitive<BusNetwork>>
,GISEditable
,GISElement
,GISFlagContainer
,GISPrimitive
,BoundedElement2afp<Rectangle2d>
,JsonableObject
public class BusHub extends AbstractBusPrimitive<BusNetwork> implements Iterable<BusStop>
A bus hub is a set ofbus stops
located inside the same geographical area. Bus network's users could easily pass from a bus stop to another when they are located inside the same bus hub.Definition from Wikipedia
A bus hub is a structure where city or intercity buses stop to pick up and drop off passengers. It is larger than a bus stop, which is usually simply a place on the roadside, where buses can stop. It may be intended as a terminal hub for a number of routes, or as a transfer hub where the routes continue. Bus hub platforms may be assigned to fixed bus lines, or variable in combination with a dynamic passenger information system. The latter requires fewer platforms, but does not supply the passenger the comfort of knowing the platform well in advance and waiting there.
Source: WikiPediaValidation
A bus hub is valid if it has at least one stop inside and all its stops are valid in turn.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:56
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- gisbus
-
-
Field Summary
Fields Modifier and Type Field Description protected List<BusStop>
busStops
List of bus stops in this hub.-
Fields inherited from class org.arakhne.afc.gis.bus.network.AbstractBusPrimitive
ATTR_COLOR, DEFAULT_COLOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.FlagContainer
FLAG_READONLY, FLAG_SELECTED
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISElement
ATTR_NAME, NAME_COMPARATOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description BusHub(BusNetwork network, String name)
Create bus hub with attributes in memory.BusHub(BusNetwork network, String name, AttributeCollection attributeProvider)
Create bus hub.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addBusStop(BusStop busStop)
Add a bus stop inside the bus hub.(package private) boolean
addBusStop(BusStop busStop, boolean fireEvents)
Add a bus stop inside the bus hub.Iterator<BusStop>
busStopIterator()
Replies the list of the bus stops of the bus hub.Iterable<BusStop>
busStops()
Replies the list of the bus stops of the bus hub.BusStop[]
busStopsArray()
Replies the array of the bus stops.protected Rectangle2d
calcBounds()
Compute the bounds of this element.protected void
checkPrimitiveValidity()
Check if the validity of this primitive is correctly set and change its values if necessary.boolean
contains(BusStop busStop)
Replies if the given bus stop is inside this hub.double
distance(double x, double y)
Replies the distance between the given point and this bus hub.double
distance(GeoLocationPoint point)
Replies the distance between the given point and this bus hub.double
distance(Point2D<?,?> point)
Replies the distance between the given point and this bus hub.BusNetwork
getBusNetwork()
Replies the bus network in which this primitive is.BusStop
getBusStopAt(int index)
Replies the bus stop at the specified index.int
getBusStopCount()
Replies the count of bus stops into this hub.static String
getFirstFreeBusHubName(BusNetwork busnetwork)
Replies a bus hub name that was not exist in the specified bus network.GeoLocation
getGeoLocation()
Replies the geo-location of this hub.GeoLocationPoint
getGeoPosition()
Replies the position of the bus hub.String
getName()
Replies the name of this hub.Point2d
getPosition2D()
Replies the position of the bus hub.Shape2d<?>
getShape()
Replies the shape of this this element.int
indexInParent()
Replies the index of this primitive in its parent.int
indexOf(BusStop busStop)
Replies the index of the specified bus stop.boolean
isEmpty()
Replies if this hub is empty.boolean
isSignificant()
Replies if this hub contains at least two bus stops.Iterator<BusStop>
iterator()
void
rebuild(boolean fireEvents)
Rebuild the primitive and all the primitive inside.void
removeAllBusStops()
Remove all the bus stops from the current hub.boolean
removeBusStop(int index)
Remove the bus stop at the specified index.boolean
removeBusStop(BusStop busStop)
Remove a bus stop from this hub.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.-
Methods inherited from class org.arakhne.afc.gis.bus.network.AbstractBusPrimitive
addBusChangeListener, addGISEditableChangeListener, addListener, finalize, fireGraphicalAttributeChanged, fireGraphicalAttributeChanged, firePrimitiveChanged, firePrimitiveChanged, firePrimitiveChanged, fireShapeChanged, fireShapeChanged, fireValidityChanged, fireValidityChangedFor, getColor, getColor, getFlags, getInvalidityReason, getRawColor, hasFlag, isReadOnlyObject, isValidPrimitive, onAttributeChanged, rebuild, removeBusChangeListener, removeGISEditableChangeListener, removeListener, revalidate, setColor, setFlag, setPrimitiveValidity, setReadOnlyObject, setUUID, switchFlag, unsetFlag
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
clone, getBoundingBox, resetBoundingBox, setBoundingBox
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractGISElement
addAttributeChangeListener, addAttributes, addAttributes, attributes, copyAttributes, flush, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCollection, getAttributeCount, getAttributeObject, getAttributeProvider, getContainer, getGeoId, getTopContainer, getUUID, hasAttribute, hashKey, isEventFirable, onAttributeChangeEvent, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setContainer, setEventFirable, setName, toMap, toMap, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeCollection
addAttributeChangeListener, addAttributes, addAttributes, flush, isEventFirable, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setEventFirable
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeProvider
attributes, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCount, getAttributeObject, hasAttribute, toMap, toMap
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.afp.BoundedElement2afp
getBoundingBox
-
Methods inherited from interface org.arakhne.afc.gis.primitive.BoundedGISElement
resetBoundingBox
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISEditable
setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISElement
clone, copyAttributes, hashKey, setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
getGeoId, getUUID
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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.
-
rebuild
public void rebuild(boolean fireEvents)
Description copied from interface:BusPrimitive
Rebuild the primitive and all the primitive inside. Rebuilding means to reset all the internal values and recompute their values.This function should be invoked when the bus primitive was construct with its flag replied by
AttributeCollection.isEventFirable()
set tofalse
. This function permits to finalize the construction.In addition, this function automatically invoke
BoundedGISElement.resetBoundingBox()
and does the same job asBusPrimitive.revalidate()
(but does not invoke it). This function invokesAttributeCollection.setEventFirable(boolean)
withtrue
as parameter.- Specified by:
rebuild
in interfaceBusPrimitive<BusNetwork>
- Parameters:
fireEvents
- indicates if the events should be fired.- See Also:
BusPrimitive.rebuild()
-
checkPrimitiveValidity
protected void checkPrimitiveValidity()
Description copied from class:AbstractBusPrimitive
Check if the validity of this primitive is correctly set and change its values if necessary. This function DO NOT revalidate the primitives inside this primitive.- Specified by:
checkPrimitiveValidity
in classAbstractBusPrimitive<BusNetwork>
- See Also:
AbstractBusPrimitive.revalidate()
-
getGeoLocation
@Pure public GeoLocation getGeoLocation()
Replies the geo-location of this hub.- Specified by:
getGeoLocation
in interfaceGISPrimitive
- Overrides:
getGeoLocation
in classAbstractBusPrimitive<BusNetwork>
- Returns:
- the geo-location of the hub, never
null
. - See Also:
GISPrimitive.getGeoId()
,GISPrimitive.getGeoLocation()
-
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
-
getBusNetwork
@Pure public BusNetwork getBusNetwork()
Description copied from interface:BusPrimitive
Replies the bus network in which this primitive is.- Specified by:
getBusNetwork
in interfaceBusPrimitive<BusNetwork>
- Returns:
- the bus network in which this primitive is.
-
toJson
@Pure public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObject
Replies the Json representation of this node.- Specified by:
toJson
in interfaceJsonableObject
- Overrides:
toJson
in classAbstractBusPrimitive<BusNetwork>
- Parameters:
buffer
- the Json buffer.
-
getName
@Pure public String getName()
Replies the name of this hub. If the bus stops inside this hub have the same names, this method replies the name of the bus stops. Otherwhise, it replies the value returned bygetName()
.The string comparison is case-insensitive.
- Specified by:
getName
in interfaceGISEditable
- Specified by:
getName
in interfaceGISElement
- Overrides:
getName
in classAbstractGISElement<BusNetwork,AbstractBusPrimitive<BusNetwork>>
- Returns:
- a name for this hub extended to the bus stops.
-
calcBounds
@Pure protected Rectangle2d calcBounds()
Description copied from class:AbstractBoundedGISElement
Compute the bounds of this element. This function does not update the internal attribute replied byAbstractBoundedGISElement.getBoundingBox()
- Specified by:
calcBounds
in classAbstractBoundedGISElement<BusNetwork,AbstractBusPrimitive<BusNetwork>>
- Returns:
- the bounds
-
getShape
public Shape2d<?> getShape()
Description copied from interface:BoundedGISElement
Replies the shape of this this element.The bounding box replied by
BoundedElement2afp.getBoundingBox()
encloses the replied shape.- Specified by:
getShape
in interfaceBoundedGISElement
- Returns:
- the shape or
null
if not applicable.
-
isEmpty
@Pure public boolean isEmpty()
Replies if this hub is empty.- Returns:
true
if the hub is empty, otherwisefalse
-
indexInParent
@Pure public int indexInParent()
Description copied from class:AbstractBusPrimitive
Replies the index of this primitive in its parent.- Specified by:
indexInParent
in classAbstractBusPrimitive<BusNetwork>
- Returns:
- the index of this primitive in its parent.
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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, otherwisefalse
-
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.
-
-