def clean_noise_type_1(s_container, command, geo_content): for line in s_container.get_features(): line_topology = Topology(s_container, line) line_topology.orient_linked_lines() if line.length > command.noise or len(line_topology.start_linked_lines) >= 2: for ind in [FIRST, LAST]: if ind == LAST: line_topology.reverse() linked_lines = line_topology.start_linked_lines if len(linked_lines) == 2 and \ is_open_arm(s_container, linked_lines[0]) and \ is_open_arm(s_container, linked_lines[1]): if linked_lines[0].length <= command.noise and linked_lines[1].length <= command.noise: p = [] for linked_line in linked_lines: p.append(linked_line.coords[-1]) p_line = LineString((p[0], p[1])) if p_line.disjoint(line): new_point = p_line.interpolate(.5, normalized=True) lst_coords = list(line.coords) new_coord = [(new_point.x, new_point.y)] lst_coords = new_coord + lst_coords line.coords = lst_coords s_container.del_features(linked_lines) geo_content.nbr_noise += 2 else: # The new line is touching something ===> No edtion pass else: # There must be 2 lines under the noise tolerance pass else: # The line to edit must have an open arm (no links) pass else: # The line is not linked to other line pass