Below is an overview of Dsubland.pas, a Delphi unit from SWMM 5.2 that implements a SubLandUsesForm dialog. This dialog is used to edit how land uses are distributed within a subcatchment. In SWMM, a subcatchment can be allocated among different land uses (e.g., residential, commercial, industrial) that have distinct buildup/washoff parameters for pollutants. The TSubLandUsesForm allows the user to specify what percentage of the subcatchment’s area each land use occupies.
1. Purpose and Context
SWMM can model nonpoint source pollutant buildup/washoff using land use objects. Each Subcatchment can contain a mix of multiple land uses (for instance, 30% residential, 70% commercial). The TSubLandUsesForm helps the user assign these percentages:
- The user sees a list of land uses (one per row).
- For each land use, the user enters the percent of subcatchment area occupied by that land use.
These allocations can sum to 100%. During simulation, pollutant buildup/washoff rates are scaled by these percentages.
2. Main Form: TSubLandUsesForm
2.1 Visual Components
- PropEdit1 (
TPropEdit
):- A custom property editor placed on
Panel1
. - The editor has two columns:
- Property (the land use name)
- Value (the percent of subcatchment area).
- A custom property editor placed on
- PropList (
TStringList
):- Holds the values (the percentages) for each land use row.
- OKBtn, CancelBtn, HelpBtn:
- Standard form action buttons at the bottom.
2.2 Data Organization
- LanduseCount / PropCount: the number of land uses in the project.
- Each row in PropEdit1 corresponds to one land use.
- The name (land use) is shown in the first column, the user’s input (percentage) in the second column.
- The string list
PropList
holds these percentage values in the same order the land uses appear inProject.Lists[LANDUSE]
.
3. Key Methods and Events
3.1 FormCreate
- Sets up the
PropEdit1
with column headings (“Land Use,” “% of Area”). - Allocates an array of
TPropRecord
(PropRecd
) to match the number of land uses in the project. - For each land use name in
Project.Lists[LANDUSE]
, it sets:PropRecd[i].Name
to the land use name,PropRecd[i].Style := esEdit
,PropRecd[i].Mask := emPosNumber
(ensuring only numeric input for the percent).
3.2 SetData(LandUses)
- Called externally to load an existing distribution of land use areas for a subcatchment.
- Each entry in the
LandUses
string list has the format:landuseName=percentValue
. - For each land use in the entire project, it checks if it appears in
LandUses
. If it does, the matching percentage is appended toPropList
; if not, it appends an empty string (“”).
3.3 GetData(LandUses, Count)
- After the user presses OK, the form calls
GetData
to store the final distribution:- Clears
LandUses
. - Walks through each row in
PropList
. - Converts the string to a float (P).
- If P > 0, it adds
landuseName=P
to theLandUses
list, incrementsCount
.
- Clears
- This results in a list of land uses with nonzero percent allocations.
3.4 OKBtnClick
- The user’s final step.
- Calls:
PropEdit1.IsValid
(ensuring no invalid numeric inputs).ValidateInput
:- Sums all percentages. If they exceed 101%, shows an error (“Percentages exceed 100%.“).
- If OK,
ModalResult := mrOK
.
3.5 ValidateInput
- Gathers each line in
PropList
, parses it as a float, sums the values. - If the sum > 101, returns an error. (The 101% threshold accounts for rounding error in user input.)
4. Usage Example
- A subcatchment has land uses: Residential, Commercial, Open Space.
- The user calls
SetData(LandUses)
whereLandUses
might have lines likeResidential=25
andCommercial=50
for the existing configuration. - The form displays three rows in
PropEdit1
: “Residential,” “Commercial,” “Open Space.” The first two have “25,” “50” and the third is blank. - The user changes values—maybe sets “Residential=30,” “Commercial=50,” “Open Space=20.” The sum is 100%.
- On OK,
GetData(LandUses, Count)
returns these final lines, andCount=3
.
5. Summary
Dsubland.pas provides a simple TSubLandUsesForm dialog to let users specify or edit percentage allocations of land uses within a subcatchment:
- The form displays all land uses in the model (one row each),
- The user enters a percentage for each relevant land use,
- The form ensures the sum does not exceed 101%,
- The final data are stored in a string list for the subcatchment’s land uses.
This helps SWMM track which portion of the subcatchment belongs to which land use categories, crucial for pollutant buildup/washoff modeling.
No comments:
Post a Comment