/** * Returns an array of all lanes connected to this node, in clock-wise order, starting at the * given lane */ public Drivelane[] getAllLanesCW(Drivelane lane) throws InfraException { Drivelane[] lanes = getAllLanes(); // in clockwise order starting at road 0, lane 0 // find the starting-lane int i = Arrayutils.findElement(lanes, lane); if (i == -1) throw new InfraException("Lane is not on this node"); // shift all the lanes i places and remove the i-th element Drivelane[] result = new Drivelane[lanes.length - 1]; System.arraycopy(lanes, i + 1, result, 0, lanes.length - i - 1); System.arraycopy(lanes, 0, result, lanes.length - i - 1, i); return result; }
/* clockwise order guaranteed */ public Drivelane[] getAllLanes() throws InfraException { int pointer = 0; Drivelane[] lanes = new Drivelane[getNumAllLanes()]; Drivelane[] temp; Road road; for (int i = 0; i < allRoads.length; i++) { road = allRoads[i]; if (road != null) { temp = road.getInboundLanes(this); System.arraycopy(temp, 0, lanes, pointer, temp.length); pointer += temp.length; temp = road.getOutboundLanes(this); System.arraycopy(temp, 0, lanes, pointer, temp.length); pointer += temp.length; } } return lanes; }
/** Returns an array of all inbound lanes on this junction */ public Drivelane[] getInboundLanes() throws InfraException { // System.out.println("Junction.getInboundLanes()"); int pointer = 0; Drivelane[] lanes = new Drivelane[getNumInboundLanes()]; Drivelane[] temp; for (int i = 0; i < allRoads.length; i++) { if (allRoads[i] != null) { temp = allRoads[i].getInboundLanes(this); System.arraycopy(temp, 0, lanes, pointer, temp.length); pointer += temp.length; } } return lanes; }