private boolean topoTypeAllowed(Link link) { if(this.topoTypesForStops == null){ // flag not set or null in config return true; } Integer topoType = this.networkCalcTopoType.getTopoType(link.getToNode()); return this.topoTypesForStops.contains(topoType); }
public void initForLink(final Link link) { this.fromNode = link.getFromNode(); this.toNode = link.getToNode(); this.tmpToNodeData = null; }
private boolean topoTypeAllowed(Link link) { if(this.topoTypesForStops == null){ // flag not set or null in config return true; } Integer topoType = this.networkCalcTopoType.getTopoType(link.getToNode()); return this.topoTypesForStops.contains(topoType); }
public static Link findLinkInOppositeDirection(Link link) { for ( Link candidateLink : link.getToNode().getOutLinks().values() ) { if ( candidateLink.getToNode().equals( link.getFromNode() ) ) { return candidateLink ; } } return null ; } public static void readNetwork( Network network, String string ) {
/** * Logic that was previously located in the relaxNode(...) method. * By doing so, the FastDijkstra can overwrite relaxNode without copying the logic. */ /*package*/ void relaxNodeLogic(final Link l, final RouterPriorityQueue<Node> pendingNodes, final double currTime, final double currCost) { addToPendingNodes(l, l.getToNode(), pendingNodes, currTime, currCost); }
public static Map<Id<Node>, ? extends Node> getOutNodes(Node node) { Map<Id<Node>, Node> nodes = new TreeMap<>(); for (Link link : node.getOutLinks().values()) { Node outNode = link.getToNode(); nodes.put(outNode.getId(), outNode); } return nodes; }
private void collectMergedLinkNodeInfo(Link inLink, Link outLink, Id<Link> mergedLinkId) { List<Node> nodes = new ArrayList<>(); if (this.mergedLinksToIntermediateNodes.containsKey(inLink.getId())) nodes.addAll(this.mergedLinksToIntermediateNodes .remove(inLink.getId())); if (this.mergedLinksToIntermediateNodes.containsKey(outLink.getId())) nodes.addAll(this.mergedLinksToIntermediateNodes .remove(outLink.getId())); nodes.add(inLink.getToNode()); this.mergedLinksToIntermediateNodes.put(mergedLinkId, nodes); }
private void getLinksTillLink(final List<Id<Link>> links, final Id<Link> nextLinkId, final Id<Link> startLinkId) { Id<Link> linkId = startLinkId; Link nextLink = this.network.getLinks().get(nextLinkId); while (true) { // loop until we hit "return;" Link link = this.network.getLinks().get(linkId); if (link.getToNode() == nextLink.getFromNode()) { return; } linkId = this.subsequentLinks.get(linkId); links.add(linkId); } }
private int getNOfIncidentNodes(final Node node) { HashMap<Id<Node>, Node> nodes = new HashMap<>(); for (Link link : node.getInLinks().values()) { nodes.put(link.getFromNode().getId(), link.getFromNode()); } for (Link link : node.getOutLinks().values()) { nodes.put(link.getToNode().getId(), link.getToNode()); } return nodes.size(); } }
public static Map<Id<Link>, Zone> createLinkToZoneMap(Network network, ZoneFinder zoneFinder) { Map<Id<Link>, Zone> linkToZone = new HashMap<>(); for (Link l : network.getLinks().values()) { linkToZone.put(l.getId(), zoneFinder.findZone(l.getToNode().getCoord())); } return linkToZone; }
private boolean linkToNodeInServiceArea(Link link) { Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord())); if(this.include.contains(p)){ if(exclude.contains(p)){ return false; } return true; } return false; }
private boolean linkToNodeInServiceArea(Link link) { Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord())); if(this.include.contains(p)){ if(exclude.contains(p)){ return false; } return true; } return false; }
/** * ASSUMPTION: A vehicle enters and exits links at their ends (link.getToNode()) */ public static VrpPathWithTravelData calcAndCreatePath(Link fromLink, Link toLink, double departureTime, LeastCostPathCalculator router, TravelTime travelTime) { Path path = null; if (fromLink != toLink) { // calc path for departureTime+1 (we need 1 second to move over the node) path = router.calcLeastCostPath(fromLink.getToNode(), toLink.getFromNode(), departureTime + 1, null, null); } return VrpPaths.createPath(fromLink, toLink, departureTime, path, travelTime); }
private static Link findLinkBetween(final Network network, final Id<Link> fromLinkId, final Id<Link> toLinkId) { Link fromLink = network.getLinks().get(fromLinkId); Link toLink = network.getLinks().get(toLinkId); Node from = fromLink.getToNode(); Node to = toLink.getFromNode(); for (Link link : from.getOutLinks().values()) { if (link.getToNode() == to) { return link; } } return null; }
/** * Helper method for type conversion. * * @param link * @return */ public static LineString createGeotoolsLineString(Link link) { Coordinate fromCoord = MGC.coord2Coordinate( link.getFromNode().getCoord() ) ; Coordinate toCoord = MGC.coord2Coordinate( link.getToNode().getCoord() ) ; LineString theSegment = new GeometryFactory().createLineString(new Coordinate[]{ fromCoord, toCoord }); return theSegment; }
private void moveToAbort(final MobsimAgent mobsimAgent, final double now, Link currentLink, Link nextLink) { log.error("Agent has no or wrong route! agentId=" + mobsimAgent.getId() + " currentLink=" + currentLink.getId().toString() + " nextLink=" + (nextLink!=null?nextLink.getId():"null") + " currentLinkToNode=" + currentLink.getToNode().getId() + " nextLinkFromNode=" + (nextLink!=null?nextLink.getFromNode().getId():"null") + ". The agent is removed from the simulation."); mobsimAgent.setStateToAbort(now); this.simEngine.internalInterface.arrangeNextAgentState(mobsimAgent); } }
private void processLink(Link link, EmissionsByPollutant emissions, Grid<Map<Pollutant, Double>> grid) { // create a clipping area to speed up calculation time // use 5*smoothing radius as longer distances result in a weighting of effectively 0 Geometry clip = factory.createPoint(new Coordinate(link.getCoord().getX(), link.getCoord().getY())).buffer(smoothingRadius * 5); grid.getCells(clip).forEach(cell -> { double normalizationFactor = grid.getCellArea() / (Math.PI * smoothingRadius * smoothingRadius); double weight = SpatialInterpolation.calculateWeightFromLine( transformToCoordinate(link.getFromNode()), transformToCoordinate(link.getToNode()), cell.getCoordinate(), smoothingRadius); processCell(cell, emissions, weight * normalizationFactor); }); }
public static double getGradientFactor(Link link) { double gradient = 0.; Double fromNodeZ = link.getFromNode().getCoord().getZ(); Double toNodeZ = link.getToNode().getCoord().getZ(); if ((fromNodeZ != null) && (toNodeZ != null)) { if (toNodeZ > fromNodeZ) { // No positive utility for downhill, only negative for uphill gradient = (toNodeZ - fromNodeZ) / link.getLength(); } } return gradient; }
@Override public String toString() { return "[" + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + ">" + ((TransitRouterNetworkNode) link.getToNode()).getStop().getStopFacility().getId() + " @ " + time + "]"; } }