Package org.planit.graph
Class EdgeImpl
- java.lang.Object
-
- org.planit.graph.EdgeImpl
-
- All Implemented Interfaces:
Serializable
,Comparable<Edge>
,Edge
- Direct Known Subclasses:
ConnectoidImpl
,LinkImpl
public class EdgeImpl extends Object implements Edge
Edge class connecting two vertices via some geometry. Each edge has one or two underlying edge segments in a particular direction which may carry additional information for each particular direction of the edge.- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected EdgeSegment
edgeSegmentAB
Edge segment A to B directionprotected EdgeSegment
edgeSegmentBA
Edge segment B to A directionprotected long
id
Unique internal identifierprotected Map<String,Object>
inputProperties
Generic input property storageprotected double
length
Length of edgeprotected String
name
Name of the edgeprotected Vertex
vertexA
Vertex Aprotected Vertex
vertexB
Vertex B
-
Constructor Summary
Constructors Modifier Constructor Description protected
EdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double length)
Constructor which injects link lengths directly
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInputProperty(String key, Object value)
Add a property from the original input that is not part of the readily available link membersint
compareTo(Edge o)
protected static long
generateEdgeId(IdGroupingToken groupId)
Generate edge idEdgeSegment
getEdgeSegmentAB()
Edge segment in the direction from A to BEdgeSegment
getEdgeSegmentBA()
Edge segment in the direction from B to Along
getId()
Return id of this instance.Object
getInputProperty(String key)
Get input property by its keydouble
getLength()
Return length of this edge in kmString
getName()
collect the name of the edgeVertex
getVertexA()
Vertex A of the edgeVertex
getVertexB()
Vertex B of the edgeprotected EdgeSegment
registerEdgeSegment(EdgeSegment edgeSegment, boolean directionAB)
Register EdgeSegment.void
setName(String name)
set the name of this edge
-
-
-
Field Detail
-
id
protected final long id
Unique internal identifier
-
name
protected String name
Name of the edge
-
vertexA
protected Vertex vertexA
Vertex A
-
vertexB
protected Vertex vertexB
Vertex B
-
length
protected double length
Length of edge
-
edgeSegmentAB
protected EdgeSegment edgeSegmentAB
Edge segment A to B direction
-
edgeSegmentBA
protected EdgeSegment edgeSegmentBA
Edge segment B to A direction
-
-
Constructor Detail
-
EdgeImpl
protected EdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double length) throws PlanItException
Constructor which injects link lengths directly- Parameters:
groupId
- , contiguous id generation within this group for instances of this classvertexA
- first vertex in the linkvertexB
- second vertex in the linklength
- length of the link- Throws:
PlanItException
- thrown if there is an error
-
-
Method Detail
-
generateEdgeId
protected static long generateEdgeId(IdGroupingToken groupId)
Generate edge id- Parameters:
groupId
- , contiguous id generation within this group for instances of this class- Returns:
- id of this Edge object
-
registerEdgeSegment
protected EdgeSegment registerEdgeSegment(EdgeSegment edgeSegment, boolean directionAB) throws PlanItException
Register EdgeSegment. If there already exists an edgeSegment for that direction it is replaced and returned- Parameters:
edgeSegment
- EdgeSegment to be registereddirectionAB
- direction of travel- Returns:
- replaced LinkSegment
- Throws:
PlanItException
- thrown if there is an error
-
addInputProperty
public void addInputProperty(String key, Object value)
Add a property from the original input that is not part of the readily available link members- Specified by:
addInputProperty
in interfaceEdge
- Parameters:
key
- key (name) of input propertyvalue
- value of input property
-
getInputProperty
public Object getInputProperty(String key)
Get input property by its key- Specified by:
getInputProperty
in interfaceEdge
- Parameters:
key
- key of input property- Returns:
- value retrieved value of input property
-
getLength
public double getLength()
Return length of this edge in km
-
getId
public long getId()
Return id of this instance. This id is expected to be generated using the org.planit.utils.misc.IdGenerator
-
getVertexA
public Vertex getVertexA()
Vertex A of the edge- Specified by:
getVertexA
in interfaceEdge
- Returns:
- vertex A
-
getVertexB
public Vertex getVertexB()
Vertex B of the edge- Specified by:
getVertexB
in interfaceEdge
- Returns:
- vertex B
-
getName
public String getName()
collect the name of the edge
-
setName
public void setName(String name)
set the name of this edge- Parameters:
name
- the name of this edge
-
getEdgeSegmentAB
public EdgeSegment getEdgeSegmentAB()
Edge segment in the direction from A to B- Specified by:
getEdgeSegmentAB
in interfaceEdge
- Returns:
- edge segment AB
-
getEdgeSegmentBA
public EdgeSegment getEdgeSegmentBA()
Edge segment in the direction from B to A- Specified by:
getEdgeSegmentBA
in interfaceEdge
- Returns:
- edge segment BA
-
compareTo
public int compareTo(Edge o)
- Specified by:
compareTo
in interfaceComparable<Edge>
-
-