Commit Graph
400 Commits
Author SHA1 Message Date
mesh-tools ab1e4342cb Merge pull request 'Guide Plex and Emby users step by step to the posters, at /guides/' (#12) from docs/guides into master 2026-11-30 11:48:21 +00:00
jschoubben c7753af419 Use a documentation address for the example Plex server 2026-11-30 12:47:36 +01:00
jschoubben 09a83f6ad9 Guide Plex and Emby users step by step to the posters, at /guides/
People put the posters in their own libraries (one in an automated F1 library in Emby), and
the only help was the Kometa example page, written for developers. The guides are for people
who are not: numbered steps of one action each, the exact menus and buttons of Plex, Kometa and
Emby as their own documentation names them, boxes to copy, the pictures from the live API,
what to see after a step and what to do when it does not work. The technical details (routes,
options, the address version, a script and Emby's API) sit at the end of each.

guides/ holds the index, plex.html (a Plex TV library on the Personal Media Shows agent, Kometa
pointed at /kometa/formula-1-metadata.yml, its daily run) and emby.html (Kometa needs Plex, so:
Set Image from URL by hand, or picture files named as Emby's TV naming page reads them, and a
script that saves a whole season from the Kometa file). They use the example site's style
sheet; every example page's nav links them, and README.md lists them.

cdn-api.py serves guides/ at /guides/ beside /examples/, and the image copies it. A mount of a
directory the image lacks stops the service at its start, so tests/test_image.py holds that
every directory the app serves is copied by service/Dockerfile.
2026-11-30 12:46:36 +01:00
mesh-tools 8754f64f80 Merge pull request 'Season posters: a free photo of each season's car, matched to the operator's curated cars' (#11) from feat/season-picks into master 2026-11-30 10:51:58 +00:00
jschoubben e5874f2d9f Key a finished picture by the credit it draws
A finished picture's key named its route, its options and its layers' keys, but not the credit
it draws from a pick. A pick whose author or licence changed while its file stayed the same kept
its photo layer's key, so the stored picture was served again with the old credit drawn on it,
while X-Credits already said the new one (seen locally for 1967, whose author lost Commons'
"upload by" appendix).

finished_key now also takes every text the picture draws from a pick: the credit of each layer
made from a pick's photo (Layer.from_pick, season and layout picks alike). A map's credit follows
its source, which its layer key already names. A picture drawn from no pick adds nothing to the
digest, so its key is the one it had: no kept race, session or pick-less season picture is drawn
again. Seen locally with the old store in place: the race poster, the session thumbnail and the
season poster with bg=none came from the store under their old keys; the 1967 and 1989 season
posters were drawn once under new keys. No release of master ever held a photo pick (neither
seasons/photos.json nor circuits/photos.json), so the running service keeps no picture whose key
changes.

The keys test: the same photo with another credit makes another key (on the old code finished_key
takes no credit; with the credit ignored the keys are equal), and a picture drawn from no pick
keeps the digest of render version, route, options and layer keys it had.

Builds: docs/posters.md at f6b9f937d0 (Finished images: the key names the credit of each layer drawn from a pick; Principles, 2: a changed input makes a new key)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 11:33:56 +01:00
jschoubben 25fee9ca85 Give the addresses an address version of their own, raised to a1
Every season poster changed with the joined picks, but the Kometa file kept handing out
?v=r3, an address clients keep for good: they would never load the new season posters. Raising
the render version instead would draw every kept layer and finished picture again, though only
the season posters changed.

poster_options.ADDRESS_VERSION ("a1") sits beside RENDER_VERSION: the Kometa file writes it into
every poster address, and only an address carrying it is sent the immutable Cache-Control; an
address with ?v=r3 is now any other address (a day, then its ETag). Layers and finished pictures
stay keyed by RENDER_VERSION, still r3, so nothing kept is drawn again except the season posters
whose photo changed. The API's option text, the Kometa docstring and the README say "address
version".

The options test: ?v=a1 is kept for good, ?v=r3 no longer (on master it fails: no
ADDRESS_VERSION, and ?v=r3 is still the immutable address).

Builds: docs/posters.md at f6b9f937d0 (Finished images: what clients keep, the address version)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 11:33:56 +01:00
jschoubben ab0c4b9244 Join the season photo picks: every season from 1950 to 2026 matched to its curated car
seasons/photos.json held only its note, so every season poster was drawn without a photo. It now
holds the 77 picks made by the curated car of each season (three runs: 1950-1975, 1976-2000,
2001-2026), keyed in year order. Licence, author and date of each were read from Commons' own
metadata. Where that date cannot be when the photo was taken, the entry says where its date
comes from: 1978, 1984, 1988 and 1991 from the description (Commons gives a scan or upload
date); 1989 the upload's month, 2012-08 (Commons' 2013-08-21 is the camera's clock, after the
upload of 2012-08-28, and neither the description, whose 1989 is the car's year, nor a category
says when it was taken). 1967's author is the photographer as Commons names him on his other
files, "edvvc from London, UK", without the uploader Commons' Artist field appends. The $comment
says where a candidate comes from, the match order and date_from's three values.

seasons/picks.md is the table of picks the design names: one row per season, newest first, the
curated car named and described (never its photo, never where it is kept), the picked file, its
licence, the match and why, joined from the three runs' tables. 1957, 1975 and 1977 are not in
their season's cars category (searched as the candidates tool searches it, and their own
categories walked up): their rows say they were found by a search for the car by name. Five
seasons are not the same car: 1952 (the champion's car), 1967, 2023 and 2026 (the same team's
car of that season), 1971 (the same model in the livery it raced that season).

The tests read both files as the service does: every season 1950-2026 written in year order and
accepted by poster_sources' reader, each date_from one of the design's three; the table names
every picked season newest first, with the file and licence of seasons/photos.json and one of the
design's four matches (on master both fail: no season is picked, no table). The licence test
gains CC BY-SA 2.5 and the three ported licences the picks use (2.0 de, 3.0 de, 3.0 nl): free,
and the picture CC BY-SA 4.0; pick_share's docstring names them. The reader does not check
date_from, so it needs no change for "upload".

Builds: docs/posters.md at f6b9f937d0 (Season posters: each season's photo is matched to the curated car, the table of picks seasons/picks.md; Picking photos: the name search said in the pick's row, date and date_from, the ported CC BY-SA licences; Licences, stated: 2.5 and the ported licences)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 11:33:56 +01:00
jschoubben f6b9f937d0 Write the lead's answers on the season photos into the design
The season photos are matched to the operator's curated cars (77 seasons, 1950-2026), and the
picks raised questions the design did not answer. The lead's answers of 2026-11-30:

- Season posters: each season's photo is matched to the curated car of that season, in order the
  same car, the same model in a livery it raced that season, the same team's car of that season,
  that season's champion car; a curated photo of another year's car gives way to that season's
  car; the table of picks, seasons/picks.md, names the match per season.
- Picking photos: tools/commons_candidates.py lists a season's candidates from its "<year>
  Formula One season cars" category; where that category holds no free photo of the curated car,
  the person or session picking searches Commons for that car by name, and the pick's row in
  seasons/picks.md says so (no part runs the search: every season is picked).
- An entry's date is when the photo was taken. Where the date Commons gives cannot be (a scan, an
  upload, a camera clock never set, a date after the file's upload), the date its description or
  category gives, marked "date_from"; where neither says, the month of the file's upload, the
  latest it can have been taken, marked "upload" (a true bound, not a date nobody measured).
- The ported CC BY-SA licences (2.0 de, 3.0 de, 3.0 nl) are free like their unported versions and
  give the picture CC BY-SA 4.0; the licences list names them, and 2.5 beside 2.0 and 3.0 (it
  also allows a later version with the same elements).
- Finished images: a finished picture's key also names the credit of each layer drawn from a
  pick, so a pick's changed credit makes a new key (principle 2: a changed input makes a new key).
- What clients keep: the address carries an address version of its own (?v=), separate from the
  render version that keys kept layers and finished pictures; raised when a look changes, so
  clients load it again from the pictures already kept. Raised now to a1 because every season
  poster changed; the render version stays r3.

The season photos leave "Not in this change".

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 11:33:50 +01:00
mesh-tools 072bbcc023 Merge pull request 'Draw Madring's track: take upstream's GPS trace instead of a point' (#10) from fix/madring-trace into master 2026-11-30 09:25:41 +00:00
mesh-tools 7cee693a2c Merge pull request 'Serve the picks from the API, so the live picker reads them' (#9) from fix/picker-reads-picks into master 2026-11-30 09:25:39 +00:00
jschoubben 82a0efabbc Fail the merge check on a point trace for a current race
Madring's point trace reached the 2026 poster unnoticed: nothing held that a layout a race draws
has a traced line. tests/test_traces.py takes every layout the service picks for a season from
2020 to next season (find_layout_slug_for_year over circuits.json, the data the posters draw
from) and fails each whose trace is not a LineString of more than ten points. On master it fails
on spain/madrid/madring/2026- alone; here it passes for all 35.

Builds: docs/posters.md at 8834df45e6 (Layers: no current race draws a layout without a traced line)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:20:48 +01:00
jschoubben 613103e670 Take upstream's re-traced Baku, Miami and Las Vegas traces
Our three files were word-for-word copies of the dataset's traces as they stood in May 2025;
the dataset (bacinger/f1-circuits, MIT) has re-traced all three since: Las Vegas on 2025-07-12 to
2025-08-05 (56 to 100 points, our line up to about 70 m off the new one, length 6116 to 6201),
Miami on 2025-07-29 (109 to 103 points, within 7 m) and Baku on 2025-07-24 and 2026-10-16 (86
points, within 11 m). A newer upstream trace of a circuit already drawn is a plain update: each
is taken word for word, as Madring's, and its SVG and PNG drawn again the same way.

Builds: docs/posters.md at 8834df45e6 (Sources: the traces follow upstream; Layers: track outline points)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:20:43 +01:00
jschoubben 9da882dd73 Draw Madring's track: take the upstream GPS trace instead of a point
The 2026 Spanish race poster showed Madrid with no track, because Madring's trace was a single
point and docs/posters.md (Layers) draws such a layout at its location without a track. The
dataset our traces come from (bacinger/f1-circuits, MIT) traced it on 2025-06-11 as
circuits/es-2026.geojson: a LineString of 116 points, length 5474. It is taken word for word, in
the form of every other trace here (two-space JSON, upstream's id es-2026 and properties).

The SVG is drawn again by generate_svgs.py (TrackLayout.save_svg), the PNG by
circuits/svg-generator.py's Circuit.plot saved transparent with a tight box, as every other PNG
here; both replace the ones drawn from the Wikimedia path. A new trace makes new layer keys,
so no kept poster of Madring is served again.

Upstream's MIT notice is copied word for word with it, as upstream's LICENSE.md holds it since
78726e6 (2025-06-11, the day Madring was traced): "Copyright (c) 2019-2025 Tomislav Bacinger",
in LICENSE.md and in README.md's licence line.

Builds: docs/posters.md at 8834df45e6 (Sources: the traces follow upstream; Layers: track outline points)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:20:37 +01:00
jschoubben 8834df45e6 Write the lead's answers on the circuits' traces into the design
The operator's symptom of 2026-11-30: the 2026 Spanish race poster draws no track, because
Madring's trace is a point. The lead's answers of 2026-11-30 to the questions it raised: a
layout's trace is upstream's newest trace of that circuit (bacinger/f1-circuits), copied once
word for word and never fetched at run time, and a newer upstream trace of a circuit already
drawn is taken as a plain update; the merge check holds that every layout
find_layout_slug_for_year chooses for a season from 2020 on has a LineString trace of more than
10 points (tests/test_traces.py). "Not in this change" now names what remains: three layouts
with an empty trace, Bahrain's offset, and Donington, a copy of Aintree's trace.

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:20:26 +01:00
jschoubben 250828710c Serve the picks from the API, so the live picker reads them
The picker read circuits/photos.json and seasons/photos.json relative to
itself. The API serves only /examples/, so the live page showed two HTTP
404 errors and a "Load it from disk" box for each.

The API now serves both picks files, read-only, at /picks/circuits.json
and /picks/seasons.json. Each answer is the file as the poster service
has it loaded, from the same loader it draws from: the notes first, then
the entries, a refused entry left out. The root route lists both routes.

The picker reads them from the API its site picks. Only a page opened
from a working copy (file:, or a loopback host) falls back to the
repository's files. A failure names each address and why.

Builds: docs/posters.md, Picking photos, as written in 780984064f (the lead's lines 1-4 of 2026-11-30 and answers Q1, Q2)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:18:16 +01:00
jschoubben 780984064f Write the lead's lines and answers for the picks routes into the design
The operator's symptom of 2026-11-30: the live picker showed two HTTP 404
errors, one for circuits/photos.json and one for seasons/photos.json,
each with a "Load it from disk" box. The page read the picks relative to
itself, and the API serves only /examples/.

These are the lead's lines and answers of 2026-11-30, written into
Picking photos. The API serves both picks files, read-only, as the poster
service has them loaded, at /picks/circuits.json and /picks/seasons.json:
the notes first, then the entries it draws from, a refused entry left out.
Both routes have the CORS of every route and, like the other JSON routes,
no Cache-Control (answer Q1). The picker reads them from the API base and
falls back to the repository's files only on file: or a loopback host:
localhost, 127.0.0.1, [::1] (answer Q2).

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
2026-11-30 10:18:11 +01:00
mesh-tools 57e1bef170 Merge pull request 'Posters from licensed sources only: kept layers, options, credits on every picture' (#8) from feat/poster-layers into master 2026-11-27 14:39:51 +00:00
jschoubben f5257d67bb Join the picker's review-round-1 fixes
Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:35:58 +01:00
jschoubben f8d3083fb4 Show the satellite sources' credits as the service draws them
The picker showed shorter PDOK and USGS credits than the design's lines; it now shows them word
for word, as it does IGN's and EOX's. A season photo dated by its category says so on its card,
and a candidate with no date gives no entry, since the service refuses one.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:35:42 +01:00
jschoubben 1cefc6dd52 Keep asked-for texts clear of the credit band; answer review round 1
At 400 to 640 px the credit band, held to 12 px after scaling, covered the date, the circuit line, the session
label and the season's subtitle. The band is now laid out first and every bottom text, the photo inset and the
poster's dark band are lifted by as much as it would cover them, which at full size is nothing, so classic draws
as before; the bottom checker is drawn last again, over the track's end. A first render now draws from the layer
as kept, so it matches every later render of its key, and the ETag is weak all the same. A Commons file's SHA-1
is kept beside the layers and asked once, so photo pictures need no Commons request after a restart. The USGS
credit carries no prefix, and /licences names a layout switched to the map among OpenStreetMap's uses.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:34:38 +01:00
jschoubben f96db9f4ac List the candidates again, every season photo dated
The run of 2026-11-27 (892 requests) changed 8 season candidates and nothing else: each had no
date of its own and now takes its season's year from its category (1969 twice, 1973, 1981, 1989,
1991, 2003, 2008). 31 of 122 layouts and 77 of 77 seasons still have a candidate.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:34:22 +01:00
jschoubben 58ac9472d0 Date an undated season photo by its season
A photo filed under "<year> Formula One season cars" is of that season, and the service refuses
a pick without a date: a season candidate whose file gives none takes the season's year, marked
"date_from": "category". An undated layout candidate still stays out.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:30:31 +01:00
jschoubben d32e57ec41 Write the operator's decisions and the lead's answers into the design
Since the first draft: Commons photos left bg=satellite for an explicit
bg=photo; EOX's 2016 mosaic was rejected for the newest; IGN takes its
frozen 2021-2023 mosaic; a layout can be switched to the map; photo
treatments are natural (default) or bw; a picture's licence follows its
sources; and the builders' questions (presets per frame, placement, dim,
season options, the picks' key and shape, header folding, the smallest
width) are answered where they belong.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:21:24 +01:00
jschoubben 812b01b9dd Join the photo picker and the example pages into the poster layers
Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:20:34 +01:00
jschoubben 445235ca58 Show bg=photo apart from bg=satellite, on the service's layers
The operator, after seeing real posters: EOX's 2016 mosaic is rejected, and a layout's Commons
photo now serves only an explicit bg=photo, which falls back to what bg=satellite draws. The
picker therefore puts the satellite-or-map choice first, per layout, on the layers the service
uses (PDOK HR, IGN's frozen BD ORTHO 2021-2023, USGS, EOxCloudless 2025), and offers the photos
as optional for bg=photo. One picks entry may carry a photo, "use": "map", or both, and each
choice keeps the other half. The builder and the posters page offer bg=photo; width starts at
400; the licences page sets the options in "used for" as code.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:20:09 +01:00
jschoubben 4362e2d10b Draw a picked photo only with bg=photo, keep bg=satellite to aerial imagery
The operator judged the Commons-photo poster unfit as a default: its crop lands beside the circuit and shows the
track only as an inset. bg=satellite is now the national aerial photo, else EOxCloudless (or the dark map where
"use": "map" is set); the new bg=photo draws the layout's picked photo and without one falls back to what
bg=satellite draws. A picks entry may hold the photo fields, "use": "map", or both; an unknown use and incomplete
photo fields are refused at load. The smallest width is 400 px so the full credit line stays readable, and the
ASCII credit header spells out ß, æ, ø, œ and đ so names stay readable.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:18:09 +01:00
jschoubben d514eb57a3 Name an unknown circuit, layout or year with a 404 instead of a 500
The circuit and track routes walked circuits.json with chained lookups, so an unknown country, locality, circuit
or layout, or a year no layout covers, raised and answered 500 (/circuits/photos.json among them). One lookup now
names the first unknown part and the API answers it 404. numpy loads only where a script uses it, so the models,
and this lookup's test, need the standard library alone.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:13:34 +01:00
jschoubben db5c19f0d4 Draw posters from kept layers of licensed sources, credited on every picture
Esri's, Bing's and Google's terms forbid keeping or serving pictures made from their maps, so the posters move to
sources whose licence allows a kept copy: a picked Wikimedia Commons photo, USGS, PDOK and IGN's frozen 2021-2023
mosaic by country, else EOxCloudless's newest mosaic, and OpenStreetMap for the maps and the locator. What needs
the network is a layer fetched once and kept whole in layers/; texts, colours, size and format are drawn on every
request, and finished pictures are kept in posters/ up to 2 GB. Every picture carries its sources' credit line,
X-Credits, X-License (which follows its sources) and a link to /licences. Options are checked into a named 422;
the Kometa file states Jolpica's licence and versions its addresses so clients keep them for good. A layout whose
trace is a point (Madring) is drawn at the circuit's location instead of failing.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:13:29 +01:00
jschoubben 4a9bd4464b Let the picker keep a layout's satellite or give it the map instead
EOX's newest mosaic suits some circuits and not others (the operator, 2026-11-27). Beside a
layout's Commons candidates the picker now frames its trace on what bg=satellite draws without
a photo: the country's own aerial photo (PDOK, IGN, USGS) and EOxCloudless (2016 for a layout
raced in or before 2016, else 2025), with each picture's licence, and the service's own poster
on request. "Keep the satellite" means no entry; "use the map instead" gives {"use": "map"},
from which the service draws the dark map for that layout.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:13:20 +01:00
jschoubben c3c98a9a74 Show the map's satellite layer from EOxCloudless, not Esri
docs/posters.md drops Esri as a source: its terms forbid how this site uses it. The GPS-trace map
now takes its satellite layer from EOX's newest Sentinel-2 mosaic, the posters' own fallback,
credited and licensed (CC BY-NC-SA 4.0) in the map's corner; the scale moves to the top left so
the two-line credit does not cover it.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:07:10 +01:00
jschoubben 49a2ebcf15 Add the photo picker, poster builder and licences pages
A pick is a repository edit, so the picker shows the Commons candidates cropped to the poster's
frame, natural or bw as the service treats them, beside the picks of the circuit's other
layouts, and gives the entry to copy (the picks file's "$comment" kept first). The builder sends
every option of docs/posters.md as a query parameter, renders only on request and shows the
answer's X-Credits and X-License. The licences page shows /licences: each source, its credit and
the licence a picture made from it gets.

Every page now carries the Formula 1 disclaimer at its foot, as F1's guidelines ask of an
unofficial site, and the posters page lists the backgrounds the design keeps (no Esri).

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:04:38 +01:00
jschoubben d087b8a4f3 List the Commons candidates for the photo picker
Made by tools/commons_candidates.py on 2026-11-27 with 892 requests: 31 of 122 layouts and
77 of 77 seasons have at least one candidate; 91 layouts have none, mostly layouts raced
before 1980.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:01:59 +01:00
jschoubben ab9e141cdf Add a tool that lists the Commons photos a poster may use
The posters take an aerial photo per layout and a car photo per season only from Wikimedia
Commons files under CC0, public domain, CC BY or CC BY-SA (docs/posters.md, "Picking photos").
The tool reads each file's licence, author, credit, date and quality marks from the API, keeps
only aerial photos dated within a layout's years, ranks quality marks, size and landscape first,
and keeps Commons' rules: a descriptive User-Agent, one request at a time, at most five a second.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 14:57:55 +01:00
jschoubben 4f00403e13 Design the posters: licensed sources, kept layers, options, credits
Decided with the operator on 2026-11-27 after reading every source's
terms: Esri (and Bing, Azure, Google, Mapbox, MapTiler) do not allow
keeping or serving images made from their maps, so satellite pictures
come from picked Commons photos, national open aerial photos and
EOxCloudless, maps from OpenStreetMap. Heavy layers are fetched once and
kept; options are drawn on the fly; every picture carries its sources'
credits. The design lives in docs/posters.md.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 14:37:13 +01:00
mesh-tools d7b5df3c40 Merge pull request 'Match races by circuit id (Qatar 404), keep schedules, fix posters, add the example site' (#7) from fix/match-circuits-by-id into master 2026-11-27 09:56:42 +00:00
jschoubben 6e62440102 Drop the tile store; a map counts only when every tile came
Review round 3 found two more holes in the disk tile store: a lone
fetched placeholder tile could not be judged and was kept, then vouched
for its neighbours; and a map with some tiles on disk and the rest
refused counted as whole, so a poster with black squares was kept for
good. Three rounds on one part: the store is taken out of this change,
to come back designed whole (placeholders remembered, a lone tile
judged against a fresh neighbour).

Tiles are fetched in parallel as before, all from the network. A map is
drawn only when every tile it needs came and they are not all one
picture; otherwise it is None, and its poster or thumb is drawn
without it, served for five minutes and not kept. A race poster is kept
only when its world locator came too.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:46:12 +01:00
jschoubben 670ecc0162 Judge fetched tiles apart from kept ones; share Esri's request slots
Review round 2: with part of a map's tiles on disk, the placeholder
check saw several pictures and let a provider's placeholder through,
drew it and kept it for 30 days. The tiles fetched now are judged on
their own: two or more that are all one picture matching no kept tile
are a placeholder, and the map fails whole (nothing drawn or kept, the
poster served for five minutes). A real uniform tile, such as open sea,
matches one kept before and passes.

From its notes: the request slots are per tile host, so the satellite
and both grey canvases share Esri's six; a weak If-None-Match matches;
the README says a poster is kept once its map or photo came.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:42:48 +01:00
jschoubben e6701fcd27 Draw the PNGs of the Indianapolis oval and Madring
Both layouts had a trace or a path but no PNG, so their png route found no file.
They are drawn as every other PNG here was: matplotlib 3.10.1, a 10 x 8 inch
figure, a black 2-point line at equal aspect, margins 0.1, tight layout, saved
transparent with a tight box (all 117 existing PNGs redraw pixel for pixel this
way). Madring has no GPS trace, so its hand-made SVG path is drawn instead.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:37:17 +01:00
jschoubben b6652c9955 Name the Le Mans and Sepang layouts by the years F1 raced on them
The Bugatti Circuit held one Grand Prix, in 1967 (1965 is when it opened),
and Sepang returns in 2026 on the same track, so its layout runs on from 1999.
A race resolves its layout by year, so the old names missed 1967 and 2026.
The README's circuit table is regenerated from circuits.json to follow.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:37:17 +01:00
jschoubben 3fadff1542 Wait 30 s for a Jolpica schedule, not 10
Jolpica answers a season it has not served lately in over 10 s (13.5 s
for 2024 on 2026-11-27), so a cold fill timed out 18 seasons and the
Kometa file and the library page went without them until asked again
(found by the library page's test).

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:33:27 +01:00
jschoubben db9f386c7a Add a library page: seasons, race weekends and sessions as Plex shows them
The operator wants to browse the posters the way a Plex or Emby Formula 1
library shows them. The page reads the whole library from the one Kometa
file (rounds, race names in the race posters' addresses, sessions in the
episodes'), waits through a fresh server's minutes-long first answer
instead of failing, and loads each picture only when it is on screen, two
at a time, dropping the queue when the reader leaves a level: every
poster is a render of about 10 s that pulls map tiles. Each level has its
own address and back/forward work; a picture the server has none for is
a plain card with its name.

The session order per weekend format moves into site.js, so the posters
page and the library read the same list.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:33:19 +01:00
jschoubben 8237aabd87 Say in the README what the service keeps in its cache and for how long
Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:31:48 +01:00
jschoubben b55f9cd615 Keep map tiles on disk and fetch them in parallel; send posters with an ETag
A race poster took 8.8 s, 78% of it fetching 40 map tiles one by one,
and every poster, thumb and locator of the same circuit fetched the same
tiles again. Tiles are now kept on disk in the cache volume for 30 days
(stored only once the stitch is no placeholder) and fetched in parallel,
at most 6 at once per Esri service and 2 for OpenStreetMap, as its tile
usage policy asks, across every render. Measured: a poster of a new
circuit 2.4 s, of a known one 0.8 s; a weekend's first thumb 1.4 s, each
further thumb 0.8 s (was about 12 s each). PNGs are saved without
optimize (1.6 s less per render, 2% larger).

A stored poster is sent with an ETag and a day's cache instead of a
year's, and an If-None-Match that matches gets a 304, so a poster whose
look changes reaches clients within a day.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:31:39 +01:00
jschoubben d9c6fdc46c Back off a failed Jolpica ask; render posters off the event loop
Review round 1 (two findings):
- While Jolpica failed, every schedule read asked it again, up to four
  times per poster request, and the poster, thumb and grand-prix routes
  were async, so the pacing, a 429's pause and a timeout stalled every
  request. A failed ask is now remembered for ten minutes (the kept
  schedule, or none, is answered meanwhile), a schedule in memory is
  answered without waiting for an ask under way, and those routes are
  plain defs in the threadpool. A rendered picture is stored whole
  (written aside, then renamed), as two may now render it side by side.
- Bytecode was tracked: tests/__pycache__ (added with the tests) and
  models/__pycache__ that the cleanup missed. Untracked; .gitignore
  already names __pycache__/.

From the review's notes: a poster whose map or photo failed is sent with
a five-minute cache instead of a year's; uvicorn trusts the proxy's
forwarded headers, so /examples redirects to https, not http; stale
comments naming CARTO and the zoom lookup's key are corrected.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:24:04 +01:00
jschoubben ec94c69222 Draw dark and light posters from Esri; keep no poster whose picture failed
CARTO's basemaps now need an API key and answer every tile with an "API
KEY REQUIRED" picture under a 200, so the dark and light backgrounds and
the world locator showed that text. They now use Esri's grey canvases,
which need no key and draw to zoom 16; each provider names its deepest
zoom, and a race poster resolves its position once, capped to it, for
the map, the projected track and the locator alike. One tile stitcher
replaces three copies and refuses a map whose tiles are all the same
picture: a provider's placeholder is said in the log, not drawn.

A race poster, a thumb or a season poster whose map or photo failed is
served but no longer kept, so the next ask renders it again; race
posters carry a render version in their file name, so those drawn over
CARTO's placeholder are rendered again.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:58:14 +01:00
jschoubben 4c4a561141 Rewrite the README for this repository, its API and its data
37 of its 39 links to files of the repository led nowhere: they named
the upstream's flat circuits/<id>.geojson, not this repository's
circuits/<country>/<locality>/<circuit>/<layout>.geo.json. It now says
what the API serves, where the example site is, how the data is laid
out, and lists every circuit with its Jolpica id and a link to each
layout's GPS trace, written from circuits.json. A test holds every
local link to a file.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:48:30 +01:00
jschoubben 6490dc5933 List the routes the API serves at its root
The root's list named a /grand-prix/{name}/year/{year} route and a
/tracks/.../layout/... route that do not exist, and left out the
per-layout file route, the session thumbs and the Kometa metadata, so a
reader of / was sent to addresses that answer 404.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:48:21 +01:00
jschoubben b6e6e9d565 Add an example site that calls every route, served at /examples/
A reader learns the API fastest from working calls: one page per area
(circuit browser, track images, GPS traces on a map, grand prix lookup,
posters, Kometa) shows the exact request URL next to its answer. Pages
call their own origin when the app serves them, and the public service
when opened from disk or given ?api=. Posters render only on a button
press, since each one fetches map tiles on the server. A body that does
not match the asked format is said in red, never shown as success.

The image copies examples/ so the deployed app serves the same pages.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:48:04 +01:00
jschoubben 3271e2d563 Log one line per request with the visitor's address
Uvicorn's access log named only the proxy (172.17.0.1), with no time
taken or client. Each request is now one line: the visitor's address
from route-proxy's X-Forwarded-For, the request, status, size, duration,
referrer and user agent; uvicorn's own access log is off.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:46:56 +01:00
jschoubben 1e2c1b898f Keep Jolpica schedules, pace the requests, never keep a failure
A Kometa YAML request asks Jolpica for every season at once; Jolpica
(4 requests a second, 500 an hour) answered 429 for 24 seasons on
2026-11-27 09:28, and lru_cache kept each failure as an empty schedule,
so every poster and thumb of those seasons answered 404 until a restart.
The service also ran two Jolpica clients, so the race lookup and the
posters held different schedules.

Now one client serves the whole service; a season that is over is kept
on disk in the cache volume for good, one not yet over is asked again
after six hours; requests are paced under the limit, a 429 is asked
again after its Retry-After; a failure is never kept. The Kometa
endpoint runs in the threadpool, as its first fill takes minutes.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 09:46:56 +01:00