Isoxml Processor Hardening

Task Details
← Task Board

Task Description

# TASK: ISOXML Processor Hardening — Moderate & Minor Fixes

**Priority:** HIGH
**Agent:** engineer
**Filed:** 2026-02-16
**Filed by:** Claude Code session (processor audit)

---

## Goal

Harden the ISOXML processor (`ISOBUS11783/tools/isoxml_processor.py`) for reliable batch processing. The critical crash bugs (BadZipFile, RuntimeError on no BIN/no points, unprotected zf.read) have already been fixed. This task covers moderate and minor issues.

## ALREADY FIXED (do not redo)
- BadZipFile protection around `zipfile.ZipFile()`
- `raise RuntimeError("No .BIN files")` → returns error dict
- `raise RuntimeError("No coverage points")` → returns error dict
- All `zf.read(bn)` calls wrapped in try-except with continue
- MemoryError guard on pd.concat
- main() checks for error return

## Moderate Issues to Fix

### 1. Bare `except: pass` clauses hiding errors
Lines: ~312, ~558, ~677, ~912, ~1239, ~1347
These silently swallow errors. Change to `except Exception as e: logging.warning(...)` so we at least log what went wrong.

### 2. `_guess_implement_width_m()` default fallback
If width detection fails entirely, it may return 0 or None which breaks swath creation. Ensure a safe default (e.g., 12.0m = ~40ft which covers most planters/drills).

### 3. Product detection edge cases
The `_build_products()` function should handle missing ProductGroup elements gracefully. Some ISOXML files from non-Topcon sources may have different XML structure.

### 4. Timestamp parsing in BIN files
Topcon TLG timestamps can have year=0 or obviously invalid dates. Add a sanity check (2000-2099 range).

### 5. CRS handling
Ensure all GeoDataFrames use EPSG:4326 consistently. Some boundary imports may have different CRS that causes silent mismatches.

## Minor Issues

### 6. Logging verbosity in batch mode
When processing 100+ ZIPs, individual BIN file logs are excessive. Add a summary mode: "Processed ZIP: X points from Y/Z BIN files" instead of per-file logging.

### 7. Output directory creation
`os.makedirs(out_dir, exist_ok=True)` is only called after all processing. If processing fails early, the directory doesn't exist for error logs.

### 8. Temp file cleanup
The processor creates intermediate GeoPackage layers that may not be cleaned up on error. Add a finally block.

## DO NOT
- Do NOT modify the core parsing algorithms (parse_topcon_tlg_structured, parse_tlg_bin_bounded, etc.)
- Do NOT change the output format or file structure
- Do NOT modify the critical fixes already applied (error returns, try-except around zf.read)
- Do NOT add new features — this is hardening only

Job Queue (0)

No job queue entries for this task yet