@adatechnology/game-urban 0.3.12 → 0.4.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.
@@ -0,0 +1,488 @@
1
+ import { DeepPartial, UtilityNetwork, UtilityConnection } from '@adatechnology/game-contracts';
2
+ import { am as PoleSlots, al as PoleSlotBand, m as PoleDef, aj as PlanRect, C as CityPlanInput, Q as DistributionSpec } from '../types-CYeqw_58.js';
3
+ export { O as DistributionPoleDef } from '../types-CYeqw_58.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
+ /** Longest low voltage path from the transformer to its farthest node, each way, metres. */
123
+ readonly lvCircuitMaxLength: number;
124
+ /** Highest demand over the rating. */
125
+ readonly maxLoading: number;
126
+ readonly transformers: readonly TransformerRating[];
127
+ /** Installed load (kVA) that splits the `low` and `high` columns of the demand table. */
128
+ readonly installedSplitKva: number;
129
+ /** By number of consumers, ascending; the last band takes any number above. */
130
+ readonly diversity: readonly DiversityBand[];
131
+ };
132
+ /** Cover of a pipe: from the ground down to its top, metres. */
133
+ type CoverRange = {
134
+ readonly min: number;
135
+ readonly max?: number;
136
+ };
137
+ type NetworkRules = {
138
+ readonly clearance: Readonly<Record<AerialClass, ClearanceRow>>;
139
+ /** Samples along a span when the catenary is checked. */
140
+ readonly catenarySamples: number;
141
+ readonly power: PowerRules;
142
+ readonly lighting: {
143
+ readonly lampKva: number;
144
+ };
145
+ readonly telecom: {
146
+ readonly dropMaxLength: number;
147
+ };
148
+ /** Least slope of each gravity pipe, m/m. */
149
+ readonly minSlope: Readonly<Record<Extract<BuriedEdgeKind, 'sewer_main' | 'sewer_lateral' | 'storm_gallery' | 'storm_lateral' | 'storm_gutter'>, number>>;
150
+ readonly cover: Readonly<Record<BuriedEdgeKind, CoverRange>>;
151
+ readonly sewer: {
152
+ /** Deepest invert below the ground before a pumping station is needed. */
153
+ readonly maxDepth: number;
154
+ /** Cover of a sewer main under a street with a storm gallery (the main passes under the gallery's laterals). */
155
+ readonly coverUnderGallery: number;
156
+ /** A storm gallery this close to a sewer main, metres in plan, puts the main under that street's rule. */
157
+ readonly galleryReach: number;
158
+ /** Deepest bottom of a sewer lateral where it crosses a storm gallery (it goes over it). */
159
+ readonly lateralOverGallery: number;
160
+ /** Longest sewer main between two manholes. */
161
+ readonly manholeSpacing: number;
162
+ };
163
+ /** Least vertical gap between two pipes that cross, and which one goes above (lower rank above). */
164
+ readonly crossing: {
165
+ readonly separation: number;
166
+ readonly rank: Readonly<Record<BuriedEdgeKind, number>>;
167
+ };
168
+ /** How far a connection node may sit from the point the lot declared, metres. */
169
+ readonly connectionTolerance: number;
170
+ /** What `generateNetworks` lays out: spacing, offsets, sags, diameters (the validator reads none of it). */
171
+ readonly layout: NetworkLayoutRules;
172
+ };
173
+ /** Brazilian practice (NBR 15688, NBR 9649, NBR 12218 and the utilities' sharing rules), with no brand. Every number is patched by `resolveNetworkRules`. */
174
+ declare const DEFAULT_NETWORK_RULES: NetworkRules;
175
+ /** The default rules with a game's numbers over them (objects merge, arrays such as the transformers replace). */
176
+ declare function resolveNetworkRules(patch?: DeepPartial<NetworkRules>): NetworkRules;
177
+ /**
178
+ * 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
179
+ * consumer whose load is not known (a connection without `installedKva`, a lot linked without a meter) counts in the `low` column.
180
+ */
181
+ declare function diversifiedDemand(installedKva: readonly number[], rules: PowerRules): number;
182
+ /** The smallest rating whose loading stays within `maxLoading` for this demand, or none. */
183
+ declare function pickTransformer(demandKva: number, rules: PowerRules): TransformerRating | undefined;
184
+
185
+ /** The networks of a street. `power_lv` is the low voltage the houses take; `lighting` is the street lights fed by it. */
186
+ type NetworkKind = 'power_mv' | 'power_lv' | 'lighting' | 'telecom' | 'sewer' | 'storm' | 'water';
187
+ type NetworkNodeKind = 'feed' | 'pole' | 'transformer' | 'light' | 'splice' | 'manhole' | 'cleanout' | 'inlet' | 'outfall' | 'valve' | 'hydrant' | 'reservoir' | 'treatment' | 'pumping_station' | 'connection';
188
+ /** A point of a network, in world metres. */
189
+ type NetworkNode = {
190
+ /** Stable: 'pole:main_street:07', 'pv:main_street:03', 'lot:street_south_3:sewer'. */
191
+ readonly id: string;
192
+ readonly kind: NetworkNodeKind;
193
+ /** `y` is the fixing height of an aerial point, or the level of the cover of a buried one (the ground there). */
194
+ readonly at: readonly [number, number, number];
195
+ /** Buried: the level of the bottom of the pipe at this node. */
196
+ readonly invert?: number;
197
+ readonly carries: readonly NetworkKind[];
198
+ /** Id in a registry: the pole `concrete_distribution`, the transformer `t45`, the cover `pv_600`. */
199
+ readonly spec?: string;
200
+ /** A connection node: the lot it serves. */
201
+ readonly lot?: string;
202
+ /** A guy wire holds the pole (corner and end of line). */
203
+ readonly guyed?: boolean;
204
+ };
205
+ 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';
206
+ /** An aerial edge: a span between poles or a drop to a lot. */
207
+ type AerialEdgeKind = 'mv_span' | 'lv_span' | 'telecom_span' | 'service_drop' | 'telecom_drop' | 'light_feed';
208
+ /** A buried edge: a pipe. */
209
+ type BuriedEdgeKind = Exclude<NetworkEdgeKind, AerialEdgeKind>;
210
+ /**
211
+ * 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
212
+ * low voltage, a light feed is the short link from the pole to its lamp.
213
+ */
214
+ type NetworkClass = 'power_mv' | 'power_lv' | 'street_light' | 'service_drop' | 'telecom' | 'sewer' | 'storm' | 'water';
215
+ /** The classes of the conductors in the air. */
216
+ type AerialClass = Extract<NetworkClass, 'power_mv' | 'power_lv' | 'street_light' | 'service_drop' | 'telecom'>;
217
+ /** A link between two nodes, in the direction of the flow: from the source to the load, and from the house to the destination. */
218
+ type NetworkEdge = {
219
+ readonly id: string;
220
+ readonly kind: NetworkEdgeKind;
221
+ readonly from: string;
222
+ readonly to: string;
223
+ /** Buried: metres. */
224
+ readonly diameter?: number;
225
+ /** Gravity networks: m/m, positive along the flow. When the inverts are known the validator reads the slope from them. */
226
+ readonly slope?: number;
227
+ /** Aerial: metres of sag at mid span. */
228
+ readonly sag?: number;
229
+ /** 3 phases of medium voltage, 4 of low voltage, 1..n telecom cables. */
230
+ readonly conductors?: number;
231
+ /** Aerial: the fixing heights at `from` and `to` when they are not the nodes' own (a pole carries each network at its own band). */
232
+ readonly heights?: readonly [number, number];
233
+ /** Buried: the inverts at `from` and `to` when they are not the nodes' own (a lateral entering a main from above). */
234
+ readonly inverts?: readonly [number, number];
235
+ };
236
+ /** The networks of a district, as data. */
237
+ type UtilityNetworks = {
238
+ readonly nodes: readonly NetworkNode[];
239
+ readonly edges: readonly NetworkEdge[];
240
+ readonly seed: number;
241
+ readonly rules: NetworkRules;
242
+ };
243
+ /** What lies under a point of an aerial span, for the clearance table. */
244
+ type NetworkSurface = 'road' | 'sidewalk' | 'lot';
245
+ /** A building a span must not cross, by its plan outline (world x, z) and height. */
246
+ type NetworkBuilding = {
247
+ readonly id: string;
248
+ /** The lot it stands on: a drop to a connection of the same lot may end over it. */
249
+ readonly lot?: string;
250
+ readonly outline: readonly (readonly [number, number])[];
251
+ readonly height: number;
252
+ };
253
+ /** A tree crown a span must not go through: a vertical cylinder from `bottom` to `top`. */
254
+ type NetworkCrown = {
255
+ readonly x: number;
256
+ readonly z: number;
257
+ readonly radius: number;
258
+ readonly bottom: number;
259
+ readonly top: number;
260
+ };
261
+
262
+ /** The network each edge belongs to. A service drop is low voltage: a lot is never linked to the medium voltage. */
263
+ declare const EDGE_NETWORK: Readonly<Record<NetworkEdgeKind, NetworkKind>>;
264
+ /** The class the rules read each edge by. */
265
+ declare const EDGE_CLASS: Readonly<Record<NetworkEdgeKind, NetworkClass>>;
266
+ declare function isAerialEdgeKind(kind: NetworkEdgeKind): kind is AerialEdgeKind;
267
+ /** The network of a street a lot connection links to: `power` takes the low voltage. */
268
+ declare const CONNECTION_NETWORK: Readonly<Record<UtilityNetwork, NetworkKind>>;
269
+ /** Supply networks flow from their sources to the loads; drain networks flow from the houses to their destinations. */
270
+ declare const NETWORK_FLOW: Readonly<Record<NetworkKind, 'supply' | 'drain'>>;
271
+ /**
272
+ * The nodes a network starts from (supply) or ends at (drain). The low voltage starts at the transformers the medium voltage reaches,
273
+ * and the lighting at the low voltage nodes, so these two are resolved by the graph.
274
+ */
275
+ declare const NETWORK_ENDS: Readonly<Record<NetworkKind, readonly NetworkNodeKind[]>>;
276
+
277
+ /** Stable codes of what `validateNetworks` finds wrong, as the `STRUCTURAL_VIOLATION` of game-floorplan-structure. */
278
+ declare const NETWORK_VIOLATION: {
279
+ readonly DUPLICATE_ID: "duplicate_id";
280
+ readonly UNKNOWN_NODE: "unknown_node";
281
+ readonly NOT_CARRIED: "not_carried";
282
+ readonly NOT_RADIAL: "not_radial";
283
+ readonly DISCONNECTED: "disconnected";
284
+ readonly LOOP_AT_END: "loop_at_end";
285
+ readonly CONNECTION_IN_PLAN_FRAME: "connection_in_plan_frame";
286
+ readonly LOT_UNCONNECTED: "lot_unconnected";
287
+ readonly LOT_CONNECTED_TWICE: "lot_connected_twice";
288
+ readonly LOT_DECLARED_TWICE: "lot_declared_twice";
289
+ readonly ORPHAN_CONNECTION: "orphan_connection";
290
+ readonly CONNECTION_MOVED: "connection_moved";
291
+ readonly DROP_TOO_LONG: "drop_too_long";
292
+ readonly MISSING_SAG: "missing_sag";
293
+ readonly CLEARANCE: "clearance";
294
+ readonly MV_OVER_LOT: "mv_over_lot";
295
+ readonly SPAN_OVER_BUILDING: "span_over_building";
296
+ readonly SPAN_THROUGH_CROWN: "span_through_crown";
297
+ readonly MISSING_INVERT: "missing_invert";
298
+ readonly MISSING_DIAMETER: "missing_diameter";
299
+ readonly SLOPE: "slope";
300
+ readonly SLOPE_MISMATCH: "slope_mismatch";
301
+ readonly COVER: "cover";
302
+ readonly TOO_DEEP: "too_deep";
303
+ readonly CROSSING_TOO_CLOSE: "crossing_too_close";
304
+ readonly CROSSING_ORDER: "crossing_order";
305
+ readonly LATERAL_TOO_DEEP: "lateral_too_deep";
306
+ readonly MANHOLE_SPACING: "manhole_spacing";
307
+ readonly UNKNOWN_TRANSFORMER: "unknown_transformer";
308
+ readonly TRANSFORMER_OVERLOADED: "transformer_overloaded";
309
+ readonly LV_CIRCUIT_TOO_LONG: "lv_circuit_too_long";
310
+ };
311
+ type NetworkViolationCode = (typeof NETWORK_VIOLATION)[keyof typeof NETWORK_VIOLATION];
312
+ /** One finding: the id of the node, edge or lot, and the number against its limit when there is one. */
313
+ type NetworkViolation = {
314
+ readonly code: NetworkViolationCode;
315
+ readonly id: string;
316
+ readonly detail?: string;
317
+ readonly value?: number;
318
+ readonly limit?: number;
319
+ };
320
+
321
+ /** 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. */
322
+ type NetworkGraph = {
323
+ readonly nodes: ReadonlyMap<string, NetworkNode>;
324
+ readonly edges: ReadonlyMap<string, NetworkEdge>;
325
+ /** Edges leaving a node, of one network or all. */
326
+ outgoing(nodeId: string, network?: NetworkKind): readonly NetworkEdge[];
327
+ /** Edges reaching a node, of one network or all. */
328
+ incoming(nodeId: string, network?: NetworkKind): readonly NetworkEdge[];
329
+ };
330
+ /** Indexes nodes and edges. The first of two entries with the same id wins (the validator reports the second). */
331
+ declare function buildNetworkGraph(input: {
332
+ readonly nodes: readonly NetworkNode[];
333
+ readonly edges: readonly NetworkEdge[];
334
+ }): NetworkGraph;
335
+ /**
336
+ * The nodes linked to their source by the edges of `network`: walked from the sources along the flow (supply), or back from the
337
+ * destinations against it (drain). The low voltage starts only at transformers the medium voltage reaches.
338
+ */
339
+ declare function connectedNodes(graph: NetworkGraph, network: NetworkKind): ReadonlySet<string>;
340
+ /** Horizontal length of an edge, metres (0 when an end is missing). */
341
+ declare function edgeLength(graph: NetworkGraph, edge: NetworkEdge): number;
342
+ /** 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. */
343
+ declare function circuitOf(graph: NetworkGraph, transformerId: string): ReadonlyMap<string, number>;
344
+
345
+ /** The bands from the top of the pole down. */
346
+ declare const POLE_SLOT_ORDER: readonly PoleSlotBand[];
347
+ /**
348
+ * 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,
349
+ * the first telecom cable 0.4 m under the lamp. A band never enters the one above (gap 0 at least).
350
+ */
351
+ declare const POLE_SLOT_GAPS: Readonly<Record<Exclude<PoleSlotBand, 'mv'>, number>>;
352
+ /** The 11 m double-T concrete pole, 1.7 m buried (9.3 m above the ground), with the bands of Brazilian distribution practice. */
353
+ declare const DEFAULT_POLE_SLOTS: PoleSlots;
354
+ type PoleSlotViolation = {
355
+ readonly code: 'slot_out_of_pole' | 'slot_inverted' | 'slot_order';
356
+ readonly band: PoleSlotBand;
357
+ readonly value: number;
358
+ readonly limit: number;
359
+ };
360
+ /** Every band inside the pole above the ground, bottom under top, in order and apart by the least gaps. */
361
+ declare function checkPoleSlots(slots: PoleSlots, gaps?: Readonly<Record<Exclude<PoleSlotBand, 'mv'>, number>>): PoleSlotViolation[];
362
+ /** The slots a pole of the registry declares (a distribution pole), or none. */
363
+ declare function slotsOfPole(pole: PoleDef): PoleSlots | undefined;
364
+
365
+ /** What the validator reads besides the networks: the lots' connections, the buildings and trees in the way, the ground. */
366
+ type ValidateNetworksOptions = {
367
+ /** Every connection a lot declared; each must be linked once, in `frame: 'world'`. */
368
+ readonly connections?: readonly UtilityConnection[];
369
+ /** Outlines no span may cross (a drop may end over the building of its own lot). */
370
+ readonly buildings?: readonly NetworkBuilding[];
371
+ /** Tree crowns no span may go through (from the scene's plant provider). */
372
+ readonly obstacles?: {
373
+ readonly crowns?: readonly NetworkCrown[];
374
+ };
375
+ /** 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. */
376
+ readonly surfaceAt?: (x: number, z: number) => NetworkSurface | undefined;
377
+ /** Ground level at a point. Default: 0 under a span; along a pipe, the cover levels of its two nodes. */
378
+ readonly groundAt?: (x: number, z: number) => number;
379
+ };
380
+
381
+ /**
382
+ * 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,
383
+ * spans (reach, sag, clearance, buildings, crowns), pipes (slope, cover, depth, crossings) and transformers (loading, circuit length).
384
+ * Pure and in input order: the same networks give the same list.
385
+ */
386
+ declare function validateNetworks(networks: UtilityNetworks, options?: ValidateNetworksOptions): NetworkViolation[];
387
+
388
+ /** The axis a straight street runs along. */
389
+ type RunAxis = 'x' | 'z';
390
+
391
+ /** 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. */
392
+ type RunEnd = 'edge' | 'river' | 'line_end';
393
+ /** Another run crossing this one: `at` is its axis along this run, `half` the half width of its roadway. */
394
+ type RunCrossing = {
395
+ readonly run: string;
396
+ readonly at: number;
397
+ readonly half: number;
398
+ };
399
+ /** A straight stretch of street between two river banks or line ends, in its own frame (`u` along, `v` across). */
400
+ type StreetRun = {
401
+ readonly id: string;
402
+ readonly line: string;
403
+ readonly along: RunAxis;
404
+ /** z of a street along x, x of one along z. */
405
+ readonly axis: number;
406
+ readonly width: number;
407
+ readonly from: number;
408
+ readonly to: number;
409
+ readonly ends: readonly [RunEnd, RunEnd];
410
+ readonly crossings: readonly RunCrossing[];
411
+ };
412
+ /** A lot of the site: its id and its rectangle on the plan. */
413
+ type NetworkLot = {
414
+ readonly id: string;
415
+ readonly rect: PlanRect;
416
+ };
417
+ /** 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. */
418
+ type ServedLot = {
419
+ readonly lot: NetworkLot;
420
+ readonly run: StreetRun;
421
+ readonly side: 1 | -1;
422
+ readonly span: readonly [number, number];
423
+ readonly front: number;
424
+ };
425
+
426
+ type GroundAt = (x: number, z: number) => number;
427
+ /**
428
+ * 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
429
+ * under it) and the water stand behind the front wall, the inspection box 1 m inside the front, the downspout outlet at the kerb.
430
+ */
431
+ declare function defaultConnectionsOf({ served, rules, groundAt }: {
432
+ readonly served: ServedLot;
433
+ readonly rules: NetworkRules;
434
+ readonly groundAt: GroundAt;
435
+ }): UtilityConnection[];
436
+
437
+ /**
438
+ * 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):
439
+ * 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.
440
+ */
441
+ type NetworkWarning = {
442
+ readonly code: 'pole_on_avoid' | 'transformer_over_capacity' | 'lot_out_of_reach';
443
+ readonly id: string;
444
+ readonly detail?: string;
445
+ };
446
+
447
+ type GenerateNetworksParams = {
448
+ readonly plan: CityPlanInput;
449
+ /** The lots of the site; each takes the networks from the street it faces. */
450
+ readonly lots: readonly NetworkLot[];
451
+ /** What the lots declared (`frame: 'world'`); a lot that declared none of a network gets the default point from its rectangle. */
452
+ readonly connections?: readonly UtilityConnection[];
453
+ /** A game's numbers over the defaults. */
454
+ readonly rules?: DeepPartial<NetworkRules>;
455
+ /** Draws (illegal hookups, telecom bundles) come from the hash of the seed and an id, never from a scene's random. */
456
+ readonly seed: number;
457
+ /** Ground no pole may stand on: the front of every gate and door, the meter posts. */
458
+ readonly avoid?: readonly PlanRect[];
459
+ /** Ground level at a point. Default 0 (the flat ground of a levelled city). */
460
+ readonly groundAt?: GroundAt;
461
+ /** The distribution pole of the registry: its bands and its lamp's reach are read from its spec. Default `concrete_distribution`. */
462
+ readonly pole?: {
463
+ readonly id: string;
464
+ readonly spec: DistributionSpec;
465
+ };
466
+ };
467
+ type GeneratedNetworks = {
468
+ readonly networks: UtilityNetworks;
469
+ /** Every connection the networks link (the declared ones and the defaults), for `validateNetworks`. */
470
+ readonly connections: readonly UtilityConnection[];
471
+ /** Road, sidewalk or lot under a point, from the plan's streets: the `surfaceAt` of `validateNetworks`. */
472
+ readonly surfaceAt: (x: number, z: number) => NetworkSurface;
473
+ /** What the generator laid against its own rules because nothing else fit (empty for a plan it can lay). */
474
+ readonly warnings: readonly NetworkWarning[];
475
+ };
476
+ /** What lies under a point: the roadway or the sidewalk of a street of the plan, else a lot. */
477
+ declare function surfaceOf({ runs, sidewalk }: {
478
+ readonly runs: readonly StreetRun[];
479
+ readonly sidewalk: number;
480
+ }): (x: number, z: number) => NetworkSurface;
481
+ /**
482
+ * 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
483
+ * leaves the map, transformers sized by the diversified demand, low voltage, a drop to every lot), a lamp on every street pole, telecom, sewer
484
+ * 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.
485
+ */
486
+ declare function generateNetworks(params: GenerateNetworksParams): GeneratedNetworks;
487
+
488
+ export { type AerialClass, type AerialEdgeKind, type BuriedEdgeKind, CONNECTION_NETWORK, type ClearanceRow, type CoverRange, DEFAULT_NETWORK_LAYOUT, DEFAULT_NETWORK_RULES, DEFAULT_POLE_SLOTS, type DefaultConnectionRules, DistributionSpec, type DiversityBand, EDGE_CLASS, EDGE_NETWORK, type GenerateNetworksParams, type GeneratedNetworks, type GroundAt, NETWORK_ENDS, NETWORK_FLOW, NETWORK_VIOLATION, type NetworkBuilding, type NetworkClass, type NetworkCrown, type NetworkEdge, type NetworkEdgeKind, type NetworkGraph, type NetworkKind, type NetworkLayoutRules, type NetworkLot, type NetworkNode, type NetworkNodeKind, type NetworkRules, type NetworkSurface, type NetworkViolation, type NetworkViolationCode, type NetworkWarning, POLE_SLOT_GAPS, POLE_SLOT_ORDER, PoleSlotBand, type PoleSlotViolation, PoleSlots, type PowerRules, type RunEnd, type ServedLot, type StreetRun, type TransformerRating, type UtilityNetworks, type ValidateNetworksOptions, buildNetworkGraph, checkPoleSlots, circuitOf, connectedNodes, defaultConnectionsOf, diversifiedDemand, edgeLength, generateNetworks, isAerialEdgeKind, pickTransformer, resolveNetworkRules, slotsOfPole, surfaceOf, validateNetworks };