Agréger la qualité de zone et ajouter les couleurs de légende de la planche PDF
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@ -119,3 +119,59 @@ def test_compose_l93_no_data_returns_empty_cells(tmp_path):
|
||||
from lidar_pipeline.export_pdf import compose_l93
|
||||
img, mask, cells = compose_l93(tmp_path, (0.0, 0.0, 100.0, 100.0), 1.0)
|
||||
assert cells == [] and mask.getextrema() == (0, 0)
|
||||
|
||||
|
||||
def test_lab_to_rgb_matches_numpy_reference():
|
||||
import numpy as np
|
||||
from lidar_pipeline.export_pdf import lab_to_rgb
|
||||
from lidar_pipeline.visualizations import _lab_to_srgb
|
||||
for L, a, b in [(64, 30, -20), (20, 0, 0), (90, -10, 40), (50, 60, 0)]:
|
||||
ref = tuple(int(round(v * 255)) for v in _lab_to_srgb(
|
||||
np.array(L, float), np.array(a, float), np.array(b, float)))
|
||||
assert all(abs(p - q) <= 1 for p, q in zip(lab_to_rgb(L, a, b), ref))
|
||||
|
||||
|
||||
def test_rose_color_distinct_orientations():
|
||||
from lidar_pipeline.export_pdf import rose_color
|
||||
colors = {rose_color(c) for c in (0, 90, 180, 270)}
|
||||
assert len(colors) == 4
|
||||
|
||||
|
||||
def test_density_color_classes():
|
||||
from lidar_pipeline.export_pdf import DENSITY_CLASSES, density_color
|
||||
assert density_color(0.0) == DENSITY_CLASSES[0][2]
|
||||
assert density_color(50.0) == DENSITY_CLASSES[-1][2]
|
||||
|
||||
|
||||
def test_pdf_text_replaces_unencodable():
|
||||
from lidar_pipeline.export_pdf import _pdf_text
|
||||
assert _pdf_text("Relief orienté — 1:2 000 ≥ 🚀") == "Relief orienté — 1:2 000 ? ?"
|
||||
|
||||
|
||||
def _q(density, start="2023-03-15", end="2023-03-17", empty=0.1):
|
||||
return {"version": 1, "ground_density": density,
|
||||
"density_grid": [[density] * 20 for _ in range(20)],
|
||||
"empty_fraction": empty, "acq_start": start, "acq_end": end,
|
||||
"acq_source": "gps"}
|
||||
|
||||
|
||||
def test_zone_quality_aggregates_two_cells():
|
||||
from lidar_pipeline.export_pdf import zone_quality
|
||||
table = {"LHD_FXX_1054_6882_PTS_LAMB93_IGN69": _q(4.0, "2023-03-15", "2023-03-15"),
|
||||
"LHD_FXX_1055_6882_PTS_LAMB93_IGN69": _q(8.0, "2023-04-02", "2023-04-03", 0.3)}
|
||||
bbox = (1054500.0, 6881500.0, 1055500.0, 6881600.0) # moitié de chaque dalle
|
||||
z = zone_quality(bbox, table, [(1054, 6882), (1055, 6882)])
|
||||
assert abs(z["density_mean"] - 6.0) < 1e-6 and z["density_min"] == 4.0
|
||||
assert abs(z["empty_fraction"] - 0.2) < 1e-6
|
||||
assert (z["acq_start"], z["acq_end"]) == ("2023-03-15", "2023-04-03")
|
||||
assert z["missing_relief"] == [] and z["missing_quality"] == []
|
||||
assert len(z["grid_cells"]) == 2 * 10 * 2 # 10 mailles en x × 2 en y par dalle
|
||||
|
||||
|
||||
def test_zone_quality_missing_cells():
|
||||
from lidar_pipeline.export_pdf import zone_quality
|
||||
bbox = (1054500.0, 6881500.0, 1055500.0, 6881600.0)
|
||||
z = zone_quality(bbox, {}, [(1054, 6882)])
|
||||
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)]
|
||||
|
||||
Reference in New Issue
Block a user