- 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<BusItinerary>
-
- org.arakhne.afc.gis.bus.network.BusItineraryHalt
-
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,AttributeChangeListener
,AttributeCollection
,AttributeProvider
,BusPrimitive<BusItinerary>
,BoundedGISElement
,FlagContainer
,GISCloneable<AbstractBusPrimitive<BusItinerary>>
,GISEditable
,GISElement
,GISFlagContainer
,GISPrimitive
,BoundedElement2afp<Rectangle2d>
,JsonableObject
public class BusItineraryHalt extends AbstractBusPrimitive<BusItinerary>
A bus halt is where a bus is able to halt its course. It is associated to a bus stop and an itinerary. It is situated on a road segment.Validation
An bus halt on an itinerary could be invalid if one of the following critera is not true:- no itinerary is associated to the bus halt,
- no curviline position is given to the bus halt,
- the bus halt on the itinerary is not associated to a
bus stop
.
- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BusItineraryHalt.BusItineraryHaltType
Type of bus halt.
-
Field Summary
Fields Modifier and Type Field Description static double
DISTANCE_BETWEEN_HALT_AND_ROAD_BORDER
Distance between the road border and the bus halt.-
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 BusItineraryHalt(UUID id, BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type)
Create a halt with attributes stored in memory.BusItineraryHalt(UUID id, BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type, AttributeCollection attributeProvider)
Create a bus halt.BusItineraryHalt(BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type)
Create a halt with attributes stored in memory.BusItineraryHalt(BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type, AttributeCollection attributeProvider)
Create a bus halt.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<BusHub>
busHubIterator()
Replies the hubs in which this bus stop is located in throught an associated bus stop.Iterable<BusHub>
busHubs()
Replies the hubs in which this bus halt is located in throught an associated bus stop.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.protected void
clearPositionBuffers()
Clear internal buffers related to the bus halt position.double
distance(double x, double y)
Replies the distance between the given point and this bus halt.double
distance(BusItineraryHalt halt)
Replies the distance between the given bus halt and this bus halt.double
distance(BusStop busStop)
Replies the distance between the given bus stop and this bus halt.double
distance(GeoLocationPoint point)
Replies the distance between the given point and this bus halt.double
distance(Point2D<?,?> point)
Replies the distance between the given point and this bus halt.double
distanceToBusStop()
Replies the distance between the position of this bus itinerary halt and the position of the bus stop associated to this bus itinerary halt.protected void
fireValidityChangedFor(Object changedObject, int index, BusPrimitiveInvalidity oldReason, BusPrimitiveInvalidity newReason)
Fire the event that indicates the validity of the object has changed.BusNetwork
getBusNetwork()
Replies the bus network in which this primitive is.BusStop
getBusStop()
Replies the bus stop associated to this halt.static String
getFirstFreeBushaltName(BusItinerary busItinerary)
Replies a bus halt name that was not exist in the specified bus itinerary.GeoLocation
getGeoLocation()
Replies the geo-location.GeoLocationPoint
getGeoPosition()
Replies the geo position.int
getInvalidListIndex()
Replies the unique id in the sorted list of invalid halts.Point1d
getPosition1D()
Replies the position of the bus halt on the road.Point2d
getPosition2D()
Replies the position of the bus halt on the road.double
getPositionOnSegment()
Replies the position on the segment.RoadSegment
getRoadSegment()
Replies the road segment on which this bus halt was.Direction1D
getRoadSegmentDirection()
Replies on which direction the bus halt is located on the road segment.int
getRoadSegmentIndex()
Replies the index of the road segment on which this bus halt was.Shape2d<?>
getShape()
Replies the shape of this this element.BusItineraryHalt.BusItineraryHaltType
getType()
Replies the type of the bus halt.int
indexInParent()
Replies the index of this primitive in its parent.boolean
insideBusHub()
Replies if this bus halt is inside a hub throught an associated bus stop.boolean
isEndingBusHalt()
Replies if this bus halt is a ending bus halt (aka. last bus halt) of an itinerary.boolean
isStartingBusHalt()
Replies if this bus halt is a starting bus halt (aka. first bus halt) of an itinerary.boolean
isTerminus()
Replies if this bus halt is a terminus (aka. first or last bus halt) of an itinerary.void
rebuild(boolean fireEvents)
Rebuild the primitive and all the primitive inside.boolean
setBusStop(BusStop busStop)
Set the bus stop associated to this halt.(package private) void
setInvalidListIndex(int id)
Set the unique id in the sorted list of invalid halts.void
setName(String name)
Set the name of the element.(package private) void
setPositionOnSegment(double position)
Set the position on the segment.(package private) void
setRoadSegmentIndex(int idx)
Set the index of the road segment on which this bus halt was.void
setType(BusItineraryHalt.BusItineraryHaltType type)
Set the type of the bus halt.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, 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, getName, 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, 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
getName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISElement
clone, copyAttributes, getName, hashKey
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
getGeoId, getUUID
-
-
-
-
Field Detail
-
DISTANCE_BETWEEN_HALT_AND_ROAD_BORDER
public static final double DISTANCE_BETWEEN_HALT_AND_ROAD_BORDER
Distance between the road border and the bus halt.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BusItineraryHalt
BusItineraryHalt(BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type)
Create a halt with attributes stored in memory.- Parameters:
itinerary
- is the itinerary on which thus bus halt was located.type
- is the type of the bus halt.name
- is the name of the new bus halt
-
BusItineraryHalt
BusItineraryHalt(UUID id, BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type)
Create a halt with attributes stored in memory.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.itinerary
- is the itinerary on which thus bus halt was located.type
- is the type of the bus halt.name
- is the name of the new bus halt- Since:
- 2.0
-
BusItineraryHalt
BusItineraryHalt(BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type, AttributeCollection attributeProvider)
Create a bus halt.- Parameters:
itinerary
- is the itinerary on which thus bus halt was located.name
- is the name of the new bus halttype
- is the type of the bus halt.attributeProvider
- is the provider of attributes used by this bus halt.
-
BusItineraryHalt
BusItineraryHalt(UUID id, BusItinerary itinerary, String name, BusItineraryHalt.BusItineraryHaltType type, AttributeCollection attributeProvider)
Create a bus halt.- Parameters:
id
- is the unique identifier of this element, ornull
if unknown.itinerary
- is the itinerary on which thus bus halt was located.name
- is the name of the new bus halttype
- is the type of the bus halt.attributeProvider
- is the provider of attributes used by this bus halt.- Since:
- 2.0
-
-
Method Detail
-
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<BusItinerary>
- Parameters:
buffer
- the Json buffer.
-
getFirstFreeBushaltName
@Pure public static String getFirstFreeBushaltName(BusItinerary busItinerary)
Replies a bus halt name that was not exist in the specified bus itinerary.- Parameters:
busItinerary
- is the bus itinerary for which a free bus halt name may be computed.- Returns:
- a name suitable for bus halt.
-
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.- Parameters:
fireEvents
- indicates if the events should be fired.- See Also:
BusPrimitive.rebuild()
-
getInvalidListIndex
@Pure public int getInvalidListIndex()
Replies the unique id in the sorted list of invalid halts.- Returns:
- the id.
-
setInvalidListIndex
void setInvalidListIndex(int id)
Set the unique id in the sorted list of invalid halts.- Parameters:
id
- the index.
-
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<BusItinerary>
- See Also:
AbstractBusPrimitive.revalidate()
-
fireValidityChangedFor
protected void fireValidityChangedFor(Object changedObject, int index, BusPrimitiveInvalidity oldReason, BusPrimitiveInvalidity newReason)
Description copied from class:AbstractBusPrimitive
Fire the event that indicates the validity of the object has changed.- Overrides:
fireValidityChangedFor
in classAbstractBusPrimitive<BusItinerary>
- Parameters:
changedObject
- is the object for which the validity has changed.index
- is the index of the changedObject in its parent.oldReason
- is the old invalidity reason before the change.newReason
- is the current invalidity reason after the change.
-
getBusNetwork
@Pure public BusNetwork getBusNetwork()
Description copied from interface:BusPrimitive
Replies the bus network in which this primitive is.- Returns:
- the bus network in which this primitive is.
-
getBusStop
@Pure public BusStop getBusStop()
Replies the bus stop associated to this halt.- Returns:
- the bus halt associated to this halt,
or
null
if this halt is not associated to a bus halt.
-
setBusStop
public boolean setBusStop(BusStop busStop)
Set the bus stop associated to this halt.- Parameters:
busStop
- is the bus stop associated to this halt, ornull
if this halt is not associated to a bus stop.- Returns:
true
if the bus stop was correctly set, otherwisefalse
.
-
setName
public void setName(String name)
Set the name of the element.- Specified by:
setName
in interfaceGISEditable
- Specified by:
setName
in interfaceGISElement
- Overrides:
setName
in classAbstractGISElement<BusItinerary,AbstractBusPrimitive<BusItinerary>>
- Parameters:
name
- the name.
-
clearPositionBuffers
protected void clearPositionBuffers()
Clear internal buffers related to the bus halt position.
-
getPosition2D
@Pure public Point2d getPosition2D()
Replies the position of the bus halt on the road. The replied position may differ from the position of the associated bus stop because the position on the road is a projection of the stop's position on the road.- Returns:
- the 2D position or
null
if the halt is not associated to a road segment.
-
getPosition1D
@Pure public Point1d getPosition1D()
Replies the position of the bus halt on the road. The replied position may differ from the position of the associated bus stop because the position on the road is a projection of the stop's position on the road.- Returns:
- the 1.5D position or
null
if the halt is not associated to a road segment.
-
getRoadSegment
@Pure public RoadSegment getRoadSegment()
Replies the road segment on which this bus halt was.- Returns:
- the road segment
-
getRoadSegmentIndex
@Pure public int getRoadSegmentIndex()
Replies the index of the road segment on which this bus halt was.- Returns:
- the index of the road segment in the itinerary.
-
setRoadSegmentIndex
void setRoadSegmentIndex(int idx)
Set the index of the road segment on which this bus halt was.- Parameters:
idx
- is the index of the road segment
-
getPositionOnSegment
@Pure public double getPositionOnSegment()
Replies the position on the segment.- Returns:
- the curviline distance on the segment from its first point.
-
setPositionOnSegment
void setPositionOnSegment(double position)
Set the position on the segment. The position is the curviline distance on the segment.This function does not check the validity of the halt.
- Parameters:
position
- is the position on the segment.
-
getRoadSegmentDirection
@Pure public Direction1D getRoadSegmentDirection()
Replies on which direction the bus halt is located on the road segment.
-
getType
@Pure public BusItineraryHalt.BusItineraryHaltType getType()
Replies the type of the bus halt.- Returns:
- the type of the bus.
-
setType
public void setType(BusItineraryHalt.BusItineraryHaltType type)
Set the type of the bus halt.- Parameters:
type
- the type of the bus.
-
isTerminus
@Pure public boolean isTerminus()
Replies if this bus halt is a terminus (aka. first or last bus halt) of an itinerary.- Returns:
true
if the bus halt is a terminus, 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<BusItinerary>
- Returns:
- the index of this primitive in its parent.
-
isStartingBusHalt
@Pure public boolean isStartingBusHalt()
Replies if this bus halt is a starting bus halt (aka. first bus halt) of an itinerary.- Returns:
true
if the bus halt is a starting bus halt, otherwisefalse
-
isEndingBusHalt
@Pure public boolean isEndingBusHalt()
Replies if this bus halt is a ending bus halt (aka. last bus halt) of an itinerary.- Returns:
true
if the bus halt is a ending bus halt, otherwisefalse
-
insideBusHub
@Pure public boolean insideBusHub()
Replies if this bus halt is inside a hub throught an associated bus stop.- Returns:
true
if this bus stop is inside a hub, otherwisefalse
-
busHubs
@Pure public Iterable<BusHub> busHubs()
Replies the hubs in which this bus halt is located in throught an associated bus stop.- Returns:
- the hubs
-
busHubIterator
@Pure public Iterator<BusHub> busHubIterator()
Replies the hubs in which this bus stop is located in throught an associated bus stop.- Returns:
- the hubs
-
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<BusItinerary,AbstractBusPrimitive<BusItinerary>>
- 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.- Returns:
- the shape or
null
if not applicable.
-
getGeoLocation
@Pure public final GeoLocation getGeoLocation()
Description copied from interface:GISPrimitive
Replies the geo-location.A GeoLocation is unique according to the geo-location of the element. If two elements have the same points in the same order, or if two elements have the same points in a reverse order, they must have equal GeoLocations.
The following code is always true (where the arguments of the constructors are the list of points of the polyline). It illustrates that for two elements with the same geo-localized points, they have the same geo-location identifier (Geo-Id) and they have different unique ientifier (Uid):
GISElement obj1 = new MapPolyline(100,10,200,30,300,4); GISElement obj2 = new MapPolyline(100,10,200,30,300,4); assert( obj1.getGeoId().equals(obj2.getGeoId()) ); assert( obj2.getGeoId().equals(obj1.getGeoId()) ); assert( ! obj1.getUid().equals(obj2.getUid()) ); assert( ! obj2.getUid().equals(obj1.getUid()) );
- Specified by:
getGeoLocation
in interfaceGISPrimitive
- Overrides:
getGeoLocation
in classAbstractBusPrimitive<BusItinerary>
- Returns:
- a location
- See Also:
GISPrimitive.getGeoId()
,GISPrimitive.getGeoLocation()
-
getGeoPosition
@Pure public GeoLocationPoint getGeoPosition()
Replies the geo position.- Returns:
- the geo position.
-
distanceToBusStop
@Pure public double distanceToBusStop()
Replies the distance between the position of this bus itinerary halt and the position of the bus stop associated to this bus itinerary halt.- Returns:
- the distance between the position of this bus itinerary halt and the position of the bus stop associated to this bus itinerary halt.
- Since:
- 2.0
-
distance
@Pure public double distance(double x, double y)
Replies the distance between the given point and this bus halt.- Parameters:
x
- x coordinate.y
- y coordinate.- Returns:
- the distance to this bus halt
-
distance
@Pure public double distance(Point2D<?,?> point)
Replies the distance between the given point and this bus halt.- Parameters:
point
- the point- Returns:
- the distance to this bus halt
-
distance
@Pure public double distance(BusItineraryHalt halt)
Replies the distance between the given bus halt and this bus halt.- Parameters:
halt
- the halt.- Returns:
- the distance to this bus halt
-
distance
@Pure public double distance(BusStop busStop)
Replies the distance between the given bus stop and this bus halt.- Parameters:
busStop
- the stop.- Returns:
- the distance to this bus halt
-
distance
@Pure public double distance(GeoLocationPoint point)
Replies the distance between the given point and this bus halt.- Parameters:
point
- the point- Returns:
- the distance to this bus halt
-
-