def classify_old(self, track_segment): past_category = 0 N = len(track_segment) for i in range(N - 2): start = track_segment[i] medium = track_segment[i + 1] stop = track_segment[i + 2] angle = 180 - Track.turn_angle(None, start, medium, stop) curr_category = self.check_category(angle) if curr_category != past_category: if past_category is None: past_category = curr_category continue self.add_category_one(curr_category) past_category = curr_category
def classify(self, track_segment): max_cat = -1 past_category = -1 N = len(track_segment) for i in range(N - 2): start = track_segment[i] medium = track_segment[i + 1] stop = track_segment[i + 2] angle = 180 - Track.turn_angle(None, start, medium, stop) curr_category = self.check_category(angle) max_cat = max(max_cat, curr_category) if curr_category == -1 and past_category != -1: self.add_category_one(max_cat) max_cat = -1 past_category = curr_category return True