Boucle du Hainaut : application de réalité augmentée (v46)

PWA three.js + LocAR : pylônes et câbles de la ligne 380 kV sur le tracé
projeté, à l'échelle réelle, cachés par le relief (SPW 10 m), les obstacles
LiDAR (1/2/4 m) et les bâtiments OpenStreetMap. Photo avant/après, calage
de la vue, mini-carte, hors-ligne complet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mathieuandClaude Opus 5.5 committed 2026-11-15 22:19:19 +01:00
commit 3662fd4993
3571 files changed
+83668

No files matched your search

+142
View File
@@ -0,0 +1,142 @@
"""Génère le logo (2 pylônes dans un champ, câbles correctement accrochés) en SVG."""
import sys
def f(v): return f"{v:.2f}"
# --- géométrie d'un pylône en unités (0 = sol, 1 = sommet), x relatif à l'axe ---
LEG = [(0.0, 0.21), (0.55, 0.075), (0.86, 0.055)] # (hauteur, demi-largeur)
def half(h):
for (h0, w0), (h1, w1) in zip(LEG, LEG[1:]):
if h <= h1:
return w0 + (w1 - w0) * (h - h0) / (h1 - h0)
return 0.055 * (1 - (h - 0.86) / 0.14)
ARMS = [(0.60, 0.33), (0.80, 0.28)] # (hauteur du bras, portée)
INS = 0.075 # longueur de la chaîne d'isolateurs
PEAK = 1.0
def attach_points(base, H):
"""Points où les câbles s'accrochent : sommet (câble de garde) + bas des 4 isolateurs."""
bx, by = base
pts = [(bx, by - PEAK * H)]
for h, reach in ARMS:
for side in (-1, 1):
pts.append((bx + side * reach * H, by - h * H + INS * H))
return pts
def pylon(base, H, color):
bx, by = base
P = lambda x, h: (bx + x * H, by - h * H)
sw = max(H * 0.024, 1.3)
out = []
line = lambda a, b, w=sw: out.append(
f'<line x1="{f(a[0])}" y1="{f(a[1])}" x2="{f(b[0])}" y2="{f(b[1])}" stroke-width="{f(w)}"/>')
# jambes
hs = [0, 0.55, 0.86]
for s in (-1, 1):
for h0, h1 in zip(hs, hs[1:]):
line(P(s * half(h0), h0), P(s * half(h1), h1), sw * 1.5)
line(P(s * half(0.86), 0.86), P(0, PEAK), sw * 1.3)
# treillis (croisillons + traverses)
lev = [0, 0.2, 0.38, 0.53, 0.60, 0.70, 0.80, 0.86]
for h0, h1 in zip(lev, lev[1:]):
line(P(-half(h0), h0), P(half(h1), h1))
line(P(half(h0), h0), P(-half(h1), h1))
line(P(-half(h1), h1), P(half(h1), h1))
line(P(-half(0.86), 0.86), P(0, 0.94)); line(P(half(0.86), 0.86), P(0, 0.94))
# bras (consoles triangulées)
for h, reach in ARMS:
for s in (-1, 1):
w = half(h)
tip = P(s * reach, h)
line(P(s * w, h), tip, sw * 1.3) # membrure basse
line(P(s * w, h + 0.075), tip, sw * 1.3) # membrure haute
n = 2
for i in range(n):
xa = w + (reach - w) * i / n
xb = w + (reach - w) * (i + 1) / n
ya = h + 0.075 * (1 - i / n)
line(P(s * xa, ya), P(s * xb, h))
line(P(s * xb, h), P(s * xb, h + 0.075 * (1 - (i + 1) / n)))
g = f'<g stroke="{color}" stroke-linecap="round">' + "".join(out) + "</g>"
# isolateurs (chaîne de disques)
ins = []
for h, reach in ARMS:
for s in (-1, 1):
x, y = P(s * reach, h)
ins.append(f'<line x1="{f(x)}" y1="{f(y)}" x2="{f(x)}" y2="{f(y + INS * H)}" '
f'stroke="{color}" stroke-width="{f(sw)}"/>')
ins.append(f'<rect x="{f(x - H * 0.017)}" y="{f(y + INS * H * 0.12)}" width="{f(H * 0.034)}" height="{f(INS * H * 0.8)}" rx="{f(H * 0.012)}" fill="#9fb3bf" stroke="{color}" stroke-width="{f(sw * 0.5)}"/>')
return g + "".join(ins)
def cable(a, b, sag, w):
mx, my = (a[0] + b[0]) / 2, (a[1] + b[1]) / 2 + sag
return (f'<path d="M{f(a[0])},{f(a[1])} Q{f(mx)},{f(my)} {f(b[0])},{f(b[1])}" '
f'fill="none" stroke="#1f2a33" stroke-width="{f(w)}" stroke-linecap="round"/>')
def scene():
V = (740, 300) # point de fuite (hors cadre, à droite)
B0, H0 = (256, 452), 295
scales = [1.8, 1.0, 0.5, 0.25] # seul 1.0 est visible ; les autres sont hors du rond
pyl = []
for s in scales:
base = (V[0] + (B0[0] - V[0]) * s, V[1] + (B0[1] - V[1]) * s)
pyl.append((base, H0 * s))
parts = []
# câbles entre pylônes successifs (même point d'accroche -> même point d'accroche)
for (b1, h1), (b2, h2) in zip(pyl, pyl[1:]):
p1, p2 = attach_points(b1, h1), attach_points(b2, h2)
for i, (a, b) in enumerate(zip(p1, p2)):
span = ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5
w = 1.6 + 1.6 * (h1 + h2) / (2 * H0) * (0.75 if i == 0 else 1)
parts.append(cable(a, b, span * 0.06, min(w, 4.2)))
pylons = "".join(pylon(b, h, "#34444f") for b, h in [pyl[1]]) # un seul pylône, centré
return pylons, "".join(parts)
def svg(maskable=False):
S = 512
c = 256
R_out = 196 if maskable else 248 # bord extérieur de l'anneau rouge
ring = R_out * 0.15
R_in = R_out - ring
k = R_in / 214 # la scène est dessinée pour un disque de rayon 214
pylons, cables = scene()
bar = ring * 0.95
d = R_in * 0.7071
return f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {S} {S}" width="{S}" height="{S}">
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#1e9bf0"/><stop offset="1" stop-color="#c6ecff"/>
</linearGradient>
<linearGradient id="field" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#9ed34a"/><stop offset="1" stop-color="#5daa2c"/>
</linearGradient>
<clipPath id="disc"><circle cx="{c}" cy="{c}" r="{f(R_in + 1)}"/></clipPath>
</defs>
<rect width="{S}" height="{S}" fill="#ffffff"/>
<g clip-path="url(#disc)">
<g transform="translate({c} {c}) scale({f(k)}) translate(-256 -256)">
<rect x="0" y="0" width="512" height="512" fill="url(#sky)"/>
<g fill="#ffffff">
<ellipse cx="380" cy="140" rx="46" ry="16"/><circle cx="366" cy="128" r="18"/><circle cx="392" cy="122" r="22"/>
<ellipse cx="120" cy="230" rx="40" ry="13"/><circle cx="110" cy="220" r="15"/><circle cx="132" cy="214" r="18"/>
</g>
<path d="M0,300 C80,276 160,286 240,296 C320,280 420,274 512,290 L512,512 L0,512 Z" fill="#3f8f3a"/>
<g fill="#2f7a31">
<circle cx="60" cy="296" r="24"/><circle cx="90" cy="286" r="28"/><circle cx="120" cy="298" r="20"/>
<circle cx="430" cy="290" r="16"/><circle cx="452" cy="284" r="20"/><circle cx="476" cy="292" r="16"/>
</g>
<path d="M0,312 C120,298 300,300 512,306 L512,512 L0,512 Z" fill="url(#field)"/>
<path d="M0,420 C140,396 360,400 512,412 L512,512 L0,512 Z" fill="#6cbd33" opacity="0.6"/>
{pylons}
{cables}
</g>
</g>
<circle cx="{c}" cy="{c}" r="{f(R_out - ring / 2)}" fill="none" stroke="#e30613" stroke-width="{f(ring)}"/>
<line x1="{f(c - d)}" y1="{f(c - d)}" x2="{f(c + d)}" y2="{f(c + d)}" stroke="#e30613" stroke-width="{f(bar)}"/>
</svg>'''
if __name__ == "__main__":
out = sys.argv[1]
open(f"{out}/logo.svg", "w").write(svg(False))
open(f"{out}/logo-maskable.svg", "w").write(svg(True))
+32
View File
@@ -0,0 +1,32 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#1e9bf0"/><stop offset="1" stop-color="#c6ecff"/>
</linearGradient>
<linearGradient id="field" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#9ed34a"/><stop offset="1" stop-color="#5daa2c"/>
</linearGradient>
<clipPath id="disc"><circle cx="256" cy="256" r="167.60"/></clipPath>
</defs>
<rect width="512" height="512" fill="#ffffff"/>
<g clip-path="url(#disc)">
<g transform="translate(256 256) scale(0.78) translate(-256 -256)">
<rect x="0" y="0" width="512" height="512" fill="url(#sky)"/>
<g fill="#ffffff">
<ellipse cx="380" cy="140" rx="46" ry="16"/><circle cx="366" cy="128" r="18"/><circle cx="392" cy="122" r="22"/>
<ellipse cx="120" cy="230" rx="40" ry="13"/><circle cx="110" cy="220" r="15"/><circle cx="132" cy="214" r="18"/>
</g>
<path d="M0,300 C80,276 160,286 240,296 C320,280 420,274 512,290 L512,512 L0,512 Z" fill="#3f8f3a"/>
<g fill="#2f7a31">
<circle cx="60" cy="296" r="24"/><circle cx="90" cy="286" r="28"/><circle cx="120" cy="298" r="20"/>
<circle cx="430" cy="290" r="16"/><circle cx="452" cy="284" r="20"/><circle cx="476" cy="292" r="16"/>
</g>
<path d="M0,312 C120,298 300,300 512,306 L512,512 L0,512 Z" fill="url(#field)"/>
<path d="M0,420 C140,396 360,400 512,412 L512,512 L0,512 Z" fill="#6cbd33" opacity="0.6"/>
<g stroke="#34444f" stroke-linecap="round"><line x1="194.05" y1="452.00" x2="233.88" y2="289.75" stroke-width="10.62"/><line x1="233.88" y1="289.75" x2="239.78" y2="198.30" stroke-width="10.62"/><line x1="239.78" y1="198.30" x2="256.00" y2="157.00" stroke-width="9.20"/><line x1="317.95" y1="452.00" x2="278.12" y2="289.75" stroke-width="10.62"/><line x1="278.12" y1="289.75" x2="272.23" y2="198.30" stroke-width="10.62"/><line x1="272.23" y1="198.30" x2="256.00" y2="157.00" stroke-width="9.20"/><line x1="194.05" y1="452.00" x2="303.47" y2="393.00" stroke-width="7.08"/><line x1="317.95" y1="452.00" x2="208.53" y2="393.00" stroke-width="7.08"/><line x1="208.53" y1="393.00" x2="303.47" y2="393.00" stroke-width="7.08"/><line x1="208.53" y1="393.00" x2="290.43" y2="339.90" stroke-width="7.08"/><line x1="303.47" y1="393.00" x2="221.57" y2="339.90" stroke-width="7.08"/><line x1="221.57" y1="339.90" x2="290.43" y2="339.90" stroke-width="7.08"/><line x1="221.57" y1="339.90" x2="279.57" y2="295.65" stroke-width="7.08"/><line x1="290.43" y1="339.90" x2="232.43" y2="295.65" stroke-width="7.08"/><line x1="232.43" y1="295.65" x2="279.57" y2="295.65" stroke-width="7.08"/><line x1="232.43" y1="295.65" x2="277.17" y2="275.00" stroke-width="7.08"/><line x1="279.57" y1="295.65" x2="234.83" y2="275.00" stroke-width="7.08"/><line x1="234.83" y1="275.00" x2="277.17" y2="275.00" stroke-width="7.08"/><line x1="234.83" y1="275.00" x2="275.27" y2="245.50" stroke-width="7.08"/><line x1="277.17" y1="275.00" x2="236.73" y2="245.50" stroke-width="7.08"/><line x1="236.73" y1="245.50" x2="275.27" y2="245.50" stroke-width="7.08"/><line x1="236.73" y1="245.50" x2="273.37" y2="216.00" stroke-width="7.08"/><line x1="275.27" y1="245.50" x2="238.63" y2="216.00" stroke-width="7.08"/><line x1="238.63" y1="216.00" x2="273.37" y2="216.00" stroke-width="7.08"/><line x1="238.63" y1="216.00" x2="272.23" y2="198.30" stroke-width="7.08"/><line x1="273.37" y1="216.00" x2="239.78" y2="198.30" stroke-width="7.08"/><line x1="239.78" y1="198.30" x2="272.23" y2="198.30" stroke-width="7.08"/><line x1="239.78" y1="198.30" x2="256.00" y2="174.70" stroke-width="7.08"/><line x1="272.23" y1="198.30" x2="256.00" y2="174.70" stroke-width="7.08"/><line x1="234.83" y1="275.00" x2="158.65" y2="275.00" stroke-width="9.20"/><line x1="234.83" y1="252.88" x2="158.65" y2="275.00" stroke-width="9.20"/><line x1="234.83" y1="252.88" x2="196.74" y2="275.00" stroke-width="7.08"/><line x1="196.74" y1="275.00" x2="196.74" y2="263.94" stroke-width="7.08"/><line x1="196.74" y1="263.94" x2="158.65" y2="275.00" stroke-width="7.08"/><line x1="158.65" y1="275.00" x2="158.65" y2="275.00" stroke-width="7.08"/><line x1="277.17" y1="275.00" x2="353.35" y2="275.00" stroke-width="9.20"/><line x1="277.17" y1="252.88" x2="353.35" y2="275.00" stroke-width="9.20"/><line x1="277.17" y1="252.88" x2="315.26" y2="275.00" stroke-width="7.08"/><line x1="315.26" y1="275.00" x2="315.26" y2="263.94" stroke-width="7.08"/><line x1="315.26" y1="263.94" x2="353.35" y2="275.00" stroke-width="7.08"/><line x1="353.35" y1="275.00" x2="353.35" y2="275.00" stroke-width="7.08"/><line x1="238.63" y1="216.00" x2="173.40" y2="216.00" stroke-width="9.20"/><line x1="238.63" y1="193.88" x2="173.40" y2="216.00" stroke-width="9.20"/><line x1="238.63" y1="193.88" x2="206.02" y2="216.00" stroke-width="7.08"/><line x1="206.02" y1="216.00" x2="206.02" y2="204.94" stroke-width="7.08"/><line x1="206.02" y1="204.94" x2="173.40" y2="216.00" stroke-width="7.08"/><line x1="173.40" y1="216.00" x2="173.40" y2="216.00" stroke-width="7.08"/><line x1="273.37" y1="216.00" x2="338.60" y2="216.00" stroke-width="9.20"/><line x1="273.37" y1="193.88" x2="338.60" y2="216.00" stroke-width="9.20"/><line x1="273.37" y1="193.88" x2="305.98" y2="216.00" stroke-width="7.08"/><line x1="305.98" y1="216.00" x2="305.98" y2="204.94" stroke-width="7.08"/><line x1="305.98" y1="204.94" x2="338.60" y2="216.00" stroke-width="7.08"/><line x1="338.60" y1="216.00" x2="338.60" y2="216.00" stroke-width="7.08"/></g><line x1="158.65" y1="275.00" x2="158.65" y2="297.12" stroke="#34444f" stroke-width="7.08"/><rect x="153.63" y="277.65" width="10.03" height="17.70" rx="3.54" fill="#9fb3bf" stroke="#34444f" stroke-width="3.54"/><line x1="353.35" y1="275.00" x2="353.35" y2="297.12" stroke="#34444f" stroke-width="7.08"/><rect x="348.34" y="277.65" width="10.03" height="17.70" rx="3.54" fill="#9fb3bf" stroke="#34444f" stroke-width="3.54"/><line x1="173.40" y1="216.00" x2="173.40" y2="238.12" stroke="#34444f" stroke-width="7.08"/><rect x="168.38" y="218.66" width="10.03" height="17.70" rx="3.54" fill="#9fb3bf" stroke="#34444f" stroke-width="3.54"/><line x1="338.60" y1="216.00" x2="338.60" y2="238.12" stroke="#34444f" stroke-width="7.08"/><rect x="333.59" y="218.66" width="10.03" height="17.70" rx="3.54" fill="#9fb3bf" stroke="#34444f" stroke-width="3.54"/>
<path d="M-131.20,42.60 Q62.40,124.02 256.00,157.00" fill="none" stroke="#1f2a33" stroke-width="3.28" stroke-linecap="round"/><path d="M-306.43,294.83 Q-73.89,323.88 158.65,297.12" fill="none" stroke="#1f2a33" stroke-width="3.84" stroke-linecap="round"/><path d="M44.03,294.83 Q198.69,314.53 353.35,297.12" fill="none" stroke="#1f2a33" stroke-width="3.84" stroke-linecap="round"/><path d="M-279.88,188.62 Q-53.24,240.73 173.40,238.12" fill="none" stroke="#1f2a33" stroke-width="3.84" stroke-linecap="round"/><path d="M17.48,188.62 Q178.04,232.87 338.60,238.12" fill="none" stroke="#1f2a33" stroke-width="3.84" stroke-linecap="round"/><path d="M256.00,157.00 Q377.00,207.89 498.00,228.50" fill="none" stroke="#1f2a33" stroke-width="2.50" stroke-linecap="round"/><path d="M158.65,297.12 Q303.99,315.28 449.32,298.56" fill="none" stroke="#1f2a33" stroke-width="2.80" stroke-linecap="round"/><path d="M353.35,297.12 Q450.01,309.44 546.67,298.56" fill="none" stroke="#1f2a33" stroke-width="2.80" stroke-linecap="round"/><path d="M173.40,238.12 Q315.05,270.69 456.70,269.06" fill="none" stroke="#1f2a33" stroke-width="2.80" stroke-linecap="round"/><path d="M338.60,238.12 Q438.95,265.78 539.30,269.06" fill="none" stroke="#1f2a33" stroke-width="2.80" stroke-linecap="round"/><path d="M498.00,228.50 Q558.50,253.95 619.00,264.25" fill="none" stroke="#1f2a33" stroke-width="2.05" stroke-linecap="round"/><path d="M449.32,298.56 Q521.99,307.64 594.66,299.28" fill="none" stroke="#1f2a33" stroke-width="2.20" stroke-linecap="round"/><path d="M546.67,298.56 Q595.01,304.72 643.34,299.28" fill="none" stroke="#1f2a33" stroke-width="2.20" stroke-linecap="round"/><path d="M456.70,269.06 Q527.52,285.35 598.35,284.53" fill="none" stroke="#1f2a33" stroke-width="2.20" stroke-linecap="round"/><path d="M539.30,269.06 Q589.47,282.89 639.65,284.53" fill="none" stroke="#1f2a33" stroke-width="2.20" stroke-linecap="round"/>
</g>
</g>
<circle cx="256" cy="256" r="181.30" fill="none" stroke="#e30613" stroke-width="29.40"/>
<line x1="138.20" y1="138.20" x2="373.80" y2="373.80" stroke="#e30613" stroke-width="27.93"/>
</svg>

After

Width:  |  Height:  |  Size: 8.3 KiB