@adatechnology/game-urban 0.4.0 → 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.
@@ -1,6 +1,6 @@
1
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';
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
4
  import '@adatechnology/game-floorplan';
5
5
 
6
6
  /** Where a lot takes each network when it declares none (a building of `fillBlock`, a lot whose house has no utilities yet), metres. */
@@ -119,6 +119,12 @@ type TransformerRating = {
119
119
  type PowerRules = {
120
120
  /** Longest service drop, metres (horizontal). */
121
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;
122
128
  /** Longest low voltage path from the transformer to its farthest node, each way, metres. */
123
129
  readonly lvCircuitMaxLength: number;
124
130
  /** Highest demand over the rating. */
@@ -289,6 +295,10 @@ declare const NETWORK_VIOLATION: {
289
295
  readonly ORPHAN_CONNECTION: "orphan_connection";
290
296
  readonly CONNECTION_MOVED: "connection_moved";
291
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";
292
302
  readonly MISSING_SAG: "missing_sag";
293
303
  readonly CLEARANCE: "clearance";
294
304
  readonly MV_OVER_LOT: "mv_over_lot";
@@ -362,6 +372,48 @@ declare function checkPoleSlots(slots: PoleSlots, gaps?: Readonly<Record<Exclude
362
372
  /** The slots a pole of the registry declares (a distribution pole), or none. */
363
373
  declare function slotsOfPole(pole: PoleDef): PoleSlots | undefined;
364
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
+
365
417
  /** What the validator reads besides the networks: the lots' connections, the buildings and trees in the way, the ground. */
366
418
  type ValidateNetworksOptions = {
367
419
  /** Every connection a lot declared; each must be linked once, in `frame: 'world'`. */
@@ -376,6 +428,8 @@ type ValidateNetworksOptions = {
376
428
  readonly surfaceAt?: (x: number, z: number) => NetworkSurface | undefined;
377
429
  /** Ground level at a point. Default: 0 under a span; along a pipe, the cover levels of its two nodes. */
378
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[];
379
433
  };
380
434
 
381
435
  /**
@@ -385,9 +439,6 @@ type ValidateNetworksOptions = {
385
439
  */
386
440
  declare function validateNetworks(networks: UtilityNetworks, options?: ValidateNetworksOptions): NetworkViolation[];
387
441
 
388
- /** The axis a straight street runs along. */
389
- type RunAxis = 'x' | 'z';
390
-
391
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. */
392
443
  type RunEnd = 'edge' | 'river' | 'line_end';
393
444
  /** Another run crossing this one: `at` is its axis along this run, `half` the half width of its roadway. */
@@ -439,7 +490,7 @@ declare function defaultConnectionsOf({ served, rules, groundAt }: {
439
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.
440
491
  */
441
492
  type NetworkWarning = {
442
- readonly code: 'pole_on_avoid' | 'transformer_over_capacity' | 'lot_out_of_reach';
493
+ readonly code: 'pole_on_avoid' | 'transformer_over_capacity' | 'lot_out_of_reach' | 'drop_off_practice';
443
494
  readonly id: string;
444
495
  readonly detail?: string;
445
496
  };
@@ -470,6 +521,8 @@ type GeneratedNetworks = {
470
521
  readonly connections: readonly UtilityConnection[];
471
522
  /** Road, sidewalk or lot under a point, from the plan's streets: the `surfaceAt` of `validateNetworks`. */
472
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[];
473
526
  /** What the generator laid against its own rules because nothing else fit (empty for a plan it can lay). */
474
527
  readonly warnings: readonly NetworkWarning[];
475
528
  };
@@ -478,6 +531,11 @@ declare function surfaceOf({ runs, sidewalk }: {
478
531
  readonly runs: readonly StreetRun[];
479
532
  readonly sidewalk: number;
480
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[];
481
539
  /**
482
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
483
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
@@ -485,4 +543,105 @@ declare function surfaceOf({ runs, sidewalk }: {
485
543
  */
486
544
  declare function generateNetworks(params: GenerateNetworksParams): GeneratedNetworks;
487
545
 
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 };
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 };