Package org.goplanit.graph
Class EdgeImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.graph.GraphEntityImpl
-
- org.goplanit.graph.EdgeImpl
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IdAble>,Edge,GraphEntity,ExternalIdAble,IdAble,ManagedId
- Direct Known Subclasses:
DirectedEdgeImpl
public class EdgeImpl 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>inputPropertiesGeneric input property storageprotected DoublelengthInKmLength of edgeprotected org.locationtech.jts.geom.LineStringlineGeometryThe line geometry of this link if setprotected StringnameName of the edge-
Fields inherited from interface org.goplanit.utils.graph.Edge
EDGE_ID_CLASS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEdgeImpl(EdgeImpl edgeImpl)Copy constructor, input properties are copied using serialisation/deserialisation because shallow copy is considered dangerousprotectedEdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB)Constructor which injects link lengths directlyprotectedEdgeImpl(IdGroupingToken groupId, Vertex vertexA, Vertex vertexB, double lengthKm)Constructor which injects link lengths directly
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInputProperty(String key, Object value)Add a property from the original input that is not part of the readily available link membersEdgeImplclone()Create a shallow copy of this entityorg.locationtech.jts.geom.LineStringgetGeometry()Collect the geometry of this lineObjectgetInputProperty(String key)Get input property by its keydoublegetLengthKm()Return length of this edge in kmStringgetName()get the name of the edgeVertexgetVertexA()Vertex A of the edgeVertexgetVertexB()Vertex B of the edgebooleanremoveVertex(Vertex vertex)Remove vertex from edgebooleanremoveVertexA()remove vertex A by setting it to nullbooleanremoveVertexB()remove vertex B by setting it to nullbooleanreplace(Vertex vertexToReplace, Vertex vertexToReplaceWith)Replace one of the vertices of the linkvoidsetGeometry(org.locationtech.jts.geom.LineString lineString)set the geometry of this link as a line stringvoidsetLengthKm(double lengthInKm)set length of this edge in kmvoidsetName(String name)set the name of the edgeprotected voidsetVertexA(Vertex vertexA)set vertex Aprotected voidsetVertexB(Vertex vertexB)set vertex Bbooleanvalidate()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
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.graph.Edge
createEnvelope, getIdClass, hasGeometry, hasName, hasVertex, isGeometryInAbDirection, transformGeometry
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
getExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, 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, Vertex vertexA, Vertex 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, Vertex vertexA, Vertex 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
-
EdgeImpl
protected EdgeImpl(EdgeImpl edgeImpl)
Copy constructor, input properties are copied using serialisation/deserialisation because shallow copy is considered dangerous- Parameters:
edgeImpl- to copy
-
-
Method Detail
-
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
-
getGeometry
public org.locationtech.jts.geom.LineString getGeometry()
Collect the geometry of this line- Specified by:
getGeometryin 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:
setGeometryin interfaceEdge- Parameters:
lineString- to set
-
removeVertex
public boolean removeVertex(Vertex vertex)
Remove vertex from edge- Specified by:
removeVertexin 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:
addInputPropertyin interfaceEdge- Parameters:
key- (name) of input propertyvalue- of input property
-
getInputProperty
public Object getInputProperty(String key)
Get input property by its key- Specified by:
getInputPropertyin 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:
getLengthKmin interfaceEdge- Returns:
- length of this edge in km
-
setLengthKm
public void setLengthKm(double lengthInKm)
set length of this edge in km- Specified by:
setLengthKmin interfaceEdge- Parameters:
lengthInKm- of this edge in km
-
getVertexA
public Vertex getVertexA()
Vertex A of the edge- Specified by:
getVertexAin interfaceEdge- Returns:
- vertex A
-
getVertexB
public Vertex getVertexB()
Vertex B of the edge- Specified by:
getVertexBin 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:
replacein 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()
Create a shallow copy of this entity
-
-