Ajouter la géométrie de planche PDF, l'accès aux sources par emprise L93 et reportlab
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -753,39 +753,52 @@ def _pick_tier(tiers, target_res):
|
||||
return tiers[-1]
|
||||
|
||||
|
||||
def _contributing(output_dir, layer, z, x, y, scale):
|
||||
"""Sources intersectant la tuile, palier choisi selon la résolution visée."""
|
||||
def sources_in_bbox(output_dir, layer, bbox, target_res):
|
||||
"""Sources d'une couche intersectant une emprise L93, au palier le plus
|
||||
grossier suffisant pour target_res (m/px). Retourne [((col, row), source)]."""
|
||||
per_cell = source_index(output_dir).get(layer)
|
||||
if not per_cell:
|
||||
return []
|
||||
min_x, min_y, max_x, max_y = tile_bounds_l93(z, x, y)
|
||||
target = target_resolution(z, y, scale)
|
||||
min_x, min_y, max_x, max_y = bbox
|
||||
out = []
|
||||
for (col, row), tiers in per_cell.items():
|
||||
b = _cell_bounds(col, row)
|
||||
if b[2] <= min_x or b[0] >= max_x or b[3] <= min_y or b[1] >= max_y:
|
||||
continue
|
||||
for src in _pick_tier(tiers, target):
|
||||
for src in _pick_tier(tiers, target_res):
|
||||
s = src.bounds
|
||||
if s[2] <= min_x or s[0] >= max_x or s[3] <= min_y or s[1] >= max_y:
|
||||
continue
|
||||
out.append(src)
|
||||
out.append(((col, row), src))
|
||||
return out
|
||||
|
||||
|
||||
def _contributing(output_dir, layer, z, x, y, scale):
|
||||
"""Sources intersectant la tuile, palier choisi selon la résolution visée."""
|
||||
return [src for _cell, src in sources_in_bbox(
|
||||
output_dir, layer, tile_bounds_l93(z, x, y), target_resolution(z, y, scale))]
|
||||
|
||||
|
||||
def load_source(src):
|
||||
"""Image décodée d'une source (rapatriée si besoin), ou None si illisible."""
|
||||
if not src.ensure():
|
||||
return None
|
||||
mtime = src.mtime()
|
||||
if mtime is None:
|
||||
return None
|
||||
try:
|
||||
return _open_source(str(src.path), mtime)
|
||||
except Exception as e: # noqa: BLE001 — source illisible : rendu partiel
|
||||
logger.debug(f"Source illisible ({src.path.name}) : {e}")
|
||||
return None
|
||||
|
||||
|
||||
def _paste_source(canvas, src, z, x, y, size, resample):
|
||||
"""Reprojette une source dans la tuile (transformation projective)."""
|
||||
from PIL import Image
|
||||
|
||||
if not src.ensure():
|
||||
return False
|
||||
mtime = src.mtime()
|
||||
if mtime is None:
|
||||
return False
|
||||
try:
|
||||
img = _open_source(str(src.path), mtime)
|
||||
except Exception as e: # noqa: BLE001 — source illisible : tuile partielle
|
||||
logger.debug(f"Source de tuile illisible ({src.path.name}) : {e}")
|
||||
img = load_source(src)
|
||||
if img is None:
|
||||
return False
|
||||
|
||||
w, h = img.size
|
||||
|
||||
Reference in New Issue
Block a user