@adatechnology/game-urban 0.3.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -1
- package/dist/index.d.ts +5 -998
- package/dist/index.global.js +365 -151
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +92 -18
- package/dist/index.js.map +1 -1
- package/dist/networks/index.d.ts +647 -0
- package/dist/networks/index.js +2070 -0
- package/dist/networks/index.js.map +1 -0
- package/dist/types-mY6VwZgN.d.ts +1087 -0
- package/package.json +11 -7
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
import { DeepPartial, UtilityNetwork, UtilityConnection } from '@adatechnology/game-contracts';
|
|
2
|
+
import { ap as PoleSlots, ao as PoleSlotBand, m as PoleDef, am as PlanRect, C as CityPlanInput, Q as DistributionSpec, a7 as LampState, a5 as LampShares } from '../types-mY6VwZgN.js';
|
|
3
|
+
export { O as DistributionPoleDef } from '../types-mY6VwZgN.js';
|
|
4
|
+
import '@adatechnology/game-floorplan';
|
|
5
|
+
|
|
6
|
+
/** Where a lot takes each network when it declares none (a building of `fillBlock`, a lot whose house has no utilities yet), metres. */
|
|
7
|
+
type DefaultConnectionRules = {
|
|
8
|
+
/** The meter post, the water stand and the sewer box stand this far inside the lot's front. */
|
|
9
|
+
readonly frontInset: number;
|
|
10
|
+
/** The inspection box stands this far inside the lot's front. */
|
|
11
|
+
readonly sewerInset: number;
|
|
12
|
+
/** From the lot's side boundary to the meter post (power and telecom), and to the water stand. */
|
|
13
|
+
readonly meterFromSide: number;
|
|
14
|
+
readonly waterFromSide: number;
|
|
15
|
+
/** The downspout outlet at the kerb this far from the lot's other side boundary. */
|
|
16
|
+
readonly downspoutFromSide: number;
|
|
17
|
+
/** Anchor of the service drop on the meter post over the ground, and of the telecom drop under it. */
|
|
18
|
+
readonly powerHeight: number;
|
|
19
|
+
readonly telecomBelowPower: number;
|
|
20
|
+
/** Invert of the inspection box outlet under the ground; a lot set back from its street gets a shallower one, never under the least. */
|
|
21
|
+
readonly sewerDepth: number;
|
|
22
|
+
readonly sewerLeastDepth: number;
|
|
23
|
+
};
|
|
24
|
+
/** How the generator lays the networks out: the numbers of a street, not checked by the validator but by the generator's own tests. */
|
|
25
|
+
type NetworkLayoutRules = {
|
|
26
|
+
/** Width of the sidewalk on each side of a street. */
|
|
27
|
+
readonly sidewalk: number;
|
|
28
|
+
/** A run end this close to the map border is where the line leaves the map (a feed, a reservoir). */
|
|
29
|
+
readonly edgeReach: number;
|
|
30
|
+
readonly poles: {
|
|
31
|
+
/** Least and longest span between two poles. */
|
|
32
|
+
readonly spacing: readonly [number, number];
|
|
33
|
+
/** The pole's axis from the kerb, on the service strip; the corner pole as far from the cross street's kerb. */
|
|
34
|
+
readonly curbSetback: number;
|
|
35
|
+
/** An end-of-line pole this far inside the end of its run. */
|
|
36
|
+
readonly endInset: number;
|
|
37
|
+
/** No two poles closer than this (a pole added to reach a lot keeps it). */
|
|
38
|
+
readonly minGap: number;
|
|
39
|
+
/** An intermediate pole at least this far from the edge of a cross street's roadway. */
|
|
40
|
+
readonly crossingClearance: number;
|
|
41
|
+
/** A pole looks this far either way (in steps) for a lot boundary near its target, and slides as far to clear a gate. */
|
|
42
|
+
readonly snap: number;
|
|
43
|
+
readonly slide: number;
|
|
44
|
+
readonly slideStep: number;
|
|
45
|
+
};
|
|
46
|
+
/** Sag at mid span of each class, metres. */
|
|
47
|
+
readonly sag: {
|
|
48
|
+
readonly mv: number;
|
|
49
|
+
readonly lv: number;
|
|
50
|
+
readonly telecom: number;
|
|
51
|
+
readonly drop: number;
|
|
52
|
+
readonly telecomDrop: number;
|
|
53
|
+
};
|
|
54
|
+
readonly telecom: {
|
|
55
|
+
/** A splice box with its reserve coil every this many spans. */
|
|
56
|
+
readonly spliceEvery: number;
|
|
57
|
+
/** Gap between two cables of a bundle, from the top of the band down. */
|
|
58
|
+
readonly cableGap: number;
|
|
59
|
+
/** Cables of a bundle, least and most, in a clean district and in the periphery. */
|
|
60
|
+
readonly cables: {
|
|
61
|
+
readonly clean: readonly [number, number];
|
|
62
|
+
readonly periphery: readonly [number, number];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/** The periphery: district kinds with telecom bundles and a few illegal hookups (a drop with no meter, counted in its transformer's load). */
|
|
66
|
+
readonly periphery: {
|
|
67
|
+
readonly kinds: readonly string[];
|
|
68
|
+
readonly hookupShare: number;
|
|
69
|
+
};
|
|
70
|
+
/** Added to every least slope and least cover the generator lays, so a pipe never sits on the limit. */
|
|
71
|
+
readonly slopeMargin: number;
|
|
72
|
+
readonly coverMargin: number;
|
|
73
|
+
readonly sewer: {
|
|
74
|
+
readonly mainDiameter: number;
|
|
75
|
+
readonly lateralDiameter: number;
|
|
76
|
+
/** The lateral drops into the main from a cleanout this far from the street's axis. */
|
|
77
|
+
readonly dropOffset: number;
|
|
78
|
+
/** The interceptor runs along the river this far from its bank. */
|
|
79
|
+
readonly interceptorOffset: number;
|
|
80
|
+
};
|
|
81
|
+
readonly storm: {
|
|
82
|
+
/** The gallery runs this far from the street's axis, on the side of the poles. */
|
|
83
|
+
readonly galleryOffset: number;
|
|
84
|
+
readonly galleryDiameter: number;
|
|
85
|
+
readonly lateralDiameter: number;
|
|
86
|
+
/** Longest gap between two inlets along a kerb; one at each corner. */
|
|
87
|
+
readonly inletSpacing: number;
|
|
88
|
+
/** An inlet's grate this far from the kerb into the road, and the corner inlet this far from the end of its kerb. */
|
|
89
|
+
readonly inletSetback: number;
|
|
90
|
+
readonly inletFromCorner: number;
|
|
91
|
+
/** Level of the river's water: an outfall's bottom stays above it. */
|
|
92
|
+
readonly riverLevel: number;
|
|
93
|
+
};
|
|
94
|
+
readonly water: {
|
|
95
|
+
readonly mainDiameter: number;
|
|
96
|
+
readonly serviceDiameter: number;
|
|
97
|
+
/** The main runs under the sidewalk opposite the poles, this share of its width out from the kerb. */
|
|
98
|
+
readonly sidewalkShare: number;
|
|
99
|
+
/** A hydrant stands this far from the valve of a crossing, toward the kerb. */
|
|
100
|
+
readonly hydrantOffset: number;
|
|
101
|
+
};
|
|
102
|
+
readonly connection: DefaultConnectionRules;
|
|
103
|
+
};
|
|
104
|
+
/** The defaults of a Brazilian street: 30 to 40 m spans, MV bare on the crossarm, LV multiplexed, sewer to an interceptor along the river. */
|
|
105
|
+
declare const DEFAULT_NETWORK_LAYOUT: NetworkLayoutRules;
|
|
106
|
+
|
|
107
|
+
/** Lowest point of a conductor over each surface, metres; `null` = the class does not go there. */
|
|
108
|
+
type ClearanceRow = Readonly<Record<NetworkSurface, number | null>>;
|
|
109
|
+
/** A band of the diversified demand table: up to `consumers` consumers, kVA per consumer at or below the split and above it. */
|
|
110
|
+
type DiversityBand = {
|
|
111
|
+
readonly consumers: number;
|
|
112
|
+
readonly low: number;
|
|
113
|
+
readonly high: number;
|
|
114
|
+
};
|
|
115
|
+
type TransformerRating = {
|
|
116
|
+
readonly id: string;
|
|
117
|
+
readonly kva: number;
|
|
118
|
+
};
|
|
119
|
+
type PowerRules = {
|
|
120
|
+
/** Longest service drop, metres (horizontal). */
|
|
121
|
+
readonly dropMaxLength: number;
|
|
122
|
+
/** A drop that crosses the street goes straight across: its horizontal direction at most this far from the street's normal, degrees. */
|
|
123
|
+
readonly dropMaxSkew: number;
|
|
124
|
+
/** A drop on the pole's own side comes from a pole in front of the lot: its station at most this far past the lot's frontage, metres. */
|
|
125
|
+
readonly dropFrontageSlack: number;
|
|
126
|
+
/** Most service drops one pole holds. */
|
|
127
|
+
readonly dropsPerPole: number;
|
|
128
|
+
/** Longest low voltage path from the transformer to its farthest node, each way, metres. */
|
|
129
|
+
readonly lvCircuitMaxLength: number;
|
|
130
|
+
/** Highest demand over the rating. */
|
|
131
|
+
readonly maxLoading: number;
|
|
132
|
+
readonly transformers: readonly TransformerRating[];
|
|
133
|
+
/** Installed load (kVA) that splits the `low` and `high` columns of the demand table. */
|
|
134
|
+
readonly installedSplitKva: number;
|
|
135
|
+
/** By number of consumers, ascending; the last band takes any number above. */
|
|
136
|
+
readonly diversity: readonly DiversityBand[];
|
|
137
|
+
};
|
|
138
|
+
/** Cover of a pipe: from the ground down to its top, metres. */
|
|
139
|
+
type CoverRange = {
|
|
140
|
+
readonly min: number;
|
|
141
|
+
readonly max?: number;
|
|
142
|
+
};
|
|
143
|
+
type NetworkRules = {
|
|
144
|
+
readonly clearance: Readonly<Record<AerialClass, ClearanceRow>>;
|
|
145
|
+
/** Samples along a span when the catenary is checked. */
|
|
146
|
+
readonly catenarySamples: number;
|
|
147
|
+
readonly power: PowerRules;
|
|
148
|
+
readonly lighting: {
|
|
149
|
+
readonly lampKva: number;
|
|
150
|
+
};
|
|
151
|
+
readonly telecom: {
|
|
152
|
+
readonly dropMaxLength: number;
|
|
153
|
+
};
|
|
154
|
+
/** Least slope of each gravity pipe, m/m. */
|
|
155
|
+
readonly minSlope: Readonly<Record<Extract<BuriedEdgeKind, 'sewer_main' | 'sewer_lateral' | 'storm_gallery' | 'storm_lateral' | 'storm_gutter'>, number>>;
|
|
156
|
+
readonly cover: Readonly<Record<BuriedEdgeKind, CoverRange>>;
|
|
157
|
+
readonly sewer: {
|
|
158
|
+
/** Deepest invert below the ground before a pumping station is needed. */
|
|
159
|
+
readonly maxDepth: number;
|
|
160
|
+
/** Cover of a sewer main under a street with a storm gallery (the main passes under the gallery's laterals). */
|
|
161
|
+
readonly coverUnderGallery: number;
|
|
162
|
+
/** A storm gallery this close to a sewer main, metres in plan, puts the main under that street's rule. */
|
|
163
|
+
readonly galleryReach: number;
|
|
164
|
+
/** Deepest bottom of a sewer lateral where it crosses a storm gallery (it goes over it). */
|
|
165
|
+
readonly lateralOverGallery: number;
|
|
166
|
+
/** Longest sewer main between two manholes. */
|
|
167
|
+
readonly manholeSpacing: number;
|
|
168
|
+
};
|
|
169
|
+
/** Least vertical gap between two pipes that cross, and which one goes above (lower rank above). */
|
|
170
|
+
readonly crossing: {
|
|
171
|
+
readonly separation: number;
|
|
172
|
+
readonly rank: Readonly<Record<BuriedEdgeKind, number>>;
|
|
173
|
+
};
|
|
174
|
+
/** How far a connection node may sit from the point the lot declared, metres. */
|
|
175
|
+
readonly connectionTolerance: number;
|
|
176
|
+
/** What `generateNetworks` lays out: spacing, offsets, sags, diameters (the validator reads none of it). */
|
|
177
|
+
readonly layout: NetworkLayoutRules;
|
|
178
|
+
};
|
|
179
|
+
/** Brazilian practice (NBR 15688, NBR 9649, NBR 12218 and the utilities' sharing rules), with no brand. Every number is patched by `resolveNetworkRules`. */
|
|
180
|
+
declare const DEFAULT_NETWORK_RULES: NetworkRules;
|
|
181
|
+
/** The default rules with a game's numbers over them (objects merge, arrays such as the transformers replace). */
|
|
182
|
+
declare function resolveNetworkRules(patch?: DeepPartial<NetworkRules>): NetworkRules;
|
|
183
|
+
/**
|
|
184
|
+
* kVA of the circuit's consumers by the diversified demand table: the band of their count, the column of each one's installed load. A
|
|
185
|
+
* consumer whose load is not known (a connection without `installedKva`, a lot linked without a meter) counts in the `low` column.
|
|
186
|
+
*/
|
|
187
|
+
declare function diversifiedDemand(installedKva: readonly number[], rules: PowerRules): number;
|
|
188
|
+
/** The smallest rating whose loading stays within `maxLoading` for this demand, or none. */
|
|
189
|
+
declare function pickTransformer(demandKva: number, rules: PowerRules): TransformerRating | undefined;
|
|
190
|
+
|
|
191
|
+
/** The networks of a street. `power_lv` is the low voltage the houses take; `lighting` is the street lights fed by it. */
|
|
192
|
+
type NetworkKind = 'power_mv' | 'power_lv' | 'lighting' | 'telecom' | 'sewer' | 'storm' | 'water';
|
|
193
|
+
type NetworkNodeKind = 'feed' | 'pole' | 'transformer' | 'light' | 'splice' | 'manhole' | 'cleanout' | 'inlet' | 'outfall' | 'valve' | 'hydrant' | 'reservoir' | 'treatment' | 'pumping_station' | 'connection';
|
|
194
|
+
/** A point of a network, in world metres. */
|
|
195
|
+
type NetworkNode = {
|
|
196
|
+
/** Stable: 'pole:main_street:07', 'pv:main_street:03', 'lot:street_south_3:sewer'. */
|
|
197
|
+
readonly id: string;
|
|
198
|
+
readonly kind: NetworkNodeKind;
|
|
199
|
+
/** `y` is the fixing height of an aerial point, or the level of the cover of a buried one (the ground there). */
|
|
200
|
+
readonly at: readonly [number, number, number];
|
|
201
|
+
/** Buried: the level of the bottom of the pipe at this node. */
|
|
202
|
+
readonly invert?: number;
|
|
203
|
+
readonly carries: readonly NetworkKind[];
|
|
204
|
+
/** Id in a registry: the pole `concrete_distribution`, the transformer `t45`, the cover `pv_600`. */
|
|
205
|
+
readonly spec?: string;
|
|
206
|
+
/** A connection node: the lot it serves. */
|
|
207
|
+
readonly lot?: string;
|
|
208
|
+
/** A guy wire holds the pole (corner and end of line). */
|
|
209
|
+
readonly guyed?: boolean;
|
|
210
|
+
};
|
|
211
|
+
type NetworkEdgeKind = 'mv_span' | 'lv_span' | 'telecom_span' | 'service_drop' | 'telecom_drop' | 'light_feed' | 'sewer_main' | 'sewer_lateral' | 'storm_gallery' | 'storm_lateral' | 'storm_gutter' | 'water_main' | 'water_service';
|
|
212
|
+
/** An aerial edge: a span between poles or a drop to a lot. */
|
|
213
|
+
type AerialEdgeKind = 'mv_span' | 'lv_span' | 'telecom_span' | 'service_drop' | 'telecom_drop' | 'light_feed';
|
|
214
|
+
/** A buried edge: a pipe. */
|
|
215
|
+
type BuriedEdgeKind = Exclude<NetworkEdgeKind, AerialEdgeKind>;
|
|
216
|
+
/**
|
|
217
|
+
* The class a rule reads an edge by: the clearance of a conductor, the slope and cover of a pipe. A service drop has the clearance of the
|
|
218
|
+
* low voltage, a light feed is the short link from the pole to its lamp.
|
|
219
|
+
*/
|
|
220
|
+
type NetworkClass = 'power_mv' | 'power_lv' | 'street_light' | 'service_drop' | 'telecom' | 'sewer' | 'storm' | 'water';
|
|
221
|
+
/** The classes of the conductors in the air. */
|
|
222
|
+
type AerialClass = Extract<NetworkClass, 'power_mv' | 'power_lv' | 'street_light' | 'service_drop' | 'telecom'>;
|
|
223
|
+
/** A link between two nodes, in the direction of the flow: from the source to the load, and from the house to the destination. */
|
|
224
|
+
type NetworkEdge = {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
readonly kind: NetworkEdgeKind;
|
|
227
|
+
readonly from: string;
|
|
228
|
+
readonly to: string;
|
|
229
|
+
/** Buried: metres. */
|
|
230
|
+
readonly diameter?: number;
|
|
231
|
+
/** Gravity networks: m/m, positive along the flow. When the inverts are known the validator reads the slope from them. */
|
|
232
|
+
readonly slope?: number;
|
|
233
|
+
/** Aerial: metres of sag at mid span. */
|
|
234
|
+
readonly sag?: number;
|
|
235
|
+
/** 3 phases of medium voltage, 4 of low voltage, 1..n telecom cables. */
|
|
236
|
+
readonly conductors?: number;
|
|
237
|
+
/** Aerial: the fixing heights at `from` and `to` when they are not the nodes' own (a pole carries each network at its own band). */
|
|
238
|
+
readonly heights?: readonly [number, number];
|
|
239
|
+
/** Buried: the inverts at `from` and `to` when they are not the nodes' own (a lateral entering a main from above). */
|
|
240
|
+
readonly inverts?: readonly [number, number];
|
|
241
|
+
};
|
|
242
|
+
/** The networks of a district, as data. */
|
|
243
|
+
type UtilityNetworks = {
|
|
244
|
+
readonly nodes: readonly NetworkNode[];
|
|
245
|
+
readonly edges: readonly NetworkEdge[];
|
|
246
|
+
readonly seed: number;
|
|
247
|
+
readonly rules: NetworkRules;
|
|
248
|
+
};
|
|
249
|
+
/** What lies under a point of an aerial span, for the clearance table. */
|
|
250
|
+
type NetworkSurface = 'road' | 'sidewalk' | 'lot';
|
|
251
|
+
/** A building a span must not cross, by its plan outline (world x, z) and height. */
|
|
252
|
+
type NetworkBuilding = {
|
|
253
|
+
readonly id: string;
|
|
254
|
+
/** The lot it stands on: a drop to a connection of the same lot may end over it. */
|
|
255
|
+
readonly lot?: string;
|
|
256
|
+
readonly outline: readonly (readonly [number, number])[];
|
|
257
|
+
readonly height: number;
|
|
258
|
+
};
|
|
259
|
+
/** A tree crown a span must not go through: a vertical cylinder from `bottom` to `top`. */
|
|
260
|
+
type NetworkCrown = {
|
|
261
|
+
readonly x: number;
|
|
262
|
+
readonly z: number;
|
|
263
|
+
readonly radius: number;
|
|
264
|
+
readonly bottom: number;
|
|
265
|
+
readonly top: number;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/** The network each edge belongs to. A service drop is low voltage: a lot is never linked to the medium voltage. */
|
|
269
|
+
declare const EDGE_NETWORK: Readonly<Record<NetworkEdgeKind, NetworkKind>>;
|
|
270
|
+
/** The class the rules read each edge by. */
|
|
271
|
+
declare const EDGE_CLASS: Readonly<Record<NetworkEdgeKind, NetworkClass>>;
|
|
272
|
+
declare function isAerialEdgeKind(kind: NetworkEdgeKind): kind is AerialEdgeKind;
|
|
273
|
+
/** The network of a street a lot connection links to: `power` takes the low voltage. */
|
|
274
|
+
declare const CONNECTION_NETWORK: Readonly<Record<UtilityNetwork, NetworkKind>>;
|
|
275
|
+
/** Supply networks flow from their sources to the loads; drain networks flow from the houses to their destinations. */
|
|
276
|
+
declare const NETWORK_FLOW: Readonly<Record<NetworkKind, 'supply' | 'drain'>>;
|
|
277
|
+
/**
|
|
278
|
+
* The nodes a network starts from (supply) or ends at (drain). The low voltage starts at the transformers the medium voltage reaches,
|
|
279
|
+
* and the lighting at the low voltage nodes, so these two are resolved by the graph.
|
|
280
|
+
*/
|
|
281
|
+
declare const NETWORK_ENDS: Readonly<Record<NetworkKind, readonly NetworkNodeKind[]>>;
|
|
282
|
+
|
|
283
|
+
/** Stable codes of what `validateNetworks` finds wrong, as the `STRUCTURAL_VIOLATION` of game-floorplan-structure. */
|
|
284
|
+
declare const NETWORK_VIOLATION: {
|
|
285
|
+
readonly DUPLICATE_ID: "duplicate_id";
|
|
286
|
+
readonly UNKNOWN_NODE: "unknown_node";
|
|
287
|
+
readonly NOT_CARRIED: "not_carried";
|
|
288
|
+
readonly NOT_RADIAL: "not_radial";
|
|
289
|
+
readonly DISCONNECTED: "disconnected";
|
|
290
|
+
readonly LOOP_AT_END: "loop_at_end";
|
|
291
|
+
readonly CONNECTION_IN_PLAN_FRAME: "connection_in_plan_frame";
|
|
292
|
+
readonly LOT_UNCONNECTED: "lot_unconnected";
|
|
293
|
+
readonly LOT_CONNECTED_TWICE: "lot_connected_twice";
|
|
294
|
+
readonly LOT_DECLARED_TWICE: "lot_declared_twice";
|
|
295
|
+
readonly ORPHAN_CONNECTION: "orphan_connection";
|
|
296
|
+
readonly CONNECTION_MOVED: "connection_moved";
|
|
297
|
+
readonly DROP_TOO_LONG: "drop_too_long";
|
|
298
|
+
readonly DROP_SKEWED: "drop_skewed";
|
|
299
|
+
readonly DROP_OFF_FRONTAGE: "drop_off_frontage";
|
|
300
|
+
readonly DROP_OVER_OTHER_LOT: "drop_over_other_lot";
|
|
301
|
+
readonly POLE_TOO_MANY_DROPS: "pole_too_many_drops";
|
|
302
|
+
readonly MISSING_SAG: "missing_sag";
|
|
303
|
+
readonly CLEARANCE: "clearance";
|
|
304
|
+
readonly MV_OVER_LOT: "mv_over_lot";
|
|
305
|
+
readonly SPAN_OVER_BUILDING: "span_over_building";
|
|
306
|
+
readonly SPAN_THROUGH_CROWN: "span_through_crown";
|
|
307
|
+
readonly MISSING_INVERT: "missing_invert";
|
|
308
|
+
readonly MISSING_DIAMETER: "missing_diameter";
|
|
309
|
+
readonly SLOPE: "slope";
|
|
310
|
+
readonly SLOPE_MISMATCH: "slope_mismatch";
|
|
311
|
+
readonly COVER: "cover";
|
|
312
|
+
readonly TOO_DEEP: "too_deep";
|
|
313
|
+
readonly CROSSING_TOO_CLOSE: "crossing_too_close";
|
|
314
|
+
readonly CROSSING_ORDER: "crossing_order";
|
|
315
|
+
readonly LATERAL_TOO_DEEP: "lateral_too_deep";
|
|
316
|
+
readonly MANHOLE_SPACING: "manhole_spacing";
|
|
317
|
+
readonly UNKNOWN_TRANSFORMER: "unknown_transformer";
|
|
318
|
+
readonly TRANSFORMER_OVERLOADED: "transformer_overloaded";
|
|
319
|
+
readonly LV_CIRCUIT_TOO_LONG: "lv_circuit_too_long";
|
|
320
|
+
};
|
|
321
|
+
type NetworkViolationCode = (typeof NETWORK_VIOLATION)[keyof typeof NETWORK_VIOLATION];
|
|
322
|
+
/** One finding: the id of the node, edge or lot, and the number against its limit when there is one. */
|
|
323
|
+
type NetworkViolation = {
|
|
324
|
+
readonly code: NetworkViolationCode;
|
|
325
|
+
readonly id: string;
|
|
326
|
+
readonly detail?: string;
|
|
327
|
+
readonly value?: number;
|
|
328
|
+
readonly limit?: number;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/** The networks indexed: nodes and edges by id, and the edges in and out of each node. Edges whose ends are missing are kept but link nothing. */
|
|
332
|
+
type NetworkGraph = {
|
|
333
|
+
readonly nodes: ReadonlyMap<string, NetworkNode>;
|
|
334
|
+
readonly edges: ReadonlyMap<string, NetworkEdge>;
|
|
335
|
+
/** Edges leaving a node, of one network or all. */
|
|
336
|
+
outgoing(nodeId: string, network?: NetworkKind): readonly NetworkEdge[];
|
|
337
|
+
/** Edges reaching a node, of one network or all. */
|
|
338
|
+
incoming(nodeId: string, network?: NetworkKind): readonly NetworkEdge[];
|
|
339
|
+
};
|
|
340
|
+
/** Indexes nodes and edges. The first of two entries with the same id wins (the validator reports the second). */
|
|
341
|
+
declare function buildNetworkGraph(input: {
|
|
342
|
+
readonly nodes: readonly NetworkNode[];
|
|
343
|
+
readonly edges: readonly NetworkEdge[];
|
|
344
|
+
}): NetworkGraph;
|
|
345
|
+
/**
|
|
346
|
+
* The nodes linked to their source by the edges of `network`: walked from the sources along the flow (supply), or back from the
|
|
347
|
+
* destinations against it (drain). The low voltage starts only at transformers the medium voltage reaches.
|
|
348
|
+
*/
|
|
349
|
+
declare function connectedNodes(graph: NetworkGraph, network: NetworkKind): ReadonlySet<string>;
|
|
350
|
+
/** Horizontal length of an edge, metres (0 when an end is missing). */
|
|
351
|
+
declare function edgeLength(graph: NetworkGraph, edge: NetworkEdge): number;
|
|
352
|
+
/** The low voltage nodes a transformer feeds, with the length of line (low voltage spans; a service drop adds none) from it to each one. */
|
|
353
|
+
declare function circuitOf(graph: NetworkGraph, transformerId: string): ReadonlyMap<string, number>;
|
|
354
|
+
|
|
355
|
+
/** The bands from the top of the pole down. */
|
|
356
|
+
declare const POLE_SLOT_ORDER: readonly PoleSlotBand[];
|
|
357
|
+
/**
|
|
358
|
+
* Least free gap between the top of a band and the bottom of the band above it, metres: the transformer drum 0.3 m under the crossarm,
|
|
359
|
+
* the first telecom cable 0.4 m under the lamp. A band never enters the one above (gap 0 at least).
|
|
360
|
+
*/
|
|
361
|
+
declare const POLE_SLOT_GAPS: Readonly<Record<Exclude<PoleSlotBand, 'mv'>, number>>;
|
|
362
|
+
/** The 11 m double-T concrete pole, 1.7 m buried (9.3 m above the ground), with the bands of Brazilian distribution practice. */
|
|
363
|
+
declare const DEFAULT_POLE_SLOTS: PoleSlots;
|
|
364
|
+
type PoleSlotViolation = {
|
|
365
|
+
readonly code: 'slot_out_of_pole' | 'slot_inverted' | 'slot_order';
|
|
366
|
+
readonly band: PoleSlotBand;
|
|
367
|
+
readonly value: number;
|
|
368
|
+
readonly limit: number;
|
|
369
|
+
};
|
|
370
|
+
/** Every band inside the pole above the ground, bottom under top, in order and apart by the least gaps. */
|
|
371
|
+
declare function checkPoleSlots(slots: PoleSlots, gaps?: Readonly<Record<Exclude<PoleSlotBand, 'mv'>, number>>): PoleSlotViolation[];
|
|
372
|
+
/** The slots a pole of the registry declares (a distribution pole), or none. */
|
|
373
|
+
declare function slotsOfPole(pole: PoleDef): PoleSlots | undefined;
|
|
374
|
+
|
|
375
|
+
/** The axis a straight street runs along. */
|
|
376
|
+
type RunAxis = 'x' | 'z';
|
|
377
|
+
/** A straight street's frame: `u` along it, `v` across it (+z for a street along x, +x for one along z). */
|
|
378
|
+
type RunFrame = {
|
|
379
|
+
readonly along: RunAxis;
|
|
380
|
+
readonly axis: number;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/** A lot's front on its street: its rectangle, the street's frame, the side of the street it stands on and its span along the street. */
|
|
384
|
+
type LotFrontage = {
|
|
385
|
+
readonly lot: string;
|
|
386
|
+
readonly rect: PlanRect;
|
|
387
|
+
readonly frame: RunFrame;
|
|
388
|
+
/** Half the street's roadway plus its sidewalk: a point farther from the axis is off the street. */
|
|
389
|
+
readonly reach: number;
|
|
390
|
+
readonly side: 1 | -1;
|
|
391
|
+
readonly span: readonly [number, number];
|
|
392
|
+
};
|
|
393
|
+
type DropFitParams = {
|
|
394
|
+
readonly frontage: LotFrontage;
|
|
395
|
+
readonly pole: {
|
|
396
|
+
readonly x: number;
|
|
397
|
+
readonly z: number;
|
|
398
|
+
};
|
|
399
|
+
readonly anchor: readonly [number, number, number];
|
|
400
|
+
readonly rules: Pick<PowerRules, 'dropMaxSkew' | 'dropFrontageSlack'>;
|
|
401
|
+
};
|
|
402
|
+
type DropMisfit = 'skewed' | 'off_frontage';
|
|
403
|
+
/**
|
|
404
|
+
* How a drop from a street pole to a lot's anchor breaks the street's practice, or nothing: on the pole's own side the pole stands in front of
|
|
405
|
+
* the lot (its station within the frontage); across the street the drop goes straight over (within `dropMaxSkew` of the street's normal),
|
|
406
|
+
* never along the street. A pole off the street (a service pole inside a lot) is not judged here.
|
|
407
|
+
*/
|
|
408
|
+
declare function dropMisfitOf({ frontage, pole, anchor, rules }: DropFitParams): DropMisfit | undefined;
|
|
409
|
+
/** The first other lot a drop's straight path passes over (sampled every 0.25 m), or none. */
|
|
410
|
+
declare function lotUnderDrop({ from, to, lot, frontages }: {
|
|
411
|
+
readonly from: readonly [number, number];
|
|
412
|
+
readonly to: readonly [number, number];
|
|
413
|
+
readonly lot: string;
|
|
414
|
+
readonly frontages: readonly LotFrontage[];
|
|
415
|
+
}): string | undefined;
|
|
416
|
+
|
|
417
|
+
/** What the validator reads besides the networks: the lots' connections, the buildings and trees in the way, the ground. */
|
|
418
|
+
type ValidateNetworksOptions = {
|
|
419
|
+
/** Every connection a lot declared; each must be linked once, in `frame: 'world'`. */
|
|
420
|
+
readonly connections?: readonly UtilityConnection[];
|
|
421
|
+
/** Outlines no span may cross (a drop may end over the building of its own lot). */
|
|
422
|
+
readonly buildings?: readonly NetworkBuilding[];
|
|
423
|
+
/** Tree crowns no span may go through (from the scene's plant provider). */
|
|
424
|
+
readonly obstacles?: {
|
|
425
|
+
readonly crowns?: readonly NetworkCrown[];
|
|
426
|
+
};
|
|
427
|
+
/** What lies under a point of a span. Default: road everywhere (the strictest clearance a conductor may have). A point with no surface is not checked. */
|
|
428
|
+
readonly surfaceAt?: (x: number, z: number) => NetworkSurface | undefined;
|
|
429
|
+
/** Ground level at a point. Default: 0 under a span; along a pipe, the cover levels of its two nodes. */
|
|
430
|
+
readonly groundAt?: (x: number, z: number) => number;
|
|
431
|
+
/** The lots' fronts on their streets (`GeneratedNetworks.frontages`): with them the drops are held to the street's practice. */
|
|
432
|
+
readonly frontages?: readonly LotFrontage[];
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Everything wrong with the networks, by the rules they carry: ids and links, each network a tree tied to its source, every lot linked once,
|
|
437
|
+
* spans (reach, sag, clearance, buildings, crowns), pipes (slope, cover, depth, crossings) and transformers (loading, circuit length).
|
|
438
|
+
* Pure and in input order: the same networks give the same list.
|
|
439
|
+
*/
|
|
440
|
+
declare function validateNetworks(networks: UtilityNetworks, options?: ValidateNetworksOptions): NetworkViolation[];
|
|
441
|
+
|
|
442
|
+
/** How a run of street ends: at the map border (the line leaves the map), at a river bank, or where the line itself ends. */
|
|
443
|
+
type RunEnd = 'edge' | 'river' | 'line_end';
|
|
444
|
+
/** Another run crossing this one: `at` is its axis along this run, `half` the half width of its roadway. */
|
|
445
|
+
type RunCrossing = {
|
|
446
|
+
readonly run: string;
|
|
447
|
+
readonly at: number;
|
|
448
|
+
readonly half: number;
|
|
449
|
+
};
|
|
450
|
+
/** A straight stretch of street between two river banks or line ends, in its own frame (`u` along, `v` across). */
|
|
451
|
+
type StreetRun = {
|
|
452
|
+
readonly id: string;
|
|
453
|
+
readonly line: string;
|
|
454
|
+
readonly along: RunAxis;
|
|
455
|
+
/** z of a street along x, x of one along z. */
|
|
456
|
+
readonly axis: number;
|
|
457
|
+
readonly width: number;
|
|
458
|
+
readonly from: number;
|
|
459
|
+
readonly to: number;
|
|
460
|
+
readonly ends: readonly [RunEnd, RunEnd];
|
|
461
|
+
readonly crossings: readonly RunCrossing[];
|
|
462
|
+
};
|
|
463
|
+
/** A lot of the site: its id and its rectangle on the plan. */
|
|
464
|
+
type NetworkLot = {
|
|
465
|
+
readonly id: string;
|
|
466
|
+
readonly rect: PlanRect;
|
|
467
|
+
};
|
|
468
|
+
/** A lot and the run it faces: the side of the street, its span along the run and the distance from the axis to its front. */
|
|
469
|
+
type ServedLot = {
|
|
470
|
+
readonly lot: NetworkLot;
|
|
471
|
+
readonly run: StreetRun;
|
|
472
|
+
readonly side: 1 | -1;
|
|
473
|
+
readonly span: readonly [number, number];
|
|
474
|
+
readonly front: number;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
type GroundAt = (x: number, z: number) => number;
|
|
478
|
+
/**
|
|
479
|
+
* Where a lot takes each network when it declares none, from its rectangle and the street it faces: the meter post (power, telecom 0.6 m
|
|
480
|
+
* under it) and the water stand behind the front wall, the inspection box 1 m inside the front, the downspout outlet at the kerb.
|
|
481
|
+
*/
|
|
482
|
+
declare function defaultConnectionsOf({ served, rules, groundAt }: {
|
|
483
|
+
readonly served: ServedLot;
|
|
484
|
+
readonly rules: NetworkRules;
|
|
485
|
+
readonly groundAt: GroundAt;
|
|
486
|
+
}): UtilityConnection[];
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* What the generator could not lay by its rules and laid anyway, for the game to see (the validator still reports what breaks a rule):
|
|
490
|
+
* a pole with no free ground but in front of a gate, a pole whose own consumers are over the largest transformer, a lot out of every reach.
|
|
491
|
+
*/
|
|
492
|
+
type NetworkWarning = {
|
|
493
|
+
readonly code: 'pole_on_avoid' | 'transformer_over_capacity' | 'lot_out_of_reach' | 'drop_off_practice';
|
|
494
|
+
readonly id: string;
|
|
495
|
+
readonly detail?: string;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
type GenerateNetworksParams = {
|
|
499
|
+
readonly plan: CityPlanInput;
|
|
500
|
+
/** The lots of the site; each takes the networks from the street it faces. */
|
|
501
|
+
readonly lots: readonly NetworkLot[];
|
|
502
|
+
/** What the lots declared (`frame: 'world'`); a lot that declared none of a network gets the default point from its rectangle. */
|
|
503
|
+
readonly connections?: readonly UtilityConnection[];
|
|
504
|
+
/** A game's numbers over the defaults. */
|
|
505
|
+
readonly rules?: DeepPartial<NetworkRules>;
|
|
506
|
+
/** Draws (illegal hookups, telecom bundles) come from the hash of the seed and an id, never from a scene's random. */
|
|
507
|
+
readonly seed: number;
|
|
508
|
+
/** Ground no pole may stand on: the front of every gate and door, the meter posts. */
|
|
509
|
+
readonly avoid?: readonly PlanRect[];
|
|
510
|
+
/** Ground level at a point. Default 0 (the flat ground of a levelled city). */
|
|
511
|
+
readonly groundAt?: GroundAt;
|
|
512
|
+
/** The distribution pole of the registry: its bands and its lamp's reach are read from its spec. Default `concrete_distribution`. */
|
|
513
|
+
readonly pole?: {
|
|
514
|
+
readonly id: string;
|
|
515
|
+
readonly spec: DistributionSpec;
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
type GeneratedNetworks = {
|
|
519
|
+
readonly networks: UtilityNetworks;
|
|
520
|
+
/** Every connection the networks link (the declared ones and the defaults), for `validateNetworks`. */
|
|
521
|
+
readonly connections: readonly UtilityConnection[];
|
|
522
|
+
/** Road, sidewalk or lot under a point, from the plan's streets: the `surfaceAt` of `validateNetworks`. */
|
|
523
|
+
readonly surfaceAt: (x: number, z: number) => NetworkSurface;
|
|
524
|
+
/** The front of every lot on its street: the `frontages` of `validateNetworks` (the drop rules). */
|
|
525
|
+
readonly frontages: readonly LotFrontage[];
|
|
526
|
+
/** What the generator laid against its own rules because nothing else fit (empty for a plan it can lay). */
|
|
527
|
+
readonly warnings: readonly NetworkWarning[];
|
|
528
|
+
};
|
|
529
|
+
/** What lies under a point: the roadway or the sidewalk of a street of the plan, else a lot. */
|
|
530
|
+
declare function surfaceOf({ runs, sidewalk }: {
|
|
531
|
+
readonly runs: readonly StreetRun[];
|
|
532
|
+
readonly sidewalk: number;
|
|
533
|
+
}): (x: number, z: number) => NetworkSurface;
|
|
534
|
+
/** The front of every lot on its street, for the drop rules (`validateNetworks`' `frontages`). */
|
|
535
|
+
declare function frontagesOf({ served, sidewalk }: {
|
|
536
|
+
readonly served: readonly ServedLot[];
|
|
537
|
+
readonly sidewalk: number;
|
|
538
|
+
}): LotFrontage[];
|
|
539
|
+
/**
|
|
540
|
+
* The utility networks of a district from its city plan and the site's lots, as data: power (medium voltage from a feed where the trunk
|
|
541
|
+
* leaves the map, transformers sized by the diversified demand, low voltage, a drop to every lot), a lamp on every street pole, telecom, sewer
|
|
542
|
+
* to an interceptor along the river, drainage to headwalls on the bank, water from a reservoir at the border. Pure: the same input gives the same bytes.
|
|
543
|
+
*/
|
|
544
|
+
declare function generateNetworks(params: GenerateNetworksParams): GeneratedNetworks;
|
|
545
|
+
|
|
546
|
+
/** A street light of the network with the state of its lamp: `pole` is the pole its `light_feed` comes from. */
|
|
547
|
+
type NetworkLamp = LampState & {
|
|
548
|
+
readonly id: string;
|
|
549
|
+
readonly pole: string;
|
|
550
|
+
readonly at: readonly [number, number, number];
|
|
551
|
+
readonly flickerPhase?: number;
|
|
552
|
+
};
|
|
553
|
+
type NetworkLampsParams = {
|
|
554
|
+
readonly networks: UtilityNetworks;
|
|
555
|
+
/** The share of lamps that work and the share that flicker (the rest are burnt out). */
|
|
556
|
+
readonly shares: LampShares;
|
|
557
|
+
/** By day every lamp is off. */
|
|
558
|
+
readonly isNight: boolean;
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* Every `light` node with its lamp's state, `lampStateOf` by the network's seed and the node's place (the same draw a pole of the scene had), and
|
|
562
|
+
* a failing lamp's flicker phase (`flickerPhaseOf`). A lamp is on at night when its state says so; the transformer that feeds it is T2.8f.
|
|
563
|
+
*/
|
|
564
|
+
declare function networkLampsOf({ networks, shares, isNight }: NetworkLampsParams): NetworkLamp[];
|
|
565
|
+
|
|
566
|
+
/** A point of a pole in its own frame: `x` toward the road (where the lamp hangs), `y` up from the ground, `z` along the line. */
|
|
567
|
+
type PolePoint = readonly [number, number, number];
|
|
568
|
+
/** What a piece of a distribution pole is, so a drawing can keep what another already draws (the single arm draws `arm`, `lamp` and the tank). */
|
|
569
|
+
type HardwareRole = 'crossarm' | 'insulator' | 'lv_clamp' | 'telecom_clamp' | 'bracket' | 'bushing' | 'arm' | 'lamp' | 'tank';
|
|
570
|
+
/** A box of the pole in its frame: `y` is the base, as the builder's boxes. */
|
|
571
|
+
type HardwareBox = {
|
|
572
|
+
readonly role: HardwareRole;
|
|
573
|
+
readonly x: number;
|
|
574
|
+
readonly y: number;
|
|
575
|
+
readonly z: number;
|
|
576
|
+
readonly width: number;
|
|
577
|
+
readonly height: number;
|
|
578
|
+
readonly depth: number;
|
|
579
|
+
readonly color: number;
|
|
580
|
+
};
|
|
581
|
+
/** An upright cylinder (the transformer tank): `y` is the base. */
|
|
582
|
+
type HardwareCylinder = {
|
|
583
|
+
readonly role: 'tank';
|
|
584
|
+
readonly x: number;
|
|
585
|
+
readonly y: number;
|
|
586
|
+
readonly z: number;
|
|
587
|
+
readonly radius: number;
|
|
588
|
+
readonly height: number;
|
|
589
|
+
readonly color: number;
|
|
590
|
+
readonly segments: number;
|
|
591
|
+
};
|
|
592
|
+
/** Where each conductor is fixed on the pole, in its frame. */
|
|
593
|
+
type PoleAttachments = {
|
|
594
|
+
/** The three medium-voltage phases, on the tops of the pin insulators. */
|
|
595
|
+
readonly mv: readonly PolePoint[];
|
|
596
|
+
/** The low-voltage multiplexed cable in its suspension clamp. */
|
|
597
|
+
readonly lv: PolePoint;
|
|
598
|
+
/** One clamp per telecom cable, the first on top. */
|
|
599
|
+
readonly telecom: readonly PolePoint[];
|
|
600
|
+
/** The transformer: its three bushing tops (medium voltage in) and the side of its tank the low voltage leaves from. */
|
|
601
|
+
readonly transformer?: {
|
|
602
|
+
readonly mv: readonly PolePoint[];
|
|
603
|
+
readonly lv: PolePoint;
|
|
604
|
+
};
|
|
605
|
+
/** The guy wire's eye, under the crossarm. */
|
|
606
|
+
readonly guy: PolePoint;
|
|
607
|
+
};
|
|
608
|
+
/** The pieces and fixing points of a distribution pole. The lens is apart: its colour is the lamp's state. */
|
|
609
|
+
type PoleHardware = {
|
|
610
|
+
readonly boxes: readonly HardwareBox[];
|
|
611
|
+
readonly cylinders: readonly HardwareCylinder[];
|
|
612
|
+
readonly lens?: HardwareBox;
|
|
613
|
+
readonly attachments: PoleAttachments;
|
|
614
|
+
};
|
|
615
|
+
type PoleHardwareOptions = {
|
|
616
|
+
/** The pole carries the medium voltage (its crossarm and insulators). */
|
|
617
|
+
readonly mv: boolean;
|
|
618
|
+
/** A transformer hangs on it. */
|
|
619
|
+
readonly transformer: boolean;
|
|
620
|
+
/** Its street light (arm, luminaire, lens). */
|
|
621
|
+
readonly lamp: boolean;
|
|
622
|
+
/** Telecom cables fixed on it, `cableGap` apart (the network's `rules.layout.telecom.cableGap`). */
|
|
623
|
+
readonly cables: number;
|
|
624
|
+
readonly cableGap: number;
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* The hardware of a distribution pole in its own frame, every fixing height read from its bands (`slots`) as the network generator reads them:
|
|
628
|
+
* the crossarm with its pin insulators at the medium voltage, the transformer under it, the low-voltage cable's suspension clamp on the field
|
|
629
|
+
* side, the street light's arm over the road, and one telecom clamp per cable under the lamp. Pure; the drawing places and instances it.
|
|
630
|
+
*/
|
|
631
|
+
declare function distributionHardwareOf(spec: DistributionSpec, o: PoleHardwareOptions): PoleHardware;
|
|
632
|
+
|
|
633
|
+
/** The 11 m double-T concrete distribution pole (9.3 m above the ground): the lamp's arm in the street light band, the drum in the transformer band. */
|
|
634
|
+
declare const DISTRIBUTION: DistributionSpec;
|
|
635
|
+
|
|
636
|
+
/** The fixing heights over the ground, read from the pole's bands. */
|
|
637
|
+
type PoleHeights = {
|
|
638
|
+
readonly mv: number;
|
|
639
|
+
readonly transformer: number;
|
|
640
|
+
readonly transformerBottom: number;
|
|
641
|
+
readonly lv: number;
|
|
642
|
+
readonly lamp: number;
|
|
643
|
+
readonly telecom: number;
|
|
644
|
+
};
|
|
645
|
+
declare function poleHeightsOf(slots: PoleSlots): PoleHeights;
|
|
646
|
+
|
|
647
|
+
export { type AerialClass, type AerialEdgeKind, type BuriedEdgeKind, CONNECTION_NETWORK, type ClearanceRow, type CoverRange, DEFAULT_NETWORK_LAYOUT, DEFAULT_NETWORK_RULES, DEFAULT_POLE_SLOTS, DISTRIBUTION, type DefaultConnectionRules, DistributionSpec, type DiversityBand, type DropMisfit, EDGE_CLASS, EDGE_NETWORK, type GenerateNetworksParams, type GeneratedNetworks, type GroundAt, type HardwareBox, type HardwareCylinder, type HardwareRole, type LotFrontage, NETWORK_ENDS, NETWORK_FLOW, NETWORK_VIOLATION, type NetworkBuilding, type NetworkClass, type NetworkCrown, type NetworkEdge, type NetworkEdgeKind, type NetworkGraph, type NetworkKind, type NetworkLamp, type NetworkLampsParams, type NetworkLayoutRules, type NetworkLot, type NetworkNode, type NetworkNodeKind, type NetworkRules, type NetworkSurface, type NetworkViolation, type NetworkViolationCode, type NetworkWarning, POLE_SLOT_GAPS, POLE_SLOT_ORDER, type PoleAttachments, type PoleHardware, type PoleHardwareOptions, type PoleHeights, type PolePoint, PoleSlotBand, type PoleSlotViolation, PoleSlots, type PowerRules, type RunEnd, type ServedLot, type StreetRun, type TransformerRating, type UtilityNetworks, type ValidateNetworksOptions, buildNetworkGraph, checkPoleSlots, circuitOf, connectedNodes, defaultConnectionsOf, distributionHardwareOf, diversifiedDemand, dropMisfitOf, edgeLength, frontagesOf, generateNetworks, isAerialEdgeKind, lotUnderDrop, networkLampsOf, pickTransformer, poleHeightsOf, resolveNetworkRules, slotsOfPole, surfaceOf, validateNetworks };
|