@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 ..." ) ; } }
@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); } }
Coord linkStartCoord = transform.transform(link.getLink().getFromNode().getCoord()); Coord linkEndCoord = transform.transform(link.getLink().getToNode().getCoord()); Point2D.Double linkStart = new Point2D.Double(linkStartCoord.getX(), linkStartCoord.getY()); Point2D.Double linkEnd = new Point2D.Double(linkEndCoord.getX(), linkEndCoord.getY()); double euclideanLinkLength = this.calculateEuclideanLinkLength(deltaLink); double linkLengthCorrectionFactor = euclideanLinkLength / link.getLink().getLength(); Point2D.Double deltaLinkNorm = new Point2D.Double(deltaLink.x / euclideanLinkLength, deltaLink.y / euclideanLinkLength); Point2D.Double normalizedOrthogonal = new Point2D.Double(deltaLinkNorm.y, - deltaLinkNorm.x); VisLinkWLanes lanesLinkData = new VisLinkWLanes(link.getLink().getId().toString()); lanesLinkData.setLinkStartEndPoint(scaledLinkStart, scaledLinkEnd); lanesLinkData.setNormalizedLinkVector(deltaLinkNorm); lanesLinkData.setLinkOrthogonalVector(normalizedOrthogonal); lanesLinkData.setNumberOfLanes(link.getLink().getNumberOfLanes()); VisLane visLane = this.createVisLane(lane, link.getLink().getLength(), linkScale, linkLengthCorrectionFactor); lanesLinkData.addLaneData(visLane); if (visLane.getAlignment() > maxAlignment) { for (Id<Link> id : link.getLink().getToNode().getOutLinks().keySet()){ lanesLinkData.addToLinkId(id.toString());
Object src = writer.getSrc(); if(src instanceof VisLink) { Link link = ((VisLink)src).getLink(); double alpha = 0.6; Coord from = link.getFromNode().getCoord();
private void installLinkWriterFactories( List<OTFWriterFactory<VisLink>> linkWriterFactoryObjects) { for (VisLink link : this.net.getVisLinks().values()) { Point2D.Double fromCoord = transform(link.getLink().getFromNode().getCoord()); Point2D.Double toCoord = transform(link.getLink().getToNode().getCoord()); double middleEast = (toCoord.getX() + fromCoord.getX()) * 0.5; double middleNorth = (toCoord.getY() + fromCoord.getY()) * 0.5; for (OTFWriterFactory<VisLink> fac : linkWriterFactoryObjects) { OTFDataWriter<VisLink> writer = fac.getWriter(); // null means take the default handler if (writer != null) { writer.setSrc(link); } // this.put(middleEast, middleNorth, writer); // try to put links twice: this.put(fromCoord.getX(), fromCoord.getY(), writer); this.put(toCoord.getX(), toCoord.getY(), writer); // (The unterlying QuadTree documentation says that it will accept the same object multiple times as // long as at different coordinates. So I am trying this out here. The result will depend on the fact if // the collections are implemented as sets (in which case duplicate links will just be ignored) or standard // collections, in which case the plotting will supposedly happen twice, this reducing plotting speed by a // factor of two. (Does not feel like it.) kai, apr'18 } } }