Initial commit — QGIS S-57 Converter

This commit is contained in:
2026-05-04 23:03:19 -04:00
commit eb12a58cb7
41 changed files with 8896 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
"""
PoC: produce a minimal valid S-57 .000 for the Wabasso test area and verify it
opens cleanly with fiona (i.e., GDAL's S-57 driver).
Expected result: fiona.listlayers() shows M_COVR + BOYLAT (and no warnings about
broken bounds), and bounds match the envelope we encoded.
"""
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).parent))
from s57_writer import (
S57Cell, OBJL_M_COVR, OBJL_BOYLAT,
ATTL_CATCOV, ATTL_CATLAM,
)
# Wabasso area envelope (lon, lat):
W, S, E, N = -80.4588, 27.7519, -80.4574, 27.7609
OUTPUT = Path(__file__).parent / "test_wabasso.000"
cell = S57Cell(
dsnm="TESTPOC.000",
edition=1,
intu=5, # Harbour
scale=10000,
agen=999,
comt="QGISS57Converter PoC",
issue_date="20260428",
)
# 1) Mandatory M_COVR feature: rectangular envelope, CATCOV=1 (data covered)
cell.add_area_feature(
objl=OBJL_M_COVR,
ring=[(W, S), (E, S), (E, N), (W, N), (W, S)],
attrs=[(ATTL_CATCOV, "1")], # CATCOV=1 (coverage present)
)
# 2) One BOYLAT (lateral buoy, port hand IALA-B = CATLAM=1) at the centre
cx = (W + E) / 2
cy = (S + N) / 2
cell.add_point_feature(
objl=OBJL_BOYLAT,
lon=cx, lat=cy,
attrs=[(ATTL_CATLAM, "1")], # CATLAM=1 (port-hand lateral mark)
)
cell.write(OUTPUT)
print(f"Wrote {OUTPUT} ({OUTPUT.stat().st_size} bytes)")
# ── Verify with fiona ────────────────────────────────────────────────────────
print()
print("Verifying with fiona...")
try:
import fiona
layers = fiona.listlayers(str(OUTPUT))
print(f" fiona.listlayers: {layers}")
for L in layers:
try:
with fiona.open(str(OUTPUT), layer=L) as src:
print(f" {L:10s} bounds={src.bounds} features={len(src)}")
except Exception as e:
print(f" {L}: open ERROR: {e}")
except Exception as e:
print(f" fiona import or listlayers failed: {e}")