Class MacroscopicPhysicalNetworkBuilderImpl
- java.lang.Object
-
- org.planit.network.macroscopic.physical.MacroscopicPhysicalNetworkBuilderImpl
-
- All Implemented Interfaces:
DirectedGraphBuilder<Node,Link,MacroscopicLinkSegment>
,GraphBuilder<Node,Link>
,MacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
,PhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
public class MacroscopicPhysicalNetworkBuilderImpl extends Object implements MacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
Create network entities for a macroscopic simulation model- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description protected PhysicalNetworkBuilderImpl
physicalNetworkBuilder
use physical network builder to create all but link segments
-
Constructor Summary
Constructors Constructor Description MacroscopicPhysicalNetworkBuilderImpl(IdGroupingToken groupId)
constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Link
createEdge(Vertex nodeA, Vertex nodeB, double length)
Create a new link instanceMacroscopicLinkSegment
createEdgeSegment(DirectedEdge parentLink, boolean directionAB)
Create a new physical link segment instanceMacroscopicLinkSegmentType
createLinkSegmentType(String name, double capacity, double maximumDensity)
Create a macroscopic link segment type instance without mode propertiesMacroscopicLinkSegmentType
createLinkSegmentType(String name, double capacity, double maximumDensity, Map<Mode,MacroscopicModeProperties> modeProperties)
Create a fully functional macroscopic link segment type instanceLink
createUniqueCopyOf(Link linkToCopy)
create a shallo copy of the passed in edge, albeit with unique internal idsMacroscopicLinkSegment
createUniqueCopyOf(MacroscopicLinkSegment linkSegmentToCopy, DirectedEdge parentEdge)
Create a unique copy of the passed in edge segment.MacroscopicLinkSegmentType
createUniqueCopyOf(MacroscopicLinkSegmentType linkSegmentTypeToCopy)
create a copy of the passed in link segment type where only the unique identifiers are differentNode
createVertex()
Create a new vertex instanceIdGroupingToken
getIdGroupingToken()
Collect the id grouping token used by this buildervoid
recreateIds(Edges<? extends Link> links)
recreate the ids for all passed in edgesvoid
recreateIds(EdgeSegments<? extends MacroscopicLinkSegment> macroscopicinkSegments)
recreate the ids for all passed in edge segmentsvoid
recreateIds(Vertices<? extends Node> nodes)
recreate the ids for all passed in verticesvoid
setIdGroupingToken(IdGroupingToken groupId)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to
-
-
-
Field Detail
-
physicalNetworkBuilder
protected final PhysicalNetworkBuilderImpl physicalNetworkBuilder
use physical network builder to create all but link segments
-
-
Constructor Detail
-
MacroscopicPhysicalNetworkBuilderImpl
public MacroscopicPhysicalNetworkBuilderImpl(IdGroupingToken groupId)
constructor- Parameters:
groupId
- to use for id generation
-
-
Method Detail
-
createLinkSegmentType
public MacroscopicLinkSegmentType createLinkSegmentType(String name, double capacity, double maximumDensity, Map<Mode,MacroscopicModeProperties> modeProperties)
Create a fully functional macroscopic link segment type instance- Specified by:
createLinkSegmentType
in interfaceMacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
name
- the name of this link typecapacity
- the capacity of this link typemaximumDensity
- the maximum density of this link typemodeProperties
- the mode properties for each mode along this link- Returns:
- macroscopicLinkSegmentType the created link segment type
-
createLinkSegmentType
public MacroscopicLinkSegmentType createLinkSegmentType(String name, double capacity, double maximumDensity)
Create a macroscopic link segment type instance without mode properties- Specified by:
createLinkSegmentType
in interfaceMacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
name
- the name of this link typecapacity
- the capacity of this link typemaximumDensity
- the maximum density of this link type- Returns:
- macroscopicLinkSegmentType the created link segment type
-
createEdgeSegment
public MacroscopicLinkSegment createEdgeSegment(DirectedEdge parentLink, boolean directionAB) throws PlanItException
Create a new physical link segment instance- Specified by:
createEdgeSegment
in interfaceDirectedGraphBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
parentLink
- the parent edge of the edge segmentdirectionAB
- direction of travel- Returns:
- edgeSegment the created edge segment
- Throws:
PlanItException
- thrown if error
-
createVertex
public Node createVertex()
Create a new vertex instance- Specified by:
createVertex
in interfaceGraphBuilder<Node,Link>
- Returns:
- created vertex
-
createEdge
public Link createEdge(Vertex nodeA, Vertex nodeB, double length) throws PlanItException
Create a new link instance- Specified by:
createEdge
in interfaceGraphBuilder<Node,Link>
- Parameters:
nodeA
- the first vertex in this edgenodeB
- the second vertex in this edgelength
- the length (in km)- Returns:
- created edge
- Throws:
PlanItException
- thrown if there is an error
-
setIdGroupingToken
public void setIdGroupingToken(IdGroupingToken groupId)
Each builder needs a group if token to allow all underlying factory methods to generated ids uniquely tied to the group the entities belong to- Specified by:
setIdGroupingToken
in interfaceGraphBuilder<Node,Link>
- Parameters:
groupId
- , contiguous id generation within this group for instances created with the factory methods
-
getIdGroupingToken
public IdGroupingToken getIdGroupingToken()
Collect the id grouping token used by this builder- Specified by:
getIdGroupingToken
in interfaceGraphBuilder<Node,Link>
- Returns:
- idGroupingToken the id grouping token used by this builder
-
recreateIds
public void recreateIds(EdgeSegments<? extends MacroscopicLinkSegment> macroscopicinkSegments)
recreate the ids for all passed in edge segments- Specified by:
recreateIds
in interfaceDirectedGraphBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
macroscopicinkSegments
- to recreate ids for
-
recreateIds
public void recreateIds(Edges<? extends Link> links)
recreate the ids for all passed in edges- Specified by:
recreateIds
in interfaceGraphBuilder<Node,Link>
- Parameters:
links
- to recreate ids for
-
recreateIds
public void recreateIds(Vertices<? extends Node> nodes)
recreate the ids for all passed in vertices- Specified by:
recreateIds
in interfaceGraphBuilder<Node,Link>
- Parameters:
nodes
- to recreate ids for
-
createUniqueCopyOf
public Link createUniqueCopyOf(Link linkToCopy)
create a shallo copy of the passed in edge, albeit with unique internal ids- Specified by:
createUniqueCopyOf
in interfaceGraphBuilder<Node,Link>
- Parameters:
linkToCopy
- the edge to copy- Returns:
- new edge based on passed in edge
-
createUniqueCopyOf
public MacroscopicLinkSegment createUniqueCopyOf(MacroscopicLinkSegment linkSegmentToCopy, DirectedEdge parentEdge)
Create a unique copy of the passed in edge segment. All members are copied as is, except for its ids which are created uniquely created so it remains identifiable, also the parent edge is updated if required- Specified by:
createUniqueCopyOf
in interfaceDirectedGraphBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
linkSegmentToCopy
- edge segment to copyparentEdge
- use this as the new parent edge- Returns:
- created copy
-
createUniqueCopyOf
public MacroscopicLinkSegmentType createUniqueCopyOf(MacroscopicLinkSegmentType linkSegmentTypeToCopy)
create a copy of the passed in link segment type where only the unique identifiers are different- Specified by:
createUniqueCopyOf
in interfaceMacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>
- Parameters:
linkSegmentTypeToCopy
- to create a unique copy of- Returns:
- copy of passed on link segment type with unique id
-
-