""" Build CO1CO01M.000 directly from dimar_ayudas_barranquilla.csv without needing a QGIS project file. """ import sys, json from pathlib import Path # Import S57CellWriter from converter (it's defined there) sys.path.insert(0, str(Path(__file__).parent)) from converter import S57CellWriter # ── paths ───────────────────────────────────────────────────────────────────── HERE = Path(__file__).parent CSV = HERE / "dimar_ayudas_barranquilla.csv" CONFIG = HERE / "cell_config.json" OUTPUT = HERE / "dist" / "CO1CO01M" / "CO1CO01M.000" # ── load config ─────────────────────────────────────────────────────────────── with open(CONFIG, encoding="utf-8") as f: cfg = json.load(f) # Update issue date and ensure correct cell name cfg["cell_name"] = "CO1CO01M" cfg["issue_date"] = "20260430" cfg["update_number"] = 1 # ── build ───────────────────────────────────────────────────────────────────── OUTPUT.parent.mkdir(parents=True, exist_ok=True) attr_map = cfg.get("attribute_mappings", {}) print(f"Input: {CSV}") print(f"Output: {OUTPUT}") print() writer = S57CellWriter(str(OUTPUT), cfg) writer.open() count = writer.add_features_from_csv( CSV, "BOYLAT", # default class (overridden per-row by feat_type column) attr_map, x_field="lon", y_field="lat", ) writer.close() writer.summary() print(f"\n✓ {count} feature(s) written") print(f" {OUTPUT} ({OUTPUT.stat().st_size // 1024} KB)")