public int getNumberOfLanesAsInt(double now) { return NetworkUtils.getNumberOfLanesAsInt(now,AbstractQLink.this.link) ; } }
@Override public void writeConstData(ByteBuffer out) throws IOException { String id = this.src.getLink().getId().toString(); ByteBufferUtils.putString(out, id); //subtract minEasting/Northing somehow! Point2D.Double.Double linkStart = OTFServerQuadTree.transform(this.src.getLink().getFromNode().getCoord()); Point2D.Double.Double linkEnd = OTFServerQuadTree.transform(this.src.getLink().getToNode().getCoord()); out.putFloat((float) linkStart.x); out.putFloat((float) linkStart.y); out.putFloat((float) linkEnd.x); out.putFloat((float) linkEnd.y); if ( OTFVisConfigGroup.NUMBER_OF_LANES.equals(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidthIsProportionalTo()) ) { out.putInt(NetworkUtils.getNumberOfLanesAsInt(0, this.src.getLink())); } else if ( OTFVisConfigGroup.CAPACITY.equals(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidthIsProportionalTo()) ) { out.putInt( 1 + (int)(2.*this.src.getLink().getCapacity()/3600.) ) ; // yyyyyy 3600. is a magic number (the default of the capacity period attribute in Network) but I cannot get to the network (where "capacityPeriod" resides). // Please do better if you know better. kai, jun'11 } else { throw new RuntimeException("I do not understand. Aborting ..." ) ; } }
public Road(Scheduler scheduler, Link link) { super(scheduler); this.link = link; /* * calculate the maximum number of cars, which can be on the road at the * same time */ this.maxNumberOfCarsOnRoad = Math.round(link.getLength() * NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link) * config.getStorageCapacityFactor() / config.getCarSize()); /** * it is assured here, that a road must have the space of at least one * car */ if (this.maxNumberOfCarsOnRoad == 0) { this.maxNumberOfCarsOnRoad = 1; } double maxInverseInFlowCapacity = 3600 / (config.getMinimumInFlowCapacity() * config.getFlowCapacityFactor() * NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link)); this.inverseOutFlowCapacity = 1 / (((Link) link).getFlowCapacityPerSec() * config.getFlowCapacityFactor()); if (this.inverseOutFlowCapacity > maxInverseInFlowCapacity) { this.inverseInFlowCapacity = maxInverseInFlowCapacity; } else { this.inverseInFlowCapacity = this.inverseOutFlowCapacity; } this.gapTravelTime = link.getLength() / config.getGapTravelSpeed(); // gap must be initialized to null because of the application logic this.gap = null; }
int lane = 1 + (agent.intId % NetworkUtils.getNumberOfLanesAsInt(time, this.link)); double speed = (time > cmp) ? 0.0 : this.link.getFreespeed(time); agent.speed = speed; int lane = 1 + (agent.intId % NetworkUtils.getNumberOfLanesAsInt(org.matsim.core.utils.misc.Time.UNDEFINED_TIME, this.link)); AgentSnapshotInfo position = snapshotInfoFactory.createAgentSnapshotInfo(agent.id, this.link, distanceOnLink/* + NetworkLayer.CELL_LENGTH*/, lane); position.setColorValueBetweenZeroAndOne( agent.speed) ; int lane = NetworkUtils.getNumberOfLanesAsInt(org.matsim.core.utils.misc.Time.UNDEFINED_TIME, this.link) + 1; // place them next to the link for (EventAgent agent : this.waitingQueue) { AgentSnapshotInfo position = snapshotInfoFactory.createAgentSnapshotInfo(agent.id, this.link, this.effectiveCellSize, lane); lane = NetworkUtils.getNumberOfLanesAsInt(org.matsim.core.utils.misc.Time.UNDEFINED_TIME, this.link) + 2; // place them next to the link for (EventAgent agent : this.parkingQueue) { AgentSnapshotInfo position = snapshotInfoFactory.createAgentSnapshotInfo(agent.id, this.link, this.effectiveCellSize, lane);
@Test public void testGetNumberOfLanesAsInt() { assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.2))); assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.1))); assertEquals(3, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(3.0))); assertEquals(2, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(2.9))); assertEquals(2, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(2.5))); assertEquals(2, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(2.0))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(1.9))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(1.5))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(1.0))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(0.9))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(0.5))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(0.1))); assertEquals(1, NetworkUtils.getNumberOfLanesAsInt(7*3600, new PseudoLink(0.0))); }
out_l.write(l.getFreespeed()+"\t" +(l.getCapacity()/capperiod)+"\t" + NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, l)+"\t" +l.getAllowedModes().toString()+"\n"); out_l.flush(); out_et.write(Math.round(l.getCapacity()/capperiod) + "\t" + NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, l) + "\t"); out_et.write(NetworkUtils.getOrigId( ((Link) l) ) + "\t" + NetworkUtils.getType(((Link) l)) + "\t"+l.getAllowedModes().toString()+"\n"); out_et.write(fc.getX() + "\t" + fc.getY() + "\n");
if (bufferSize + drivingQueueSize + waitingQueueSize + parkingQueueSize > 0 ) { int cnt = bufferSize + drivingQueueSize; int nLanes = NetworkUtils.getNumberOfLanesAsInt(time, this.link); double linkLength = this.link.getLength(); if (cnt > 0) {
int lanes = NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link1) + NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link2); double length = Math.max(link1.getLength(),link2.getLength()); int lanes = Math.max(NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link1), NetworkUtils.getNumberOfLanesAsInt(Time.UNDEFINED_TIME, link2)); double length = Math.max(link1.getLength(),link2.getLength());