Dessiner la planche PDF : quadrillage L93, légende, encart qualité et cartouche
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@ -175,3 +175,69 @@ def test_zone_quality_missing_cells():
|
||||
assert z["density_mean"] is None and z["acq_start"] is None
|
||||
assert z["missing_quality"] == [(1054, 6882), (1055, 6882)]
|
||||
assert z["missing_relief"] == [(1055, 6882)]
|
||||
|
||||
|
||||
def _mediabox(pdf):
|
||||
import re
|
||||
m = re.search(rb"/MediaBox \[\s*0 0 ([\d.]+) ([\d.]+)\s*\]", pdf)
|
||||
return float(m.group(1)), float(m.group(2))
|
||||
|
||||
|
||||
def _cell_center_wgs84(col, row):
|
||||
from lidar_pipeline.tiles import _transformer
|
||||
lon, lat = _transformer("EPSG:2154", "EPSG:4326").transform(col * 1000 + 500, (row - 1) * 1000 + 500)
|
||||
return lat, lon
|
||||
|
||||
|
||||
def test_build_pdf_a4_landscape(tmp_path, monkeypatch):
|
||||
from lidar_pipeline import index
|
||||
from lidar_pipeline.export_pdf import build_pdf
|
||||
from lidar_pipeline.quality import write_quality
|
||||
monkeypatch.setattr(index, "PANEL_VIZ", None)
|
||||
_dalle(tmp_path, 1054, 6882, px=200)
|
||||
write_quality(tmp_path, "LHD_FXX_1054_6882_PTS_LAMB93_IGN69", _q(6.5))
|
||||
lat, lon = _cell_center_wgs84(1054, 6882)
|
||||
pdf, name = build_pdf(tmp_path, lat, lon, "A4", "paysage", 2000,
|
||||
title="Prospection 🚀 bois", compress=False)
|
||||
assert pdf.startswith(b"%PDF")
|
||||
w, h = _mediabox(pdf)
|
||||
assert abs(w - 841.89) < 0.5 and abs(h - 595.28) < 0.5
|
||||
assert name.startswith("relief_1054.") and name.endswith("_1-2000.pdf")
|
||||
for s in (b"Prospection ? bois", b"1:2 000", b"Densit", b"2023-03-15", b"LiDAR HD"):
|
||||
assert s in pdf, s
|
||||
|
||||
|
||||
def test_build_pdf_a3_portrait_size(tmp_path, monkeypatch):
|
||||
from lidar_pipeline import index
|
||||
from lidar_pipeline.export_pdf import build_pdf
|
||||
monkeypatch.setattr(index, "PANEL_VIZ", None)
|
||||
_dalle(tmp_path, 1054, 6882)
|
||||
lat, lon = _cell_center_wgs84(1054, 6882)
|
||||
pdf, _name = build_pdf(tmp_path, lat, lon, "A3", "portrait", 5000)
|
||||
w, h = _mediabox(pdf)
|
||||
assert abs(w - 841.89) < 0.5 and abs(h - 1190.55) < 0.5
|
||||
|
||||
|
||||
def test_build_pdf_partial_zone_hatched(tmp_path, monkeypatch):
|
||||
"""Zone à cheval sur le bord des données : planche produite, dalle absente listée."""
|
||||
from lidar_pipeline import index
|
||||
from lidar_pipeline.export_pdf import build_pdf
|
||||
from lidar_pipeline.tiles import _transformer
|
||||
monkeypatch.setattr(index, "PANEL_VIZ", None)
|
||||
_dalle(tmp_path, 1054, 6882)
|
||||
lon, lat = _transformer("EPSG:2154", "EPSG:4326").transform(1055000.0, 6881500.0)
|
||||
pdf, _ = build_pdf(tmp_path, lat, lon, "A4", "paysage", 2000, compress=False)
|
||||
assert pdf.startswith(b"%PDF") and b"1055_6882" in pdf
|
||||
assert b"non renseign" in pdf
|
||||
|
||||
|
||||
def test_build_pdf_no_data_raises(tmp_path):
|
||||
import pytest
|
||||
from lidar_pipeline.export_pdf import NoDataError, build_pdf
|
||||
with pytest.raises(NoDataError):
|
||||
build_pdf(tmp_path, 46.5, 2.5, "A4", "paysage", 2000)
|
||||
|
||||
|
||||
def test_fmt_int():
|
||||
from lidar_pipeline.export_pdf import _fmt_int
|
||||
assert _fmt_int(2000) == "2 000" and _fmt_int(500) == "500"
|
||||
|
||||
Reference in New Issue
Block a user