@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 writeDynData(ByteBuffer out) throws IOException { out.putFloat((float)0.) ; positions.clear(); this.src.getVisData().addAgentSnapshotInfo( positions); if (showParked) { out.putInt(positions.size()); for (AgentSnapshotInfo pos : positions) { writeAgent(pos, out); } } else { int valid = 0; for (AgentSnapshotInfo pos : positions) { if (pos.getAgentState() != AgentState.PERSON_AT_ACTIVITY) valid++; } out.putInt(valid); for (AgentSnapshotInfo pos : positions) { if (pos.getAgentState() != AgentState.PERSON_AT_ACTIVITY) writeAgent(pos, out); } } }
private List<Plan> getPersonsNOW() { List<Plan> actPersons = new ArrayList<>(); VisLink link = simulationView.getVisNetwork().getVisLinks().get(this.queryLinkId); Collection<? extends VisVehicle> vehs = link.getAllVehicles(); for( VisVehicle veh : vehs) { if ( veh.getDriver() instanceof PlanAgent ) { Plan plan = ((PlanAgent)veh.getDriver()).getCurrentPlan() ; actPersons.add( plan ); } } return actPersons; }
@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); } }
private void doSnapshot(final double time, VisMobsim visMobsim) { if (!this.snapshotWriters.isEmpty()) { Collection<AgentSnapshotInfo> positions = new ArrayList<AgentSnapshotInfo>(); for (VisLink link : visMobsim.getVisNetwork().getVisLinks().values()) { link.getVisData().addAgentSnapshotInfo(positions); } // We do not put non-network agents in movies. // Otherwise, we would add snapshots from visMobsim.getNonNetworkAgentSnapshots() here. for (SnapshotWriter writer : this.snapshotWriters) { writer.beginSnapshot(time); for (AgentSnapshotInfo position : positions) { writer.addAgent(position); } writer.endSnapshot(); } } }
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());
Collection<AgentSnapshotInfo> positions = new LinkedList<AgentSnapshotInfo>(); for(VisLink qlink : simulationView.getVisNetwork().getVisLinks().values()) { qlink.getVisData().addAgentSnapshotInfo(positions);
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 } } }