@Override public QLinkI createNetsimLink(Link link, QNodeI queueNode) { QLinkI ql = null; LanesToLinkAssignment l2l = this.laneDefinitions.getLanesToLinkAssignments().get(link.getId()); if (l2l != null){ List<ModelLane> lanes = LanesUtils.createLanes(link, l2l); // LinkSpeedCalculator linkSpeedCalculator = new DefaultLinkSpeedCalculator() ; // // yyyyyy I don't think that this was set correctly for this execution path before I refactored this. kai, feb'18 // ql = new QLinkLanesImpl(link, queueNode, lanes, context, netsimEngine, linkSpeedCalculator); QLinkLanesImpl.Builder builder = new QLinkLanesImpl.Builder(context, netsimEngine) ; ql = builder.build( link, queueNode, lanes ) ; } else { ql = this.delegate.createNetsimLink(link, queueNode); } return ql; }
LanesUtils.createAndAddLane(lanesForLink12, factory, Id.create("12.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, null, Arrays.asList(Id.create("12.l", Lane.class), Id.create("12.r", Lane.class))); LanesUtils.createAndAddLane(lanesForLink12, factory, Id.create("12.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, Collections.singletonList(Id.create("23", Link.class)), null); LanesUtils.createAndAddLane(lanesForLink12, factory, Id.create("12.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, Collections.singletonList(Id.create("27", Link.class)), null); LanesUtils.createAndAddLane(lanesForLink65, factory, Id.create("65.ol", Lane.class), LANE_CAPACITY, LINK_LENGTH, 0, NO_LANES, null, Arrays.asList(Id.create("65.l", Lane.class), Id.create("65.r", Lane.class))); LanesUtils.createAndAddLane(lanesForLink65, factory, Id.create("65.r", Lane.class), LANE_CAPACITY, LANE_LENGTH, -1, NO_LANES, Collections.singletonList(Id.create("54", Link.class)), null); LanesUtils.createAndAddLane(lanesForLink65, factory, Id.create("65.l", Lane.class), LANE_CAPACITY, LANE_LENGTH, 1, NO_LANES, Collections.singletonList(Id.create("58", Link.class)), null);
public static void calculateMissingCapacitiesForLanes20(String networkInputFilename, String lanes20InputFilename, String lanes20OutputFilename){ Config config = ConfigUtils.createConfig(); config.network().setInputFile(networkInputFilename); config.qsim().setUseLanes(true); config.network().setLaneDefinitionsFile(lanes20InputFilename); Scenario scenario = ScenarioUtils.loadScenario(config); Network network = scenario.getNetwork(); Lanes lanes = scenario.getLanes(); for (LanesToLinkAssignment l2l : lanes.getLanesToLinkAssignments().values()){ Link link = network.getLinks().get(l2l.getLinkId()); for (Lane lane : l2l.getLanes().values()){ if (lane.getToLaneIds() == null || lane.getToLaneIds().isEmpty()){ calculateAndSetCapacity(lane, true, link, network); } else { calculateAndSetCapacity(lane, false, link, network); } } } LanesWriter writerDelegate = new LanesWriter(lanes); writerDelegate.write(lanes20OutputFilename); }
MutableScenario(Config config) { this.config = config; this.network = NetworkUtils.createNetwork(this.config); this.population = PopulationUtils.createPopulation(this.config, this.network); this.facilities = new ActivityFacilitiesImpl(); this.households = new HouseholdsImpl(); this.lanes = LanesUtils.createLanesContainer(); this.vehicles = VehicleUtils.createVehiclesContainer(); this.transitVehicles = VehicleUtils.createVehiclesContainer(); this.transitSchedule = new TransitScheduleFactoryImpl().createTransitSchedule(); this.config.network().setLocked(); }
/** * Replaces the method that converted a lane from format 11 to format 20. * Use this when you have not defined an original lane of the link and when you have not set lane capacities yet. */ public static void createOriginalLanesAndSetLaneCapacities(Network network, Lanes lanes){ LanesFactory factory = lanes.getFactory(); for (LanesToLinkAssignment l2l : lanes.getLanesToLinkAssignments().values()){ Link link = network.getLinks().get(l2l.getLinkId()); Lane olLane = factory.createLane(Id.create(l2l.getLinkId().toString() + ".ol", Lane.class)); l2l.addLane(olLane); for (Lane lane : l2l.getLanes().values()) { olLane.addToLaneId(lane.getId()); //set capacity of the lane depending on link capacity and number of representative lanes LanesUtils.calculateAndSetCapacity(lane, true, link, network); } olLane.setNumberOfRepresentedLanes(link.getNumberOfLanes()); olLane.setStartsAtMeterFromLinkEnd(link.getLength()); } }
@Override public void writeConstData(ByteBuffer out) throws IOException { //write the data for the links out.putInt(this.network.getVisLinks().size()); for (VisLink visLink : this.network.getVisLinks().values()) { LanesToLinkAssignment l2l = null; if (this.lanes != null){ l2l = this.lanes.getLanesToLinkAssignments().get(visLink.getLink().getId()); } List<ModelLane> la = null; if (l2l != null) { la = LanesUtils.createLanes(visLink.getLink(), l2l); } VisLinkWLanes otfLink = this.laneModelBuilder.createVisLinkLanes(OTFServerQuadTree.getOTFTransformation(), visLink, config.qsim().getNodeOffset(), la); //write link data ByteBufferUtils.putObject(out, otfLink); } }