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,50 @@
|
||||
# Périmètre du Parc naturel régional du Vercors (BD TOPO) et position des noms des fleuves.
|
||||
import json, math
|
||||
import numpy as np
|
||||
|
||||
c = json.load(open('carte.json', encoding='utf-8'))
|
||||
K, M, LON0, LAT1 = c['k'], c['m'], c['lon0'], c['lat1']
|
||||
proj = lambda lon, lat: ((lon - LON0) * K * M, (LAT1 - lat) * M)
|
||||
|
||||
def rdp(pts, eps):
|
||||
if len(pts) < 3:
|
||||
return pts
|
||||
a, b = pts[0], pts[-1]
|
||||
d = b - a
|
||||
n = math.hypot(*d)
|
||||
dist = np.hypot(*(pts - a).T) if n == 0 else np.abs(d[0] * (pts[:, 1] - a[1]) - d[1] * (pts[:, 0] - a[0])) / n
|
||||
i = int(np.argmax(dist))
|
||||
if dist[i] > eps:
|
||||
return np.vstack([rdp(pts[:i + 1], eps)[:-1], rdp(pts[i:], eps)])
|
||||
return np.array([a, b])
|
||||
|
||||
f = lambda v: (f'{v:.1f}')[:-2] if f'{v:.1f}'.endswith('.0') else f'{v:.1f}'
|
||||
|
||||
if __name__ == '__main__':
|
||||
parc = next(x for x in json.load(open('parcs.json', encoding='utf-8'))['features']
|
||||
if x['properties']['toponyme'] == 'Parc Naturel Régional du Vercors')
|
||||
d = ''
|
||||
for poly in parc['geometry']['coordinates']:
|
||||
for ring in poly:
|
||||
pts = np.array([proj(lo, la) for lo, la, *_ in ring])
|
||||
s = rdp(pts, 0.4)
|
||||
if len(s) >= 4:
|
||||
d += 'M' + 'L'.join(f'{f(x)} {f(y)}' for x, y in s) + 'Z'
|
||||
|
||||
# nom de chaque fleuve posé sur son cours, au plus près d'un point choisi
|
||||
cibles = {"l'Isère": ('Isère', 5.45, 45.215), 'le Drac': ('Drac', 5.70, 45.06), 'la Drôme': ('Drôme', 5.30, 44.74)}
|
||||
fleuves = []
|
||||
for ft in json.load(open('ce.json', encoding='utf-8'))['features']:
|
||||
n = ft['properties']['toponyme']
|
||||
if n in cibles:
|
||||
nom, lo0, la0 = cibles[n]
|
||||
for ligne in ft['geometry']['coordinates']:
|
||||
for lo, la, *_ in ligne:
|
||||
dd = math.hypot((lo - lo0) * K, la - la0)
|
||||
fleuves.append((dd, nom, lo, la))
|
||||
noms = {}
|
||||
for dd, nom, lo, la in sorted(fleuves):
|
||||
noms.setdefault(nom, {'n': nom, 'lon': round(lo, 5), 'lat': round(la, 5), 'p': 1, 't': 'fleuve'})
|
||||
|
||||
json.dump({'pnr': d, 'fleuves': list(noms.values())}, open('pnr.json', 'w', encoding='utf-8'), ensure_ascii=False)
|
||||
print('pnr', len(d), list(noms.values()))
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur