MEGAINFRA-WEBAPP/scripts/site-model
2026-10-14 07:06:13 +02:00
..
alignment.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
dxf_reader.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
extract_bushveld.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
extract_extras.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
extract_surface.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
extract_xs.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
model_keys.py feat(site-map): model upload script with progress-key parity 2026-10-14 07:06:13 +02:00
README.md feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
test_alignment.py feat(site-map): model pipeline with 20 m chainage sections 2026-10-14 07:04:34 +02:00
test_model_keys.py feat(site-map): model upload script with progress-key parity 2026-10-14 07:06:13 +02:00
test_upload.py feat(site-map): model upload script with progress-key parity 2026-10-14 07:06:13 +02:00
upload.py feat(site-map): model upload script with progress-key parity 2026-10-14 07:06:13 +02:00

Site model pipeline (Phase 1, run by hand)

Turns a consultant's drawings into the five JSON files the Site map page loads (bushveld.json, services.json, earthworks.json, schedules.json, surface.json). Specific to Civil Concepts' layer names on Bushveld Joy Road (C3092); other drawing sets need the layer maps at the top of each script adjusted.

Tools

  • LibreDWG (brew install libredwg) → dwg2dxf
  • poppler (brew install poppler) → pdftotext, pdftocairo
  • Python 3 with numpy

Build (Bushveld Joy example)

  1. Convert DWGs: dwg2dxf -y -o out.dxf in.dwg (road layout M910-001, signs & markings M910-002, studs M910-005, stormwater LS M921-001).
  2. Run in this order, all writing into one output folder OUT:
    python3 -I extract_bushveld.py <road-layout.dxf> "<SO DATA folder>" OUT/bushveld.json
    python3 -I extract_extras.py <drawings folder> <converted DXF folder> OUT
    python3 -I extract_surface.py <road-layout.dxf> OUT
    python3 -I extract_xs.py <cross-section.pdf> <road-layout.dxf> OUT
    
    (extract_xs.py validates against surface.json, so run it last.)
  3. Upload: python3 upload.py --site <site id> --label "<text>" [--dry-run] OUT.

Checks printed by the scripts

  • extract_bushveld: areas per work type and the 20 m chainage sections.
  • extract_surface: contour-only surface vs peg levels (median / 90th percentile).
  • extract_xs: rebuilt alignment length vs the drawing (674.412 m for Bushveld Joy) and cross-section vs design-surface agreement.
  • upload: progress keys recorded on the site that the new model no longer has.

Tests

python3 -m unittest discover -s scripts/site-model -p "test_*.py"