@chrtco/sdk 0.10.36 → 0.10.38

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/dist/index.cjs CHANGED
@@ -593,7 +593,7 @@ var BASE_REGION = "CHRT_BASE";
593
593
  var BASE_MINZOOM = 0;
594
594
  var BASE_MAXZOOM = 11;
595
595
  var RELIEF_MINZOOM = 9;
596
- var RELIEF_MAXZOOM = 12;
596
+ var RELIEF_MAXZOOM = 13;
597
597
  var RELIEF_TILE_SIZE = 512;
598
598
  var BUILD_PARAM = "v";
599
599
  function tileTemplate(base, region, extension, buildId) {
@@ -24578,6 +24578,23 @@ function buildPlaceNameLayers(sourceId) {
24578
24578
  }
24579
24579
  var DRGNOTE_SOURCE_LAYER = "DRGNOTE";
24580
24580
  var DRGNOTE_LABEL_PRIORITY = 300;
24581
+ var BRGNOTE_SOURCE_LAYER = "BRGNOTE";
24582
+ var BRGNOTE_MINZOOM = 13;
24583
+ var BRGNOTE_LABEL_PRIORITY = 320;
24584
+ var BRGNOTE_CATBRG_TEXT = {
24585
+ "1": "FIXED BRIDGE",
24586
+ "2": "OPENING BRIDGE",
24587
+ "3": "SWING BRIDGE",
24588
+ "4": "VERT LIFT BRIDGE",
24589
+ "5": "BASCULE BRIDGE",
24590
+ "6": "PONTOON BRIDGE",
24591
+ "7": "DRAW BRIDGE",
24592
+ "8": "TRANSPORTER BRIDGE",
24593
+ "9": "FOOTBRIDGE",
24594
+ "10": "VIADUCT",
24595
+ "11": "AQUEDUCT",
24596
+ "12": "SUSPENSION BRIDGE"
24597
+ };
24581
24598
  var DRGNOTE_MINZOOM = 13;
24582
24599
  var DRGNOTE_FULL_ZOOM = 16;
24583
24600
  var DRGNOTE_MIN_TEXT_PX = 1;
@@ -24767,6 +24784,147 @@ function buildDredgeNoteLayers(sourceId, palette = "DAY", depthUnits = "meters")
24767
24784
  }
24768
24785
  ];
24769
24786
  }
24787
+ function buildBridgeNoteLayers(sourceId, palette = "DAY", depthUnits = "meters") {
24788
+ const imperial = depthUnits === "feet";
24789
+ const unit = imperial ? " FT" : " M";
24790
+ const measure = (prop) => imperial ? [
24791
+ "concat",
24792
+ ["to-string", ["floor", ["+", 0.5, ["*", 3.28084, ["to-number", ["get", prop]]]]]],
24793
+ unit
24794
+ ] : [
24795
+ "concat",
24796
+ ["to-string", ["/", ["floor", ["+", 0.5, ["*", 10, ["to-number", ["get", prop]]]]], 10]],
24797
+ unit
24798
+ ];
24799
+ const clearance = (prop, prefix, suffix = "") => [
24800
+ "case",
24801
+ [
24802
+ "all",
24803
+ ["!", ["get", "conflict"]],
24804
+ ["!=", ["to-string", ["get", prop]], ""]
24805
+ ],
24806
+ ["concat", "\n", prefix, measure(prop), suffix],
24807
+ ""
24808
+ ];
24809
+ const clearances = [
24810
+ "concat",
24811
+ clearance("horclr_m", "HOR CL "),
24812
+ clearance("verclr_m", "VERT CL "),
24813
+ clearance("verccl_m", "VERT CL ", " DOWN"),
24814
+ clearance("vercop_m", "VERT CL ", " UP"),
24815
+ clearance("cable_m", "OVHD PWR CAB AUTH CL ")
24816
+ ];
24817
+ const typeText = [
24818
+ "match",
24819
+ ["to-string", ["get", "cat"]],
24820
+ ...Object.entries(BRGNOTE_CATBRG_TEXT).flatMap(([k, v]) => [k, v]),
24821
+ "BRIDGE"
24822
+ ];
24823
+ const fullName = ["upcase", ["to-string", ["coalesce", ["get", "name"], ""]]];
24824
+ const shortName = [
24825
+ "let",
24826
+ "n",
24827
+ fullName,
24828
+ [
24829
+ "case",
24830
+ [">", ["index-of", " ", ["var", "n"]], 0],
24831
+ ["slice", ["var", "n"], 0, ["index-of", " ", ["var", "n"]]],
24832
+ ["var", "n"]
24833
+ ]
24834
+ ];
24835
+ const named = (which) => [
24836
+ "case",
24837
+ [">", ["length", ["to-string", ["coalesce", ["get", "name"], ""]]], 0],
24838
+ ["concat", which, "\n", typeText, clearances],
24839
+ ["concat", typeText, clearances]
24840
+ ];
24841
+ const alone = (body) => [
24842
+ "let",
24843
+ "b",
24844
+ body,
24845
+ [
24846
+ "case",
24847
+ ["==", ["slice", ["var", "b"], 0, 1], "\n"],
24848
+ ["slice", ["var", "b"], 1],
24849
+ ["var", "b"]
24850
+ ]
24851
+ ];
24852
+ const noteField = [
24853
+ "step",
24854
+ ["to-number", ["coalesce", ["get", "rung"], 0]],
24855
+ named(fullName),
24856
+ // rung 0
24857
+ 1,
24858
+ named(shortName),
24859
+ // rung 1
24860
+ 2,
24861
+ ["concat", typeText, clearances],
24862
+ 3,
24863
+ alone(clearances),
24864
+ 4,
24865
+ alone([
24866
+ "concat",
24867
+ clearance("verclr_m", "VERT CL "),
24868
+ clearance("verccl_m", "VERT CL ", " DOWN"),
24869
+ clearance("vercop_m", "VERT CL ", " UP")
24870
+ ])
24871
+ ];
24872
+ return [
24873
+ {
24874
+ id: "chrt-bridge-note-label",
24875
+ type: "symbol",
24876
+ source: sourceId,
24877
+ "source-layer": BRGNOTE_SOURCE_LAYER,
24878
+ minzoom: BRGNOTE_MINZOOM,
24879
+ layout: {
24880
+ "text-field": noteField,
24881
+ "text-font": ["Open Sans Regular"],
24882
+ // Fitted at build time against the land the note has to sit on, in px
24883
+ // at z15, then doubled per zoom — the same geographic sizing DRGNOTE
24884
+ // uses, and for the same reason: a note that keeps its proportion to
24885
+ // its own bridge is how the eye tells which crossing it describes.
24886
+ //
24887
+ // The zoom test is the DIRECT input of this interpolate. Nested any
24888
+ // deeper it is invalid in a paint or layout property and MapLibre
24889
+ // drops the whole layer, silently — which is exactly how CHRTland's
24890
+ // contours went unrendered on every client (see zoom-expression-guard).
24891
+ "text-size": [
24892
+ "interpolate",
24893
+ ["exponential", 2],
24894
+ ["zoom"],
24895
+ 15,
24896
+ ["to-number", ["coalesce", ["get", imperial ? "size_ft" : "size_m"], 4]],
24897
+ 16,
24898
+ ["*", 2, ["to-number", ["coalesce", ["get", imperial ? "size_ft" : "size_m"], 4]]]
24899
+ ],
24900
+ "text-transform": "uppercase",
24901
+ "text-letter-spacing": 0.08,
24902
+ "text-line-height": 1.2,
24903
+ // Every break here is an explicit "\n" this expression chose. A wrap
24904
+ // on top of that would re-flow lines nothing measured.
24905
+ "text-max-width": 512,
24906
+ // NOT rotated. A dredge note lies along its channel because the
24907
+ // channel has a direction; a bridge note sits on the bank and reads
24908
+ // horizontally, as the paper chart sets it.
24909
+ "text-anchor": "center",
24910
+ "text-padding": 3,
24911
+ "text-allow-overlap": false,
24912
+ "text-ignore-placement": false,
24913
+ "text-optional": true
24914
+ },
24915
+ paint: {
24916
+ "text-color": resolveColor("CHBLK", palette),
24917
+ // Haloed against the land tint it sits on, not the water.
24918
+ "text-halo-color": resolveColor("LANDA", palette),
24919
+ "text-halo-width": 1
24920
+ },
24921
+ metadata: {
24922
+ "chrt:bridgeNote": true,
24923
+ "chrt:labelPriority": BRGNOTE_LABEL_PRIORITY
24924
+ }
24925
+ }
24926
+ ];
24927
+ }
24770
24928
 
24771
24929
  // src/atlas/feature-decimation.ts
24772
24930
  function getGridSizeForZoom(zoom) {
@@ -30347,6 +30505,15 @@ function generateStyle(palette = "DAY", opts = {}) {
30347
30505
  ),
30348
30506
  DRGNOTE_LABEL_PRIORITY
30349
30507
  );
30508
+ spliceByLabelPriority(
30509
+ labelLayers,
30510
+ buildBridgeNoteLayers(
30511
+ sourceId,
30512
+ palette,
30513
+ opts.depthUnits ?? "meters"
30514
+ ),
30515
+ BRGNOTE_LABEL_PRIORITY
30516
+ );
30350
30517
  layers.push(...labelLayers);
30351
30518
  } else {
30352
30519
  const emitBand = (base, code) => bandFan === "legacy" ? makeBandVariants(base, code) : makeCollapsedBandVariant(base, code, isDominanceExempt(base));
@@ -30443,6 +30610,15 @@ function generateStyle(palette = "DAY", opts = {}) {
30443
30610
  ),
30444
30611
  DRGNOTE_LABEL_PRIORITY
30445
30612
  );
30613
+ spliceByLabelPriority(
30614
+ labelLayers,
30615
+ buildBridgeNoteLayers(
30616
+ sourceId,
30617
+ palette,
30618
+ opts.depthUnits ?? "meters"
30619
+ ),
30620
+ BRGNOTE_LABEL_PRIORITY
30621
+ );
30446
30622
  layers.push(...labelLayers);
30447
30623
  }
30448
30624
  const symbolSet = opts.symbolSet ?? "s52";