Package org.planit.graph
Class VertexImpl
- java.lang.Object
-
- org.planit.graph.VertexImpl
-
- All Implemented Interfaces:
Serializable
,Comparable<Idable>
,Vertex
,ExternalIdable
,Idable
- Direct Known Subclasses:
DirectedVertexImpl
public class VertexImpl extends Object implements Vertex
vertex representation connected to one or more entry and exit edges- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Long,Edge>
edges
Edges of this vertexprotected String
externalId
External identifier used in input filesprotected long
id
Unique internal identifierprotected Map<String,Object>
inputProperties
generic input property storageprotected org.locationtech.jts.geom.Point
position
Position of the vertex
-
Constructor Summary
Constructors Modifier Constructor Description protected
VertexImpl(VertexImpl vertexImpl)
Copy constructor (for now input properties are NOT copied, because a shallow copy of contents is dangerous).protected
VertexImpl(IdGroupingToken groupId)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(Edge edge)
Add edge, do not invoke when parsing networks, this connection is auto-populated before the assignment starts based on the edge and its two vertices that have been registered.void
addInputProperty(String key, Object value)
Add a property from the original input that is not part of the readily available membersVertexImpl
clone()
Clone the vertexprotected static long
generateVertexId(IdGroupingToken groupId)
generate unique node idCollection<Edge>
getEdges()
Returns a collection of Edge objectsSet<Edge>
getEdges(Vertex otherVertex)
colect the edge(s) based on the other vertexString
getExternalId()
get external id of the entitylong
getId()
#collect id of the entityObject
getInputProperty(String key)
Get input property by its keyint
getNumberOfEdges()
Number of entries in edge segmentsorg.locationtech.jts.geom.Point
getPosition()
#Collect the geometry of the point location of this vertexString
getXmlId()
the id exposed to users as the "normal" id in the PLANit native xml formatboolean
removeEdge(long edgeId)
Remove edgeboolean
removeEdge(Edge edge)
Remove edgevoid
setExternalId(String externalId)
set the external idprotected void
setId(Long id)
Set id on vertexvoid
setPosition(org.locationtech.jts.geom.Point position)
#Set the center point geometry for a vertexvoid
setXmlId(String xmlId)
set the external idboolean
validate()
validate the vertex regarding it connections to edges etc.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
hasExternalId, hasXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, idEquals, idHashCode
-
Methods inherited from interface org.planit.utils.graph.Vertex
replace, transformPosition
-
-
-
-
Field Detail
-
id
protected long id
Unique internal identifier
-
externalId
protected String externalId
External identifier used in input files
-
position
protected org.locationtech.jts.geom.Point position
Position of the vertex
-
-
Constructor Detail
-
VertexImpl
protected VertexImpl(IdGroupingToken groupId)
Constructor- Parameters:
groupId
- , contiguous id generation within this group for instances of this class
-
VertexImpl
protected VertexImpl(VertexImpl vertexImpl)
Copy constructor (for now input properties are NOT copied, because a shallow copy of contents is dangerous). Geometry is deep copied, edges are not because they are not owned by the vertex.- Parameters:
vertexImpl
- to copy
-
-
Method Detail
-
generateVertexId
protected static long generateVertexId(IdGroupingToken groupId)
generate unique node id- Parameters:
groupId
- , contiguous id generation within this group for instances of this class- Returns:
- nodeId
-
setId
protected void setId(Long id)
Set id on vertex- Parameters:
id
- to set
-
getPosition
public org.locationtech.jts.geom.Point getPosition()
#Collect the geometry of the point location of this vertex- Specified by:
getPosition
in interfaceVertex
- Returns:
- direct position reflecting point location
-
setPosition
public void setPosition(org.locationtech.jts.geom.Point position)
#Set the center point geometry for a vertex- Specified by:
setPosition
in interfaceVertex
- Parameters:
position
- the center point for a vertex
-
getId
public long getId()
#collect id of the entity
-
getExternalId
public String getExternalId()
get external id of the entity- Specified by:
getExternalId
in interfaceExternalIdable
- Returns:
- external id
-
setExternalId
public void setExternalId(String externalId)
set the external id- Specified by:
setExternalId
in interfaceExternalIdable
- Parameters:
externalId
- to set
-
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
-
addInputProperty
public void addInputProperty(String key, Object value)
Add a property from the original input that is not part of the readily available members- Specified by:
addInputProperty
in interfaceVertex
- Parameters:
key
- key (name) of the input propertyvalue
- value of the input property
-
getInputProperty
public Object getInputProperty(String key)
Get input property by its key- Parameters:
key
- the key of the input property- Returns:
- value the value of the input property
-
addEdge
public boolean addEdge(Edge edge)
Add edge, do not invoke when parsing networks, this connection is auto-populated before the assignment starts based on the edge and its two vertices that have been registered.
-
removeEdge
public boolean removeEdge(Edge edge)
Remove edge- Specified by:
removeEdge
in interfaceVertex
- Parameters:
edge
- Edge to be removed- Returns:
- true when removed, false when not present (and not removed)
-
removeEdge
public boolean removeEdge(long edgeId)
Description copied from interface:Vertex
Remove edge- Specified by:
removeEdge
in interfaceVertex
- Parameters:
edgeId
- Edge to be removed- Returns:
- true when removed, false when not present (and not removed)
-
getEdges
public Collection<Edge> getEdges()
Returns a collection of Edge objects
-
getNumberOfEdges
public int getNumberOfEdges()
Number of entries in edge segments- Specified by:
getNumberOfEdges
in interfaceVertex
- Returns:
- the number of edges connected to this vertex
-
getEdges
public Set<Edge> getEdges(Vertex otherVertex)
colect the edge(s) based on the other vertex
-
clone
public VertexImpl clone()
Clone the vertex
-
-