Posters from licensed sources only: kept layers, options, credits on every picture #8

Merged
mesh-tools merged 17 commits from feat/poster-layers into master 2026-11-27 14:39:52 +00:00
5 changed files with 105 additions and 75 deletions
Showing only changes of commit 445235ca58 - Show all commits
+5 -4
View File
@@ -99,8 +99,9 @@
{ name: 'style', kind: 'select', def: 'classic', values: [['classic', 'classic'], ['minimal', 'minimal']],
note: 'A preset of the options below; any option given overrides it.' },
{ name: 'bg', kind: 'select', def: 'satellite', values: [
['satellite', 'satellite: the layout’s picked Commons photo, else the national aerial photo, else EOxCloudless'],
['satellite', 'satellite: the national aerial photo, else EOxCloudless 2025; the dark map for a layout that asks for it'],
['aerial', 'aerial: the same as satellite, for addresses in use'],
['photo', 'photo: the layout’s picked Commons photo, else what satellite draws'],
['osm', 'osm: OpenStreetMap'], ['dark', 'dark: OpenStreetMap, recoloured dark'],
['light', 'light: OpenStreetMap, recoloured light'], ['none', 'none: no map']],
note: 'The kept map or photo layer.' },
@@ -112,7 +113,7 @@
{ name: 'track', kind: 'track', def: 'white, 6', note: 'The outline, from the kept points; an inset over a photo layer.' },
{ name: 'dim', kind: 'range', def: 'the style’s', note: 'How much the background is darkened, 0 to 1.' },
{ name: 'accent', kind: 'color', def: 'the style’s', note: 'The wordmark’s colour.' },
{ name: 'width', kind: 'width', def: 'the frame’s', note: 'Scaled down at encoding, from 200 up to the frame’s width.' },
{ name: 'width', kind: 'width', def: 'the frame’s', note: 'Scaled down at encoding, from 400 up to the frame’s width.' },
{ name: 'format', kind: 'select', def: 'png', values: [['png', 'png'], ['jpg', 'jpg'], ['webp', 'webp']], note: 'The encoding.' },
];
@@ -182,11 +183,11 @@
value = () => pick.value;
box._set = (v) => { if (/^#[0-9a-f]{6}$/i.test(v)) pick.value = v; };
} else if (o.kind === 'width') {
const num = h('input', { type: 'number', min: 200, step: 10, value: 600, 'aria-label': o.name });
const num = h('input', { type: 'number', min: 400, step: 10, value: 600, 'aria-label': o.name });
const max = h('span', { class: 'hint' });
num.addEventListener('input', touch);
body.append(num, max);
box._max = (m) => { num.max = m; max.textContent = `200 to ${m} for this route`; };
box._max = (m) => { num.max = m; max.textContent = `400 to ${m} for this route`; };
value = () => num.value;
box._set = (v) => { num.value = v; };
}
+2 -2
View File
@@ -78,9 +78,9 @@
</a>
<a class="page" href="posters.html">
<h3>Posters</h3>
<p>Race posters on five backgrounds, season posters and a thumbnail per session of a race weekend, rendered on request.</p>
<p>Race posters on six backgrounds, season posters and a thumbnail per session of a race weekend, rendered on request.</p>
<ul>
<li><code>/posters/race/{race name}/{season}.png?bg={satellite|osm|dark|light|none}</code></li>
<li><code>/posters/race/{race name}/{season}.png?bg={satellite|photo|osm|dark|light|none}</code></li>
<li><code>/posters/season/{season}.png</code></li>
<li><code>/posters/session/{race name}/{season}/{session}.png</code></li>
</ul>
+11 -2
View File
@@ -88,7 +88,7 @@
rule: 'A picture’s licence follows the sources it is made from.',
licences: [
{ licence: 'CC BY-SA 4.0', licence_url: CC('by-sa'), when: 'made from a CC BY-SA photo' },
{ licence: 'CC BY-NC-SA 4.0', licence_url: CC('by-nc-sa'), when: 'made from EOX’s mosaics after 2016' },
{ licence: 'CC BY-NC-SA 4.0', licence_url: CC('by-nc-sa'), when: 'made from EOxCloudless 2025' },
{ licence: 'CC BY 4.0', licence_url: CC('by'), when: 'otherwise' },
],
},
@@ -104,6 +104,15 @@
const link = (href, text) => (href ? h('a', { href, target: '_blank', rel: 'noopener' }, text || href) : text || '–');
/** What a source is used for, its options (bg=photo, bg=satellite, …) set as code so they read as the options they are. */
function usedFor(text) {
const out = h('span');
for (const part of String(text).split(/(\b(?:bg|photo|locator|track)=[a-z0-9#]+(?:\|[a-z0-9]+)*)/)) {
if (part) out.append(/^(bg|photo|locator|track)=/.test(part) ? h('code', {}, part) : part);
}
return out;
}
/** A credit form, its placeholders marked. */
function credit(text) {
const code = h('code');
@@ -119,7 +128,7 @@
h('thead', {}, h('tr', {}, ...['Source', 'Used for', 'Licence', 'Credit', 'Terms', 'A picture from it'].map((t) => h('th', {}, t)))),
h('tbody', {}, ...sources.map((s) => h('tr', { id: `source-${s.id}` },
h('td', {}, h('b', {}, s.name || s.id), h('br'), h('small', {}, h('code', {}, s.id))),
h('td', {}, s.used_for || '–'),
h('td', {}, s.used_for ? usedFor(s.used_for) : '–'),
h('td', {}, link(s.licence_url, s.licence)),
h('td', {}, credit(s.credit)),
h('td', {}, s.terms ? link(s.terms, new URL(s.terms, location.href).host || s.terms) : '–'),
+85 -66
View File
@@ -39,10 +39,12 @@
<main>
<h1>Photo picker</h1>
<p class="lead">
A race poster over <code>bg=satellite</code> uses a layout’s picked Wikimedia Commons photo when it has one, and a
season poster shows that season’s cars only from a picked photo. This page shows the candidates
Per layout, the main choice is what <code>bg=satellite</code> draws: the country’s own aerial photo or
EOxCloudless 2025, or the dark map instead. A layout may also have a Wikimedia Commons photo picked for
<code>bg=photo</code>, which falls back to what <code>bg=satellite</code> draws while none is picked; a season poster
shows that season’s cars only from a picked photo. The photos are the candidates
<code>tools/commons_candidates.py</code> found, cropped to the poster’s frame as the service crops them, in natural
colour or black and white. Choosing one gives the entry to copy into the picks file. The page writes nothing to the
colour or black and white. Each choice gives the entry to copy into the picks file. The page writes nothing to the
server: a pick is a change to the repository.
</p>
<p>
@@ -106,10 +108,10 @@
</section>
<div id="photos-root">
<h2 id="sat-title" hidden>bg=satellite: the satellite, or the map</h2>
<div id="sat"></div>
<h2 id="others-title">Picks of the circuit’s other layouts</h2>
<div id="others"></div>
<h2 id="sat-title" hidden>Without a photo: the satellite, or the map</h2>
<div id="sat"></div>
<h2 id="cands-title">Candidates</h2>
<div id="cands"></div>
</div>
@@ -301,11 +303,16 @@
/** A pick as the picks file holds it: a photo, or {"use": "map"}. */
function pickCard(entry, label, picked) {
if (typeof entry.file === 'string' && entry.use === 'map') {
const card = photoCard({ ...entry, thumb: thumbOf(entry.file) }, { label, picked });
card.querySelector('.name').after(h('div', { class: 'tags' }, h('span', { class: 'tag', title: 'Its entry also says "use": "map"' }, 'the dark map for bg=satellite')));
return card;
}
if (entry.use === 'map') {
return h('article', { class: `photo-card${picked ? ' picked' : ''}` },
h('div', { class: 'map-frame plain' }, h('span', {}, 'The dark map')),
h('div', { class: 'meta' }, h('b', {}, label)),
h('div', { class: 'name' }, '{"use": "map"}'));
h('div', { class: 'name' }, '{"use": "map"}: the dark map for bg=satellite'));
}
return photoCard({ ...entry, thumb: thumbOf(entry.file) }, { label, picked });
}
@@ -350,42 +357,67 @@
return h('div', { class: 'copy-block' }, h('div', { class: 'head' }, h('span', {}, title), button), body);
}
/**
* The entry a choice leaves for a key, from the one there now: one entry may carry the photo fields (bg=photo),
* "use": "map" (bg=satellite), or both. Choosing a photo keeps "use": "map"; the map keeps the photo; keeping the
* satellite drops only "use". null: no entry is left.
*/
function entryFor(existing, kind, cand) {
const photo = existing && typeof existing.file === 'string'
? Object.fromEntries(PICK_FIELDS.filter((k) => k in existing).map((k) => [k, existing[k]])) : null;
const map = !!existing && existing.use === 'map';
if (kind === 'photo') return { ...entryOf(cand), ...(map ? { use: 'map' } : {}) };
if (kind === 'map') return { ...(photo || {}), use: 'map' };
return photo;
}
/** What of the entry there now a choice keeps, said in one sentence. */
function keeps(existing, kind) {
if (!existing) return '';
if (kind === 'photo' && existing.use === 'map') return ' It keeps "use": "map" for bg=satellite.';
if (kind === 'map' && typeof existing.file === 'string') return ' It keeps the photo picked for bg=photo.';
if (kind === 'satellite') return ' It keeps the photo picked for bg=photo, without "use".';
return '';
}
function showEntry() {
const section = $('entry');
const body = $('entry-body');
if (!state.chosen) { section.hidden = true; return; }
const { key, cand, fileName, fileKey, kind } = state.chosen;
const file = state.picks[fileKey];
const existing = file && Object.prototype.hasOwnProperty.call(file, key) ? file[key] : null;
const entry = entryFor(existing, kind, cand);
const rule = [' ', h('a', { href: F1.linkWithKept('licences.html') }, 'The licences page'), ' states the rule.'];
const parts = [];
const what = kind === 'satellite' ? 'the satellite, not the map' : kind === 'map' ? 'the dark map instead of the satellite' : cand.file;
const parts = [h('p', {}, 'For ', h('code', {}, key), ': ', h('b', {}, what), '.')];
if (entry) {
parts.push(
h('p', {}, 'Copy the entry into ', h('code', {}, fileName), ', or the whole file below with the entry in place.', keeps(existing, kind)),
copyBlock(`The entry, for ${fileName}`, `${JSON.stringify(key)}: ${JSON.stringify(entry, null, 2)}`));
} else if (!file) {
parts.push(h('p', {}, 'No entry is needed for it.'));
} else if (existing) {
parts.push(h('p', {}, `No entry is left for it: remove the one ${fileName} has now.`));
} else {
parts.push(h('p', { class: 'hint' }, `No entry is needed for it, and ${fileName} has none: nothing to change.`));
}
if (kind === 'satellite') {
const src = satelliteSource(key);
const has = file && Object.prototype.hasOwnProperty.call(file, key);
parts.push(h('p', {}, 'Keep the satellite for ', h('code', {}, key), ': no entry. Without a picked photo, ', h('code', {}, 'bg=satellite'),
` draws ${src.name}; a poster from it is ${src.poster}.`), notice('info', 'A picture’s licence follows its sources.', ...rule));
if (!file) parts.push(notice('error', `${fileName} was not read, so the page cannot say whether it has an entry for this layout to remove.`));
else if (has) parts.push(h('p', {}, `${fileName} has an entry for it now: remove it. The whole file without it:`), copyBlock(`The whole of ${fileName} without an entry for ${key}`, withPick(file, key, null)));
else parts.push(h('p', { class: 'hint' }, `${fileName} has no entry for it: nothing to change.`));
parts.push(notice('info', `bg=satellite draws ${src.name} for this layout; a poster from it is ${src.poster}. A picture’s licence follows its sources.`, ...rule));
} else if (kind === 'map') {
parts.push(notice('info', 'The service draws the dark OpenStreetMap map for this layout in place of the satellite: for bg=satellite, and for bg=photo while no photo is picked. A poster on it is CC BY 4.0.', ...rule));
} else {
const entry = kind === 'map' ? { use: 'map' } : entryOf(cand);
parts.push(
h('p', {}, 'For ', h('code', {}, key), ': ', h('b', {}, kind === 'map' ? 'the dark map instead of the satellite' : cand.file), '. Copy the entry into ', h('code', {}, fileName),
', or the whole file below with the entry in place.'),
copyBlock(`The entry, for ${fileName}`, `${JSON.stringify(key)}: ${JSON.stringify(entry, null, 2)}`));
if (kind === 'map') {
parts.push(notice('info', 'With this entry and no picked photo, the service draws the dark OpenStreetMap map for this layout where bg=satellite is asked. A poster on it is CC BY 4.0.', ...rule));
} else {
const sa = /\bBY-SA\b/i.test(cand.licence);
parts.push(notice('info', sa
? `${cand.licence} is share-alike: a poster made from it is adapted material, shared under CC BY-SA terms. Such a poster is CC BY-SA 4.0.`
: `A poster made from it is CC BY 4.0: a picture’s licence follows its sources, and ${cand.licence} asks no share-alike.`, ...rule));
if ((cand.restrictions || []).length) {
parts.push(notice('', `Commons names ${cand.restrictions.join(' and ')} rights for this file: rights beside its copyright licence, such as a person’s likeness or a trade mark shown in it.`));
}
const sa = /\bBY-SA\b/i.test(cand.licence);
parts.push(notice('info', fileKey === 'circuits' ? 'This photo serves bg=photo only; bg=satellite does not change. ' : '', sa
? `${cand.licence} is share-alike: a poster made from it is adapted material, shared under CC BY-SA terms. Such a poster is CC BY-SA 4.0.`
: `A poster made from it is CC BY 4.0: a picture’s licence follows its sources, and ${cand.licence} asks no share-alike.`, ...rule));
if ((cand.restrictions || []).length) {
parts.push(notice('', `Commons names ${cand.restrictions.join(' and ')} rights for this file: rights beside its copyright licence, such as a person’s likeness or a trade mark shown in it.`));
}
if (file) parts.push(copyBlock(`The whole of ${fileName} with this entry`, withPick(file, key, entry)));
else parts.push(notice('error', `${fileName} was not read, so the whole file cannot be shown: copy the entry, or load the file from disk above.`));
}
if (!file) parts.push(notice('error', `${fileName} was not read, so the whole file cannot be shown${kind === 'photo' ? '' : ', nor whether it has an entry for this layout now'}: load it from disk above.`));
else if (entry || existing) parts.push(copyBlock(`The whole of ${fileName} ${entry ? 'with this entry' : 'without an entry for it'}`, withPick(file, key, entry)));
body.replaceChildren(...parts);
section.hidden = false;
}
@@ -416,40 +448,29 @@
// ------------------------------------------------------------ without a photo: the satellite, or the map
// The satellite chain without a pick (docs/posters.md, Sources): the country's own aerial photo, else EOxCloudless
// (its 2016 mosaic for a layout raced in or before 2016, else the newest). Tile addresses as each provider serves
// them, checked 2026-11-27; past maxNativeZoom Leaflet scales the deepest tiles up.
// What bg=satellite draws (the operator, 2026-11-27): the country's own aerial photo, else EOxCloudless 2025; a
// Commons photo only ever for bg=photo. The layers the service uses; past maxNativeZoom (the deepest level every
// circuit of that country has, checked 2026-11-27) Leaflet scales the deepest tiles up.
const NATIONAL = {
netherlands: { name: 'PDOK’s aerial photo', url: 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_ortho25/EPSG:3857/{z}/{x}/{y}.jpeg',
netherlands: { name: 'PDOK’s aerial photo', url: 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:3857/{z}/{x}/{y}.jpeg',
maxNativeZoom: 19, credit: 'Luchtfoto: PDOK / Beeldmateriaal Nederland', licence: 'CC BY 4.0', poster: 'CC BY 4.0' },
france: { name: 'IGN’s BD ORTHO', url: 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg',
maxNativeZoom: 19, credit: '© IGN – BD ORTHO', licence: 'Licence Ouverte (Etalab) 2.0', poster: 'CC BY 4.0' },
france: { name: 'IGN’s BD ORTHO 2021–2023', url: 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS2021-2023&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg',
maxNativeZoom: 18, credit: '© IGN – BD ORTHO, 2021–2023', licence: 'Licence Ouverte (Etalab) 2.0', poster: 'CC BY 4.0' },
'united-states': { name: 'USGS imagery', url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}',
maxNativeZoom: 16, credit: 'Imagery: USGS', licence: 'public domain', poster: 'CC BY 4.0' },
};
const NEWEST_EOX = 2025;
const EOX = {
name: 'EOxCloudless 2025',
url: 'https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-2025_3857/default/g/{z}/{y}/{x}.jpg',
maxNativeZoom: 15,
credit: 'EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data 2025)',
licence: 'CC BY-NC-SA 4.0',
poster: 'CC BY-NC-SA 4.0',
};
function eox(year) {
return {
name: `EOxCloudless ${year}`,
url: `https://tiles.maps.eox.at/wmts/1.0.0/${year === 2016 ? 's2cloudless_3857' : `s2cloudless-${year}_3857`}/default/g/{z}/{y}/{x}.jpg`,
maxNativeZoom: 15,
credit: `EOxCloudless https://cloudless.eox.at by EOX IT Services GmbH (Contains modified Copernicus Sentinel data ${year})`,
licence: year === 2016 ? 'CC BY 4.0' : 'CC BY-NC-SA 4.0',
poster: year === 2016 ? 'CC BY 4.0' : 'CC BY-NC-SA 4.0',
};
}
/** The EOX mosaic of a layout: 2016 for one raced in or before 2016, else the newest. */
function eoxOf(layout) {
const last = layout.endsWith('-') ? Infinity : parseInt(layout.split('-')[1] || layout, 10);
return eox(last <= 2016 ? 2016 : NEWEST_EOX);
}
/** What bg=satellite draws for a layout with no picked photo. */
/** What bg=satellite draws for a layout that does not ask for the map. */
function satelliteSource(key) {
const [country, , , layout] = key.split('/');
return NATIONAL[country] || eoxOf(layout);
return NATIONAL[key.split('/')[0]] || EOX;
}
const traces = new Map();
@@ -544,10 +565,9 @@
const sig = `${key}|${frameNow()}`;
const src = satelliteSource(key);
const status = !state.picks.circuits ? 'circuits/photos.json was not read, so what this layout uses now is not known.'
: !current ? `No entry: without a photo, bg=satellite draws ${src.name} for it now.`
: current.use === 'map' ? 'Its entry says {"use": "map"}: it uses the dark map now.'
: `A photo is picked for it (${current.file}), so neither is used now.`;
const head = h('p', { class: 'hint' }, `Without a picked photo, bg=satellite draws ${src.name} for this layout. Judge it below, its trace drawn in white: keep the satellite, or have the service draw the dark map instead. `, h('b', {}, status));
: current && current.use === 'map' ? 'Its entry says "use": "map": bg=satellite draws the dark map for it now.'
: `Its entry does not ask for the map: bg=satellite draws ${src.name} for it now.`;
const head = h('p', { class: 'hint' }, `bg=satellite draws ${src.name} for this layout, and bg=photo does too while it has no picked photo. Judge it below, its trace drawn in white: keep the satellite, or have the service draw the dark map instead. `, h('b', {}, status));
const choices = h('div', { class: 'choices' },
h('button', { type: 'button', 'data-kind': 'satellite', onclick: () => chooseSurface(key, 'satellite') }, 'Keep the satellite (no entry)'),
h('button', { type: 'button', 'data-kind': 'map', onclick: () => chooseSurface(key, 'map') }, 'Use the map instead'));
@@ -563,8 +583,7 @@
const country = p.country;
const cards = [];
if (NATIONAL[country]) cards.push(mapCard(NATIONAL[country], 'What bg=satellite draws for this country'));
const e = eoxOf(p.layout);
cards.push(mapCard(e, NATIONAL[country] ? 'What bg=satellite draws where the national photo has no tiles' : 'What bg=satellite draws here'));
cards.push(mapCard(EOX, NATIONAL[country] ? 'What bg=satellite draws where the national photo has no tiles' : 'What bg=satellite draws here'));
cards.push(serviceCard(p));
$('sat').replaceChildren(head, grid(cards), choices);
markChoices();
@@ -631,7 +650,7 @@
// The circuit's other layouts, and this one's pick when it has one.
$('others-title').hidden = false;
$('others-title').textContent = `Picks of ${p.circuitName || 'this circuit'}’s layouts`;
$('others-title').textContent = `For bg=photo (optional): the picks of ${p.circuitName || 'this circuit'}’s layouts`;
if (!picks) {
$('others').replaceChildren(notice('error', 'circuits/photos.json was not read (see 1), so the picks are not shown.'));
} else {
@@ -645,14 +664,14 @@
}
const undated = ((state.candidates.about || {}).undated_per_circuit || {})[circuitKey];
$('cands-title').textContent = `Candidates for ${layoutYears(p.layout)}${list ? ` (${list.length})` : ''}`;
$('cands-title').textContent = `Candidates for bg=photo (optional), ${layoutYears(p.layout)}${list ? ` (${list.length})` : ''}`;
if (!list) {
$('cands').replaceChildren(notice('error', `The candidates file has no entry for ${key}: run tools/commons_candidates.py again.`));
return;
}
const why = undated ? ` The tool found ${undated} more photo${undated === 1 ? '' : 's'} of this circuit with no date it can read; a layout lists only photos dated within its years.` : '';
if (!list.length) {
$('cands').replaceChildren(notice('', `Commons has no freely licensed aerial photo of this circuit dated ${layoutYears(p.layout)} that the tool found: the layout keeps the satellite or uses the map (above).${why}`));
$('cands').replaceChildren(notice('', `Commons has no freely licensed aerial photo of this circuit dated ${layoutYears(p.layout)} that the tool found: bg=photo draws what bg=satellite draws for it (above).${why}`));
return;
}
$('cands').replaceChildren(
+2 -1
View File
@@ -51,7 +51,8 @@
<div class="controls">
<label><span>Background (<code>bg</code>)</span>
<select id="bg">
<option value="satellite">satellite: the layout’s picked Commons photo, the national aerial photo, or EOxCloudless (the default)</option>
<option value="satellite">satellite: the national aerial photo, else EOxCloudless 2025 (the default)</option>
<option value="photo">photo: the layout’s picked Commons photo, else what satellite draws</option>
<option value="osm">osm: OpenStreetMap street map</option>
<option value="dark">dark: OpenStreetMap, recoloured dark</option>
<option value="light">light: OpenStreetMap, recoloured light</option>