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
This commit is contained in:
@@ -24,10 +24,22 @@ How posters are made (sources and their licences, kept layers, options, credits)
|
||||
| `GET /circuits/{country}/{locality}/{circuit}/layout/{layout}/{format}` | the layout's file: `geojson`, `svg` or `png` |
|
||||
| `GET /tracks/{country}/{locality}/{circuit}/year/{year}/{format}` | the layout the circuit used that year |
|
||||
| `GET /grand-prix/{race}/{season}/{format}` | the layout a race ran on, such as `/grand-prix/Qatar Grand Prix/2025/geojson` |
|
||||
| `GET /posters/race/{race}/{season}.png?bg=…` | a 1000×1500 race poster; `bg` is `aerial` (default), `osm`, `dark`, `light` or `none` |
|
||||
| `GET /posters/season/{season}.png` | a 1000×1500 season poster |
|
||||
| `GET /posters/session/{race}/{season}/{session}.png` | a 1920×1080 thumbnail for one session, such as `fp1`, `qualifying`, `sprint` or `race` |
|
||||
| `GET /posters/race/{race}/{season}.png?…` | a 1000×1500 race poster: the round, the race's name and date and its track over a picture of its circuit |
|
||||
| `GET /posters/season/{season}.png?…` | a 1000×1500 season poster: the year over a picked photo of that season's cars, or over black |
|
||||
| `GET /posters/session/{race}/{season}/{session}.png?…` | a 1920×1080 thumbnail for one session, such as `fp1`, `qualifying`, `sprint` or `race` |
|
||||
| `GET /kometa/formula-1-metadata.yml` | [Kometa](https://kometa.wiki/) metadata that sets these posters on a Plex Formula 1 library |
|
||||
| `GET /licences` | every source a picture may be made from: its licence, its credit and its terms, and how a picture's licence follows from them |
|
||||
|
||||
The three picture routes take the same options as query parameters ([docs/posters.md](docs/posters.md) lists
|
||||
them): `style` (`classic`, `minimal`), `bg` (`satellite`, its alias `aerial`, `osm`, `dark`, `light`, `none`),
|
||||
`photo` (`natural`, `bw`), `show` (a comma list of `wordmark`, `round`, `name`, `subtitle`, `date`, `circuit`,
|
||||
`locality`, `session`), `locator` and `checker` (`on`, `off`), `track` (`off`, or a colour with an optional width,
|
||||
`#ffffff,6`), `dim` (0 to 1), `accent` (a colour), `width` (200 up to the picture's own) and `format` (`png`, `jpg`,
|
||||
`webp`). An unknown option or value is answered 422, naming it. `bg=satellite` takes the layout's picked Wikimedia
|
||||
Commons photo, else the national aerial photo (USGS in the United States, PDOK in the Netherlands, IGN in France),
|
||||
else EOxCloudless; [circuits/photos.json](circuits/photos.json) holds the picks, and `{"use": "map"}` there makes a
|
||||
layout draw the dark map instead of EOxCloudless. Every picture carries the credit line of its sources at its
|
||||
bottom and in `X-Credits`, its licence in `X-License` (it follows its sources), and `Link: </licences>; rel="license"`.
|
||||
|
||||
A race is named as [Jolpica](https://github.com/jolpica/jolpica-f1) (the Ergast API's successor) names it in
|
||||
its schedule, and its circuit is found by Jolpica's circuit id (`ergastId` in `circuits.json`), never by the
|
||||
@@ -133,18 +145,26 @@ rate limit and kept in `cache/jolpica/`; a throttled or failed fetch is said in
|
||||
|
||||
## Caching
|
||||
|
||||
What the service fetches or renders is kept in `cache/` (the module's cache volume): race schedules from Jolpica
|
||||
in `cache/jolpica/` (a season that is over for good, the running one for six hours), and every poster and thumbnail
|
||||
in `cache/posters/` once every map tile and photo it needs came. A poster is sent with an `ETag` and a day's
|
||||
`Cache-Control`; one whose map or photo failed is not kept, and is sent with five minutes', so it is rendered again
|
||||
once its source answers. Map tiles are fetched in parallel, at most six at once from Esri and two from
|
||||
OpenStreetMap.
|
||||
Race schedules from Jolpica are kept in `cache/jolpica/` (a season that is over for good, the running one for six
|
||||
hours). What a picture needs from the network is a layer, kept for good in `layers/` (the module's `layers` directory,
|
||||
backed up and fetched again if lost): the map picture of one source around a layout, a picked photo cropped to the
|
||||
picture, the world locator and the track's outline. A layer is kept only whole, when every tile came and they are
|
||||
not all one picture. Every finished picture is kept in `posters/` under a key of its route, its options and its
|
||||
layers, at most 2 GB, the least recently used going first; a second season of a circuit draws from the kept layers
|
||||
and fetches nothing. A picture whose map or photo did not arrive is served without it, kept nowhere, and sent with
|
||||
five minutes' `Cache-Control` and no `ETag`.
|
||||
|
||||
Clients keep an address that carries the render version (`?v=r3`, as the Kometa file writes it) for good
|
||||
(`immutable`); any other address a day, then ask again with its `ETag` and get a 304 while it is unchanged. Every
|
||||
request the service makes carries the User-Agent `f1-circuits/<version> (+<its public address>)`. OpenStreetMap tiles
|
||||
are fetched only when a picture asks for them, at most two at once; Wikimedia Commons is asked one request at a time.
|
||||
|
||||
## Checks
|
||||
|
||||
`merge-check.sh` runs before a change merges: every Python file the service ships must parse, and the tests in
|
||||
`tests/` must pass (every circuit has one unique `ergastId`, a race resolves by it, a failed Jolpica fetch is never
|
||||
kept, every link in this README leads to a file).
|
||||
kept, every link in this README leads to a file; a poster's satellite source,
|
||||
credits and licence, its options, keys and cache headers, and the picture store's cap).
|
||||
|
||||
## Acknowledgment
|
||||
|
||||
@@ -152,8 +172,9 @@ kept, every link in this README leads to a file).
|
||||
[initial data source](https://www.google.com/maps/d/u/0/viewer?mid=1nv6ugq4H67CSzKUauW92-pPstYw&ll=-37.84579005412956%2C144.96881158570557&z=16)
|
||||
and altitudes (from [Highs and lows - which F1 track has the most elevation changes?](https://www.formula1.com/en/latest/features/2016/10/highs-and-lows---which-f1-track-has-the-most-elevation-changes-.html))
|
||||
are kept in the upstream files.
|
||||
* Race schedules from [Jolpica](https://github.com/jolpica/jolpica-f1); poster backgrounds from Esri (World Imagery
|
||||
and the grey canvases) and OpenStreetMap.
|
||||
* Race schedules from [Jolpica](https://github.com/jolpica/jolpica-f1) (CC BY-NC-SA 4.0); the posters' pictures from
|
||||
Wikimedia Commons, USGS, PDOK (Beeldmateriaal Nederland), IGN, EOX (EOxCloudless) and OpenStreetMap, each under
|
||||
its licence and with its credit: `/licences` and [docs/posters.md](docs/posters.md).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user