Site public Météo Vercors (phase 0) : page statique, collecteur WeatherLink, données d'exemple
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
révision
0ee7b8e723
17 fichiers modifiés
+1491
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,3 @@
|
||||
__pycache__/
|
||||
*.tmp
|
||||
.env*
|
||||
@@ -0,0 +1,13 @@
|
||||
# meteo-vercors (site public vercors.me, phase 0)
|
||||
|
||||
Copie publique du site LAN « Météo Vercors » (page du port 30, source : cornafserver `~/services/meteo-direct/www/index.html`),
|
||||
restylée (Inter, monochrome) et alimentée par un JSON en cache : `public/data/meteo.json`.
|
||||
|
||||
- `public/` : site statique (aucune dépendance externe sauf les tuiles de carte OSM/OpenTopoMap). Leaflet et Inter sont embarqués.
|
||||
- `collecte/collecter_weatherlink.py` : API WeatherLink v2 `/current` -> JSON public filtré (liste blanche de champs).
|
||||
Clés lues dans `MC_WL_BRUYERES_*`, `MC_WL_ALLIERES_*`, `MC_WL_VP2_*` (CLE et SECRET). Jamais de valeur dans le dépôt.
|
||||
- `config/stations.json` : stations (noms de variables, pas de valeurs). `station_id` à fournir pour Les Allières et la VP2.
|
||||
- `python collecte/collecter_weatherlink.py --exemple` : données marquées « exemple ». Sans option : appels réels (cron toutes les 5 à 10 min).
|
||||
- Tests : `python -I tests/test_collecteur.py`. Aperçu local : `python -m http.server -d public 8931`.
|
||||
|
||||
Ne pas publier sans décision de Théo (licences : voir le rapport 43). Aucune donnée Infoclimat CC BY-NC n'est incluse.
|
||||
@@ -0,0 +1,288 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Collecte WeatherLink v2 (/current) -> JSON public filtre (public/data/meteo.json).
|
||||
|
||||
Python standard uniquement. Les cles sont lues dans des variables d'environnement (noms dans
|
||||
config/stations.json : MC_WL_*_CLE / MC_WL_*_SECRET). Les valeurs ne sont jamais affichees, jamais ecrites.
|
||||
|
||||
Usage :
|
||||
python collecter_weatherlink.py # appels reels (une requete /current par station)
|
||||
python collecter_weatherlink.py --exemple # donnees d'exemple, marquees "exemple", aucun appel
|
||||
options : --sortie CHEMIN --config CHEMIN --jours-historique 1
|
||||
|
||||
Filtrage : seule une liste blanche de champs exterieurs sort (voir CHAMPS_PUBLICS). Pas d'IP, pas de chemin,
|
||||
pas de temperature/humidite interieure, pas de trame brute, pas d'identifiant de compte ni de station_id.
|
||||
Avant d'ecrire, le JSON est controle (verifier_public) ; en cas de motif interdit, rien n'est ecrit.
|
||||
|
||||
A VERIFIER sur une vraie reponse : les noms exacts des champs (voir CHAMPS_WL) et les unites (imperiales supposees).
|
||||
"""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
URL_BASE = "https://api.weatherlink.com/v2"
|
||||
SOURCE_WL = "WeatherLink (Davis Instruments)"
|
||||
UA = "vercors.me/0.1 (meteo-vercors)"
|
||||
RACINE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SORTIE_DEFAUT = os.path.join(RACINE, "public", "data", "meteo.json")
|
||||
CONFIG_DEFAUT = os.path.join(RACINE, "config", "stations.json")
|
||||
|
||||
# Liste blanche des champs d'un releve public (rien d'autre ne sort).
|
||||
CHAMPS_PUBLICS = ("dh_utc", "temperature", "humidite", "point_de_rosee", "pression", "vent_moyen",
|
||||
"vent_rafales", "vent_direction", "pluie_1h", "pluie_cumul_0h", "temperature_min", "temperature_max")
|
||||
|
||||
|
||||
def _f2c(x): return (x - 32.0) * 5.0 / 9.0
|
||||
def _mph(x): return x * 1.609344
|
||||
def _inhg(x): return x * 33.8639
|
||||
def _inch(x): return x * 25.4
|
||||
def _id(x): return x
|
||||
|
||||
|
||||
# Champs WeatherLink exterieurs uniquement ("temp_in", "hum_in" ne figurent volontairement pas ici).
|
||||
CHAMPS_WL = {
|
||||
"temperature": (("temp", _f2c), ("temp_out", _f2c)),
|
||||
"humidite": (("hum", _id), ("hum_out", _id)),
|
||||
"point_de_rosee": (("dew_point", _f2c),),
|
||||
"pression": (("bar_sea_level", _inhg), ("bar", _inhg)),
|
||||
"vent_moyen": (("wind_speed_avg_last_10_min", _mph), ("wind_speed_last", _mph)),
|
||||
"vent_rafales": (("wind_speed_hi_last_10_min", _mph),),
|
||||
"vent_direction": (("wind_dir_scalar_avg_last_10_min", _id), ("wind_dir_last", _id)),
|
||||
"pluie_1h": (("rainfall_last_60_min_in", _inch),),
|
||||
"pluie_cumul_0h": (("rainfall_daily_in", _inch),),
|
||||
}
|
||||
DECIMALES = {"vent_direction": 0, "humidite": 0}
|
||||
|
||||
# Motifs qui ne doivent JAMAIS apparaitre dans le JSON public.
|
||||
MOTIFS_INTERDITS = [
|
||||
(r"\b\d{1,3}(?:\.\d{1,3}){3}\b", "adresse IP"),
|
||||
(r"/(?:mnt|home|etc|var|root|srv)/", "chemin"),
|
||||
(r"[A-Za-z]:\\", "chemin Windows"),
|
||||
(r"hdd\d|nvme|weather-db|weather-collector|cornafserver|cornafsuisse|crocserver", "nom interne"),
|
||||
(r"api[-_]?key|api[-_]?secret|secret|token|password|mot_de_passe", "mot sensible"),
|
||||
(r"trame|_hex|temp_in|hum_in|interieur|MC_WL_", "donnee interne"),
|
||||
(r"station_id|account|compte", "identifiant de compte"),
|
||||
]
|
||||
|
||||
|
||||
class ErreurWL(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def maintenant():
|
||||
return dt.datetime.now(dt.timezone.utc).replace(microsecond=0)
|
||||
|
||||
|
||||
def fmt_utc(d):
|
||||
return d.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def arrondir(champ, v):
|
||||
return round(v, DECIMALES.get(champ, 1))
|
||||
|
||||
|
||||
def mesure_depuis_current(corps):
|
||||
"""Reponse /current (texte JSON) -> releve public {dh_utc, ...} ou ErreurWL. N'utilise que CHAMPS_WL."""
|
||||
try:
|
||||
rep = json.loads(corps)
|
||||
except ValueError:
|
||||
raise ErreurWL("reponse non JSON")
|
||||
capteurs = rep.get("sensors") if isinstance(rep, dict) else None
|
||||
if not isinstance(capteurs, list):
|
||||
raise ErreurWL("pas de liste sensors")
|
||||
brut, ts_champ = {}, {}
|
||||
for cap in capteurs:
|
||||
data = cap.get("data") if isinstance(cap, dict) else None
|
||||
if not isinstance(data, list) or not data or not isinstance(data[0], dict):
|
||||
continue
|
||||
rec = data[0]
|
||||
for k, v in rec.items():
|
||||
if k == "ts" or isinstance(v, bool) or not isinstance(v, (int, float)):
|
||||
continue
|
||||
if k not in brut:
|
||||
brut[k], ts_champ[k] = float(v), rec.get("ts")
|
||||
mesure, ts_t = {}, None
|
||||
for champ, candidats in CHAMPS_WL.items():
|
||||
for nom, conv in candidats:
|
||||
if nom in brut:
|
||||
mesure[champ] = arrondir(champ, conv(brut[nom]))
|
||||
if champ == "temperature":
|
||||
ts_t = ts_champ[nom]
|
||||
break
|
||||
if "temperature" not in mesure:
|
||||
raise ErreurWL("pas de temperature exterieure")
|
||||
if "vent_direction" in mesure:
|
||||
mesure["vent_direction"] = mesure["vent_direction"] % 360
|
||||
if not isinstance(ts_t, (int, float)):
|
||||
ts_t = rep.get("generated_at")
|
||||
if not isinstance(ts_t, (int, float)):
|
||||
raise ErreurWL("pas d'horodatage")
|
||||
mesure["dh_utc"] = fmt_utc(dt.datetime.fromtimestamp(ts_t, dt.timezone.utc))
|
||||
return mesure
|
||||
|
||||
|
||||
def appeler_current(station_id, cle, secret):
|
||||
"""Une requete /current. Retourne le corps (texte). La cle n'apparait dans aucun message d'erreur."""
|
||||
url = "%s/current/%s?api-key=%s" % (URL_BASE, urllib.parse.quote(str(station_id), safe=""),
|
||||
urllib.parse.quote(cle, safe=""))
|
||||
req = urllib.request.Request(url, headers={"X-Api-Secret": secret, "User-Agent": UA, "Accept": "application/json"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
return r.read().decode("utf-8", errors="replace")
|
||||
except urllib.error.HTTPError as e:
|
||||
raise ErreurWL("HTTP %d" % e.code)
|
||||
except Exception as e:
|
||||
raise ErreurWL("reseau : %s" % type(e).__name__)
|
||||
|
||||
|
||||
def verifier_public(obj):
|
||||
"""Leve ValueError si le JSON public contient un motif interdit."""
|
||||
texte = json.dumps(obj, ensure_ascii=False)
|
||||
for motif, nom in MOTIFS_INTERDITS:
|
||||
m = re.search(motif, texte, re.I)
|
||||
if m:
|
||||
raise ValueError("motif interdit dans le JSON public (%s)" % nom)
|
||||
for st in obj.get("stations", {}).values():
|
||||
for r in st.get("releves", []):
|
||||
extra = set(r) - set(CHAMPS_PUBLICS)
|
||||
if extra:
|
||||
raise ValueError("champ non autorise : %s" % sorted(extra))
|
||||
|
||||
|
||||
def fusionner(anciens, nouveau, jours):
|
||||
"""Ajoute `nouveau` (ou rien) a l'historique, sans doublon, borne a `jours` jours."""
|
||||
par_date = {r["dh_utc"]: {k: r[k] for k in CHAMPS_PUBLICS if k in r} for r in anciens if "dh_utc" in r}
|
||||
if nouveau:
|
||||
par_date[nouveau["dh_utc"]] = nouveau
|
||||
limite = fmt_utc(maintenant() - dt.timedelta(days=jours))
|
||||
return [par_date[d] for d in sorted(par_date) if d >= limite]
|
||||
|
||||
|
||||
def min_max_jour(releves):
|
||||
"""Min/max de temperature sur les 24 dernieres heures du JSON (recalcules, pas fournis par l'API)."""
|
||||
ts = [r["temperature"] for r in releves if "temperature" in r]
|
||||
return (min(ts), max(ts)) if ts else (None, None)
|
||||
|
||||
|
||||
def charger_json(chemin):
|
||||
try:
|
||||
with open(chemin, encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except (OSError, ValueError):
|
||||
return {}
|
||||
|
||||
|
||||
def ecrire_atomique(chemin, obj):
|
||||
os.makedirs(os.path.dirname(chemin), exist_ok=True)
|
||||
fd, tmp = tempfile.mkstemp(dir=os.path.dirname(chemin), suffix=".tmp")
|
||||
with os.fdopen(fd, "w", encoding="utf-8") as f:
|
||||
json.dump(obj, f, ensure_ascii=False, separators=(",", ":"))
|
||||
os.replace(tmp, chemin)
|
||||
|
||||
|
||||
def exemple_releves(graine, base_t, fin, heures=24, pas_min=10, vent=True):
|
||||
"""Serie synthetique deterministe (pas de hasard) ; marquee 'exemple' par l'appelant."""
|
||||
out = []
|
||||
n = heures * 60 // pas_min
|
||||
for i in range(n + 1):
|
||||
t = fin - dt.timedelta(minutes=pas_min * (n - i))
|
||||
h = (t.hour + t.minute / 60.0)
|
||||
cyc = math.sin((h - 9) / 24.0 * 2 * math.pi)
|
||||
r = {"dh_utc": fmt_utc(t),
|
||||
"temperature": round(base_t + 4.0 * cyc + 0.3 * math.sin(i / 3.0 + graine), 1),
|
||||
"humidite": int(70 - 15 * cyc + 3 * math.sin(i / 5.0 + graine)),
|
||||
"pression": round(1018 + 2.0 * math.sin(i / 40.0 + graine), 1),
|
||||
"pluie_cumul_0h": 0.0, "pluie_1h": 0.0}
|
||||
r["point_de_rosee"] = round(r["temperature"] - (100 - r["humidite"]) / 5.0, 1)
|
||||
if vent:
|
||||
r["vent_moyen"] = round(6 + 4 * abs(math.sin(i / 7.0 + graine)), 1)
|
||||
r["vent_rafales"] = round(r["vent_moyen"] * 1.6, 1)
|
||||
r["vent_direction"] = int((200 + 40 * math.sin(i / 11.0 + graine)) % 360)
|
||||
out.append(r)
|
||||
return out
|
||||
|
||||
|
||||
def construire_exemple(config):
|
||||
fin = maintenant()
|
||||
stations, meta = {}, {}
|
||||
plan = {"bruyeres": (3.0, 1, 0), "meaudre": (3.5, 2, 0), "geve": (0.5, 3, 0), "allieres": (-0.5, 4, 0), "vp2-lans": (4.0, 5, 8)}
|
||||
for compte in config["comptes"].values():
|
||||
for sid, c in compte["stations"].items():
|
||||
base, graine, retard_h = plan.get(sid, (2.0, 9, 0))
|
||||
vp2 = sid == "vp2-lans"
|
||||
rel = exemple_releves(graine, base, fin - dt.timedelta(hours=retard_h), vent=not vp2)
|
||||
mn, mx = min_max_jour(rel)
|
||||
rel[-1]["temperature_min"], rel[-1]["temperature_max"] = mn, mx
|
||||
stations[sid] = {"nom": c["nom"], "source": SOURCE_WL, "exemple": True, "hors_ligne": bool(retard_h), "releves": rel}
|
||||
meta[sid] = meta_station(c)
|
||||
return {"source": "Donnees d'exemple (pas de mesure reelle)", "exemple": True,
|
||||
"mis_a_jour_utc": fin.strftime("%Y-%m-%dT%H:%M:%SZ"), "metadonnees": meta, "stations": stations}
|
||||
|
||||
|
||||
def meta_station(c):
|
||||
m = {"lat": round(c["lat"], 2), "lon": round(c["lon"], 2), "licence": "donnees de l'exploitant de la station"}
|
||||
if c.get("altitude") is not None:
|
||||
m["altitude"] = c["altitude"]
|
||||
return m
|
||||
|
||||
|
||||
def collecter(config, ancien, jours):
|
||||
"""Appels reels. Une station sans cle / sans station_id / en erreur : hors ligne, historique conserve."""
|
||||
fin = maintenant()
|
||||
stations, meta, journal = {}, {}, []
|
||||
anciennes = ancien.get("stations", {}) if not ancien.get("exemple") else {}
|
||||
for nom_compte, compte in config["comptes"].items():
|
||||
cle = os.environ.get(compte["var_cle"], "")
|
||||
secret = os.environ.get(compte["var_secret"], "")
|
||||
for sid, c in compte["stations"].items():
|
||||
meta[sid] = meta_station(c)
|
||||
hist = anciennes.get(sid, {}).get("releves", [])
|
||||
nouveau, etat = None, "ok"
|
||||
if not cle or not secret:
|
||||
etat = "sans_cle"
|
||||
elif not c.get("station_id"):
|
||||
etat = "sans_station_id"
|
||||
else:
|
||||
try:
|
||||
nouveau = mesure_depuis_current(appeler_current(c["station_id"], cle, secret))
|
||||
except ErreurWL as e:
|
||||
etat = "erreur (%s)" % e
|
||||
rel = fusionner(hist, nouveau, jours)
|
||||
if rel and nouveau:
|
||||
rel[-1]["temperature_min"], rel[-1]["temperature_max"] = min_max_jour(rel)
|
||||
stations[sid] = {"nom": c["nom"], "source": SOURCE_WL, "hors_ligne": nouveau is None, "releves": rel}
|
||||
journal.append("%s: %s" % (sid, etat))
|
||||
obj = {"source": "WeatherLink (Davis Instruments)", "mis_a_jour_utc": fin.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
"metadonnees": meta, "stations": stations}
|
||||
return obj, journal
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
||||
ap.add_argument("--exemple", action="store_true")
|
||||
ap.add_argument("--sortie", default=SORTIE_DEFAUT)
|
||||
ap.add_argument("--config", default=CONFIG_DEFAUT)
|
||||
ap.add_argument("--jours-historique", type=float, default=1.0)
|
||||
a = ap.parse_args(argv)
|
||||
with open(a.config, encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
if a.exemple:
|
||||
obj, journal = construire_exemple(config), ["mode exemple"]
|
||||
else:
|
||||
obj, journal = collecter(config, charger_json(a.sortie), a.jours_historique)
|
||||
verifier_public(obj)
|
||||
ecrire_atomique(a.sortie, obj)
|
||||
print("ecrit : %s (%d stations)" % (os.path.basename(a.sortie), len(obj["stations"])))
|
||||
print("; ".join(journal))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_note": "Aucune valeur secrete ici : seulement les NOMS des variables d'environnement. station_id est lu par le collecteur et n'est jamais ecrit dans le JSON public. Positions arrondies a 2 decimales.",
|
||||
"comptes": {
|
||||
"bruyeres-meaudre": {
|
||||
"var_cle": "MC_WL_BRUYERES_CLE",
|
||||
"var_secret": "MC_WL_BRUYERES_SECRET",
|
||||
"stations": {
|
||||
"bruyeres": {"station_id": "41723", "nom": "Lans-en-Vercors – Les Bruyères", "altitude": 990, "lat": 45.10, "lon": 5.57},
|
||||
"meaudre": {"station_id": "208771", "nom": "Méaudre", "altitude": 976, "lat": 45.13, "lon": 5.53},
|
||||
"geve": {"station_id": "211934", "nom": "Autrans – Gêve nordique", "altitude": 1353, "lat": 45.21, "lon": 5.56}
|
||||
}
|
||||
},
|
||||
"allieres": {
|
||||
"var_cle": "MC_WL_ALLIERES_CLE",
|
||||
"var_secret": "MC_WL_ALLIERES_SECRET",
|
||||
"stations": {
|
||||
"allieres": {"station_id": null, "nom": "Lans-en-Vercors – Les Allières", "altitude": 1449, "lat": 45.10, "lon": 5.60}
|
||||
}
|
||||
},
|
||||
"vp2-lans": {
|
||||
"var_cle": "MC_WL_VP2_CLE",
|
||||
"var_secret": "MC_WL_VP2_SECRET",
|
||||
"stations": {
|
||||
"vp2-lans": {"station_id": null, "nom": "Lans-en-Vercors – VP2", "altitude": null, "lat": 45.13, "lon": 5.60}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
'use strict';
|
||||
const $ = (s) => document.querySelector(s);
|
||||
const el = (t, c, txt) => { const e = document.createElement(t); if (c) e.className = c; if (txt != null) e.textContent = txt; return e; };
|
||||
const num = (v) => (v === null || v === undefined || v === '' || isNaN(+v)) ? null : +v;
|
||||
const fmt = (v, u, d = 1) => v === null ? '—' : v.toFixed(d).replace('.', ',') + (u ? ' ' + u : '');
|
||||
const utc = (s) => new Date(s.replace(' ', 'T') + 'Z');
|
||||
const heure = (d) => d.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
|
||||
const age = (m) => m < 60 ? m + ' min' : Math.floor(m / 60) + ' h ' + String(m % 60).padStart(2, '0');
|
||||
const POINTS = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO'];
|
||||
const cardinal = (d) => POINTS[Math.round(d / 22.5) % 16];
|
||||
|
||||
const couleurT = () => 'var(--texte)';
|
||||
|
||||
const SEUIL_HORS_MIN = 90;
|
||||
let donnees = null, tri = 'altitude', couche = 'temperature', choisie = null, carte = null, marqueurs = {}, cadrage = false;
|
||||
|
||||
function stations() {
|
||||
if (!donnees) return [];
|
||||
return Object.entries(donnees.stations).map(([id, s]) => {
|
||||
const meta = (donnees.metadonnees || {})[id] || {};
|
||||
const rel = s.releves || [];
|
||||
const der = rel[rel.length - 1] || {};
|
||||
// valeur d'il y a environ 1 h pour la tendance
|
||||
let avant = null;
|
||||
if (der.dh_utc) {
|
||||
const cible = utc(der.dh_utc) - 3600e3;
|
||||
for (const r of rel) if (utc(r.dh_utc) <= cible) avant = r;
|
||||
}
|
||||
const hors = !der.dh_utc || s.hors_ligne === true || (Date.now() - utc(der.dh_utc)) > SEUIL_HORS_MIN * 60000;
|
||||
return { id, nom: s.nom, meta, rel, der, avant, hors, exemple: s.exemple === true, source: s.source || '', t: hors ? null : num(der.temperature) };
|
||||
});
|
||||
}
|
||||
|
||||
function valeurCouche(s) {
|
||||
if (s.hors) return null;
|
||||
const d = s.der;
|
||||
switch (couche) {
|
||||
case 'vent': { const v = num(d.vent_moyen); return v === null ? null : fmt(v, '', 0) + (num(d.vent_direction) !== null ? ' ' + cardinal(+d.vent_direction) : ''); }
|
||||
case 'humidite': { const v = num(d.humidite); return v === null ? null : fmt(v, '%', 0); }
|
||||
case 'pluie': { const v = num(d.pluie_cumul_0h); return v === null ? null : fmt(v, 'mm', 1); }
|
||||
case 'pression': { const v = num(d.pression); return v === null ? null : fmt(v, '', 0); }
|
||||
default: return s.t === null ? null : fmt(s.t, '°', 1);
|
||||
}
|
||||
}
|
||||
|
||||
function initCarte() {
|
||||
carte = L.map('carte', { zoomControl: false, attributionControl: true }).setView([45.05, 5.5], 9);
|
||||
const plan = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '© OpenStreetMap' });
|
||||
const relief = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { maxZoom: 16, attribution: '© OpenStreetMap, © OpenTopoMap' });
|
||||
relief.addTo(carte);
|
||||
L.control.layers({ 'Relief': relief, 'Plan': plan }, null, { position: 'topright' }).addTo(carte);
|
||||
L.control.zoom({ position: 'bottomright' }).addTo(carte);
|
||||
}
|
||||
|
||||
function majCarte(liste) {
|
||||
for (const s of liste) {
|
||||
if (s.meta.lat == null || s.meta.lon == null) continue;
|
||||
const v = valeurCouche(s);
|
||||
const b = el('span', 'bulle' + (s.id === choisie ? ' choisie' : ''), v === null ? '—' : v);
|
||||
if (s.hors) b.classList.add('hors');
|
||||
b.title = s.nom;
|
||||
const icone = L.divIcon({ className: '', html: b.outerHTML, iconSize: null });
|
||||
if (marqueurs[s.id]) marqueurs[s.id].setIcon(icone);
|
||||
else {
|
||||
marqueurs[s.id] = L.marker([s.meta.lat, s.meta.lon], { icon: icone, title: s.nom, riseOnHover: true })
|
||||
.on('click', () => ouvrir(s.id)).addTo(carte);
|
||||
}
|
||||
}
|
||||
if (!cadrage) {
|
||||
const pts = liste.filter((s) => s.meta.lat != null).map((s) => [s.meta.lat, s.meta.lon]);
|
||||
if (pts.length) { carte.fitBounds(pts, { padding: [30, 30] }); cadrage = true; }
|
||||
}
|
||||
}
|
||||
|
||||
function majResume(liste) {
|
||||
const r = $('#resume'); r.replaceChildren();
|
||||
const avecT = liste.filter((s) => !s.hors && s.t !== null);
|
||||
if (!avecT.length) return;
|
||||
const chaud = avecT.reduce((a, b) => (b.t > a.t ? b : a)), froid = avecT.reduce((a, b) => (b.t < a.t ? b : a));
|
||||
const vents = liste.filter((s) => !s.hors).filter((s) => num(s.der.vent_rafales) !== null || num(s.der.vent_moyen) !== null);
|
||||
const fort = vents.length ? vents.reduce((a, b) => ((num(b.der.vent_rafales) ?? num(b.der.vent_moyen)) > (num(a.der.vent_rafales) ?? num(a.der.vent_moyen)) ? b : a)) : null;
|
||||
const bloc = (val, lib, coul) => { const d = el('div'); const b = el('b', null, val); if (coul) b.style.color = coul; d.append(b, el('span', null, lib)); return d; };
|
||||
r.append(bloc(fmt(chaud.t, '°C'), 'Plus chaud · ' + court(chaud.nom), couleurT(chaud.t)),
|
||||
bloc(fmt(froid.t, '°C'), 'Plus froid · ' + court(froid.nom), couleurT(froid.t)),
|
||||
fort ? bloc(fmt(num(fort.der.vent_rafales) ?? num(fort.der.vent_moyen), 'km/h', 0), 'Vent max · ' + court(fort.nom)) : bloc('—', 'Vent'));
|
||||
}
|
||||
const court = (n) => n.replace(/^Lans-en-Vercors – /, '').replace(/^La Chapelle-en-Vercors – /, '').replace(/^Combe de /, '').replace(/^Crête de la /, '');
|
||||
|
||||
function tendance(s) {
|
||||
const a = num(s.avant && s.avant.temperature);
|
||||
if (s.t === null || a === null) return '';
|
||||
const d = s.t - a;
|
||||
return Math.abs(d) < 0.3 ? '→' : d > 0 ? '↗' : '↘';
|
||||
}
|
||||
|
||||
function majListe(liste) {
|
||||
const tries = [...liste].sort((a, b) => tri === 'nom' ? a.nom.localeCompare(b.nom, 'fr')
|
||||
: tri === 'temperature' ? (b.t ?? -99) - (a.t ?? -99) : (b.meta.altitude ?? 0) - (a.meta.altitude ?? 0));
|
||||
const ul = $('#liste');
|
||||
ul.replaceChildren(...tries.map((s) => {
|
||||
const li = el('li', 'ligne' + (s.id === choisie ? ' choisie' : '') + (s.hors ? ' hors' : ''));
|
||||
li.tabIndex = 0; li.setAttribute('role', 'button');
|
||||
li.style.setProperty('--c', couleurT(s.t));
|
||||
const t = el('div', 't', s.hors ? 'Hors ligne' : fmt(s.t, '°', 1));
|
||||
const tend = tendance(s); if (tend) t.append(el('span', 'tendance', tend));
|
||||
const d = el('div', 'd');
|
||||
const h = s.hors ? null : num(s.der.humidite), v = s.hors ? null : num(s.der.vent_moyen), p = s.hors ? null : num(s.der.pluie_cumul_0h);
|
||||
if (h !== null) d.append(el('span', null, 'Humidité ' + fmt(h, '%', 0)));
|
||||
if (v !== null) d.append(el('span', null, 'Vent ' + fmt(v, 'km/h', 0) + (num(s.der.vent_direction) !== null ? ' ' + cardinal(+s.der.vent_direction) : '')));
|
||||
if (p !== null && p > 0) d.append(el('span', null, 'Pluie ' + fmt(p, 'mm', 1)));
|
||||
const mn = s.hors ? null : num(s.der.temperature_min), mx = s.hors ? null : num(s.der.temperature_max);
|
||||
if (mn !== null && mx !== null) d.append(el('span', null, '↓' + fmt(mn, '', 1) + ' ↑' + fmt(mx, '', 1)));
|
||||
let m = el('div', 'm vieux', 'pas de relevé');
|
||||
if (s.der.dh_utc) { const min = Math.round((Date.now() - utc(s.der.dh_utc)) / 60000); m = el('div', 'm' + (min > 30 ? ' vieux' : ''), (s.exemple ? 'exemple · ' : '') + 'il y a ' + age(min)); }
|
||||
const nom = el('div', 'n', s.nom); if (s.exemple) nom.append(el('span', 'etiquette', 'exemple'));
|
||||
li.append(t, nom, el('div', 'a', s.meta.altitude != null ? s.meta.altitude + ' m' : ''), d, m);
|
||||
li.addEventListener('click', () => ouvrir(s.id));
|
||||
li.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); ouvrir(s.id); } });
|
||||
return li;
|
||||
}));
|
||||
}
|
||||
|
||||
// ---- Graphique SVG détaillé avec axes ----
|
||||
function graphe(titre, rel, champ, unite, opts = {}) {
|
||||
const NS = 'http://www.w3.org/2000/svg';
|
||||
const fin = Date.now(), debut = fin - 24 * 3600e3;
|
||||
const pts = rel.map((r) => [utc(r.dh_utc).getTime(), num(r[champ])]).filter((p) => p[1] !== null && p[0] >= debut);
|
||||
if (pts.length < 2) return null;
|
||||
const box = el('div', 'graphe');
|
||||
const vals = pts.map((p) => p[1]);
|
||||
let mn = Math.min(...vals), mx = Math.max(...vals);
|
||||
if (opts.zero) mn = Math.min(0, mn);
|
||||
if (opts.zero && mx - mn < (opts.ecartMin || 1)) mx = mn + (opts.ecartMin || 1);
|
||||
else if (mx - mn < (opts.ecartMin || 1)) { const c = (mx + mn) / 2, e = (opts.ecartMin || 1) / 2; mn = c - e; mx = c + e; }
|
||||
const h3 = el('h3', null, titre);
|
||||
h3.append(el('em', null, 'min ' + fmt(Math.min(...vals), unite, opts.dec ?? 1) + ' · max ' + fmt(Math.max(...vals), unite, opts.dec ?? 1)));
|
||||
box.append(h3);
|
||||
const W = 320, H = 120, G = 30, B = 16;
|
||||
const x = (t) => G + ((t - debut) / (fin - debut)) * (W - G - 4), y = (v) => 6 + (1 - (v - mn) / (mx - mn)) * (H - B - 6);
|
||||
const svg = document.createElementNS(NS, 'svg'); svg.setAttribute('viewBox', `0 0 ${W} ${H}`); svg.setAttribute('role', 'img');
|
||||
svg.setAttribute('aria-label', titre + ' sur 24 h');
|
||||
const mk = (t, a) => { const n = document.createElementNS(NS, t); for (const k in a) n.setAttribute(k, a[k]); svg.append(n); return n; };
|
||||
for (let i = 0; i <= 3; i++) {
|
||||
const v = mn + (mx - mn) * i / 3, yy = y(v);
|
||||
mk('line', { x1: G, x2: W - 4, y1: yy, y2: yy, class: 'grille' });
|
||||
mk('text', { x: G - 4, y: yy + 3, 'text-anchor': 'end' }).textContent = fmt(v, '', opts.dec ?? (mx - mn < 5 ? 1 : 0));
|
||||
}
|
||||
for (let hh = 0; hh <= 24; hh += 6) {
|
||||
const t = debut + hh * 3600e3;
|
||||
mk('text', { x: x(t), y: H - 2, 'text-anchor': hh === 0 ? 'start' : hh === 24 ? 'end' : 'middle' }).textContent = heure(new Date(t)).replace(':00', 'h');
|
||||
}
|
||||
const coul = opts.couleur || 'var(--accent)';
|
||||
if (opts.barres) {
|
||||
const bw = Math.max(2, (W - G) / 150);
|
||||
for (const p of pts) if (p[1] > 0) mk('rect', { x: x(p[0]) - bw / 2, y: y(p[1]), width: bw, height: y(mn) - y(p[1]), fill: coul, opacity: .8 });
|
||||
} else {
|
||||
const d = pts.map((q, i) => (i ? 'L' : 'M') + x(q[0]).toFixed(1) + ' ' + y(q[1]).toFixed(1)).join(' ');
|
||||
if (opts.aire) mk('path', { d: d + ` L${x(pts[pts.length - 1][0]).toFixed(1)} ${y(mn)} L${x(pts[0][0]).toFixed(1)} ${y(mn)} Z`, fill: coul, opacity: .12 });
|
||||
mk('path', { d, fill: 'none', stroke: coul, 'stroke-width': 2, 'stroke-linejoin': 'round' });
|
||||
const dern = pts[pts.length - 1]; mk('circle', { cx: x(dern[0]), cy: y(dern[1]), r: 3.5, fill: coul });
|
||||
}
|
||||
if (opts.serie2) {
|
||||
const p2 = rel.map((r) => [utc(r.dh_utc).getTime(), num(r[opts.serie2])]).filter((p) => p[1] !== null && p[0] >= debut);
|
||||
if (p2.length > 1) mk('path', { d: p2.map((q, i) => (i ? 'L' : 'M') + x(q[0]).toFixed(1) + ' ' + y(Math.min(Math.max(q[1], mn), mx)).toFixed(1)).join(' '), fill: 'none', stroke: coul, 'stroke-width': 1.2, 'stroke-dasharray': '3 3', opacity: .7 });
|
||||
}
|
||||
box.append(svg);
|
||||
return box;
|
||||
}
|
||||
|
||||
function boussole(dir) {
|
||||
const NS = 'http://www.w3.org/2000/svg';
|
||||
const s = document.createElementNS(NS, 'svg'); s.setAttribute('viewBox', '-12 -12 24 24'); s.setAttribute('class', 'boussole'); s.setAttribute('aria-hidden', 'true');
|
||||
const c = document.createElementNS(NS, 'circle'); c.setAttribute('r', 11); c.setAttribute('fill', 'none'); c.setAttribute('stroke', 'currentColor'); c.setAttribute('opacity', '.3');
|
||||
const p = document.createElementNS(NS, 'path'); p.setAttribute('d', 'M0 9 L-4 -5 L0 -2 L4 -5 Z'); p.setAttribute('fill', 'var(--accent)');
|
||||
p.setAttribute('transform', 'rotate(' + dir + ')');
|
||||
s.append(c, p); return s;
|
||||
}
|
||||
|
||||
function remplirFiche(s) {
|
||||
const f = $('#fiche'); f.replaceChildren();
|
||||
const d = s.der;
|
||||
f.append(el('div', 'poignee'));
|
||||
const tete = el('div', 'fiche-tete');
|
||||
const ti = el('div'); const h2 = el('h2', null, s.nom); h2.id = 'fiche-nom';
|
||||
let sous = (s.meta.altitude != null ? s.meta.altitude + ' m' : '');
|
||||
if (d.dh_utc) { const q = utc(d.dh_utc); sous += ' · relevé de ' + heure(q) + ' (il y a ' + age(Math.round((Date.now() - q) / 60000)) + ')'; }
|
||||
ti.append(h2, el('small', null, sous));
|
||||
const fx = el('button', 'fermer', '×'); fx.type = 'button'; fx.setAttribute('aria-label', 'Fermer'); fx.onclick = fermer;
|
||||
tete.append(ti, fx); f.append(tete);
|
||||
|
||||
if (s.hors) f.append(el('p', 'horsligne', 'Station hors ligne. Dernier relevé connu : ' + (d.dh_utc ? heure(utc(d.dh_utc)) + ' le ' + utc(d.dh_utc).toLocaleDateString('fr-FR') : 'aucun') + ". Il n'est pas affiché comme valeur actuelle."));
|
||||
if (s.exemple) f.append(el('p', 'horsligne', "Données d'exemple, pas de mesure réelle."));
|
||||
const gros = el('div', 'gros');
|
||||
gros.append(el('div', 't', s.hors ? '—' : fmt(s.t, '°C', 1)));
|
||||
const x = el('div', 'x');
|
||||
const mn = num(d.temperature_min), mx = num(d.temperature_max);
|
||||
if (mn !== null || mx !== null) x.append(el('div', null, 'Min ' + fmt(mn, '°', 1) + ' · Max ' + fmt(mx, '°', 1)));
|
||||
const a = num(s.avant && s.avant.temperature);
|
||||
if (s.t !== null && a !== null) { const dd = s.t - a; x.append(el('div', null, (dd >= 0 ? '+' : '') + fmt(dd, '°C', 1) + ' en 1 h')); }
|
||||
gros.append(x); f.append(gros);
|
||||
|
||||
const tu = el('div', 'tuiles');
|
||||
const tuile = (lib, val, extra, noeud) => { const t = el('div', 'tuile'); t.append(el('span', null, lib)); const b = el('b', null, val); t.append(b); if (extra) t.append(el('i', null, extra)); if (noeud) t.append(noeud); tu.append(t); };
|
||||
const dir = num(d.vent_direction);
|
||||
const champs = [
|
||||
['Humidité', num(d.humidite), (v) => fmt(v, '%', 0)],
|
||||
['Point de rosée', num(d.point_de_rosee), (v) => fmt(v, '°C', 1)],
|
||||
['Pression', num(d.pression), (v) => fmt(v, 'hPa', 1)],
|
||||
['Pluie 1 h', num(d.pluie_1h), (v) => fmt(v, 'mm', 1)],
|
||||
['Pluie depuis 0 h', num(d.pluie_cumul_0h), (v) => fmt(v, 'mm', 1)],
|
||||
['Rafales', num(d.vent_rafales), (v) => fmt(v, 'km/h', 0)],
|
||||
];
|
||||
if (num(d.vent_moyen) !== null) tuile('Vent moyen', fmt(num(d.vent_moyen), 'km/h', 0), dir !== null ? cardinal(dir) : '', dir !== null ? boussole(dir) : null);
|
||||
for (const [lib, v, f2] of champs) if (v !== null) tuile(lib, f2(v));
|
||||
if (s.avant && num(s.avant.pression) !== null && num(d.pression) !== null) {
|
||||
const dp = num(d.pression) - num(s.avant.pression);
|
||||
tuile('Tendance pression', (dp >= 0 ? '+' : '') + fmt(dp, 'hPa', 1), '/ 1 h');
|
||||
}
|
||||
f.append(tu);
|
||||
|
||||
const gs = [
|
||||
graphe('Température', s.rel, 'temperature', '°C', { aire: true, serie2: 'point_de_rosee' }),
|
||||
graphe('Humidité', s.rel, 'humidite', '%', { dec: 0, ecartMin: 10 }),
|
||||
graphe('Vent moyen et rafales', s.rel, 'vent_moyen', 'km/h', { dec: 0, zero: true, ecartMin: 10, serie2: 'vent_rafales' }),
|
||||
graphe('Pression', s.rel, 'pression', 'hPa', { dec: 1, ecartMin: 2 }),
|
||||
graphe('Pluie horaire', s.rel, 'pluie_1h', 'mm', { barres: true, zero: true, ecartMin: 1 }),
|
||||
];
|
||||
for (const g of gs) if (g) f.append(g);
|
||||
if (gs[0]) gs[0].querySelector('h3 em').textContent += ' · pointillés : rosée';
|
||||
|
||||
// tableau des derniers relevés
|
||||
const der = s.rel.slice(-12).reverse();
|
||||
if (der.length) {
|
||||
const tb = el('div', 'table'); const t = el('table'); const tr = el('tr');
|
||||
for (const c of ['Heure', 'Temp.', 'Hum.', 'Vent', 'Pluie']) tr.append(el('th', null, c));
|
||||
const thead = el('thead'); thead.append(tr); t.append(thead);
|
||||
const tbody = el('tbody');
|
||||
for (const r of der) {
|
||||
const l = el('tr');
|
||||
const v = num(r.vent_moyen), dr = num(r.vent_direction);
|
||||
l.append(el('td', null, heure(utc(r.dh_utc))), el('td', null, fmt(num(r.temperature), '°', 1)), el('td', null, fmt(num(r.humidite), '%', 0)),
|
||||
el('td', null, v === null ? '—' : fmt(v, '', 0) + (dr !== null ? ' ' + cardinal(dr) : '')), el('td', null, fmt(num(r.pluie_1h), '', 1)));
|
||||
tbody.append(l);
|
||||
}
|
||||
t.append(tbody); tb.append(t); f.append(tb);
|
||||
}
|
||||
f.append(el('p', 'pied', 'Source : ' + (s.source || 'inconnue') + (s.meta.licence ? ' · licence ' + s.meta.licence : '') + (s.exemple ? ' · exemple' : '')));
|
||||
}
|
||||
|
||||
function ouvrir(id) {
|
||||
choisie = id;
|
||||
const s = stations().find((x) => x.id === id); if (!s) return;
|
||||
remplirFiche(s);
|
||||
$('#fiche').classList.add('ouverte'); $('#voile').classList.add('ouvert');
|
||||
$('#fiche').scrollTop = 0;
|
||||
if (s.meta.lat != null) carte.panTo([s.meta.lat, s.meta.lon]);
|
||||
rendre(false);
|
||||
$('#fiche .fermer').focus({ preventScroll: true });
|
||||
}
|
||||
function fermer() {
|
||||
choisie = null;
|
||||
$('#fiche').classList.remove('ouverte'); $('#voile').classList.remove('ouvert');
|
||||
rendre(false);
|
||||
}
|
||||
$('#voile').addEventListener('click', fermer);
|
||||
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') fermer(); });
|
||||
|
||||
function rendre(refiche = true) {
|
||||
const liste = stations();
|
||||
majCarte(liste); majResume(liste); majListe(liste);
|
||||
if (refiche && choisie) { const s = liste.find((x) => x.id === choisie); if (s) { const st = $('#fiche').scrollTop; remplirFiche(s); $('#fiche').scrollTop = st; } }
|
||||
if (donnees) {
|
||||
const maj = new Date(donnees.mis_a_jour_utc), min = Math.round((Date.now() - maj) / 60000);
|
||||
$('#etat').textContent = min <= 1 ? 'En direct · ' + heure(maj) : 'Mis à jour il y a ' + age(min);
|
||||
$('#point').classList.toggle('vieux', min > 20);
|
||||
}
|
||||
}
|
||||
|
||||
async function charger() {
|
||||
try {
|
||||
const r = await fetch('data/meteo.json', { cache: 'no-store' });
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||
donnees = await r.json();
|
||||
$('#erreur').replaceChildren();
|
||||
$('#bandeau').replaceChildren(...(donnees.exemple ? [el('div', 'exemple', "Données d'exemple : ces valeurs ne sont pas des mesures réelles.")] : []));
|
||||
rendre();
|
||||
} catch (e) {
|
||||
$('#erreur').replaceChildren(el('div', 'erreur', 'Données indisponibles (' + e.message + ').'));
|
||||
$('#point').classList.add('vieux');
|
||||
}
|
||||
}
|
||||
|
||||
for (const [attr, set] of [['tri', (v) => { tri = v; }], ['couche', (v) => { couche = v; }]]) {
|
||||
document.querySelectorAll('[data-' + attr + ']').forEach((b) => b.addEventListener('click', () => {
|
||||
set(b.dataset[attr]);
|
||||
document.querySelectorAll('[data-' + attr + ']').forEach((x) => x.setAttribute('aria-pressed', String(x === b)));
|
||||
rendre(false);
|
||||
}));
|
||||
}
|
||||
|
||||
(function () {
|
||||
const b = $('#theme');
|
||||
const appliquer = (t) => { if (t === 'sombre') document.documentElement.dataset.theme = 'sombre'; else delete document.documentElement.dataset.theme; b.textContent = t === 'sombre' ? 'Clair' : 'Sombre'; };
|
||||
let t = 'clair'; try { t = localStorage.getItem('theme') || 'clair'; } catch (e) {}
|
||||
appliquer(t);
|
||||
b.addEventListener('click', () => { t = t === 'sombre' ? 'clair' : 'sombre'; appliquer(t); try { localStorage.setItem('theme', t); } catch (e) {} });
|
||||
})();
|
||||
initCarte();
|
||||
charger();
|
||||
setInterval(charger, 60000);
|
||||
setInterval(() => rendre(false), 30000);
|
||||
document.addEventListener('visibilitychange', () => { if (!document.hidden) charger(); });
|
||||
@@ -0,0 +1 @@
|
||||
{"source":"Donnees d'exemple (pas de mesure reelle)","exemple":true,"mis_a_jour_utc":"2026-10-28T22:58:08Z","metadonnees":{"bruyeres":{"lat":45.1,"lon":5.57,"licence":"donnees de l'exploitant de la station","altitude":990},"meaudre":{"lat":45.13,"lon":5.53,"licence":"donnees de l'exploitant de la station","altitude":976},"geve":{"lat":45.21,"lon":5.56,"licence":"donnees de l'exploitant de la station","altitude":1353},"allieres":{"lat":45.1,"lon":5.6,"licence":"donnees de l'exploitant de la station","altitude":1449},"vp2-lans":{"lat":45.13,"lon":5.6,"licence":"donnees de l'exploitant de la station"}},"stations":{"bruyeres":{"nom":"Lans-en-Vercors – Les Bruyères","source":"WeatherLink (Davis Instruments)","exemple":true,"hors_ligne":false,"releves":[{"dh_utc":"2026-10-27 22:58:08","temperature":1.3,"humidite":79,"pression":1019.7,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-2.9,"vent_moyen":9.4,"vent_rafales":15.0,"vent_direction":233},{"dh_utc":"2026-10-27 23:08:08","temperature":1.2,"humidite":80,"pression":1019.7,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-2.8,"vent_moyen":9.6,"vent_rafales":15.4,"vent_direction":235},{"dh_utc":"2026-10-27 23:18:08","temperature":1.0,"humidite":81,"pression":1019.7,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-2.8,"vent_moyen":9.8,"vent_rafales":15.7,"vent_direction":237},{"dh_utc":"2026-10-27 23:28:08","temperature":0.9,"humidite":82,"pression":1019.8,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-2.7,"vent_moyen":10.0,"vent_rafales":16.0,"vent_direction":238},{"dh_utc":"2026-10-27 23:38:08","temperature":0.7,"humidite":82,"pression":1019.8,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-2.9,"vent_moyen":10.0,"vent_rafales":16.0,"vent_direction":239},{"dh_utc":"2026-10-27 23:48:08","temperature":0.5,"humidite":82,"pression":1019.8,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-3.1,"vent_moyen":10.0,"vent_rafales":16.0,"vent_direction":239},{"dh_utc":"2026-10-27 23:58:08","temperature":0.2,"humidite":82,"pression":1019.8,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-3.4,"vent_moyen":9.8,"vent_rafales":15.7,"vent_direction":239},{"dh_utc":"2026-10-28 00:08:08","temperature":0.0,"humidite":82,"pression":1019.8,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-3.6,"vent_moyen":9.6,"vent_rafales":15.4,"vent_direction":239},{"dh_utc":"2026-10-28 00:18:08","temperature":-0.2,"humidite":82,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-3.8,"vent_moyen":9.4,"vent_rafales":15.0,"vent_direction":239},{"dh_utc":"2026-10-28 00:28:08","temperature":-0.4,"humidite":82,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.0,"vent_moyen":9.0,"vent_rafales":14.4,"vent_direction":238},{"dh_utc":"2026-10-28 00:38:08","temperature":-0.5,"humidite":82,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.1,"vent_moyen":8.6,"vent_rafales":13.8,"vent_direction":237},{"dh_utc":"2026-10-28 00:48:08","temperature":-0.7,"humidite":82,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.3,"vent_moyen":8.2,"vent_rafales":13.1,"vent_direction":236},{"dh_utc":"2026-10-28 00:58:08","temperature":-0.7,"humidite":82,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.3,"vent_moyen":7.7,"vent_rafales":12.3,"vent_direction":234},{"dh_utc":"2026-10-28 01:08:08","temperature":-0.8,"humidite":81,"pression":1019.9,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.6,"vent_moyen":7.1,"vent_rafales":11.4,"vent_direction":232},{"dh_utc":"2026-10-28 01:18:08","temperature":-0.8,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.6,"vent_moyen":6.6,"vent_rafales":10.6,"vent_direction":230},{"dh_utc":"2026-10-28 01:28:08","temperature":-0.8,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.6,"vent_moyen":6.0,"vent_rafales":9.6,"vent_direction":228},{"dh_utc":"2026-10-28 01:38:08","temperature":-0.7,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.5,"vent_moyen":6.6,"vent_rafales":10.6,"vent_direction":225},{"dh_utc":"2026-10-28 01:48:08","temperature":-0.7,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.5,"vent_moyen":7.1,"vent_rafales":11.4,"vent_direction":222},{"dh_utc":"2026-10-28 01:58:08","temperature":-0.7,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.5,"vent_moyen":7.7,"vent_rafales":12.3,"vent_direction":219},{"dh_utc":"2026-10-28 02:08:08","temperature":-0.6,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.4,"vent_moyen":8.2,"vent_rafales":13.1,"vent_direction":216},{"dh_utc":"2026-10-28 02:18:08","temperature":-0.6,"humidite":81,"pression":1020.0,"pluie_cumul_0h":0.0,"pluie_1h":0.0,"point_de_rosee":-4.4,"vent_moyen":8.6,"vent_rafales":13.8,"vent_direction":212},{"dh_utc":"2026-10-28 02:28:08","temperatureLigne tronquée
|
||||
Fichier binaire non affiché.
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<meta name="description" content="Météo en direct des stations du Vercors. Site indépendant.">
|
||||
<title>Météo Vercors</title>
|
||||
<link rel="preload" href="fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<link rel="stylesheet" href="vendor/leaflet/leaflet.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="haut">
|
||||
<h1>Météo Vercors</h1>
|
||||
<div class="direct"><span class="point" id="point"></span><span id="etat">Chargement…</span></div>
|
||||
<button type="button" id="theme" class="theme" aria-label="Changer de thème">Sombre</button>
|
||||
</header>
|
||||
<div id="bandeau"></div>
|
||||
<div id="carte" role="region" aria-label="Carte des stations"></div>
|
||||
<div class="couches" role="group" aria-label="Valeur affichée sur la carte">
|
||||
<button type="button" data-couche="temperature" aria-pressed="true">Température</button>
|
||||
<button type="button" data-couche="vent" aria-pressed="false">Vent</button>
|
||||
<button type="button" data-couche="humidite" aria-pressed="false">Humidité</button>
|
||||
<button type="button" data-couche="pluie" aria-pressed="false">Pluie</button>
|
||||
<button type="button" data-couche="pression" aria-pressed="false">Pression</button>
|
||||
</div>
|
||||
<div class="resume" id="resume"></div>
|
||||
<div id="erreur"></div>
|
||||
<div class="tri" role="group" aria-label="Tri">
|
||||
<span>Trier</span>
|
||||
<button type="button" data-tri="altitude" aria-pressed="true">Altitude</button>
|
||||
<button type="button" data-tri="temperature" aria-pressed="false">Température</button>
|
||||
<button type="button" data-tri="nom" aria-pressed="false">Nom</button>
|
||||
</div>
|
||||
<ul class="liste" id="liste"></ul>
|
||||
|
||||
<section class="sources" id="sources">
|
||||
<h2>Sources et licences</h2>
|
||||
<p>Stations Davis : relevés des stations WeatherLink de Théo Gastinel et de ses proches (Les Bruyères, Méaudre, Gêve, Les Allières, Lans-en-Vercors), via l'API WeatherLink v2 de Davis Instruments.</p>
|
||||
<p>Réseau Infoclimat : à venir, uniquement les stations sous licence CC BY, avec mention de la station et de la licence. Les stations CC BY-NC ne sont pas republiées.</p>
|
||||
<p>Fond de carte : © contributeurs OpenStreetMap, © OpenTopoMap (CC BY-SA). Les valeurs de chaque station restent séparées : aucune moyenne entre sources.</p>
|
||||
<p>Site indépendant, sans lien avec le Parc naturel régional du Vercors ni avec une commune. Actualisation automatique toutes les minutes.</p>
|
||||
</section>
|
||||
|
||||
<div class="voile" id="voile"></div>
|
||||
<section class="fiche" id="fiche" aria-modal="true" role="dialog" aria-labelledby="fiche-nom"></section>
|
||||
|
||||
<script src="vendor/leaflet/leaflet.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,79 @@
|
||||
@font-face{font-family:Inter;src:url(fonts/inter-latin.woff2) format("woff2");font-weight:100 900;font-display:swap}
|
||||
:root{--fond:#fff;--texte:#111;--doux:#6b6b6b;--ligne:#e6e6e6;--accent:#111;--sur-accent:#fff;--vieux:#8a5a00}
|
||||
:root[data-theme=sombre]{--fond:#0e0e0e;--texte:#f2f2f2;--doux:#9a9a9a;--ligne:#2a2a2a;--accent:#f2f2f2;--sur-accent:#0e0e0e;--vieux:#e0b050}
|
||||
*{box-sizing:border-box}
|
||||
html,body{margin:0;background:var(--fond);color:var(--texte);font:15px/1.5 Inter,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-tap-highlight-color:transparent}
|
||||
button{font:inherit;cursor:pointer}
|
||||
.haut{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;padding:calc(20px + env(safe-area-inset-top)) 16px 14px;max-width:1100px;margin:0 auto}
|
||||
.haut h1{margin:0;font-size:20px;font-weight:600;letter-spacing:-.01em}
|
||||
.direct{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--doux);margin-left:auto;min-width:0}
|
||||
.theme{flex:none}
|
||||
.point{width:7px;height:7px;border-radius:50%;background:var(--texte)}
|
||||
.point.vieux{background:transparent;border:1px solid var(--doux)}
|
||||
.theme{background:none;border:1px solid var(--ligne);color:var(--texte);border-radius:16px;padding:4px 12px;font-size:12px}
|
||||
#bandeau .exemple{margin:0 16px 12px;padding:10px 14px;border:1px solid var(--texte);font-size:13px}
|
||||
@media (min-width:1132px){#bandeau .exemple{max-width:1068px;margin:0 auto 12px}}
|
||||
#carte{height:44vh;min-height:260px;max-height:460px;border-block:1px solid var(--ligne)}
|
||||
.leaflet-container{background:var(--fond);font:inherit}
|
||||
.bulle{background:var(--fond);color:var(--texte);font-weight:600;font-size:12px;padding:3px 8px;border-radius:12px;border:1px solid var(--texte);white-space:nowrap;transform:translate(-50%,-50%);display:inline-block;cursor:pointer}
|
||||
.bulle.hors{color:var(--doux);border-color:var(--doux);border-style:dashed}
|
||||
.bulle.choisie{background:var(--texte);color:var(--fond)}
|
||||
.couches,.tri,.resume,.liste,.sources{max-width:1100px;margin-inline:auto}
|
||||
.couches{display:flex;gap:8px;padding:16px 16px 0;overflow-x:auto;scrollbar-width:none}
|
||||
.couches button,.tri button{flex:none;background:none;color:var(--texte);border:1px solid var(--ligne);border-radius:16px;padding:6px 14px;font-size:13px}
|
||||
.couches button[aria-pressed=true],.tri button[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:var(--sur-accent)}
|
||||
.resume{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;padding:28px 16px 8px}
|
||||
.resume b{display:block;font-size:22px;font-weight:300;letter-spacing:-.01em}
|
||||
.resume span{font-size:12px;color:var(--doux)}
|
||||
.tri{display:flex;gap:8px;padding:24px 16px 8px;align-items:center}
|
||||
.tri span{font-size:12px;color:var(--doux);margin-right:4px}
|
||||
ul.liste{list-style:none;margin:0 auto;padding:8px 16px 32px;display:grid;grid-template-columns:minmax(0,1fr);gap:0}
|
||||
@media (min-width:760px){ul.liste{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:32px}}
|
||||
.ligne{padding:18px 0;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:2px 16px;align-items:center;cursor:pointer;border-bottom:1px solid var(--ligne)}
|
||||
.ligne:focus-visible{outline:2px solid var(--texte);outline-offset:2px}
|
||||
.ligne.choisie .n{text-decoration:underline}
|
||||
.ligne .t{grid-row:span 2;font-size:32px;font-weight:200;min-width:76px;letter-spacing:-.02em}
|
||||
.ligne.hors .t{color:var(--doux);font-size:16px;font-weight:400}
|
||||
.ligne .n{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.ligne .a{font-size:12px;color:var(--doux);text-align:right}
|
||||
.ligne .d{font-size:12px;color:var(--doux);display:flex;gap:12px;flex-wrap:wrap}
|
||||
.ligne .m{grid-column:3;font-size:11px;color:var(--doux);text-align:right}
|
||||
.ligne .m.vieux{color:var(--vieux);font-weight:600}
|
||||
.etiquette{font-size:10px;border:1px solid var(--doux);color:var(--doux);padding:0 5px;border-radius:8px;margin-left:6px;font-weight:500;vertical-align:1px}
|
||||
.tendance{font-size:13px;margin-left:2px}
|
||||
.voile{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:1500;opacity:0;pointer-events:none;transition:opacity .2s}
|
||||
.voile.ouvert{opacity:1;pointer-events:auto}
|
||||
.fiche{overflow-x:hidden;position:fixed;left:0;right:0;bottom:0;z-index:1600;background:var(--fond);border-radius:16px 16px 0 0;max-height:88vh;overflow-y:auto;transform:translateY(100%);transition:transform .25s ease;padding:0 0 calc(24px + env(safe-area-inset-bottom));box-shadow:0 -4px 24px rgba(0,0,0,.18)}
|
||||
.fiche.ouverte{transform:none}
|
||||
@media (min-width:760px){.fiche{left:auto;top:0;width:460px;max-height:none;border-radius:0;transform:translateX(100%)}}
|
||||
.poignee{width:40px;height:4px;border-radius:2px;background:var(--ligne);margin:8px auto 0}
|
||||
.fiche-tete{position:sticky;top:0;background:var(--fond);padding:16px 20px 10px;display:flex;justify-content:space-between;align-items:flex-start;gap:12px;z-index:2}
|
||||
.fiche-tete>div{min-width:0}.fiche-tete h2{margin:0;font-size:19px;font-weight:600}
|
||||
.fiche-tete small{color:var(--doux)}
|
||||
.fermer{background:none;border:1px solid var(--ligne);color:var(--texte);border-radius:50%;width:34px;height:34px;font-size:18px;flex:none}
|
||||
.gros{display:flex;align-items:flex-end;gap:16px;padding:0 20px 16px}
|
||||
.gros .t{font-size:64px;font-weight:200;line-height:1;letter-spacing:-.03em}
|
||||
.gros .x{font-size:13px;color:var(--doux);padding-bottom:6px}
|
||||
.tuiles{display:grid;grid-template-columns:repeat(2,1fr);gap:0 20px;padding:0 20px}
|
||||
.tuile{padding:12px 0;border-top:1px solid var(--ligne)}
|
||||
.tuile span{display:block;font-size:11px;color:var(--doux);text-transform:uppercase;letter-spacing:.06em}
|
||||
.tuile b{font-size:18px;font-weight:500}
|
||||
.tuile i{font-style:normal;font-size:12px;color:var(--doux);margin-left:4px}
|
||||
.boussole{width:22px;height:22px;vertical-align:-5px;margin-left:6px}
|
||||
.graphe{margin:16px 20px 0;padding-top:12px;border-top:1px solid var(--ligne)}
|
||||
.graphe h3{margin:0 0 4px;font-size:13px;font-weight:600;display:flex;justify-content:space-between;flex-wrap:wrap;gap:0 8px}
|
||||
.graphe h3 em{font-style:normal;font-weight:400;color:var(--doux);font-size:12px}
|
||||
.graphe svg{width:100%;height:120px;display:block;overflow:visible}
|
||||
.graphe text{font-size:10px;fill:var(--doux)}
|
||||
.graphe .grille{stroke:var(--ligne);stroke-width:1}
|
||||
.table{margin:20px 20px 0;overflow:hidden;border-top:1px solid var(--ligne)}
|
||||
.table table{width:100%;border-collapse:collapse;font-size:12px}
|
||||
.table th,.table td{padding:7px 4px;text-align:right;border-bottom:1px solid var(--ligne)}
|
||||
.table th:first-child,.table td:first-child{text-align:left}
|
||||
.table th{color:var(--doux);font-weight:500}
|
||||
.pied{color:var(--doux);font-size:11px;padding:12px 20px 0;margin:0}
|
||||
.horsligne{margin:0 20px 12px;padding:10px 14px;border:1px solid var(--doux);font-size:13px}
|
||||
.erreur{margin:12px 16px;padding:10px 14px;border:1px solid var(--texte);font-size:13px}
|
||||
.sources{padding:24px 16px 56px;color:var(--doux);font-size:13px;border-top:1px solid var(--ligne)}
|
||||
.sources h2{color:var(--texte);font-size:14px;font-weight:600;margin:0 0 8px}
|
||||
.sources p{margin:0 0 8px;max-width:70ch}
|
||||
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 1.2 KiB |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 696 B |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 2.4 KiB |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 1.4 KiB |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 618 B |
+661
@@ -0,0 +1,661 @@
|
||||
/* required styles */
|
||||
|
||||
.leaflet-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-pane > svg,
|
||||
.leaflet-pane > canvas,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
.leaflet-tile::selection {
|
||||
background: transparent;
|
||||
}
|
||||
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
|
||||
.leaflet-safari .leaflet-tile {
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
}
|
||||
/* hack that prevents hw layers "stretching" when loading new tiles */
|
||||
.leaflet-safari .leaflet-tile-container {
|
||||
width: 1600px;
|
||||
height: 1600px;
|
||||
-webkit-transform-origin: 0 0;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
|
||||
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container .leaflet-overlay-pane svg {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
.leaflet-container .leaflet-marker-pane img,
|
||||
.leaflet-container .leaflet-shadow-pane img,
|
||||
.leaflet-container .leaflet-tile-pane img,
|
||||
.leaflet-container img.leaflet-image-layer,
|
||||
.leaflet-container .leaflet-tile {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.leaflet-container img.leaflet-tile {
|
||||
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
|
||||
mix-blend-mode: plus-lighter;
|
||||
}
|
||||
|
||||
.leaflet-container.leaflet-touch-zoom {
|
||||
-ms-touch-action: pan-x pan-y;
|
||||
touch-action: pan-x pan-y;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag {
|
||||
-ms-touch-action: pinch-zoom;
|
||||
/* Fallback for FF which doesn't support pinch-zoom */
|
||||
touch-action: none;
|
||||
touch-action: pinch-zoom;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.leaflet-container {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.leaflet-container a {
|
||||
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
z-index: 800;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-pane { z-index: 400; }
|
||||
|
||||
.leaflet-tile-pane { z-index: 200; }
|
||||
.leaflet-overlay-pane { z-index: 400; }
|
||||
.leaflet-shadow-pane { z-index: 500; }
|
||||
.leaflet-marker-pane { z-index: 600; }
|
||||
.leaflet-tooltip-pane { z-index: 650; }
|
||||
.leaflet-popup-pane { z-index: 700; }
|
||||
|
||||
.leaflet-map-pane canvas { z-index: 100; }
|
||||
.leaflet-map-pane svg { z-index: 200; }
|
||||
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
z-index: 800;
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-top {
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-right {
|
||||
right: 0;
|
||||
}
|
||||
.leaflet-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.leaflet-left {
|
||||
left: 0;
|
||||
}
|
||||
.leaflet-control {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
float: right;
|
||||
}
|
||||
.leaflet-top .leaflet-control {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.leaflet-left .leaflet-control {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
.leaflet-zoom-animated {
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
svg.leaflet-zoom-animated {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-grab {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.leaflet-crosshair,
|
||||
.leaflet-crosshair .leaflet-interactive {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging .leaflet-grab,
|
||||
.leaflet-dragging .leaflet-grab .leaflet-interactive,
|
||||
.leaflet-dragging .leaflet-marker-draggable {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* marker & overlays interactivity */
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-pane > svg path,
|
||||
.leaflet-tile-container {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.leaflet-interactive,
|
||||
.leaflet-image-layer.leaflet-interactive,
|
||||
.leaflet-pane > svg path.leaflet-interactive,
|
||||
svg.leaflet-image-layer.leaflet-interactive path {
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #38f;
|
||||
background: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-bar a:hover,
|
||||
.leaflet-bar a:focus {
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.leaflet-bar a.leaflet-disabled {
|
||||
cursor: default;
|
||||
background-color: #f4f4f4;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:first-child {
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
font: bold 18px 'Lucida Console', Monaco, monospace;
|
||||
text-indent: 1px;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-retina .leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers-2x.png);
|
||||
background-size: 26px 26px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display: none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers-scrollbar {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height: 0;
|
||||
border-top: 1px solid #ddd;
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
/* Default icon URLs */
|
||||
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
|
||||
background-image: url(images/marker-icon.png);
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
margin: 0;
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-control-attribution a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover,
|
||||
.leaflet-control-attribution a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.leaflet-attribution-flag {
|
||||
display: inline !important;
|
||||
vertical-align: baseline !important;
|
||||
width: 1em;
|
||||
height: 0.6669em;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
white-space: nowrap;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
text-shadow: 1px 1px #fff;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 13px 24px 13px 20px;
|
||||
line-height: 1.3;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
min-height: 1px;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 17px 0;
|
||||
margin: 1.3em 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-top: -1px;
|
||||
margin-left: -20px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 1px;
|
||||
|
||||
margin: -10px auto 0;
|
||||
pointer-events: auto;
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
background: white;
|
||||
color: #333;
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border: none;
|
||||
text-align: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font: 16px/24px Tahoma, Verdana, sans-serif;
|
||||
color: #757575;
|
||||
text-decoration: none;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover,
|
||||
.leaflet-container a.leaflet-popup-close-button:focus {
|
||||
color: #585858;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper {
|
||||
-ms-zoom: 1;
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
width: 24px;
|
||||
margin: 0 auto;
|
||||
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-zoom,
|
||||
.leaflet-oldie .leaflet-control-layers,
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper,
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
/* div icon */
|
||||
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
|
||||
/* Tooltip */
|
||||
/* Base styles for the element that has a tooltip */
|
||||
.leaflet-tooltip {
|
||||
position: absolute;
|
||||
padding: 6px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
white-space: nowrap;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-tooltip.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-tooltip-top:before,
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border: 6px solid transparent;
|
||||
background: transparent;
|
||||
content: "";
|
||||
}
|
||||
|
||||
/* Directions */
|
||||
|
||||
.leaflet-tooltip-bottom {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.leaflet-tooltip-top {
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-top:before {
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-top:before {
|
||||
bottom: 0;
|
||||
margin-bottom: -12px;
|
||||
border-top-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before {
|
||||
top: 0;
|
||||
margin-top: -12px;
|
||||
margin-left: -6px;
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-left {
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-right {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before {
|
||||
right: 0;
|
||||
margin-right: -12px;
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-right:before {
|
||||
left: 0;
|
||||
margin-left: -12px;
|
||||
border-right-color: #fff;
|
||||
}
|
||||
|
||||
/* Printing */
|
||||
|
||||
@media print {
|
||||
/* Prevent printers from removing background-images of controls. */
|
||||
.leaflet-control {
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
}
|
||||
Externe
@@ -0,0 +1,6 @@
|
||||
/* @preserve
|
||||
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
|
||||
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n<o;n++)for(e in i=arguments[n])t[e]=i[e];return t}var R=Object.create||function(t){return N.prototype=t,new N};function N(){}function a(t,e){var i,n=Array.prototype.slice;return t.bind?t.bind.apply(t,n.call(arguments,1)):(i=n.call(arguments,2),function(){return t.apply(e,i.length?i.concat(n.call(arguments)):arguments)})}var D=0;function h(t){return"_leaflet_id"in t||(t._leaflet_id=++D),t._leaflet_id}function j(t,e,i){var n,o,s=function(){n=!1,o&&(r.apply(i,o),o=!1)},r=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(s,e),n=!0)};return r}function H(t,e,i){var n=e[1],e=e[0],o=n-e;return t===n&&i?t:((t-e)%o+o)%o+e}function u(){return!1}function i(t,e){return!1===e?t:(e=Math.pow(10,void 0===e?6:e),Math.round(t*e)/e)}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return W(t).split(/\s+/)}function c(t,e){for(var i in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?R(t.options):{}),e)t.options[i]=e[i];return t.options}function U(t,e,i){var n,o=[];for(n in t)o.push(encodeURIComponent(i?n.toUpperCase():n)+"="+encodeURIComponent(t[n]));return(e&&-1!==e.indexOf("?")?"&":"?")+o.join("&")}var V=/\{ *([\w_ -]+) *\}/g;function q(t,i){return t.replace(V,function(t,e){e=i[e];if(void 0===e)throw new Error("No value provided for variable "+t);return e="function"==typeof e?e(i):e})}var d=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function G(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1}var K="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Y(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var X=0;function J(t){var e=+new Date,i=Math.max(0,16-(e-X));return X=e+i,window.setTimeout(t,i)}var $=window.requestAnimationFrame||Y("RequestAnimationFrame")||J,Q=window.cancelAnimationFrame||Y("CancelAnimationFrame")||Y("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function x(t,e,i){if(!i||$!==J)return $.call(window,a(t,e));t.call(e)}function r(t){t&&Q.call(window,t)}var tt={__proto__:null,extend:l,create:R,bind:a,get lastId(){return D},stamp:h,throttle:j,wrapNum:H,falseFn:u,formatNum:i,trim:W,splitWords:F,setOptions:c,getParamString:U,template:q,isArray:d,indexOf:G,emptyImageUrl:K,requestFn:$,cancelFn:Q,requestAnimFrame:x,cancelAnimFrame:r};function et(){}et.extend=function(t){function e(){c(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var i,n=e.__super__=this.prototype,o=R(n);for(i in(o.constructor=e).prototype=o,this)Object.prototype.hasOwnProperty.call(this,i)&&"prototype"!==i&&"__super__"!==i&&(e[i]=this[i]);if(t.statics&&l(e,t.statics),t.includes){var s=t.includes;if("undefined"!=typeof L&&L&&L.Mixin){s=d(s)?s:[s];for(var r=0;r<s.length;r++)s[r]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}l.apply(null,[o].concat(t.includes))}return l(o,t),delete o.statics,delete o.includes,o.options&&(o.options=n.options?R(n.options):{},l(o.options,t.options)),o._initHooks=[],o.callInitHooks=function(){if(!this._initHooksCalled){n.callInitHooks&&n.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=o._initHooks.length;t<e;t++)o._initHooks[t].call(this)}},e},et.include=function(t){var e=this.prototype.options;return l(this.prototype,t),t.options&&(this.prototype.options=e,this.mergeOptions(t.options)),this},et.mergeOptions=function(t){return l(this.prototype.options,t),this},et.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this};var e={on:function(t,e,i){if("object"==typeof t)for(var n in t)this._on(n,t[n],e);else for(var o=0,s=(t=F(t)).length;o<s;o++)this._on(t[o],e,i);return this},off:function(t,e,i){if(arguments.length)if("object"==typeof t)for(var n in t)this._off(n,t[n],e);else{t=F(t);for(var o=1===arguments.length,s=0,r=t.length;s<r;s++)o?this._off(t[s]):this._off(t[s],e,i)}else delete this._events;return this},_on:function(t,e,i,n){"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1===this._listens(t,e,i)&&(e={fn:e,ctx:i=i===this?void 0:i},n&&(e.once=!0),this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e))},_off:function(t,e,i){var n,o,s;if(this._events&&(n=this._events[t]))if(1===arguments.length){if(this._firingCount)for(o=0,s=n.length;o<s;o++)n[o].fn=u;delete this._events[t]}else"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1!==(e=this._listens(Ligne tronquée
|
||||
//# sourceMappingURL=leaflet.js.map
|
||||
@@ -0,0 +1,48 @@
|
||||
import json, os, sys, unittest
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "collecte"))
|
||||
import collecter_weatherlink as c
|
||||
|
||||
REPONSE = json.dumps({"station_id": 1, "generated_at": 1761700000, "sensors": [
|
||||
{"lsid": 1, "data": [{"ts": 1761699900, "temp": 50.0, "hum": 80.4, "dew_point": 44.0, "wind_speed_avg_last_10_min": 10.0,
|
||||
"wind_dir_scalar_avg_last_10_min": 370, "rainfall_daily_in": 0.1, "temp_in": 70.0, "hum_in": 40}]},
|
||||
{"lsid": 2, "data": [{"ts": 1761699900, "bar_sea_level": 30.0}]}]})
|
||||
|
||||
|
||||
class T(unittest.TestCase):
|
||||
def test_conversion_et_filtre(self):
|
||||
m = c.mesure_depuis_current(REPONSE)
|
||||
self.assertEqual(m["temperature"], 10.0)
|
||||
self.assertEqual(m["humidite"], 80)
|
||||
self.assertEqual(m["vent_direction"], 10)
|
||||
self.assertAlmostEqual(m["pression"], 1015.9, 1)
|
||||
self.assertNotIn("temp_in", m)
|
||||
self.assertTrue(set(m) <= set(c.CHAMPS_PUBLICS))
|
||||
|
||||
def test_sans_temperature(self):
|
||||
with self.assertRaises(c.ErreurWL):
|
||||
c.mesure_depuis_current(json.dumps({"sensors": [{"data": [{"ts": 1, "hum": 50}]}]}))
|
||||
|
||||
def test_exemple_propre(self):
|
||||
cfg = json.load(open(c.CONFIG_DEFAUT, encoding="utf-8"))
|
||||
obj = c.construire_exemple(cfg)
|
||||
c.verifier_public(obj)
|
||||
self.assertTrue(all(s["exemple"] for s in obj["stations"].values()))
|
||||
|
||||
def test_fuite_refusee(self):
|
||||
for mauvais in ({"x": "192.168.1.15"}, {"x": "/mnt/hdd3/a"}, {"x": "api-key"}, {"x": "weather-db"}):
|
||||
with self.assertRaises(ValueError):
|
||||
c.verifier_public(mauvais)
|
||||
with self.assertRaises(ValueError):
|
||||
c.verifier_public({"stations": {"a": {"releves": [{"dh_utc": "x", "trame_brute": 1}]}}})
|
||||
|
||||
def test_sans_cle_hors_ligne(self):
|
||||
for v in ("MC_WL_BRUYERES_CLE", "MC_WL_ALLIERES_CLE", "MC_WL_VP2_CLE"):
|
||||
os.environ.pop(v, None)
|
||||
cfg = json.load(open(c.CONFIG_DEFAUT, encoding="utf-8"))
|
||||
obj, j = c.collecter(cfg, {}, 1)
|
||||
c.verifier_public(obj)
|
||||
self.assertTrue(all(s["hors_ligne"] for s in obj["stations"].values()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur