public static Link createLink(Id<Link> id, Node from, Node to, Network network, double length, double freespeed, double capacity, double lanes) { return new LinkImpl(id, from, to, network, length, freespeed, capacity, lanes); }
@Override public void setCapacity(double capacityPerNetworkCapcityPeriod){ this.capacity = capacityPerNetworkCapcityPeriod; this.checkCapacitySemantics(); }
@Override public void setFreespeed(double freespeed) { this.freespeed = freespeed; this.checkFreespeedSemantics(); }
/*deliberately package*/ LinkImpl(final Id<Link> id, final Node from, final Node to, final Network network, final double length, final double freespeed, final double capacity, final double lanes) { this.id = id; this.network = network; this.from = from; this.to = to; this.allowedModes = DEFAULT_ALLOWED_MODES; this.setLength(length); //for the eventual time variant attributes don't call the setter as it must be overwritten in TimeVariantLinkImpl //and thus causes problems during object initialization, dg nov 2010 this.freespeed = freespeed; this.checkFreespeedSemantics(); this.capacity = capacity; this.checkCapacitySemantics(); this.nofLanes = lanes; this.checkNumberOfLanesSemantics(); if (this.from.equals(this.to) && (loopWarnCnt < maxLoopWarnCnt)) { loopWarnCnt++ ; log.warn("fromNode=toNode=" + this.to + ": link is a loop"); if ( loopWarnCnt == maxLoopWarnCnt ) log.warn(Gbl.FUTURE_SUPPRESSED ) ; } }
@Override public Coord getCoord() { Coord fromXY = getFromNode().getCoord(); Coord toXY = getToNode().getCoord(); return new Coord((fromXY.getX() + toXY.getX()) / 2.0, (fromXY.getY() + toXY.getY()) / 2.0); }
private void checkNumberOfLanesSemantics(){ if ((this.nofLanes < 1) && (plWarnCnt < maxPlWarnCnt) ) { plWarnCnt++ ; log.warn("permlanes=" + this.nofLanes + " of link id " + this.getId() +" may cause problems"); if ( plWarnCnt == maxPlWarnCnt ) log.warn( Gbl.FUTURE_SUPPRESSED ) ; } }
@Override public void setNumberOfLanes(double lanes) { this.nofLanes = lanes; this.checkNumberOfLanesSemantics(); }
@Override public double getFlowCapacityPerSec() { return getFlowCapacityPerSec(Time.UNDEFINED_TIME); } @Override
@Override public final void setLength(double length) { this.length = length; this.checkLengthSemantics(); }
@Override public double getFlowCapacityPerSec(@SuppressWarnings("unused") final double time) { return this.getCapacity(time) / network.getCapacityPeriod(); }
private void checkCapacitySemantics() { /* * I see no reason why a freespeed and a capacity of zero should not be * allowed! joh 9may2008 * The warning says that it _may_ cause problems. Not pretty if you want to get rid of warnings completely, but * hopefully acceptable for the time being. kai, oct'10 */ if ((this.capacity <= 0.0) && (cpWarnCnt < maxCpWarnCnt) ) { cpWarnCnt++ ; log.warn("capacity=" + this.capacity + " of link id " + this.getId() + " may cause problems"); log.warn( Gbl.FUTURE_SUPPRESSED ) ; } }
@Override public String toString() { return super.toString() + "[id=" + this.getId() + "]" + "[from_id=" + this.from.getId() + "]" + "[to_id=" + this.to.getId() + "]" + "[length=" + this.length + "]" + "[freespeed=" + this.freespeed + "]" + "[capacity=" + this.capacity + "]" + "[permlanes=" + this.nofLanes + "]" + "[modes=" + this.allowedModes ; // "[origid=" + this.origid + "]" + // not in api // "[type=" + this.type + "]"; // not in api // yyyyyy add the "free text" attributes }