@Override protected C readValue(Command resp) throws TraCIException { Storage content = resp.content(); List<String> ids = new StringList(content, true); C out = makeCollection(); for (String id : ids) { try { out.add(repository.getByID(id)); } catch (IOException e) { throw new TraCIException(e.toString()); } } return out; }
@Override List<Command> getRequests() { if (roadmapPos == null && cartesianPos == null) throw new IllegalStateException("position must be set first"); List<Command> reqs = super.getRequests(); Command req = reqs.iterator().next(); req.content().writeByte(Constants.TYPE_COMPOUND); req.content().writeInt(2); if (cartesianPos != null) { // conversion 2D-to-2D int srcType; double x; double y; if (srcLonLat) { srcType = Constants.POSITION_LAT_LON; // TraCI wants lat-long, which is vertical-horizontal x = cartesianPos.getY(); y = cartesianPos.getX(); } else { srcType = Constants.POSITION_2D; x = cartesianPos.getX(); y = cartesianPos.getY(); } int destType = destLonLat ? Constants.POSITION_LAT_LON : Constants.POSITION_2D; req.content().writeUnsignedByte(srcType); req.content().writeDouble(x); req.content().writeDouble(y); req.content().writeUnsignedByte(Constants.TYPE_UBYTE); req.content().writeUnsignedByte(destType); setPositionType(destType); } else { req.content().writeUnsignedByte(Constants.POSITION_ROADMAP); req.content().writeStringUTF8(roadmapPos.edgeID); req.content().writeDouble(roadmapPos.pos); req.content().writeUnsignedByte(roadmapPos.laneID); req.content().writeUnsignedByte(Constants.TYPE_UBYTE); req.content().writeUnsignedByte(Constants.POSITION_LAT_LON); setPositionType(Constants.POSITION_LAT_LON); } return reqs; }