devkit_f2c_planner.test_obstacles

Unit tests for obstacle polygon building and swath clipping (shapely only, no fields2cover).

Functions

build(rings_xy[, pad_m])

Run _build_obstacle_polys() on rings given in local xy metres.

clip(rows, obstacles[, min_fragment_len_m])

Run _clip_lines_against_obstacles() with obstacles given as xy rectangles.

square(x0, y0, size)

Classes

BuildObstaclePolysTest([methodName])

ClipLinesAgainstObstaclesTest([methodName])

class devkit_f2c_planner.test_obstacles.BuildObstaclePolysTest(methodName='runTest')[source]

Bases: TestCase

test_bad_ring_does_not_affect_the_others()[source]
test_no_padding_leaves_the_polygon_unchanged()[source]
test_padding_grows_the_polygon_by_the_pad_on_every_side()[source]

Mitre joins: a 10 m square padded by 1 m is exactly 12 m x 12 m.

test_ring_with_a_zero_width_spike_is_repaired_not_dropped()[source]

A dropped obstacle means swaths run straight through it.

test_rings_with_fewer_than_three_points_are_skipped()[source]
test_self_intersecting_ring_is_repaired_or_dropped_never_returned_invalid()[source]
test_valid_ring_becomes_polygon_with_matching_area()[source]
test_zero_area_ring_is_dropped()[source]
class devkit_f2c_planner.test_obstacles.ClipLinesAgainstObstaclesTest(methodName='runTest')[source]

Bases: TestCase

OBSTACLE = [(4, -1), (6, -1), (6, 1), (4, 1)]
test_each_row_is_clipped_independently()[source]
test_fragment_exactly_at_the_minimum_length_is_dropped()[source]
test_fragments_keep_the_direction_of_the_input_row()[source]

Snake ordering reverses rows before clipping and relies on this.

test_fragments_shorter_than_the_minimum_are_dropped()[source]
test_overlapping_obstacles_act_as_their_union()[source]
test_row_fully_inside_the_obstacle_is_dropped()[source]
test_row_missing_the_obstacle_is_unchanged()[source]
test_row_through_the_obstacle_is_split_at_its_edges()[source]
devkit_f2c_planner.test_obstacles.build(rings_xy: list, pad_m: float = 0.0) → list[source]

Run _build_obstacle_polys() on rings given in local xy metres.

devkit_f2c_planner.test_obstacles.clip(rows: list, obstacles: list, min_fragment_len_m: float = 0.5) → list[source]

Run _clip_lines_against_obstacles() with obstacles given as xy rectangles.

devkit_f2c_planner.test_obstacles.square(x0: float, y0: float, size: float) → list[source]