devkit_f2c_planner.f2c_test_helpers

Shared helpers for the devkit_f2c_planner unit tests.

  • planner: f2c_planner imported even where fields2cover is not installed (fields2cover is built in docker/Dockerfile and is not pip-installable in CI). Only the shapely-based functions work without it; tests that go through _run_f2c() patch planner.f2c with FakeF2C.

  • to_ll / to_xy: build fixtures in metres and convert them with the planner’s own projection. The projection itself is tested independently in test_projection.py.

  • FakeF2C: records calls and returns canned swaths. It mirrors only the fields2cover calls made by _run_f2c(), so it tests the planner’s own logic (ordering, clipping, projection), not fields2cover.

Functions

silence_planner_log(test)

The planner logs to stderr with print(); keep test output clean.

to_ll(points_xy[, lat0, lon0])

Local xy metres -> lat/lon, anchored at (lat0, lon0) == xy (0, 0).

to_xy(points_ll[, lat0, lon0])

lat/lon -> local xy metres, anchored at (lat0, lon0).

Classes

FakeCell()

f2c.Cell stand-in.

FakeF2C(swaths_xy[, headland_cells, ...])

Canned stand-in for the fields2cover module, as used by _run_f2c().

class devkit_f2c_planner.f2c_test_helpers.FakeCell[source]

Bases: object

f2c.Cell stand-in. rings[0] is the outer boundary, the rest are hole hints.

addRing(ring: _FakeRing) → None[source]
class devkit_f2c_planner.f2c_test_helpers.FakeF2C(swaths_xy: list, headland_cells: list | None = None, headland_error: Exception | None = None)[source]

Bases: object

Canned stand-in for the fields2cover module, as used by _run_f2c().

swaths_xy swaths (lists of local-xy points) returned by SG_BruteForce headland_cells cells returned by the headland generator (default: one inset cell) headland_error exception raised by the headland generator instead

Cell

alias of FakeCell

Cells(cell: FakeCell) → FakeCell[source]
HG_Const_gen() → _FakeHeadlandGenerator[source]
LinearRing

alias of _FakeRing

Point

alias of _FakePoint

SG_BruteForce() → _FakeSwathGenerator[source]
devkit_f2c_planner.f2c_test_helpers.silence_planner_log(test: TestCase) → None[source]

The planner logs to stderr with print(); keep test output clean.

devkit_f2c_planner.f2c_test_helpers.to_ll(points_xy: list, lat0: float = 55.0, lon0: float = -1.5) → list[source]

Local xy metres -> lat/lon, anchored at (lat0, lon0) == xy (0, 0).

devkit_f2c_planner.f2c_test_helpers.to_xy(points_ll: list, lat0: float = 55.0, lon0: float = -1.5) → list[source]

lat/lon -> local xy metres, anchored at (lat0, lon0).