RoadNetwork

public class RoadNetwork

Routable road network built from the shapefiles.

Author:Milan Lovric

Fields

averageSpeedFerry

public double averageSpeedFerry

freeFlowSpeedARoad

public double freeFlowSpeedARoad

freeFlowSpeedMRoad

public double freeFlowSpeedMRoad

maximumEdgeID

public int maximumEdgeID

maximumNodeID

public int maximumNodeID

numberOfLanesARoadCollapsedDualCarriageway

public int numberOfLanesARoadCollapsedDualCarriageway

numberOfLanesARoadDualCarriageway

public int numberOfLanesARoadDualCarriageway

numberOfLanesARoadRoundabout

public int numberOfLanesARoadRoundabout

numberOfLanesARoadSingleCarriageway

public int numberOfLanesARoadSingleCarriageway

numberOfLanesARoadSlipRoad

public int numberOfLanesARoadSlipRoad

numberOfLanesMRoadCollapsedDualCarriageway

public int numberOfLanesMRoadCollapsedDualCarriageway

numberOfLanesMRoadDualCarriageway

public int numberOfLanesMRoadDualCarriageway

numberOfLanesMRoadSlipRoad

public int numberOfLanesMRoadSlipRoad

Constructors

RoadNetwork

public RoadNetwork(URL zonesUrl, URL networkUrl, URL nodesUrl, URL AADFurl, String areaCodeFileName, String areaCodeNearestNodeFile, String workplaceZoneFileName, String workplaceZoneNearestNodeFile, String freightZoneToLADfile, String freightZoneNearestNodeFile, Properties params)
Parameters:
  • zonesUrl – Url for the shapefile with zone polygons.
  • networkUrl – Url for the shapefile with road network.
  • nodesUrl – Url for the shapefile with nodes.
  • AADFurl – Url for the shapefile with AADF counts.
  • areaCodeFileName – Path to the file with census output areas.
  • areaCodeNearestNodeFile – Path to the file with nearest nodes to output area centroids.
  • workplaceZoneFileName – Path to the file with workplace zones.
  • workplaceZoneNearestNodeFile – Path to the file with nearest nodes to workplace zone centroids.
  • freightZoneToLADfile – Path to the file with freight zone to LAD mapping.
  • freightZoneNearestNodeFile – Path to the file with nearest nodes to freight zones that are points.
  • params – Properties with parameters from the config file.
Throws:
  • IOException – if any.

Methods

createCustomFeatureType

public static SimpleFeatureType createCustomFeatureType(String linkDataLabel)

Creates a custom schema for the network.

Parameters:
  • linkDataLabel – The label for the link data (e.g. “DayVolume”).
Returns:

SimpleFeature type.

createNetworkFeatureCollection

public SimpleFeatureCollection createNetworkFeatureCollection(Map<Integer, Double> linkData, String linkDataLabel, String shapefilePath)

Creates a custom feature collection for the network.

Parameters:
  • linkData – Data assigned to network links.
  • linkDataLabel – The label of the link data.
  • shapefilePath – The path to the shapefile into which data will be stored.
Throws:
  • IOException – if any.
Returns:

Feature collection.

exportToShapefile

public void exportToShapefile(String fileName)

Exports a directed multigraph representation of the network as a shapefile.

Parameters:
  • fileName – The name of the output shapefile.
Throws:
  • IOException – if any.

getAADFCarTrafficCounts

public Integer[] getAADFCarTrafficCounts()

Get car traffic counts data for each link (for combined counts return 1/2 of the count per direction).

Returns:AADF traffic counts per link.

getAADFFreightTrafficCounts

public Map<VehicleType, Integer[]> getAADFFreightTrafficCounts()

Get car traffic counts data for each link (for combined counts return 1/2 of the count per direction).

Returns:AADF traffic counts per freight vehicle type and per link.

getAADFShapefile

public ShapefileDataStore getAADFShapefile()

getAreaCodeToNearestNodeID

public HashMap<String, Integer> getAreaCodeToNearestNodeID()

Getter method for the area code to the nearest node mapping.

Returns:Area code to the nearest node mapping.

getAreaCodeToPopulation

public HashMap<String, Integer> getAreaCodeToPopulation()

Getter method for the area code to population mapping.

Returns:Area code to population mapping.

getAstarFunctions

public AStarIterator.AStarFunctions getAstarFunctions(Node destinationNode)

Getter method for the AStar functions (edge cost and heuristic function) based on distance.

Parameters:
  • destinationNode – Destination node.
Returns:

AStar functions.

getAstarFunctionsTime

public AStarIterator.AStarFunctions getAstarFunctionsTime(Node destinationNode, double[] linkTravelTime)

Getter method for the AStar functions (edge cost and heuristic function) based on travel time.

Parameters:
  • destinationNode – Destination node.
  • linkTravelTime – Link travel times to use for edge weighting.
Returns:

AStar functions.

getAverageAcessEgressDistance

public double getAverageAcessEgressDistance(int node)

Average access/egress distance to access a node that has gravitating population.

Parameters:
  • node – Node to which
Returns:

Gravitating population.

getAverageAcessEgressDistanceFreight

public double getAverageAcessEgressDistanceFreight(int node)

Average access/egress distance to access a node that has gravitating population.

Parameters:
  • node – Node to which
Returns:

Gravitating population.

getAverageSpeedFerry

public double getAverageSpeedFerry()

getDijkstraTimeWeighter

public DijkstraIterator.EdgeWeighter getDijkstraTimeWeighter(double[] linkTravelTime)

Getter method for the Dijkstra edge weighter with time.

Parameters:
  • linkTravelTime – Link travel times to use for edge weighting.
Returns:

Dijkstra edge weighter with time.

getDijkstraWeighter

public DijkstraIterator.EdgeWeighter getDijkstraWeighter()

Getter method for the Dijkstra edge weighter.

Returns:Dijkstra edge weighter.

getEdgeIDtoEdge

public Edge[] getEdgeIDtoEdge()

Getter method for edgeID to edge mapping.

Returns:Edge ID to edge mapping.

getEdgeIDtoOtherDirectionEdgeID

public Integer[] getEdgeIDtoOtherDirectionEdgeID()

Getter method for edgeID to other direction edgeID mapping.

Returns:Edge ID to other direction edge ID mapping.

getEdgeLength

public double getEdgeLength(int edgeID)

Gets edge length for a given edge ID.

Parameters:
  • edgeID – Edge ID.
Returns:

Edge length.

getEdgeToZone

public HashMap<Integer, String> getEdgeToZone()

Getter method for the edge to zone mapping.

Returns:Node to zone mapping.

getEdgesType

public EdgeType[] getEdgesType()

Getter method for the array saying if the edge is A-road, motorway, or ferry. Array index is edge ID (without -1 shift).

Returns:Map between the edge ID and whether the edge is ferry.

getEndNodeBlacklist

public boolean[] getEndNodeBlacklist()

getFastestPath

public RoadPath getFastestPath(DirectedNode from, DirectedNode to, double[] linkTravelTime)

Gets the fastest path between two nodes using astar algorithm and provided link travel times. Links which have no travel time provided will use free flow travel times.

Parameters:
  • from – Origin node.
  • to – Destination node.
  • linkTravelTime – The map with link travel times.
Returns:

Fastest path.

getFastestPathDijkstra

public RoadPath getFastestPathDijkstra(DirectedNode from, DirectedNode to, double[] linkTravelTime)

Gets the fastest path between two nodes using Dijkstra’s algorithm and provided link travel times. Links which have no travel time provided will use free flow travel times.

Parameters:
  • from – Origin node.
  • to – Destination node.
  • linkTravelTime – The map with link travel times.
Returns:

Fastest path.

getFreeFlowSpeedARoad

public double getFreeFlowSpeedARoad()

getFreeFlowSpeedMRoad

public double getFreeFlowSpeedMRoad()

getFreeFlowTravelTime

public double[] getFreeFlowTravelTime()

Getter method for free flow travel time.

Returns:Free flow travel time.

getFreightZoneToLAD

public HashMap<Integer, String> getFreightZoneToLAD()

Getter method for the freight zone to LAD mapping.

Returns:Area code to the nearest node mapping.

getFreightZoneToNearestNode

public HashMap<Integer, Integer> getFreightZoneToNearestNode()

Getter method for the freight zone to the nearest node mapping.

Returns:Area code to the nearest node mapping.

getGravitatingPopulation

public int getGravitatingPopulation(int node)

Population gravitating to a node.

Parameters:
  • node – Node to which the population gravitates.
Returns:

Gravitating population.

getGravitatingWorkplacePopulation

public int getGravitatingWorkplacePopulation(int node)

Workplace population gravitating to a node.

Parameters:
  • node – Node to which the workplace population gravitates.
Returns:

Gravitating workplace population.

getIsEdgeUrban

public Boolean[] getIsEdgeUrban()

Getter method for the array saying if the edge is urban (true), rural (false), or unkown (null). Array index is edge ID (without -1 shift).

Returns:Array saying if the edge is urban/rural/unkown.

getMaximumEdgeID

public int getMaximumEdgeID()

Getter method for maximum edge ID.

Returns:Maximum edge ID.

getMaximumNodeID

public int getMaximumNodeID()

Getter method for maximum node ID.

Returns:Maximum node ID.

getNetwork

public DirectedGraph getNetwork()

Getter method for the road network.

Returns:Directed graph representation of the road network.

getNetworkShapefile

public ShapefileDataStore getNetworkShapefile()

getNewNetworkShapefile

public ShapefileDataStore getNewNetworkShapefile()

getNodeIDtoNode

public Node[] getNodeIDtoNode()

Getter method for nodeID to node mapping.

Returns:Node ID to node mapping.

getNodeToAverageAccessEgressDistance

public double[] getNodeToAverageAccessEgressDistance()

Getter method for the node to average access/egress distance mapping [in metres].

Returns:Node ID to average access/egress distance mapping.

getNodeToAverageAccessEgressDistanceFreight

public double[] getNodeToAverageAccessEgressDistanceFreight()

Getter method for the node to average access/egress distance mapping for freight [in metres].

Returns:Node ID to average access/egress distance mapping for freight.

getNodeToGravitatingPopulation

public int[] getNodeToGravitatingPopulation()

Getter method for the node to gravitating population mapping.

Returns:Node to gravitating population mapping.

getNodeToZone

public HashMap<Integer, String> getNodeToZone()

Getter method for the node to zone mapping.

Returns:Node to zone mapping.

getNodesShapefile

public ShapefileDataStore getNodesShapefile()

getNumberOfLanes

public int[] getNumberOfLanes()

Getter method for the number of lanes for each link.

Returns:Link id to number of lanes mapping.

getNumberOfLanesARoad

public int getNumberOfLanesARoad(String wayType)

getNumberOfLanesMRoad

public int getNumberOfLanesMRoad(String wayType)

getStartNodeBlacklist

public boolean[] getStartNodeBlacklist()

getWorkplaceCodeToPopulation

public HashMap<String, Integer> getWorkplaceCodeToPopulation()

Getter method for the workplace zone to population mapping.

Returns:Workplace zone to population mapping.

getWorkplaceZoneToNearestNode

public HashMap<String, Integer> getWorkplaceZoneToNearestNode()

Getter method for the workplace code to the nearest node mapping.

Returns:Workplace code to the nearest node mapping.

getZoneToAreaCodes

public HashMap<String, List<String>> getZoneToAreaCodes()

Getter method for the zone to area codes mapping.

Returns:Zone to area codes mapping.

getZoneToNodes

public HashMap<String, List<Integer>> getZoneToNodes()

Getter method for the zone to nodes mapping.

Returns:Zone to nodes mapping.

getZoneToWorkplaceCodes

public HashMap<String, List<String>> getZoneToWorkplaceCodes()

Getter method for the LAD zone to workplace zones mapping.

Returns:Zone to workplace code mapping.

getZonesShapefile

public ShapefileDataStore getZonesShapefile()

isBlacklistedAsEndNode

public boolean isBlacklistedAsEndNode(int nodeId)

Finds out if the node is blacklisted as a path end node.

Parameters:
  • nodeId – Node ID.
Returns:

Whether nodes is blacklisted or not.

isBlacklistedAsStartNode

public boolean isBlacklistedAsStartNode(int nodeId)

Finds out if the node is blacklisted as a path start node.

Parameters:
  • nodeId – Node ID.
Returns:

Whether nodes is blacklisted or not.

makeEdgesAdmissible

public void makeEdgesAdmissible()

Overrides actual edge lengths with straight line distances, when they are smaller than straight line distances.

replaceNetworkEdgeIDs

public void replaceNetworkEdgeIDs(URL networkShapeFile)

Replaces edge IDs in the road network object with fixed edge IDs provided in a shapefile.

Parameters:
  • networkShapeFile – Path to the shapefile with the network with edge IDs.
Throws:
  • IOException – if any.

sortGravityNodes

public void sortGravityNodes()

For each zone (LAD) sorts the list of contained nodes based on the gravitating population.

sortGravityNodesFreight

public void sortGravityNodesFreight()

For each zone (LAD) sorts the list of contained nodes based on the gravitating workplace population.

toString

public String toString()