Package org.goplanit.graph
Class EdgeImpl<V extends Vertex>
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.graph.GraphEntityImpl
-
- org.goplanit.graph.EdgeImpl<V>
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,Edge
,GraphEntity
,ExternalIdAble
,IdAble
,ManagedId
- Direct Known Subclasses:
ConjugateEdgeImpl
,DirectedEdgeImpl
public class EdgeImpl<V extends Vertex> extends GraphEntityImpl 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 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 edge-
Fields inherited from interface org.goplanit.utils.graph.Edge
EDGE_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
EdgeImpl(EdgeImpl<V> other, boolean deepCopy)
Copy constructorprotected
EdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB)
Constructor which injects link lengths directlyprotected
EdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB, double lengthKm)
Constructor which injects link lengths directly
-
Method Summary
All 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<V>
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.org.locationtech.jts.geom.LineString
getGeometry()
Collect the geometry of this lineObject
getInputProperty(String key)
Get input property by its keydouble
getLengthKm()
Return length of this edge in kmString
getName()
get the name of the edgeV
getVertexA()
Vertex A of the edgeV
getVertexB()
Vertex B of the edgeboolean
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
setGeometry(org.locationtech.jts.geom.LineString lineString)
set the geometry of this link as a line stringvoid
setLengthKm(double lengthInKm)
set length of this edge in kmvoid
setName(String name)
set the name of the edgeprotected void
setVertexA(V vertexA)
set vertex Aprotected void
setVertexB(V vertexB)
set vertex BEdgeImpl<V>
shallowClone()
Create a shallow copy of this entityboolean
validate()
validate the contents of this edge-
Methods inherited from class org.goplanit.graph.GraphEntityImpl
generateAndSetId, generateId, recreateManagedIds, toString
-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.graph.Edge
createEnvelope, getIdClass, hasGeometry, hasName, hasVertex, hasVertexA, hasVertexB, hasVertices, isGeometryInAbDirection, isGeometryInAbDirection, isVertexA, populateBasicGeometry, transformGeometry, updateGeometryInjectCoordinateAtProjectedLocation
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
recreateManagedIds, resetChildManagedIdEntities
-
-
-
-
Constructor Detail
-
EdgeImpl
protected EdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB)
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 link
-
EdgeImpl
protected EdgeImpl(IdGroupingToken groupId, V vertexA, V vertexB, double lengthKm)
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
-
-
Method Detail
-
setVertexB
protected void setVertexB(V vertexB)
set vertex B- Parameters:
vertexB
- to set
-
setVertexA
protected void setVertexA(V vertexA)
set vertex A- Parameters:
vertexA
- to set
-
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
-
getVertexA
public V getVertexA()
Vertex A of the edge- Specified by:
getVertexA
in interfaceEdge
- Returns:
- vertex A
-
getVertexB
public V 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)
Replace one of the vertices of the link
-
shallowClone
public EdgeImpl<V> shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceEdge
- Specified by:
shallowClone
in interfaceGraphEntity
- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in classGraphEntityImpl
- Returns:
- shallow copy of entity
-
deepClone
public EdgeImpl<V> deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceEdge
- Specified by:
deepClone
in interfaceGraphEntity
- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in classGraphEntityImpl
- Returns:
- deep copy of entity
-
-