| 383 | tree.write(rouFile, encoding='utf-8') |
| 384 | |
| 385 | def selectRoute(self): |
| 386 | elementTree = ET.parse(self.netFile) |
| 387 | root = elementTree.getroot() |
| 388 | for child in root: |
| 389 | if child.tag == 'location': |
| 390 | boundary = child.attrib['convBoundary'].split(',') |
| 391 | (x1, y1, x2, y2) = (float(i) for i in boundary) |
| 392 | mid_x = (x1 + x2) / 2 |
| 393 | mid_y = (y1 + y2) / 2 |
| 394 | self.nb.plotScene(self.widget, mid_x, mid_y, self.ctf, True) |
| 395 | if ',' in self.rouFile: |
| 396 | rouFile = self.rouFile.split(',')[1] |
| 397 | else: |
| 398 | rouFile = self.rouFile |
| 399 | elementTree = ET.parse(rouFile) |
| 400 | root = elementTree.getroot() |
| 401 | for child in root: |
| 402 | if child.tag == 'vehicle': |
| 403 | vtid = child.attrib['id'] |
| 404 | if vtid == self.ego.id: |
| 405 | startLaneId = child.attrib['departLane'] |
| 406 | arrivalLaneId = child.attrib['arrivalLane'] |
| 407 | for gchild in child: |
| 408 | if gchild.tag == 'route': |
| 409 | route = gchild.attrib['edges'] |
| 410 | break |
| 411 | try: |
| 412 | route = route.split(' ') |
| 413 | return route[0] + '_' + startLaneId, route[-1] + '_' + arrivalLaneId |
| 414 | except NameError: |
| 415 | print('The ego vehicle id does not exist. Program exits.') |
| 416 | sys.exit() |
| 417 | |
| 418 | def putFrameInfo(self, vid: str, vtag: str, veh: Vehicle): |
| 419 | self.dataQue.put( |