Cache what has been looked up, make it browsable, and say where this lives
Four things asked for in turn, landing together because they run through the same files. THE MAPS. The tiles were already cached and always had been -- a second evening on the same view was measured at nought network requests -- but the work done on them was not. Every window open decoded forty PNGs and resampled a megapixel and a half into this program's own projection, for an answer that cannot have changed, because a coastline does not move. The finished map is kept beside the tiles now: 0.61 seconds become 0.01, byte for byte identical, two hundred kilobytes a view. Both windows and both kinds of still picture get it, all four reaching the ground through one function. A map with squares missing is deliberately not kept, since caching a hole would keep it for a month and the point of calling a partial map provisional is that it is asked for again. And because this adds a disk consumer, the whole cache is now pruned to four hundred megabytes, least recently *used* first: a tile fetched a year ago and looked at last night is the receiver's own neighbourhood, and discarding that to keep last week's holiday is the wrong way round. THE LOOKUPS. APRS and FT8 now ask who each station is licensed to. Every other mode that hears a callsign already did -- speech transcripts, Morse idents, the recording browser -- and all five resolve through one file, so a callsign heard on two bands is asked about once. The rules for finding the licensed callsign inside a heard one are now in one place rather than per band, because getting them wrong is silent: a register asked about W1AW-9 returns nothing, which looks exactly like a station that is not licensed. An SSID, a rover suffix, a guest prefix, a digipeater alias and an unspelled hash all come off or are refused. The bug worth recording is that the first cut of this did the lookups and threw them away. The book has to be told to save and was not, so every evening would have asked the register about the same net again -- which is the one thing caching them was for, and is invisible from inside a single run because the answers are all in memory while it lasts. Caught by looking at the file on disk rather than at the display. There is a test for each side of it now, and a register of which modules resolve callsigns at all, which fails when a new one starts so that somebody has to decide whether it should. THE REGISTER. c in saunterbrowse opens everything ever looked up: sixty-odd callsigns and sixteen hundred aircraft here, every field of each in two columns because a licence has a dozen and a screen is wider than it is tall. tab switches, / searches every field rather than the name -- the question is usually "who was in Arizona" rather than "which callsign" -- and g opens the place in a browser. Only the coordinates go into that link: a map does not need to be told whose licence it is looking at, and the link is the one part of this that leaves the machine. A headless box, which is the normal case for a receiver, gets the coordinates printed instead. Callsigns no register could place are kept rather than dropped, because "asked about, and in no register reachable from here" is a fact about a station. THE FRONT OF IT. A title screen for each program: five rows of blocks cut by hand, a figlet dependency to draw eleven letters being the largest thing that would then be in the requirements, coloured blue to red across the width, which is the ramp every waterfall here already uses because it is what a spectrum looks like. The interesting part is where it does not appear -- everything here can be piped into something else and a banner in the middle of that is corruption rather than decoration, so anything that is not a terminal gets nothing, --help is untouched because it is drawn after parsing, --no-splash turns it off for a run and BANDSAUNTER_NO_SPLASH=1 for good. And the address. INSTALL.md said "git clone <the repository>" for a long time: a placeholder in the first command anybody types, unnoticed because nothing reads install instructions except somebody installing, who then cannot. It is filled in, along with the readme, the metadata, both manuals and the Homepage field of all three packages. The tile server's User-Agent pointed at a topic listing on somebody else's site for want of an address of its own; the usage policy of that service asks for one naming the application and giving somewhere to look it up, so an operator with a question about the traffic has somebody to ask, and now it gives the real one. Seven tests so the placeholder cannot come back, verified by putting it back and watching two of them fail. One thing forced by all this: the keys page in saunterbrowse was exactly as tall as an eighty-by-twenty-four terminal, so the register entry pushed "q quit" off the bottom. A test caught it. Home and End have merged into the Page Up line, which were always the same thought. THE WINDOWS. They open maximised now, this being a map and the thing anybody wants more of being map; f goes to true full screen and back, and is written along the top of the screen because a window with no frame is one somebody has to know a key to get out of. Maximised rather than frameless by default, because the title bar is where the band and the frequency are written. And a map made bigger now gets a sharper map, which it did not. The window only ever re-examined the ground when the view left the box that had been fetched, so a window opened at its default size and taken to the whole screen kept the map it started with until an aircraft wandered far enough to move it -- on a quiet band, a long time to look at a blurred coastline. Measured before it was believed: 1100 to 1920 asked for nothing and stretched a 1364-pixel map across 1920, then across 3840. It now compares map pixels per degree in hand against what the view wants, and asks when it is being blown up by more than fifteen per cent. That comparison has to be per degree rather than pixel against pixel, which a surviving mutation was what established: the fetched box is a quarter wider than the view, so a map with exactly as many pixels as the window is wide has only four fifths of them on the screen. The two ways of measuring agree everywhere except a narrow band, and the realistic case sits inside it. There is a test pinning that case now. Asking is safe at any size, because the request is keyed on the window's dimensions: once answered, nothing more is asked, which is what stops a window larger than the tile budget can cover from asking all evening. The braille, while this was open. The banners were blocks in capitals; they are braille in mixed case, two dots wide and four tall to a character, which is eight times the detail and is what makes room for two heights of letter at once -- a five-row block font has no second height to spend, so the name came out shouted. Two attempts failed first: thin one-dot strokes came out as confetti, because braille dots render as dots and a one-dot stroke reads as a dotted line rather than a line. What worked was cutting the font small, at cap height seven where there is only one way to draw each letter, and doubling it. Coloured deep blue through cyan to a cool white, which is deliberately not the waterfall ramp the rest of the program draws in: that one has to run to red because it stands in for a spectrum, and a title screen stands in for nothing. One hundred and four new tests. Full suite 2892 passed. Built as 2026-09-24_01. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg
This commit is contained in:
parent
93120b80a6
commit
2665a17a22
27 changed files with 3733 additions and 49 deletions
|
|
@ -2419,3 +2419,249 @@ def test_the_empty_picture_draws_the_words_it_was_given(app):
|
|||
waiting="listening on 144.39 MHz\n\nnothing placed yet — a station "
|
||||
"appears\nonce it has said where it is"))
|
||||
assert int((plane != station).any(axis=2).sum()) > 200
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Keeping up with the window
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class _Quiet(_NoPainter):
|
||||
"""A painter that lets the ground be drawn, once there is any.
|
||||
|
||||
_NoPainter refuses, on purpose, so that a test of "it asked and drew
|
||||
nothing" cannot pass by drawing something. These tests are about what
|
||||
happens once there *is* a map.
|
||||
"""
|
||||
|
||||
def drawImage(self, *a):
|
||||
pass
|
||||
|
||||
|
||||
def _grown(sky, view, painter, width, height):
|
||||
"""Resize, paint the ground, and say what was asked for."""
|
||||
view.resize(width, height)
|
||||
view._draw_ground(painter, view.projection())
|
||||
return sky.wanted_ground()
|
||||
|
||||
|
||||
@qt
|
||||
def test_a_window_made_bigger_fetches_a_sharper_map(app):
|
||||
"""A map fetched for a smaller window is still a map of the right piece
|
||||
of world, so nothing else notices it is being stretched. Opening at the
|
||||
default size and then going to the whole screen used to keep the first
|
||||
map until an aircraft wandered far enough to move the view out of the
|
||||
fetched box -- which on a quiet band is a long time to look at a blurred
|
||||
coastline.
|
||||
"""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
painter = _Quiet()
|
||||
|
||||
asked = _grown(sky, view, painter, 900, 650)
|
||||
assert asked is not None
|
||||
key, box, size = asked
|
||||
first = size[0]
|
||||
sky.set_ground(np.zeros((size[1], size[0]), dtype=np.uint8), key, box)
|
||||
|
||||
# Twice as wide: the map in hand now covers each of its pixels with two.
|
||||
asked = _grown(sky, view, painter, 1800, 1300)
|
||||
assert asked is not None, "it kept stretching the map it had"
|
||||
assert asked[2][0] > first * 1.5, asked[2]
|
||||
|
||||
|
||||
@qt
|
||||
def test_a_window_nudged_a_few_pixels_does_not_refetch(app):
|
||||
"""Dragging an edge must not send somebody's evening to a tile server a
|
||||
hundred times."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
painter = _Quiet()
|
||||
key, box, size = _grown(sky, view, painter, 1200, 850)
|
||||
sky.set_ground(np.zeros((size[1], size[0]), dtype=np.uint8), key, box)
|
||||
|
||||
for extra in (1, 4, 20, 60):
|
||||
sky._wanted = None
|
||||
view.resize(1200 + extra, 850)
|
||||
view._draw_ground(painter, view.projection())
|
||||
assert sky.wanted_ground() is None, f"refetched over {extra} pixels"
|
||||
|
||||
|
||||
@qt
|
||||
def test_it_stops_asking_once_the_sharper_map_has_arrived(app):
|
||||
"""The check is "am I being stretched", and a window larger than the
|
||||
tile budget can cover is stretched by design -- so this had better be
|
||||
answered by the request rather than by the result, or a 4K window asks
|
||||
for a map for the rest of the evening."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
painter = _Quiet()
|
||||
key, box, size = _grown(sky, view, painter, 3840, 2160)
|
||||
# Answered with a map of the size asked for, which is what the fetching
|
||||
# does however far the zoom had to be capped to get it.
|
||||
sky.set_ground(np.zeros((size[1], size[0]), dtype=np.uint8), key, box)
|
||||
for _ in range(5):
|
||||
sky._wanted = None
|
||||
view._draw_ground(painter, view.projection())
|
||||
assert sky.wanted_ground() is None, "it is still asking"
|
||||
|
||||
|
||||
@qt
|
||||
def test_a_window_made_smaller_does_not_refetch(app):
|
||||
"""Shrinking leaves the map finer than it needs to be, which costs
|
||||
nothing and looks perfect."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
painter = _Quiet()
|
||||
key, box, size = _grown(sky, view, painter, 1800, 1300)
|
||||
sky.set_ground(np.zeros((size[1], size[0]), dtype=np.uint8), key, box)
|
||||
sky._wanted = None
|
||||
view.resize(900, 650)
|
||||
view._draw_ground(painter, view.projection())
|
||||
assert sky.wanted_ground() is None
|
||||
|
||||
|
||||
@qt
|
||||
def test_the_stretch_is_measured_in_map_pixels_per_degree(app):
|
||||
"""Not in window pixels: the fetched box is wider than the view, so the
|
||||
two numbers are not the same and comparing the wrong pair would either
|
||||
never refetch or always."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
view.resize(1000, 700)
|
||||
projection = view.projection()
|
||||
box = view.ground_box(projection)
|
||||
across = box[3] - box[1]
|
||||
shown = projection.east - projection.west
|
||||
assert across > shown, "the fetched box is not wider than the view"
|
||||
|
||||
# A map at exactly the density the view wants is not stretched; one at
|
||||
# half that is.
|
||||
want = projection.width / shown
|
||||
exact = np.zeros((10, int(round(want * across))), dtype=np.uint8)
|
||||
assert not SkyView._stretched(exact, box, projection)
|
||||
half = np.zeros((10, max(1, exact.shape[1] // 2)), dtype=np.uint8)
|
||||
assert SkyView._stretched(half, box, projection)
|
||||
|
||||
# The case that tells the two ways of measuring apart, and the realistic
|
||||
# one: a map with exactly as many pixels as the window is wide, spread
|
||||
# over a box a quarter wider than the view. Only four fifths of those
|
||||
# pixels land on the screen, so it *is* being stretched -- and counting
|
||||
# raw pixels against raw pixels would call it fine.
|
||||
same = np.zeros((10, projection.width), dtype=np.uint8)
|
||||
assert SkyView._stretched(same, box, projection), (
|
||||
"the stretch is being measured in window pixels rather than in map "
|
||||
"pixels per degree")
|
||||
|
||||
|
||||
@qt
|
||||
def test_nothing_is_stretched_when_there_is_nothing_to_stretch(app):
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
view.resize(900, 650)
|
||||
projection = view.projection()
|
||||
assert not SkyView._stretched(None, (0.0, 0.0, 1.0, 1.0), projection)
|
||||
assert not SkyView._stretched(np.zeros((4, 4), dtype=np.uint8), None,
|
||||
projection)
|
||||
# A box with no width at all cannot be divided by.
|
||||
assert not SkyView._stretched(np.zeros((4, 4), dtype=np.uint8),
|
||||
(1.0, 2.0, 1.0, 2.0), projection)
|
||||
|
||||
|
||||
@qt
|
||||
def test_the_window_opens_maximised(app):
|
||||
"""This is a map, and the thing somebody wants more of is map. It used
|
||||
to open at eleven hundred by eight hundred whatever the screen was."""
|
||||
from bandsaunter.livemap import _build
|
||||
|
||||
window = _build()["Window"](a_sky(a_blip()), "test")
|
||||
assert window.isMaximized()
|
||||
assert not window.isFullScreen()
|
||||
|
||||
|
||||
@qt
|
||||
def test_un_maximising_gives_back_a_usable_window(app):
|
||||
"""Set before maximising, so that there is a size to come back to: a
|
||||
window maximised from nothing restores to whatever the toolkit guessed."""
|
||||
from bandsaunter.livemap import _build
|
||||
|
||||
window = _build()["Window"](a_sky(a_blip()), "test")
|
||||
restored = window.normalGeometry()
|
||||
assert restored.width() >= 800 and restored.height() >= 600
|
||||
|
||||
|
||||
@qt
|
||||
def test_f_goes_to_true_full_screen_and_back_to_maximised(app):
|
||||
"""Back to maximised rather than to the size it was built at: leaving
|
||||
full screen should not shrink the map to a quarter of the screen."""
|
||||
from bandsaunter.livemap import _build, _qt
|
||||
|
||||
_name, core, gui, _widgets, _signal = _qt()
|
||||
window = _build()["Window"](a_sky(a_blip()), "test")
|
||||
|
||||
def press(letter):
|
||||
window.keyPressEvent(gui.QKeyEvent(
|
||||
core.QEvent.Type.KeyPress, 0,
|
||||
core.Qt.KeyboardModifier.NoModifier, letter))
|
||||
|
||||
press("f")
|
||||
assert window.isFullScreen() and not window.isMaximized()
|
||||
press("f")
|
||||
assert window.isMaximized() and not window.isFullScreen()
|
||||
|
||||
|
||||
@qt
|
||||
def test_the_keys_along_the_top_say_how_to_go_full_screen(app):
|
||||
"""A window with no frame is one somebody has to know a key to get out
|
||||
of, so the key is on the screen rather than only in the manual."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
view.resize(1400, 700)
|
||||
said = []
|
||||
|
||||
class _Spy:
|
||||
"""Swallows everything a painter is asked to do, and keeps the text."""
|
||||
|
||||
def __getattr__(self, name):
|
||||
return lambda *a, **k: None
|
||||
|
||||
def drawText(self, *a):
|
||||
said.append(a[-1])
|
||||
|
||||
view._draw_header(_Spy(), 1)
|
||||
assert any("f full" in line for line in said), said
|
||||
|
||||
|
||||
@qt
|
||||
def test_opening_maximised_fetches_a_map_for_the_size_it_opened_at(app):
|
||||
"""The two halves of this belong together: a window that opens big is no
|
||||
use if the map it fetches is for a window that opened small."""
|
||||
from bandsaunter.livemap import SkyView
|
||||
|
||||
sky = a_sky(a_blip())
|
||||
view = SkyView(sky)
|
||||
painter = _Quiet()
|
||||
|
||||
# The small size a window used to open at, answered.
|
||||
key, box, size = _grown(sky, view, painter, 1100, 800)
|
||||
small = size[0]
|
||||
sky.set_ground(np.zeros((size[1], size[0]), dtype=np.uint8), key, box)
|
||||
|
||||
# Now the size a maximised window on an ordinary screen has.
|
||||
sky._wanted = None
|
||||
asked = _grown(sky, view, painter, 1920, 1080)
|
||||
assert asked is not None, "it opened big and kept the small map"
|
||||
assert asked[2][0] > small
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue