Skip to content

feat(swat): SWAT+ project model and TxtInOut reader/writer (phase 6a) - #1

Merged
andriyanto merged 1 commit into
mainfrom
feat/swat-txtinout
Oct 28, 2026
Merged

andriyanto merged 1 commit into
mainfrom
feat/swat-txtinout

Conversation

@andriyanto

Copy link
Copy Markdown
Owner

Phase 6a of the SWAT+ editor (design: docs/swat/design.md on swat-plus-design).

  • rustgis-swat-model (L1): a project as its TxtInOut files, kept losslessly: lines, per-line endings (files mixing \r\n and \n keep them), UTF-8 or Latin-1. Edits replace a token and keep the columns aligned (numbers keep their right edge, names their left).
  • rustgis-swat-txtinout (L2): read/write from and to bytes (no file system, so it runs in the browser); cio reads file.cio and lists the inputs it names (with the climate lists' weather files and recall.rec's files) and the missing ones; view gives each file's layout: tables (connections' repeated outflow columns named obj_typ_2…), counted tables, print.prt, and records owning lines (soil layers, plant communities, schedules with their automatic tables and operations, decision tables' conditions and actions, weather generator months, calibration conditions). A view never fails: an unexpected line is Kind::Other.

Written from the format's documentation, not SWAT+'s code (the engine is LGPL; this is Apache-2.0).

Tests: unit tests for round trips and aligned edits; tests/projects.rs reads the private scenarios from SWAT_TESTDATA (skipped in CI): Osu_1hru, Ames_sub1, Batanghari and Pessel all come back byte for byte, and every line of every file is placed (no Other), with checks on the nested layouts.

Next: 6b (runner + swat.run).


Generated by Claude Code

Two new crates for the SWAT+ editor:

- rustgis-swat-model (L1): a SWAT+ project as its TxtInOut text files,
  kept losslessly (lines, per-line endings, UTF-8 or Latin-1), with
  token-level edits that keep columns aligned.
- rustgis-swat-txtinout (L2): files from and to bytes (so it runs in the
  browser), file.cio's index and the input files it names, and each
  file's layout: tables, counted tables, and records owning the lines
  after them (soil layers, plant communities, schedules, decision
  tables, weather generator months, calibration conditions).

Written from the format's documentation, not SWAT+'s code. A test reads
the private test scenarios from SWAT_TESTDATA (skipped without it): all
four (Osu_1hru, Ames_sub1, Batanghari, Pessel) come back byte for byte,
and every line of every file has a place in its view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L94WcvvLDssnAEZihGAwYo
@andriyanto
andriyanto merged commit a38df60 into main Oct 28, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants