Ajouter des exemples au README et adapter la légende PDF aux hachures sans donnée
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -469,7 +469,7 @@ def _draw_legend(c, box, mm):
|
||||
c.drawRightString((bx + bw) * mm, (by - 2.8) * mm, _pdf_text("bosse, crête"))
|
||||
c.drawString(bx * mm, (by + bh + 0.8) * mm, _pdf_text("Clarté = micro-relief"))
|
||||
# Rose des orientations (couleur = orientation de la pente)
|
||||
r_out, r_in = 11.0, 5.0
|
||||
r_out, r_in = 8.5, 3.9 # place pour les 4 phrases de lecture
|
||||
rcx, rcy = x + r_out + 2, by - 5 - r_out - 2
|
||||
for deg in range(0, 360, 5):
|
||||
c.setFillColor(HexColor(_hex(rose_color(deg))))
|
||||
@ -490,16 +490,23 @@ def _draw_legend(c, box, mm):
|
||||
# Texte de légende ("Comment lire" : phrases habillées à la largeur de la boîte)
|
||||
from reportlab.pdfbase.pdfmetrics import stringWidth
|
||||
ty = rcy - r_out - 6
|
||||
c.setFont("Helvetica", 5.8)
|
||||
c.setFont("Helvetica", 5.2) # 4 phrases dans la boîte, A4 compris
|
||||
for sentence in VIZ_LEGENDS[LAYER].get("reading") or VIZ_LEGENDS[LAYER]["legend"].split("\n"):
|
||||
# Sur la planche, les pixels sans point sol sont hachurés en blanc
|
||||
# (pas noirs comme sur la carte) : même phrase, repère adapté.
|
||||
if sentence.startswith("Trous noirs"):
|
||||
sentence = "Hachures blanches" + sentence[len("Trous noirs"):]
|
||||
# La teinte est déjà légendée à côté de la rose : phrase redondante.
|
||||
if sentence.startswith("Teinte = orientation"):
|
||||
continue
|
||||
line = ""
|
||||
for word in _pdf_text(sentence).split(" "):
|
||||
test = (line + " " + word).strip()
|
||||
if stringWidth(test, "Helvetica", 5.8) * 0.3528 > w and line: # pt → mm
|
||||
if stringWidth(test, "Helvetica", 5.2) * 0.3528 > w and line: # pt → mm
|
||||
if ty < y + 1:
|
||||
return
|
||||
c.drawString(x * mm, ty * mm, line)
|
||||
ty -= 2.9
|
||||
ty -= 2.5
|
||||
line = word
|
||||
else:
|
||||
line = test
|
||||
@ -507,7 +514,7 @@ def _draw_legend(c, box, mm):
|
||||
if ty < y + 1:
|
||||
return
|
||||
c.drawString(x * mm, ty * mm, line)
|
||||
ty -= 3.6 # interligne un peu plus grand entre deux phrases
|
||||
ty -= 3.1 # interligne un peu plus grand entre deux phrases
|
||||
|
||||
|
||||
def _draw_quality(c, box, bbox, zq, mm):
|
||||
|
||||
Reference in New Issue
Block a user