street.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //----------------------------------------------------------------------------- | ||
| 2 | // street.c | ||
| 3 | // | ||
| 4 | // Project: EPA SWMM5 | ||
| 5 | // Version: 5.2 | ||
| 6 | // Date: 07/13/23 (Build 5.2.4) | ||
| 7 | // Author: L. Rossman | ||
| 8 | // | ||
| 9 | // Street Cross-Section Functions | ||
| 10 | // | ||
| 11 | // Build 5.2.4: | ||
| 12 | // - Fixed incorrect index used to retrieve street backing parameters | ||
| 13 | // in street_readParams. | ||
| 14 | //----------------------------------------------------------------------------- | ||
| 15 | #define _CRT_SECURE_NO_DEPRECATE | ||
| 16 | |||
| 17 | #include <stdlib.h> | ||
| 18 | #include "headers.h" | ||
| 19 | |||
| 20 | //----------------------------------------------------------------------------- | ||
| 21 | // External functions (declared in street.h) | ||
| 22 | //----------------------------------------------------------------------------- | ||
| 23 | // street_create called by createObjects in project.c | ||
| 24 | // street_delete called by deleteObjects in project.c | ||
| 25 | // street_readParams called by parseLine in input.c | ||
| 26 | |||
| 27 | //============================================================================= | ||
| 28 | |||
| 29 | 58 | int street_create(int nStreets) | |
| 30 | // | ||
| 31 | // Input: nStreets = number of Street objects to create | ||
| 32 | // Output: none | ||
| 33 | // Purpose: creats a collection of Street objects. | ||
| 34 | // | ||
| 35 | { | ||
| 36 | 58 | Street = NULL; | |
| 37 | 58 | Nobjects[STREET] = 0; | |
| 38 | 58 | Street = (TStreet *)calloc(nStreets, sizeof(TStreet)); | |
| 39 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
|
58 | if (Street == NULL) return ERR_MEMORY; |
| 40 | 58 | Nobjects[STREET] = nStreets; | |
| 41 | 58 | return 0; | |
| 42 | } | ||
| 43 | |||
| 44 | //============================================================================= | ||
| 45 | |||
| 46 | 58 | void street_delete() | |
| 47 | // | ||
| 48 | // Input: none | ||
| 49 | // Output: none | ||
| 50 | // Purpose: deletes the collection of Street objects. | ||
| 51 | // | ||
| 52 | { | ||
| 53 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | FREE(Street) |
| 54 | 58 | } | |
| 55 | |||
| 56 | //============================================================================= | ||
| 57 | |||
| 58 | 3 | int street_readParams(char* tok[], int ntoks) | |
| 59 | // | ||
| 60 | // Format is: | ||
| 61 | // ID Tcrown Hcurb Sx nRoad (Hdep Wg Sides Tback Sback nBack) | ||
| 62 | // where | ||
| 63 | // ID = name assigned to street cross section | ||
| 64 | // Tcrown = distance from curb to street crown (ft or m) | ||
| 65 | // Hcurb = curb height (ft or m) | ||
| 66 | // Sx = roadway cross slope (%) | ||
| 67 | // nRoad = roadway Manning's n | ||
| 68 | // Hdep = depressed gutter height (ft or m) | ||
| 69 | // Wg = depressed gutter width (ft or m) | ||
| 70 | // Sides = 1 or 2 sided | ||
| 71 | // Tback = width of street backing (ft or m) | ||
| 72 | // Sback = slope of street backing (ft or m) | ||
| 73 | // nBack = Manning's n of street backing | ||
| 74 | { | ||
| 75 | int i, k, sides; | ||
| 76 | double x[11]; | ||
| 77 | TStreet *street; | ||
| 78 | |||
| 79 | // --- check for minimum number of tokens | ||
| 80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ntoks < 5) return error_setInpError(ERR_ITEMS, ""); |
| 81 | |||
| 82 | // --- check that street exists in project | ||
| 83 | 3 | i = project_findObject(STREET, tok[0]); | |
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (i < 0) return error_setInpError(ERR_NAME, tok[0]); |
| 85 | 3 | Street[i].ID = project_findID(STREET, tok[0]); | |
| 86 | |||
| 87 | // --- parse required data | ||
| 88 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
|
33 | for (k = 0; k <= 9; k++) x[k] = 0.0; |
| 89 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
|
15 | for (k = 1; k <= 4; k++) |
| 90 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
|
12 | if (!getDouble(tok[k], &x[k]) || x[k] <= 0.0) |
| 91 | ✗ | return error_setInpError(ERR_NUMBER, tok[k]); | |
| 92 | |||
| 93 | // --- read gutter depression | ||
| 94 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ntoks > 5) |
| 95 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (!getDouble(tok[5], &x[5]) || x[5] < 0.0) |
| 96 | ✗ | return error_setInpError(ERR_NUMBER, tok[5]); | |
| 97 | |||
| 98 | // --- read gutter width | ||
| 99 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ntoks > 6) |
| 100 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (!getDouble(tok[6], &x[6]) || x[6] < 0.0) |
| 101 | ✗ | return error_setInpError(ERR_NUMBER, tok[6]); | |
| 102 | |||
| 103 | // --- read if 1- or 2-sided | ||
| 104 | 3 | sides = 2; | |
| 105 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ntoks > 7) |
| 106 |
3/6✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
|
3 | if (!getInt(tok[7], &sides) || sides < 1 || sides > 2) |
| 107 | ✗ | return error_setInpError(ERR_NUMBER, tok[7]); | |
| 108 | |||
| 109 | // --- read street backing parameters | ||
| 110 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ntoks > 8) |
| 111 | { | ||
| 112 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (!getDouble(tok[8], &x[8]) || x[8] < 0.0) |
| 113 | ✗ | return error_setInpError(ERR_NUMBER, tok[8]); | |
| 114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (x[8] > 0.0) |
| 115 | { | ||
| 116 | ✗ | if (ntoks < 11) return error_setInpError(ERR_ITEMS, ""); | |
| 117 | ✗ | for (k = 9; k <= 10; k++) | |
| 118 | ✗ | if (!getDouble(tok[k], &x[k]) || x[k] <= 0.0) | |
| 119 | ✗ | return error_setInpError(ERR_NUMBER, tok[k]); | |
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | // --- assign input values to street object | ||
| 124 | 3 | street = &Street[i]; | |
| 125 | 3 | street->width = x[1] / UCF(LENGTH); | |
| 126 | 3 | street->curbHeight = x[2] / UCF(LENGTH); | |
| 127 | 3 | street->slope = x[3] / 100.0; | |
| 128 | 3 | street->roughness = x[4]; | |
| 129 | 3 | street->gutterDepression = x[5] / UCF(LENGTH); | |
| 130 | 3 | street->gutterWidth = x[6] / UCF(LENGTH); | |
| 131 | 3 | street->sides = sides; | |
| 132 | 3 | street->backWidth = x[8] / UCF(LENGTH); | |
| 133 | 3 | street->backSlope = x[9] / 100.0; | |
| 134 | 3 | street->backRoughness = x[10]; | |
| 135 | 3 | transect_createStreetTransect(street); | |
| 136 | 3 | return 0; | |
| 137 | } | ||
| 138 | |||
| 139 | //============================================================================= | ||
| 140 | |||
| 141 | 10964 | double street_getExtentFilled(int link) | |
| 142 | // | ||
| 143 | // Input: link = a link index | ||
| 144 | // Output: degree to which street is filled | ||
| 145 | // Purpose: finds the degree to which a street link is filled based on the | ||
| 146 | // depth (for DW routing) or cross section area at the higher end. | ||
| 147 | // | ||
| 148 | { | ||
| 149 | int k, t; | ||
| 150 | double filled; | ||
| 151 | |||
| 152 | 10964 | t = Link[link].xsect.transect; | |
| 153 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10964 times.
|
10964 | if (t < 0) return 0.0; |
| 154 |
1/2✓ Branch 0 taken 10964 times.
✗ Branch 1 not taken.
|
10964 | if (RouteModel == DW) |
| 155 | { | ||
| 156 |
2/2✓ Branch 0 taken 850 times.
✓ Branch 1 taken 10114 times.
|
10964 | filled = MAX(Node[Link[link].node1].newDepth, |
| 157 | Node[Link[link].node2].newDepth); | ||
| 158 | } | ||
| 159 | else | ||
| 160 | { | ||
| 161 | ✗ | k = Link[link].subIndex; | |
| 162 | ✗ | filled = MAX(Conduit[k].a1, Conduit[k].a2); | |
| 163 | } | ||
| 164 | 10964 | return filled; | |
| 165 | } | ||
| 166 |