vercors.me : collecte Météo-France / Infoclimat / VP2, archive SQLite, accueil en carte, forum (squelette)
- collecte : collecter_meteofrance, extraire_infoclimat, extraire_vp2, archiver_historique, importer_opendata ; WeatherLink allégé (alleger) - tests : meteofrance, infoclimat, vp2, archive, opendata (tous verts) - maquettes/accueil-carte : sources de la maquette (générateurs de tuiles, page, À propos, CGU, confidentialité) - forum : noyau local (rôles, droits, SQLite, serveur de test, 18 tests) - deploy : Caddyfile.vercors.me.v2 (non appliqué) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
956d08ffd7
révision
ff42faca16
42 fichiers modifiés
+5127
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,55 @@
|
||||
# Découpe la carte (rendu.html) en images WebP de 512 px à 4 niveaux de zoom, avec Edge sans affichage.
|
||||
import json, os, subprocess, time, urllib.request, base64
|
||||
import websocket
|
||||
|
||||
EDGE = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
|
||||
T, M = 512, 8 # taille d'une image ; marge rendue autour (le flou ne doit pas laisser de bord clair)
|
||||
X0, Y0, LW, LH = json.load(open('large.json'))['cadre']
|
||||
# niveau : échelle (px par unité de 100 m) et zone couverte (unités) ; le niveau 0 couvre tout le cadre
|
||||
NIVEAUX = [(0, 1, (X0, Y0, X0 + LW, Y0 + LH)), (1, 2, (-400, -300, 950, 1050)),
|
||||
(2, 4, (-150, -60, 700, 800)), (3, 8, (-70, -20, 590, 775))]
|
||||
|
||||
proc = subprocess.Popen([EDGE, '--headless=new', '--hide-scrollbars', '--remote-debugging-port=9334',
|
||||
'--user-data-dir=' + os.path.abspath('profil-tuiles'), 'about:blank'])
|
||||
try:
|
||||
for _ in range(50):
|
||||
try:
|
||||
page = next(t for t in json.load(urllib.request.urlopen('http://127.0.0.1:9334/json')) if t['type'] == 'page'); break
|
||||
except Exception:
|
||||
time.sleep(0.2)
|
||||
ws = websocket.create_connection(page['webSocketDebuggerUrl'], timeout=120)
|
||||
n = 0
|
||||
def cmd(method, **params):
|
||||
global n
|
||||
n += 1
|
||||
ws.send(json.dumps({'id': n, 'method': method, 'params': params}))
|
||||
while True:
|
||||
r = json.loads(ws.recv())
|
||||
if r.get('id') == n:
|
||||
return r.get('result', r)
|
||||
cmd('Emulation.setDeviceMetricsOverride', width=T + 2 * M, height=T + 2 * M, deviceScaleFactor=1, mobile=False)
|
||||
cmd('Page.navigate', url='file:///' + os.path.abspath('rendu.html').replace(os.sep, '/'))
|
||||
time.sleep(3)
|
||||
manifeste = {'taille': T, 'ox': X0, 'oy': Y0, 'niveaux': []}
|
||||
total = 0
|
||||
for L, s, (xa, ya, xb, yb) in NIVEAUX:
|
||||
i0, i1 = int((xa - X0) * s // T), int((xb - X0) * s // T)
|
||||
j0, j1 = int((ya - Y0) * s // T), int((yb - Y0) * s // T)
|
||||
os.makedirs(f'tuiles/{L}', exist_ok=True)
|
||||
cmd('Runtime.evaluate', expression=f'document.body.dataset.n = "{L}"')
|
||||
for i in range(i0, i1 + 1):
|
||||
for j in range(j0, j1 + 1):
|
||||
x, y = X0 + i * T / s, Y0 + j * T / s
|
||||
cmd('Runtime.evaluate', expression=f'poser({x - M / s},{y - M / s},{s});'
|
||||
'new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r)))', awaitPromise=True)
|
||||
img = cmd('Page.captureScreenshot', format='webp', quality=82,
|
||||
clip={'x': M, 'y': M, 'width': T, 'height': T, 'scale': 1})
|
||||
open(f'tuiles/{L}/{i}_{j}.webp', 'wb').write(base64.b64decode(img['data']))
|
||||
total += 1
|
||||
manifeste['niveaux'].append({'L': L, 's': s, 'i0': i0, 'i1': i1, 'j0': j0, 'j1': j1})
|
||||
print('niveau', L, (i1 - i0 + 1) * (j1 - j0 + 1), 'images', flush=True)
|
||||
manifeste['version'] = int(time.time()) # dans l'adresse des images : un nouveau rendu n'est jamais pris dans le cache
|
||||
json.dump(manifeste, open('tuiles/manifeste.json', 'w'))
|
||||
print('total', total)
|
||||
finally:
|
||||
proc.kill()
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur