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 PhysicalNetworkBuilderImplphysicalNetworkBuilderuse 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 LinkcreateEdge(Vertex nodeA, Vertex nodeB, double length)Create a new link instanceMacroscopicLinkSegmentcreateEdgeSegment(DirectedEdge parentLink, boolean directionAB)Create a new physical link segment instanceMacroscopicLinkSegmentTypecreateLinkSegmentType(String name, double capacity, double maximumDensity)Create a macroscopic link segment type instance without mode propertiesMacroscopicLinkSegmentTypecreateLinkSegmentType(String name, double capacity, double maximumDensity, Map<Mode,MacroscopicModeProperties> modeProperties)Create a fully functional macroscopic link segment type instanceLinkcreateUniqueCopyOf(Link linkToCopy)create a shallo copy of the passed in edge, albeit with unique internal idsMacroscopicLinkSegmentcreateUniqueCopyOf(MacroscopicLinkSegment linkSegmentToCopy, DirectedEdge parentEdge)Create a unique copy of the passed in edge segment.MacroscopicLinkSegmentTypecreateUniqueCopyOf(MacroscopicLinkSegmentType linkSegmentTypeToCopy)create a copy of the passed in link segment type where only the unique identifiers are differentNodecreateVertex()Create a new vertex instanceIdGroupingTokengetIdGroupingToken()Collect the id grouping token used by this buildervoidrecreateIds(Edges<? extends Link> links)recreate the ids for all passed in edgesvoidrecreateIds(EdgeSegments<? extends MacroscopicLinkSegment> macroscopicinkSegments)recreate the ids for all passed in edge segmentsvoidrecreateIds(Vertices<? extends Node> nodes)recreate the ids for all passed in verticesvoidsetIdGroupingToken(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:
createLinkSegmentTypein 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:
createLinkSegmentTypein 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:
createEdgeSegmentin 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:
createVertexin 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:
createEdgein 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:
setIdGroupingTokenin 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:
getIdGroupingTokenin 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:
recreateIdsin 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:
recreateIdsin 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:
recreateIdsin 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:
createUniqueCopyOfin 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:
createUniqueCopyOfin 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:
createUniqueCopyOfin interfaceMacroscopicPhysicalNetworkBuilder<Node,Link,MacroscopicLinkSegment>- Parameters:
linkSegmentTypeToCopy- to create a unique copy of- Returns:
- copy of passed on link segment type with unique id
-
-