def __add_lane_surface_workers__(self, hov, hd): "..." lane_collection = {} # get all lanes from partition_manager for lane_id in self.partition_manager.added_lane_ids: lane = admap.GetLane(lane_id) typ = lane['Type'] # check lane type and put it in corresponding collection if typ not in self.layers.lane_types(): if "OTHER" in lane_collection: lane_collection["OTHER"].append(lane_id) else: lane_collection["OTHER"] = [lane_id] else: if typ in lane_collection: lane_collection[typ].append(lane_id) else: lane_collection[typ] = [lane_id] # go over collections and add workers for typ, lane_ids in lane_collection.iteritems(): title = self.layers.lane_surface_layer_name(typ, hov, hd) layer = self.layers.layer[title] layer_manager = self.layers.layer_managers[title] runner = LaneRunnerSurface(layer_manager, lane_ids, hd) self.worker = Worker(title, layer, runner, self.worker)
def work(self): "..." for lane_id in self.lane_ids: lane = admap.GetLane(lane_id) if lane is not None: self.work_lane(lane) else: self.error.emit("Failed to GetLane(" + str(lane_id) + ")") return None return len(self.lane_ids)
def update_lane_on_layers(self, lane_id, layer_names): "..." to_refresh = [] lane = admap.GetLane(lane_id) for layer_name in layer_names: layer = self.layer[layer_name] manager = self.layer_managers[layer_name] manager.add(lane) to_refresh.append(layer) return to_refresh
def update_lane_speed_layers(self, lane_id): "..." lane = admap.GetLane(lane_id) to_refresh = self.__remove_lane_from__(lane_id, self.layer_managers_speed) if "SpeedLimit" in lane.keys(): for speed_limit in lane['SpeedLimit']: limit = speed_limit[0] layer_manager = self.speed_layer_manager(limit) layer_manager.add_speed_limit(lane, speed_limit) to_refresh.append(layer_manager) return to_refresh
def update_lane_other_layers(self, lane_id): "..." to_refresh = [] for layer_manager_name in self.layer_managers: layer_manager = self.layer_managers[layer_manager_name] if not layer_manager in self.layer_managers_speed: if not layer_manager in self.layer_managers_surface: if layer_manager.is_on_layer(lane_id): lane = admap.GetLane(lane_id) layer_manager.add(lane) to_refresh.append(layer_manager) return to_refresh
def update_lane_surface_layers(self, lane_id): "..." lane = admap.GetLane(lane_id) to_refresh = self.__remove_lane_from__(lane_id, self.layer_managers_surface) typ = lane['Type'] hov = lane['HOV'] > 1 high_definition = lane['ComplianceVer'] > 0 layer_manager_name = self.lane_surface_layer_name(typ, hov, high_definition) layer_manager = self.layer_managers[layer_manager_name] layer_manager.add(lane) to_refresh.append(layer_manager) return to_refresh
def add(self, lane): "..." lane_id = lane['Id'] pts_from = self.__generate_alt_points__(lane_id, self.tlon, self.tlat) if self.position in lane.keys(): conns = lane[self.position] for conn in conns: to_lane_id = conn['ToLane'] to_lane = admap.GetLane(to_lane_id) if to_lane is not None: key = (lane_id, to_lane_id) LayerManager.remove_old_feature(self, key) types = conn['Type'] attrs = [lane_id, to_lane_id, str(types)] pts_to = self.__generate_alt_points__( to_lane_id, self.tlon, self.tlat) feature = self.__add_shortest_arrow__( self.layer, pts_from, pts_to, attrs) LayerManager.add_new_feature(self, key, feature) if lane_id in self.to_topo: self.to_topo[lane_id].append(to_lane_id) else: self.to_topo[lane_id] = [to_lane_id]
def readd(self, lane_id): "..." lane = admap.GetLane(lane_id) self.remove(lane_id) self.add(lane)