Below is an overview of Dlanduse.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TLanduseForm) for creating or editing Land Use objects. A land use can have:
- General Properties (e.g., name, street sweeping interval)
- Buildup properties (how pollutants accumulate)
- Washoff properties (how pollutants wash off with runoff)
1. Purpose and Context
In SWMM, Land Use objects define how pollutants build up over time and wash off during a rainfall event. This helps simulate nonpoint source pollution loading in subcatchments. The TLanduseForm allows users to specify:
- General: Land use name, description, street sweeping data.
- Buildup: How pollutants accumulate on the land surface over time.
- Washoff: How pollutants are washed off by runoff or how an Event Mean Concentration (EMC) is defined.
2. Key Form Elements
2.1 Controls
- TabControl1: Has three tabs:
- General (land use name, description, street cleaning)
- Buildup (power, exponential, saturation, or external time series)
- Washoff (exponential, rating curve, or EMC)
- TPropEdit (
PropEditor
) on each tab to edit properties in a name/value table. BuildupGrid
&WashoffGrid
: Hidden string grids that store pollutant-specific data for Buildup/Washoff.PollutCombo
: Drop-down list of pollutants for the Buildup and Washoff tabs.GeneralProps
: ATStringlist
that holds the general land use properties.OKBtn
,CancelBtn
,HelpBtn
: Standard dialog buttons.
2.2 Property Records
Three sets of TPropRecord arrays define how each tab's properties appear in the PropEditor
:
- DefGeneralProps (name, description, street sweeping).
- DefBuildupProps1 and DefBuildupProps2 (for different buildup “Function” types; EXT has different fields).
- DefWashoffProps (exponential, rating curve, EMC).
These records specify each property’s display label, editing style (e.g., esEdit
, esComboList
, esButton
), valid input mask (e.g., numeric only), and other characteristics.
3. Data Structures in SWMM
3.1 TLanduse
- Holds an array (
Data[]
) for general properties such as:Data[COMMENT_INDEX]
= DescriptionData[LANDUSE_CLEANING_INDEX]
= Street sweeping intervalData[LANDUSE_AVAILABLE_INDEX]
= Fraction of buildup available for sweepingData[LANDUSE_LASTCLEAN_INDEX]
= Days since last sweeping
- Contains a list of TNonpointSource objects (one per pollutant), each with:
BuildupData[]
(array of up to five strings).WashoffData[]
(another array of up to five strings).
3.2 TNonpointSource
- Manages buildup/washoff properties for one pollutant under a land use.
- Buildup properties: function type, coefficients, normalizer, etc.
- Washoff properties: function type, coefficients, exponent, BMP efficiency, etc.
4. Workflow and Event Handling
4.1 FormCreate
- Creates a string list (
GeneralProps
) for general properties. - Instantiates the
PropEditor
, setting column titles, read-only color, event handlers (OnButtonClick
,OnValidate
,OnRowSelect
), etc.
4.2 SetData(I: Integer)
Called to load an existing land use (index I
) or start a new one:
- GeneralProps receives default or existing values:
- Name, Description, Sweeping Interval, etc.
- BuildupGrid / WashoffGrid are sized to have one row per pollutant. Each row stores the buildup/washoff parameters for that pollutant.
- If
I >= 0
, it reads the existing land use objectProject.Lists[LANDUSE].Objects[I]
:- Copies general properties into
GeneralProps
. - Reads each pollutant’s TNonpointSource into BuildupGrid and WashoffGrid rows.
- Copies general properties into
4.3 TabControl1Change
When the user switches tabs:
- Tab 0 (General): Display
DefGeneralProps
inPropEditor
, with data fromGeneralProps
. - Tab 1 (Buildup) or Tab 2 (Washoff): Show
PollutCombo
(if there are pollutants).- If the tab is Buildup, then either use
BuildupProps1
orBuildupProps2
depending on whether the selected function is EXT. The data come from the current row of BuildupGrid (matching the selected pollutant). - If the tab is Washoff, display
DefWashoffProps
, with data from WashoffGrid.
- If the tab is Buildup, then either use
4.4 PollutComboClick
- The user changes the active pollutant in
PollutCombo
. - The form loads that pollutant’s buildup or washoff row in
PropEditor
. - This allows switching between pollutants’ parameters without leaving the tab.
4.5 OKBtnClick
- Validates the land use name to ensure it isn’t blank or duplicated.
- If valid, calls
GetData
to write the edited properties back to the SWMM data structures. - Closes the form with
ModalResult := mrOK
.
4.6 GetData(I: Integer)
- Retrieves name, description, street sweeping info from
GeneralProps
. - Either updates an existing TLanduse or creates a new one if
I < 0
. - Clears any existing NonpointSource objects on that TLanduse, then for each pollutant row in BuildupGrid / WashoffGrid:
- Creates a new TNonpointSource with those properties.
- Adds it to the land use’s list of nonpoint sources.
4.7 Other Events
- OnValidate (
ValidateData
) triggers whenever a user changes a property value inPropEditor
. It setsHasChanged := True
and checks if the user changed the Buildup “Function” to or from “EXT,” then reloads the correct property set. - OnButtonClick (
EditComment
): opens a text editor dialog for the land use “Description” property (the second field inGeneralProps
).
5. Summary of Operation
- Initialization: The form is created, and
SetData
is called with the index of a land use in the project (or -1 if new). - Editing: The user picks among tabs:
- General: Edits name, description, sweeping parameters.
- Buildup: Switches pollutants in
PollutCombo
, edits buildup parameters inPropEditor
. - Washoff: Similarly, edits washoff properties per pollutant.
- Validation and Save: On OK, the code checks for a valid (non-duplicate) name, then calls
GetData
to write changes back to the SWMM project data structures. - Result: The project now has updated land use definitions that specify how each pollutant accumulates and washes off for each land use category.
By splitting parameters into General, Buildup, and Washoff tabs, Dlanduse.pas provides a clear, tab-based editor for land use configurations—integral to modeling stormwater quality in SWMM.
No comments:
Post a Comment