@Override public void addAgent(AgentSnapshotInfo position) { //drop all parking vehicles if (position.getAgentState() == AgentSnapshotInfo.AgentState.PERSON_AT_ACTIVITY) return; String buffer = position.getId().toString() + "\t" + (int)this.currentTime + "\t0\t0\t1\t0\t" + position.getColorValueBetweenZeroAndOne() // link(0), from node(0), lane(1), dist(0), speed + "\t1\t0\t" + position.getId().toString() // vehtype(1), acceleration(0), driver-id + "\t0\t" + position.getEasting() // # of passengers(0), easting + "\t" + position.getNorthing() + "\t0" // elevation + "\t0" // azimuth + "\t"+ "0" + "\n"; // user(0) try { out.write(buffer); } catch (IOException e) { e.printStackTrace(); } }
private static void writeAgent(AgentSnapshotInfo agInfo, ByteBuffer out) { String id = agInfo.getId().toString(); ByteBufferUtils.putString(out, id); Point2D.Double point = OTFServerQuadTree.transform(new Coord(agInfo.getEasting(), agInfo.getNorthing())); out.putFloat((float) point.getX()); out.putFloat((float) point.getY()); out.putInt(agInfo.getAgentState().ordinal() ) ; out.putInt(agInfo.getUserDefined()); out.putFloat((float)agInfo.getColorValueBetweenZeroAndOne()); }
private static void writeAgent(AgentSnapshotInfo pos, ByteBuffer out) { String id = pos.getId().toString(); ByteBufferUtils.putString(out, id); Point2D.Double point = OTFServerQuadTree.transform(new Coord(pos.getEasting(), pos.getNorthing())); out.putFloat((float) point.getX()); out.putFloat((float) point.getY()); out.putInt(pos.getUserDefined()); out.putFloat((float) pos.getColorValueBetweenZeroAndOne()); out.putInt(pos.getAgentState().ordinal()); }
this.posBuffers.add(this.vertexIN); this.vertexIN.put((float)agInfo.getEasting()); this.vertexIN.put((float)agInfo.getNorthing()); this.id2coord.put(Arrays.hashCode(agInfo.getId().toString().toCharArray()),this.count);
@Override public void addAgent(final AgentSnapshotInfo info) { //drop all parking vehicles if (info.getAgentState() == AgentSnapshotInfo.AgentState.PERSON_AT_ACTIVITY) { return; } this.writeThisSnapshot = true ; Coord coord = this.coordTransform.transform(new Coord(info.getEasting(), info.getNorthing())); PointType point = kmlObjectFactory.createPointType(); point.getCoordinates().add(Double.toString(coord.getX()) + "," + Double.toString(coord.getY()) + ",0.0"); if ( info.getColorValueBetweenZeroAndOne() < 0.33 ) { this.timeGeometryRed.getAbstractGeometryGroup().add(kmlObjectFactory.createPoint(point)); } else if ( info.getColorValueBetweenZeroAndOne() < 0.66 ) { this.timeGeometryYellow.getAbstractGeometryGroup().add(kmlObjectFactory.createPoint(point)); } else { this.timeGeometryGreen.getAbstractGeometryGroup().add(kmlObjectFactory.createPoint(point)); } }
for(AgentSnapshotInfo info : positions) { if ((info.getAgentState()== AgentState.PERSON_AT_ACTIVITY) && !OTFLinkAgentsHandler.showParked) continue; java.awt.geom.Point2D.Double xy = OTFServerQuadTree.transform(new Coord(info.getEasting(), info.getNorthing())); double xDist = xy.getX() - this.x; double yDist = xy.getY() - this.y;
@Override public void writeConstData(ByteBuffer out) throws IOException { out.putInt(this.schedule.getFacilities().size()); for (TransitStopFacility facility : this.schedule.getFacilities().values()) { ByteBufferUtils.putString(out, facility.getId().toString()); if (facility.getLinkId() != null) { // yyyy would most probably make sense to have something that generates coordinates for facilities Link link = this.network.getLinks().get( facility.getLinkId() ) ; if ( link==null ) { log.warn( " link not found; linkId: " + facility.getLinkId() ) ; ByteBufferUtils.putString(out,""); Point2D.Double point = OTFServerQuadTree.transform(facility.getCoord()); out.putDouble(point.getX()); out.putDouble(point.getY()); } else { ByteBufferUtils.putString(out, facility.getLinkId().toString()); AgentSnapshotInfo ps = agentSnapshotInfoFactory.createAgentSnapshotInfo(Id.create(facility.getId(), Person.class), link, 0.9*link.getLength(), 0) ; Point2D.Double point = OTFServerQuadTree.transform(new Coord(ps.getEasting(), ps.getNorthing())); out.putDouble(point.getX()) ; out.putDouble(point.getY()) ; } } else { ByteBufferUtils.putString(out,""); Point2D.Double point = OTFServerQuadTree.transform(facility.getCoord()); out.putDouble(point.getX()); out.putDouble(point.getY()); } } }
Link link = net.getLinks().get(act.getLinkId()); AgentSnapshotInfo pi = snapshotInfoFactory.createAgentSnapshotInfo(agentId, link, 0.9*link.getLength(), 0); coord = new Coord(pi.getEasting(), pi.getNorthing());
/** * Test the calculation of a vehicles position if the actual link length is * shorter than the euklidean distance. * * @author mrieser */ public void testDistanceOnLink_shortLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 1000, (double) 1000)); final Node fromNode = node1; final Node toNode = node2; Link link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 1000, (double) 10, (double) 9999, (double) 1 ); // place the vehicle at one quarter of the link SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); AgentSnapshotInfo posInfo = new AgentSnapshotInfoFactory(linkWidthCalculator).createAgentSnapshotInfo(Id.create(1, Person.class), link1, 250, 0); assertEquals(260.60660171779824, posInfo.getEasting(), epsilon); assertEquals(239.3933982822018, posInfo.getNorthing(), epsilon); // These numbers became a little weird when I moved vehicles away from the center of a link. Kai, Dec/08 // These numbers changed again when I mad the orthogonal offset adaptive. kai, aug/10 // Made the orthogonal offsets non-adaptive again. kai, feb'13 }
/** * Test the calculation of a vehicles position if the actual link length is * longer than the euklidean distance. * * @author mrieser */ public void testDistanceOnLink_longLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 1000, (double) 1000)); final Node fromNode = node1; final Node toNode = node2; Link link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 2000, (double) 10, (double) 9999, (double) 1 ); // place the vehicle at one quarter of the link SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); AgentSnapshotInfo posInfo = new AgentSnapshotInfoFactory(linkWidthCalculator).createAgentSnapshotInfo(Id.create(1, Person.class), link1, 500, 0); assertEquals(260.60660171779824, posInfo.getEasting(), epsilon); assertEquals(239.3933982822018, posInfo.getNorthing(), epsilon); // These numbers became a little weird when I moved vehicles away from the center of a link. Kai, Dec/08 // These numbers changed again when I mad the orthogonal offset adaptive. kai, aug/10 // Made the orthogonal offsets non-adaptive again. kai, feb'13 }