Package org.planit.network.physical
Class PhysicalNetwork<N extends Node,L extends Link,LS extends LinkSegment>
- java.lang.Object
-
- org.planit.network.InfrastructureLayerImpl
-
- org.planit.network.physical.PhysicalNetwork<N,L,LS>
-
- All Implemented Interfaces:
Comparable<Idable>
,InfrastructureLayer
,ExternalIdable
,Idable
- Direct Known Subclasses:
MacroscopicPhysicalNetwork
public class PhysicalNetwork<N extends Node,L extends Link,LS extends LinkSegment> extends InfrastructureLayerImpl implements InfrastructureLayer
Model free Network consisting of nodes and links, each of which can be iterated over. This network does not contain any transport specific information, hence the qualification "model free".- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description Links<L>
links
class instance containing all link specific functionalityLinkSegments<LS>
linkSegments
class instance containing all link segment specific functionalityNodes<N>
nodes
class instance containing all nodes specific functionality-
Fields inherited from class org.planit.network.InfrastructureLayerImpl
externalId, id, supportedModes, xmlId
-
-
Constructor Summary
Constructors Constructor Description PhysicalNetwork(IdGroupingToken tokenId, PhysicalNetworkBuilder<N,L,LS> networkBuilder)
Network Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Long,Set<L>>
breakLinkAt(L linkToBreak, N nodeToBreakAt, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Break the passed in link by inserting the passed in node in between.Map<Long,Set<L>>
breakLinksAt(List<? extends L> linksToBreak, N nodeToBreakAt, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Break the passed in links by inserting the passed in node in between.protected DirectedGraph<N,L,LS>
getGraph()
collect the graphLinks<L>
getLinks()
alternative to using the links public memberLinkSegments<LS>
getLinkSegments()
alternative to using the linkSegments public memberprotected PhysicalNetworkBuilder<N,L,LS>
getNetworkBuilder()
collect the registered network builderIdGroupingToken
getNetworkIdGroupingToken()
Collect the id grouping token used for all entities registered on the network, i.e., this network's specific identifier for generating ids unique and contiguous within this network and this network onlyNodes<N>
getNodes()
alternative to using the nodes public memberboolean
isEmpty()
check if network is empty, meaning not a single link, node, or link segment is registered yetvoid
logInfo(String prefix)
invoked by entities inquiring about general information about the layer to display to usersvoid
removeDanglingSubnetworks()
remove any dangling subnetworks from the network if they exist and subsequently reorder the internal ids if neededvoid
removeDanglingSubnetworks(Integer belowSize, Integer aboveSize, boolean alwaysKeepLargest)
remove any dangling subnetworks below a given size from the network if they exist and subsequently reorder the internal ids if neededvoid
transform(org.opengis.referencing.crs.CoordinateReferenceSystem fromCoordinateReferenceSystem, org.opengis.referencing.crs.CoordinateReferenceSystem toCoordinateReferenceSystem)
transform all underlying geometries in the layer from the given crs to the new crsboolean
validate()
Basic validation of the network verifying if all nodes and link s are properly set and connected-
Methods inherited from class org.planit.network.InfrastructureLayerImpl
generateId, getExternalId, getId, getSupportedModes, getXmlId, registerSupportedMode, registerSupportedModes, setExternalId, setId, setXmlId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.id.ExternalIdable
getExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.planit.network.InfrastructureLayer
getSupportedModes, registerSupportedMode, registerSupportedModes, supports
-
-
-
-
Field Detail
-
links
public final Links<L extends Link> links
class instance containing all link specific functionality
-
linkSegments
public final LinkSegments<LS extends LinkSegment> linkSegments
class instance containing all link segment specific functionality
-
-
Constructor Detail
-
PhysicalNetwork
public PhysicalNetwork(IdGroupingToken tokenId, PhysicalNetworkBuilder<N,L,LS> networkBuilder)
Network Constructor- Parameters:
tokenId
- contiguous id generation within this group for instances of this classnetworkBuilder
- the builder to be used to create this network
-
-
Method Detail
-
getGraph
protected DirectedGraph<N,L,LS> getGraph()
collect the graph- Returns:
- graph
-
getNetworkBuilder
protected PhysicalNetworkBuilder<N,L,LS> getNetworkBuilder()
collect the registered network builder- Returns:
- networkBuilder the network builder registered
-
getLinks
public final Links<L> getLinks()
alternative to using the links public member- Returns:
- the links
-
getLinkSegments
public final LinkSegments<LS> getLinkSegments()
alternative to using the linkSegments public member- Returns:
- the linkSegments
-
getNodes
public final Nodes<N> getNodes()
alternative to using the nodes public member- Returns:
- the nodes
-
getNetworkIdGroupingToken
public IdGroupingToken getNetworkIdGroupingToken()
Collect the id grouping token used for all entities registered on the network, i.e., this network's specific identifier for generating ids unique and contiguous within this network and this network only- Returns:
- the network id grouping token
-
transform
public void transform(org.opengis.referencing.crs.CoordinateReferenceSystem fromCoordinateReferenceSystem, org.opengis.referencing.crs.CoordinateReferenceSystem toCoordinateReferenceSystem) throws PlanItException
transform all underlying geometries in the layer from the given crs to the new crs- Specified by:
transform
in interfaceInfrastructureLayer
- Parameters:
fromCoordinateReferenceSystem
- presumed current crstoCoordinateReferenceSystem
- to tranform to crs- Throws:
PlanItException
- thrown if error
-
isEmpty
public boolean isEmpty()
check if network is empty, meaning not a single link, node, or link segment is registered yet- Specified by:
isEmpty
in interfaceInfrastructureLayer
- Returns:
- true if empty fals otherwise
-
removeDanglingSubnetworks
public void removeDanglingSubnetworks() throws PlanItException
remove any dangling subnetworks from the network if they exist and subsequently reorder the internal ids if needed- Specified by:
removeDanglingSubnetworks
in interfaceInfrastructureLayer
- Throws:
PlanItException
- thrown if error
-
removeDanglingSubnetworks
public void removeDanglingSubnetworks(Integer belowSize, Integer aboveSize, boolean alwaysKeepLargest) throws PlanItException
remove any dangling subnetworks below a given size from the network if they exist and subsequently reorder the internal ids if needed- Specified by:
removeDanglingSubnetworks
in interfaceInfrastructureLayer
- Parameters:
belowSize
- remove subnetworks below the given sizeaboveSize
- remove subnetworks above the given size (typically set to maximum value)alwaysKeepLargest
- when true the largest of the subnetworks is always kept, otherwise not- Throws:
PlanItException
- thrown if error
-
breakLinkAt
public Map<Long,Set<L>> breakLinkAt(L linkToBreak, N nodeToBreakAt, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws PlanItException
Break the passed in link by inserting the passed in node in between. After completion the original links remain as (NodeA,NodeToBreakAt), and new links as inserted for (NodeToBreakAt,NodeB). Underlying link segments (if any) are also updated accordingly in the same manner- Parameters:
linkToBreak
- the link to breaknodeToBreakAt
- the node to break atcrs
- to use to recompute link lengths of broken links- Returns:
- the broken edges for each original edge's id
- Throws:
PlanItException
- thrown if error
-
breakLinksAt
public Map<Long,Set<L>> breakLinksAt(List<? extends L> linksToBreak, N nodeToBreakAt, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws PlanItException
Break the passed in links by inserting the passed in node in between. After completion the original links remain as (NodeA,NodeToBreakAt), and new links as inserted for (NodeToBreakAt,NodeB). Underlying link segments (if any) are also updated accordingly in the same manner- Parameters:
linksToBreak
- the links to breaknodeToBreakAt
- the node to break atcrs
- to use to recompute link lengths of broken links- Returns:
- the broken edges for each original edge's id
- Throws:
PlanItException
- thrown if error
-
validate
public boolean validate()
Basic validation of the network verifying if all nodes and link s are properly set and connected- Specified by:
validate
in interfaceInfrastructureLayer
- Returns:
- true when valid, false otherwise
-
logInfo
public void logInfo(String prefix)
invoked by entities inquiring about general information about the layer to display to users- Specified by:
logInfo
in interfaceInfrastructureLayer
- Parameters:
prefix
- optional prefix to include in each line of logging
-
-