def __handleGroups(self): """ Данный метод обрабатывает группы активных вариантов, имеющие равные segment.id Текущая реализация в каждой группе оставляет активным наиболее вероятный вариант с использованием метода VariantStorage.__selectMostProbable """ groups = {} for variant in funcs.genVariants(self.variants, 'active'): if groups.get(variant.segment.id) is None: groups[variant.segment.id] = [] groups[variant.segment.id].append(variant) for key in groups: if len(groups[key]) > 1: self.__selectMostProbable(groups[key], 0) logger.logByCondFunc(self.isLog, log_mergeVariants, args=(groups[key],), end='')
def __pointToTrack(self, point, track, iteration): segments = getSegmentsByDist(self.mapsDB, point) if self.enableAllowedSegmentsFilter: segments = self.__allowedSegmentsFilter(point, segments) if len(segments) == 0: return False if config.FILTER_UNATTAINABLE_SEGMENTS_ENABLED and not track.isAmbiguity and track.getPointCount() > 0 and not track.prevPointNotBind: segments = filterSegments(self.baseDB, point, track.getLastPoint(), track.getLastSegment(), segments) if len(segments) == 0: return False if (len(segments) > 1 or track.isAmbiguity): if not track.isAmbiguity: track.setAmbiguity(True, self.isLogFull) for segment in segments: v = Variant(segment, point) track.vStorage.addVariant(v) v.addDist(segment.dist) logger.logByCondFunc(self.isLogFull, log_variants, (track.vStorage.variants,), end='') return True elif track.isAmbiguity: track.vStorage.filter(segments, point) logger.logByCondFunc(self.isLogFull, log_variants, (track.vStorage.variants,), end='') if track.vStorage.getActiveCount() == 1: if track.vStorage.selectMostProbable(0.3): logger.logByCondFunc(self.isLogFull, log_selMostProbable, (track.vStorage.variants,)) track.importFromVStorage() track.setAmbiguity(False) return True elif track.vStorage.getActiveCount() > 1: return True elif track.vStorage.getActiveCount() == 0: if track.vStorage.selectMostProbable(0.1): logger.logByCondFunc(self.isLogFull, log_selMostProbable, (track.vStorage.variants,)) track.importFromVStorage() track.setAmbiguity(False) return self.__pointToTrack(point, track, iteration) logger.logByCond(self.isLogFull, ' - add segment %s' % segments[0].id) point.selSegment(segments[0].id) track.addSegment(segments[0]) track.addPoint(point) return True