Package org.planit.graph
Class EdgeImpl
- java.lang.Object
-
- org.planit.graph.EdgeImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Idable>
,Edge
,ExternalIdable
,Idable
- Direct Known Subclasses:
DirectedEdgeImpl
public class EdgeImpl extends Object implements Edge, Cloneable
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 String
externalId
External Id of the physical linkprotected Map<String,Object>
inputProperties
Generic input property storageprotected double
lengthInKm
Length of edgeprotected org.locationtech.jts.geom.LineString
lineGeometry
The line geometry of this link if setprotected String
name
Name of the edgeprotected String
xmlId
Xml Id of the physical link
-
Constructor Summary
Constructors Modifier Constructor Description protected
EdgeImpl(EdgeImpl edgeImpl)
Copy constructor, input properties are not copied because shallow copy is considered dangerous at this pointprotected
EdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double lengthKm)
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 membersEdgeImpl
clone()
Clone the edge as is, all shared members are shallow copied, fully owned members are deep copiedboolean
equals(Object obj)
protected static long
generateEdgeId(IdGroupingToken groupId)
Generate edge idString
getExternalId()
get external id of the entityorg.locationtech.jts.geom.LineString
getGeometry()
Collect the geometry of this linelong
getId()
collect id of the entityObject
getInputProperty(String key)
Get input property by its keydouble
getLengthKm()
Return length of this edge in kmString
getName()
get the name of the edgeVertex
getVertexA()
Vertex A of the edgeVertex
getVertexB()
Vertex B of the edgeString
getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml formatboolean
hasExternalId()
check if external id is available or notint
hashCode()
boolean
removeVertex(Vertex vertex)
Remove vertex from edgeboolean
removeVertexA()
remove vertex A by setting it to nullboolean
removeVertexB()
remove vertex B by setting it to nullboolean
replace(Vertex vertexToReplace, Vertex vertexToReplaceWith)
Replace one of the vertices of the linkvoid
setExternalId(String externalId)
set the external idvoid
setGeometry(org.locationtech.jts.geom.LineString lineString)
set the geometry of this link as a line stringprotected void
setId(long id)
set id on this edgevoid
setLengthKm(double lengthInKm)
set length of this edge in kmvoid
setName(String name)
set the name of the edgeprotected void
setVertexA(Vertex vertexA)
set vertex Aprotected void
setVertexB(Vertex vertexB)
set vertex Bvoid
setXmlId(String xmlId)
set the external idboolean
validate()
validate the contents of this edge-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.graph.Edge
hasGeometry, hasVertex, isGeometryInAbDirection, transformGeometry
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
hasXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
externalId
protected String externalId
External Id of the physical link
-
xmlId
protected String xmlId
Xml Id of the physical link
-
lineGeometry
protected org.locationtech.jts.geom.LineString lineGeometry
The line geometry of this link if set
-
name
protected String name
Name of the edge
-
lengthInKm
protected double lengthInKm
Length of edge
-
-
Constructor Detail
-
EdgeImpl
protected EdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double lengthKm) 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 linklengthKm
- length of the link- Throws:
PlanItException
- thrown if there is an error
-
EdgeImpl
protected EdgeImpl(EdgeImpl edgeImpl)
Copy constructor, input properties are not copied because shallow copy is considered dangerous at this point- Parameters:
edgeImpl
- to copy
-
-
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
-
setId
protected void setId(long id)
set id on this edge- Parameters:
id
- to set
-
setVertexB
protected void setVertexB(Vertex vertexB)
set vertex B- Parameters:
vertexB
- to set
-
setVertexA
protected void setVertexA(Vertex vertexA)
set vertex A- Parameters:
vertexA
- to set
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalId
in interfaceExternalIdable
- Parameters:
externalId
- to set
-
getExternalId
public String getExternalId()
get external id of the entity- Specified by:
getExternalId
in interfaceExternalIdable
- Returns:
- external id
-
getXmlId
public String getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml format- Specified by:
getXmlId
in interfaceExternalIdable
- Returns:
- xmlId
-
setXmlId
public void setXmlId(String xmlId)
set the external id- Specified by:
setXmlId
in interfaceExternalIdable
- Parameters:
xmlId
- to set
-
hasExternalId
public boolean hasExternalId()
check if external id is available or not- Specified by:
hasExternalId
in interfaceExternalIdable
- Returns:
- true when nont null, false otherwise
-
getGeometry
public org.locationtech.jts.geom.LineString getGeometry()
Collect the geometry of this line- Specified by:
getGeometry
in interfaceEdge
- Returns:
- lineString
-
setGeometry
public void setGeometry(org.locationtech.jts.geom.LineString lineString)
set the geometry of this link as a line string- Specified by:
setGeometry
in interfaceEdge
- Parameters:
lineString
- to set
-
removeVertex
public boolean removeVertex(Vertex vertex)
Remove vertex from edge- Specified by:
removeVertex
in interfaceEdge
- Parameters:
vertex
- to remove- Returns:
- true when successful false otherwise
-
removeVertexB
public boolean removeVertexB()
remove vertex B by setting it to null- Returns:
- true
-
removeVertexA
public boolean removeVertexA()
remove vertex A by setting it to null- Returns:
- true
-
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
- (name) of input propertyvalue
- of input property
-
getInputProperty
public Object getInputProperty(String key)
Get input property by its key- Specified by:
getInputProperty
in interfaceEdge
- Parameters:
key
- of input property- Returns:
- value retrieved value of input property
-
getLengthKm
public double getLengthKm()
Return length of this edge in km- Specified by:
getLengthKm
in interfaceEdge
- Returns:
- length of this edge in km
-
setLengthKm
public void setLengthKm(double lengthInKm)
set length of this edge in km- Specified by:
setLengthKm
in interfaceEdge
- Parameters:
lengthInKm
- of this edge in km
-
getId
public long getId()
collect id of the entity
-
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()
get the name of the edge
-
setName
public void setName(String name)
set the name of the edge
-
replace
public boolean replace(Vertex vertexToReplace, Vertex vertexToReplaceWith) throws PlanItException
Replace one of the vertices of the link- Specified by:
replace
in interfaceEdge
- Parameters:
vertexToReplace
- the vertex to replacevertexToReplaceWith
- the vertex to replace with- Returns:
- true when replaced, false otherwise
- Throws:
PlanItException
- thrown if error
-
clone
public EdgeImpl clone()
Clone the edge as is, all shared members are shallow copied, fully owned members are deep copied
-
-