Cover every option in the help, the manual and the readme, and say what to install
An audit rather than a feature, prompted by wanting this fit to hand to somebody else. Five options had no command-line flag written down in the table the manual is generated from -- location, hold, schedules, tile_url and speed_unit -- so five flags that exist were missing from the manual. Four of them did exist under other names and are now recorded; hold had no flag at all and has one. Four switches could be turned off from the command line and not back on: --no-lookup, --no-basemap, --no-airports and --no-labels had no positive halves, so an option turned off in the saved settings could not be turned on again for one run. All four now have both. And adsb, which opens the window and draws a map when it stops, could not be given any of the settings that decide what those look like: no --at, no --radius, no --tiles, no --map-brightness, no --width, --fps, --trail, --fade, --stale, --airports or --labels. It takes all of them now. The manual had no list of the aircraft options at all -- the ADS-B sections were hand-written prose -- so five of them appeared nowhere in it. It now generates an AIRCRAFT OPTIONS section from the same table the menu and the flags come from, and the readme carries a table of all thirty-four with their flags and defaults. Three tests hold the three of them together: one that every option records its flag, one that every flag the table claims actually exists on a command, and one that the readme names them all. The installing instructions now list every dependency rather than only the optional ones: the four Python packages with their names in Debian, Fedora and Arch, and librtlsdr, which is a C library and therefore the one thing pip cannot bring and a virtual environment cannot supply. What reaches a network is written down too -- which host, when, and which file it is cached in -- since somebody installing this on a metered or air-gapped machine has to be able to see that nothing is fetched behind their back. build-repo.sh needs dpkg-dev and apt-utils, which a minimal system does not have, and now says so. Verified rather than asserted: a clean virtual environment, pip install from this tree, and a real log read back through the installed command. It pulls seven wheels rather than the four the page claimed, the other three being what Rich brings with it. Also: matplotlib is gone from the readme's dependency table, nothing having imported it; ffmpeg and Qt are in it, both having been missing; ffmpeg is a Suggests on the package; and resume.sh is ignored. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg
This commit is contained in:
parent
6d2436cde1
commit
8ed01f991f
16 changed files with 1012 additions and 46 deletions
|
|
@ -1566,13 +1566,14 @@ def test_an_airport_cannot_be_mistaken_for_an_aircraft():
|
|||
# The flag on the receiver
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_the_background_flies_a_flag_where_the_receiver_was_told_it_is():
|
||||
def test_the_frame_flies_a_flag_where_the_receiver_was_told_it_is():
|
||||
track = straight()
|
||||
view = fm.fit([track], width=600)
|
||||
middle = ((view.south + view.north) / 2, (view.west + view.east) / 2)
|
||||
plain = fm.background(view, unit="knots")
|
||||
flagged = fm.background(view, unit="knots", home=middle)
|
||||
assert not (plain == fm.HOME).any()
|
||||
base = fm.background(view, unit="knots")
|
||||
assert not (base == fm.HOME).any(), "the ground still flies the flag"
|
||||
flagged = fm.render_frame(base, view, [track], track.fixes[0].at,
|
||||
unit="knots", home=middle)
|
||||
assert (flagged == fm.HOME).any(), "no flag was drawn"
|
||||
# The foot of the pole is the position it is pointing at.
|
||||
x, y = view.xy(*middle)
|
||||
|
|
@ -1584,14 +1585,37 @@ def test_no_flag_where_nobody_said_the_receiver_is():
|
|||
not a place anybody is standing, and a flag on it would say one is."""
|
||||
track = straight()
|
||||
view = fm.fit([track], width=600)
|
||||
assert not (fm.background(view, unit="knots") == fm.HOME).any()
|
||||
base = fm.background(view, unit="knots")
|
||||
assert not (fm.render_frame(base, view, [track], track.fixes[0].at,
|
||||
unit="knots") == fm.HOME).any()
|
||||
|
||||
|
||||
def test_a_receiver_outside_the_picture_is_not_flagged_at_its_edge():
|
||||
track = straight()
|
||||
view = fm.fit([track], width=600)
|
||||
base = fm.background(view, unit="knots")
|
||||
away = (view.north + 20.0, view.east + 20.0)
|
||||
assert not (fm.background(view, unit="knots", home=away) == fm.HOME).any()
|
||||
assert not (fm.render_frame(base, view, [track], track.fixes[0].at,
|
||||
unit="knots", home=away) == fm.HOME).any()
|
||||
|
||||
|
||||
def test_nothing_is_drawn_over_the_flag():
|
||||
"""It says where the receiver is standing, which is the one thing on
|
||||
the picture that must never be hidden behind an aeroplane that happened
|
||||
to fly over it."""
|
||||
track = straight()
|
||||
view = fm.fit([track], width=600)
|
||||
base = fm.background(view, unit="knots")
|
||||
# An aircraft exactly on top of the receiver, with a label and a trail.
|
||||
here = (track.fixes[0].latitude, track.fixes[0].longitude)
|
||||
img = fm.render_frame(base, view, [track], track.fixes[0].at,
|
||||
unit="knots", labels=True, home=here,
|
||||
trail_seconds=600.0)
|
||||
x, y = view.xy(*here)
|
||||
assert img[y, x] == fm.HOME, "the aircraft was drawn over the flag"
|
||||
# The whole pole, not just its foot.
|
||||
pole = img[y - fm.HOME_POLE:y + 1, x]
|
||||
assert (pole == fm.HOME).all(), "part of the pole was painted over"
|
||||
|
||||
|
||||
def test_the_animation_flies_the_flag_only_where_it_was_given_a_centre(tmp_path):
|
||||
|
|
@ -1789,9 +1813,10 @@ def test_no_rings_without_a_radius_or_without_a_position():
|
|||
assert np.array_equal(
|
||||
fm.background(view, unit="knots", ground=ground, home=None,
|
||||
rings=60.0), plain)
|
||||
flagged = fm.background(view, unit="knots", ground=ground, home=home)
|
||||
assert (flagged == fm.HOME).any() # the flag, but no rings
|
||||
assert not (flagged == fm.GROUND + fm.RING_LIFT).any()
|
||||
# A position on its own is not a reason to draw rings: it is the radius
|
||||
# that says how far out they go.
|
||||
placed = fm.background(view, unit="knots", ground=ground, home=home)
|
||||
assert not (placed == fm.GROUND + fm.RING_LIFT).any()
|
||||
|
||||
|
||||
def _labels_drawn(**over):
|
||||
|
|
@ -1851,3 +1876,74 @@ def test_a_distance_field_measures_from_the_place_it_was_given():
|
|||
assert away[0, 0] == pytest.approx(0.0, abs=0.01)
|
||||
# A degree of latitude is sixty nautical miles, near enough.
|
||||
assert away[1, 0] == pytest.approx(60.0, abs=0.5)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# The card behind a label
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _labelled(opacity, shade=20):
|
||||
track = straight()
|
||||
view = fm.fit([track], width=800, box=(50.0, -3.0, 52.0, 3.0))
|
||||
ground = np.full((view.height, view.width), shade, dtype=np.uint8)
|
||||
base = fm.background(view, unit="knots", ground=ground, brightness=1.0)
|
||||
img = base.copy()
|
||||
fm._label(img, 300, 200, track, track.fixes[0], fm.RAMP, [], "knots",
|
||||
entry=_Entry(), opacity=opacity)
|
||||
return base, img
|
||||
|
||||
|
||||
def test_no_card_at_all_puts_the_words_straight_on_the_map():
|
||||
"""Which is what the pictures used to look like, and still can."""
|
||||
base, img = _labelled(0.0)
|
||||
# Only pixels that are still map in both: the words themselves turn map
|
||||
# into ink, and that is the label being drawn rather than a card.
|
||||
ground = (base >= fm.GROUND) & (base < fm.GROUND + fm.GROUND_SHADES)
|
||||
still = ground & (img >= fm.GROUND) & (img < fm.GROUND + fm.GROUND_SHADES)
|
||||
assert np.array_equal(img[still], base[still]), "the map was darkened"
|
||||
|
||||
|
||||
def test_a_card_darkens_the_map_under_the_words():
|
||||
base, img = _labelled(0.6)
|
||||
darker = (img < base) & (base >= fm.GROUND) & \
|
||||
(base < fm.GROUND + fm.GROUND_SHADES)
|
||||
assert darker.sum() > 200, "nothing was darkened"
|
||||
# And the coastline still shows through: not everything went to one shade.
|
||||
under = img[darker]
|
||||
assert under.max() > under.min() or under.min() > fm.GROUND
|
||||
|
||||
|
||||
def test_the_card_gets_darker_the_more_of_it_is_asked_for():
|
||||
def under(opacity):
|
||||
base, img = _labelled(opacity)
|
||||
return int(img[195:215, 295:400].astype(int).sum())
|
||||
|
||||
steps = [under(part) for part in (0.0, 0.3, 0.6, 0.9)]
|
||||
assert steps == sorted(steps, reverse=True), steps
|
||||
|
||||
|
||||
def test_a_card_the_whole_way_up_is_a_solid_panel():
|
||||
base, img = _labelled(1.0)
|
||||
assert (img == fm.PANEL).any(), "the panel colour was never used"
|
||||
ground = (base >= fm.GROUND) & (base < fm.GROUND + fm.GROUND_SHADES)
|
||||
covered = ground & (img == fm.PANEL)
|
||||
assert covered.sum() > 200, "the map still shows through a solid panel"
|
||||
|
||||
|
||||
def test_the_card_fades_with_the_label_it_is_behind():
|
||||
"""A card at full strength under a label on its way out would be the
|
||||
brightest thing left of it."""
|
||||
track = straight()
|
||||
view = fm.fit([track], width=800, box=(50.0, -3.0, 52.0, 3.0))
|
||||
ground = np.full((view.height, view.width), 20, dtype=np.uint8)
|
||||
base = fm.background(view, unit="knots", ground=ground, brightness=1.0)
|
||||
|
||||
def darkness(strength):
|
||||
img = base.copy()
|
||||
fm._label(img, 300, 200, track, track.fixes[0], fm.RAMP, [], "knots",
|
||||
entry=_Entry(), opacity=0.9, strength=strength)
|
||||
# How much darker, not how many pixels: a fainter card covers the
|
||||
# same rectangle and merely takes less out of it.
|
||||
return int((base.astype(int) - img.astype(int)).clip(0).sum())
|
||||
|
||||
assert darkness(1.0) > darkness(0.5) > 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue