Give the aerodromes a colour of their own, and say what each aircraft is

Four things about the animated pictures, and the window kept in step with
them.

The aerodromes were amber, and so is an aeroplane at twelve thousand feet.
Sixteen units of CIELAB apart is not two colours, it is one: an aircraft low
over a field was drawn in the field's own colour and neither could be picked
out from the other.  They are magenta now, fifty-six units from the nearest
altitude colour, which is what the ramp leaves free once red, amber, green,
cyan and violet have gone on height -- and what an aeronautical chart marks
an aerodrome in anyway.  The test states that as the distance rather than as
the colour, so that changing the ramp cannot quietly walk an aircraft back
into the airports.

The height beside an aircraft was the flight level, which is shorter and is
what an aviator reads, but "376" is only a height to somebody who already
knows it is one.  It is feet with the unit on it now, rounded to the
twenty-five feet Mode S reports altitude in: a real reading is a multiple of
that and comes through untouched, while a moment interpolated between two
reports stops claiming to know the height to the foot.

The flag of the country of registration now comes off the address block
where no register answered.  Taking it from the register's answer alone left
the flag off exactly the aircraft that had nothing else beside them either.
Mexico was missing from the address table while we were in there, which a
receiver in the American southwest notices; two registers independently give
XA- registrations for that block.

And what sort of aircraft it is, which is two facts and not one.  What it is
comes off the air: every identification message carries three bits under its
type code saying whether it is light, large, heavy, a rotorcraft, a glider,
a drone or a van on the apron, and that is the only word about what an
aircraft *is* that needs no register.  They were being decoded and thrown
away.  They are inside the identification frame the log already writes down
in full, so every log this program has ever written has them, including the
ones written before anything here knew to look.

Whether it is military comes off no air at all -- a tanker calls itself
heavy exactly as an airliner does -- and is read from the address block
instead.  On one evening here AE07D3 broadcast "heavy" and sat in the United
States military block; the register, asked separately, came back with a
C-17A Globemaster III, tail 90-0534, United States Air Force.

Labels in an animation now behave as the boxes in the window do.  One keeps
its place for as long as that place still works and is moved only when
something takes it, which on a real log is about half as many moves as
deciding afresh every frame; the moves that are left are eased over half a
second of playback; and what the next label is laid out against is where a
moving one is going rather than where it has reached.  A still has no frame
before it and places its labels exactly as it always did.

The fading was only half done.  A label's name faded, because it is drawn in
the aircraft's own colour, but its rows and its flag were fixed colours and
stayed at full brightness -- so the brightest thing on that part of the
picture was the one aeroplane nothing had been heard from.  An indexed
picture cannot blend, so the row grey and all twelve flag colours now have
dimmed copies at each of the four fade steps, and the whole box goes
together.  A crowded frame, which drops back to the short label, drops the
class and the flag with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg
This commit is contained in:
The Dust Council 2026-09-04 22:45:41 -07:00
parent 8eb3bdbb86
commit f9b21f7e35
13 changed files with 1616 additions and 67 deletions

View file

@ -1002,3 +1002,357 @@ def test_a_route_it_could_be_flying_stays_in_the_box():
assert blip.route_fits is True
labels = [label for label, _v, _f in blip.lines("knots")]
assert "from" in labels and "to" in labels
# ---------------------------------------------------------------------------
# A box that has to move swings there rather than jumping
# ---------------------------------------------------------------------------
def test_the_glide_moves_towards_the_target_without_passing_it():
from bandsaunter.livemap import glide
here = (0.0, 0.0)
last = here
for _ in range(40):
here = glide(here, (100.0, -60.0), 0.05)
assert 0.0 <= here[0] <= 100.0 and -60.0 <= here[1] <= 0.0
assert here[0] >= last[0] and here[1] <= last[1]
last = here
assert here == (100.0, -60.0), "never actually arrived"
def test_the_glide_arrives_and_stops_asking_for_frames():
"""It has to land exactly on the target, not approach it forever: the
window repaints faster while anything is moving, and a box that is
always a thousandth of a pixel out never lets it stop."""
from bandsaunter.livemap import BOX_GLIDE, glide
here = glide((0.0, 0.0), (50.0, 50.0), BOX_GLIDE * 4)
assert here == (50.0, 50.0)
assert glide(here, (50.0, 50.0), 0.1) == (50.0, 50.0)
def test_the_glide_is_the_same_swing_at_any_frame_rate():
"""Eased by the distance left rather than counted in frames, so a busy
machine drawing half as often makes the same movement, not a slower
one."""
from bandsaunter.livemap import glide
fast = (0.0, 0.0)
for _ in range(8):
fast = glide(fast, (200.0, 0.0), 0.025)
slow = (0.0, 0.0)
for _ in range(2):
slow = glide(slow, (200.0, 0.0), 0.1)
assert abs(fast[0] - slow[0]) < 1.0
def test_a_frame_that_took_no_time_moves_nothing():
from bandsaunter.livemap import glide
assert glide((3.0, 4.0), (99.0, 99.0), 0.0) == (3.0, 4.0)
def test_a_window_left_buried_does_not_replay_the_moves():
"""Ten seconds behind another window is not ten seconds of animation
owed; it is a box that should already be where it belongs."""
from bandsaunter.livemap import glide
assert glide((0.0, 0.0), (300.0, 300.0), 10.0) == (300.0, 300.0)
@qt
def test_a_box_that_need_not_move_does_not_move(app):
"""The whole point of remembering the spot: one aircraft shifting a
pixel must not send its neighbour's box across the window."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.60, lon=-111.30),
a_blip(icao="A00002", callsign="AAL2", lat=32.20, lon=-110.60))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
first = dict(view._box_want)
assert first, "no box was placed at all"
for _ in range(4):
_rendered(view)
assert dict(view._box_want) == first
@qt
def test_a_spot_that_still_works_is_kept(app):
"""Hysteresis, and the reason boxes stay still: a box is only moved
when its own place is actually taken, never because the placer would
now prefer a different one."""
from bandsaunter.livemap import SkyView
view = SkyView(a_sky(a_blip()))
view.resize(900, 650)
view._box_want["A00001"] = (50, 20)
assert view._box_spot("A00001", 400, 300, (120, 60), []) == (450, 320)
@qt
def test_a_spot_that_has_been_taken_is_given_up(app):
from bandsaunter.livemap import SkyView
view = SkyView(a_sky(a_blip()))
view.resize(900, 650)
view._box_want["A00001"] = (50, 20)
spot = view._box_spot("A00001", 400, 300, (120, 60),
[(450, 320, 120, 60)])
assert spot != (450, 320)
assert view._box_want["A00001"] == (spot[0] - 400, spot[1] - 300)
@qt
def test_the_settled_place_is_what_is_spoken_for(app):
"""Laying the next box out against one still in mid-swing would move
that one too, and again when the first arrived; the screen would never
settle. So the target is what goes into the taken list."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.55, lon=-111.20))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
was = view._box_at["A00001"]
view._box_want["A00001"] = (was[0] + 200, was[1] + 100)
view._glide_at = time.time() - 0.05
_rendered(view)
# Mid-swing, and the spot it is heading for is the one it holds.
assert view._box_at["A00001"] != view._box_want["A00001"]
assert view._box_spot("A00001", 0, 0, (10, 10), []) == \
tuple(view._box_want["A00001"])
@qt
def test_the_placer_is_shown_the_settled_spot_not_the_gliding_one(app, monkeypatch):
"""The one that decides whether the screen settles. If a box in mid-
swing is what the next box is laid out against, that next box moves
too -- and moves back when the first one arrives."""
from bandsaunter.livemap import SkyView
early, late = now() - 900, now() - 800
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.55, lon=-111.20,
first_seen=early),
a_blip(icao="B00002", callsign="AAL2", lat=32.25, lon=-110.70,
first_seen=late))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
was = view._box_at["A00001"]
settled = view._box_want["A00001"]
view._box_want["A00001"] = (was[0] + 220, was[1] + 130)
# The second one is made to ask for a place, so we can see what it is
# shown when it does.
view._box_want.pop("B00002")
seen = []
real = livemap.place_box
monkeypatch.setattr(livemap, "place_box",
lambda *a: (seen.append(list(a[4])), real(*a))[1])
view._glide_at = time.time() - 0.05
_rendered(view)
assert seen, "the second box never asked for a place"
offered = [(r[0], r[1]) for r in seen[-1]]
# The offsets are from the symbol, so they only mean anything once the
# symbol is where the picture put it.
ax, ay = view.projection().xy(32.55, -111.20)
target = view._box_want["A00001"]
drawn = view._box_at["A00001"]
assert drawn != settled and drawn != (float(target[0]), float(target[1])), \
"the first box was not in mid-swing, so this proves nothing"
going = (ax + target[0], ay + target[1])
got_to = (int(round(ax + drawn[0])), int(round(ay + drawn[1])))
assert going != got_to, "the two places are the same; nothing is proved"
assert going in offered, "the settled spot was not spoken for"
assert got_to not in offered, "laid out against a box in mid-swing"
@qt
def test_a_box_pushed_off_its_spot_swings_rather_than_jumps(app):
"""Drawn between where it was and where it now belongs, for several
frames, instead of being in the new place on the very next one."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.55, lon=-111.20))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
was = view._box_at["A00001"]
# Push its settled spot well away, as a crowd of new aircraft would.
view._box_want["A00001"] = (was[0] + 240, was[1] + 120)
view._glide_at = time.time() - 0.05 # a frame's worth of clock
_rendered(view)
# Read the target back rather than assuming it: a spot near the edge is
# clamped into the window, so the swing may be shorter than it was asked
# to be.
target = view._box_want["A00001"]
moved = view._box_at["A00001"]
assert target != was, "the test did not actually displace it"
assert moved != was, "it did not move at all"
assert moved != target, "it jumped the whole way in one frame"
part = (moved[0] - was[0]) / (target[0] - was[0])
assert 0.05 < part < 0.60, f"one frame carried it {part:.0%} of the way"
assert view._box_moving is True
# And it does get there, given the frames.
for _ in range(30):
view._glide_at = time.time() - 0.05
_rendered(view)
assert view._box_at["A00001"] == (float(target[0]), float(target[1]))
assert view._box_moving is False, "still asking for frames after arriving"
@qt
def test_a_box_follows_its_aeroplane_without_that_counting_as_a_move(app):
"""The offset is what is remembered, so an aircraft crossing the window
carries its box along instead of dragging it there a frame late."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.50, lon=-111.10))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
settled = view._box_at["A00001"]
sky.update([a_blip(icao="A00001", callsign="AAL1",
lat=32.70, lon=-110.70)], 1, 1)
_rendered(view)
assert view._box_at["A00001"] == settled # same offset, new place
assert view._box_moving is False
@qt
def test_an_aircraft_that_goes_is_forgotten(app):
"""Otherwise one that comes back an hour later glides in from wherever
it was standing then, across the whole window."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1"))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
assert "A00001" in view._box_at
view.detail = 0 # symbols only: no boxes
_rendered(view)
assert view._box_at == {} and view._box_want == {}
@qt
def test_a_box_in_motion_is_drawn_over_the_ones_standing_still(app):
"""It crosses its neighbours for a moment on the way, and the one that
is moving is the one being followed, so it is the one that has to stay
readable while it does."""
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(icao="A00001", callsign="AAL1", lat=32.55, lon=-111.20,
first_seen=now() - 900),
a_blip(icao="B00002", callsign="AAL2", lat=32.25, lon=-110.70,
first_seen=now() - 800))
view = SkyView(sky)
view.resize(900, 650)
_rendered(view)
order = []
real = SkyView._paint_label
def watch(self, painter, laid):
order.append((laid[0], laid[1].icao))
return real(self, painter, laid)
SkyView._paint_label = watch
try:
was = view._box_at["A00001"]
# Away from the other one, so that only this box is on the move.
view._box_want["A00001"] = (was[0] - 160, was[1] + 150)
view._glide_at = time.time() - 0.05
_rendered(view)
finally:
SkyView._paint_label = real
assert [icao for moving, icao in order if moving] == ["A00001"], \
f"expected only the displaced box to be moving, got {order}"
# Everything standing still goes down before anything that is moving.
assert order == sorted(order, key=lambda seen: seen[0])
assert order[-1][1] == "A00001"
# ---------------------------------------------------------------------------
# The ground is dimmed once, not every frame
# ---------------------------------------------------------------------------
def _with_ground(width=900, height=650, brightness=0.70):
from bandsaunter.livemap import SkyView
sky = a_sky(a_blip(), brightness=brightness)
view = SkyView(sky)
view.resize(width, height)
projection = view.projection()
levels = np.random.default_rng(7).integers(
0, 32, (int(height * 1.3), int(width * 1.3)), dtype=np.uint8)
sky.set_ground(levels, view.ground_key(projection),
view.ground_box(projection))
return sky, view
@qt
def test_the_dimmed_map_is_kept_between_frames(app):
"""Cutting the view out, dimming it and looking every level up in the
palette is most of a tenth of a second over two megapixels. Doing it
again for a frame in which nothing about it changed put a ceiling of a
dozen frames a second on the window."""
sky, view = _with_ground()
_rendered(view)
made = view._ground_pixels
assert made is not None
_rendered(view)
assert view._ground_pixels is made, "the map was dimmed all over again"
@qt
def test_a_new_map_is_dimmed_afresh(app):
"""Same window, same brightness, same view: only the map itself is
different, which is what the count on it is for."""
sky, view = _with_ground()
_rendered(view)
made = view._ground_pixels
projection = view.projection()
sky.set_ground(np.full_like(sky._ground, 31),
view.ground_key(projection), view.ground_box(projection))
_rendered(view)
assert view._ground_pixels is not made
@qt
def test_turning_the_brightness_up_redraws_the_map(app):
sky, view = _with_ground()
_rendered(view)
made = view._ground_pixels.copy()
sky.brightness = 0.30
_rendered(view)
assert not np.array_equal(view._ground_pixels, made)
@qt
def test_resizing_the_window_redraws_the_map(app):
sky, view = _with_ground()
_rendered(view)
_rendered(view, width=700, height=500)
assert view._ground_pixels.shape[:2] == (500, 700)
def test_the_window_box_says_what_sort_of_aircraft_it_is():
"""The same two facts the animation shows, so the two look like the
same program: what it broadcast, and whether its address is military."""
military = a_blip(icao="AE07D3", callsign="PRIME04")
military.category = "heavy"
rows = military.lines("knots")
assert ("class", "military heavy", "") in rows
plain = a_blip(icao="AC4C44", callsign="SWA2444")
plain.category = "large"
assert ("class", "large", "") in plain.lines("knots")
quiet = a_blip(icao="AC4C44", callsign="SWA2444")
assert not any(label == "class" for label, _v, _f in quiet.lines("knots"))
def test_the_category_reaches_the_window_from_the_air():
from bandsaunter.adsb import Aircraft
craft = Aircraft(icao="AE07D3", callsign="PRIME04", latitude=32.5,
longitude=-111.0, category="heavy")
assert blip_for(craft).category == "heavy"