@chrtco/sdk 0.10.37 → 0.10.39
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 +190 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +190 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24353,6 +24353,23 @@ function buildPlaceNameLayers(sourceId) {
|
|
|
24353
24353
|
}
|
|
24354
24354
|
var DRGNOTE_SOURCE_LAYER = "DRGNOTE";
|
|
24355
24355
|
var DRGNOTE_LABEL_PRIORITY = 300;
|
|
24356
|
+
var BRGNOTE_SOURCE_LAYER = "BRGNOTE";
|
|
24357
|
+
var BRGNOTE_MINZOOM = 13;
|
|
24358
|
+
var BRGNOTE_LABEL_PRIORITY = 320;
|
|
24359
|
+
var BRGNOTE_CATBRG_TEXT = {
|
|
24360
|
+
"1": "FIXED BRIDGE",
|
|
24361
|
+
"2": "OPENING BRIDGE",
|
|
24362
|
+
"3": "SWING BRIDGE",
|
|
24363
|
+
"4": "VERT LIFT BRIDGE",
|
|
24364
|
+
"5": "BASCULE BRIDGE",
|
|
24365
|
+
"6": "PONTOON BRIDGE",
|
|
24366
|
+
"7": "DRAW BRIDGE",
|
|
24367
|
+
"8": "TRANSPORTER BRIDGE",
|
|
24368
|
+
"9": "FOOTBRIDGE",
|
|
24369
|
+
"10": "VIADUCT",
|
|
24370
|
+
"11": "AQUEDUCT",
|
|
24371
|
+
"12": "SUSPENSION BRIDGE"
|
|
24372
|
+
};
|
|
24356
24373
|
var DRGNOTE_MINZOOM = 13;
|
|
24357
24374
|
var DRGNOTE_FULL_ZOOM = 16;
|
|
24358
24375
|
var DRGNOTE_MIN_TEXT_PX = 1;
|
|
@@ -24542,6 +24559,147 @@ function buildDredgeNoteLayers(sourceId, palette = "DAY", depthUnits = "meters")
|
|
|
24542
24559
|
}
|
|
24543
24560
|
];
|
|
24544
24561
|
}
|
|
24562
|
+
function buildBridgeNoteLayers(sourceId, palette = "DAY", depthUnits = "meters") {
|
|
24563
|
+
const imperial = depthUnits === "feet";
|
|
24564
|
+
const unit = imperial ? " FT" : " M";
|
|
24565
|
+
const measure = (prop) => imperial ? [
|
|
24566
|
+
"concat",
|
|
24567
|
+
["to-string", ["floor", ["+", 0.5, ["*", 3.28084, ["to-number", ["get", prop]]]]]],
|
|
24568
|
+
unit
|
|
24569
|
+
] : [
|
|
24570
|
+
"concat",
|
|
24571
|
+
["to-string", ["/", ["floor", ["+", 0.5, ["*", 10, ["to-number", ["get", prop]]]]], 10]],
|
|
24572
|
+
unit
|
|
24573
|
+
];
|
|
24574
|
+
const clearance = (prop, prefix, suffix = "") => [
|
|
24575
|
+
"case",
|
|
24576
|
+
[
|
|
24577
|
+
"all",
|
|
24578
|
+
["!", ["get", "conflict"]],
|
|
24579
|
+
["!=", ["to-string", ["get", prop]], ""]
|
|
24580
|
+
],
|
|
24581
|
+
["concat", "\n", prefix, measure(prop), suffix],
|
|
24582
|
+
""
|
|
24583
|
+
];
|
|
24584
|
+
const clearances = [
|
|
24585
|
+
"concat",
|
|
24586
|
+
clearance("horclr_m", "HOR CL "),
|
|
24587
|
+
clearance("verclr_m", "VERT CL "),
|
|
24588
|
+
clearance("verccl_m", "VERT CL ", " DOWN"),
|
|
24589
|
+
clearance("vercop_m", "VERT CL ", " UP"),
|
|
24590
|
+
clearance("cable_m", "OVHD PWR CAB AUTH CL ")
|
|
24591
|
+
];
|
|
24592
|
+
const typeText = [
|
|
24593
|
+
"match",
|
|
24594
|
+
["to-string", ["get", "cat"]],
|
|
24595
|
+
...Object.entries(BRGNOTE_CATBRG_TEXT).flatMap(([k, v]) => [k, v]),
|
|
24596
|
+
"BRIDGE"
|
|
24597
|
+
];
|
|
24598
|
+
const fullName = ["upcase", ["to-string", ["coalesce", ["get", "name"], ""]]];
|
|
24599
|
+
const shortName = [
|
|
24600
|
+
"let",
|
|
24601
|
+
"n",
|
|
24602
|
+
fullName,
|
|
24603
|
+
[
|
|
24604
|
+
"case",
|
|
24605
|
+
[">", ["index-of", " ", ["var", "n"]], 0],
|
|
24606
|
+
["slice", ["var", "n"], 0, ["index-of", " ", ["var", "n"]]],
|
|
24607
|
+
["var", "n"]
|
|
24608
|
+
]
|
|
24609
|
+
];
|
|
24610
|
+
const named = (which) => [
|
|
24611
|
+
"case",
|
|
24612
|
+
[">", ["length", ["to-string", ["coalesce", ["get", "name"], ""]]], 0],
|
|
24613
|
+
["concat", which, "\n", typeText, clearances],
|
|
24614
|
+
["concat", typeText, clearances]
|
|
24615
|
+
];
|
|
24616
|
+
const alone = (body) => [
|
|
24617
|
+
"let",
|
|
24618
|
+
"b",
|
|
24619
|
+
body,
|
|
24620
|
+
[
|
|
24621
|
+
"case",
|
|
24622
|
+
["==", ["slice", ["var", "b"], 0, 1], "\n"],
|
|
24623
|
+
["slice", ["var", "b"], 1],
|
|
24624
|
+
["var", "b"]
|
|
24625
|
+
]
|
|
24626
|
+
];
|
|
24627
|
+
const noteField = [
|
|
24628
|
+
"step",
|
|
24629
|
+
["to-number", ["coalesce", ["get", "rung"], 0]],
|
|
24630
|
+
named(fullName),
|
|
24631
|
+
// rung 0
|
|
24632
|
+
1,
|
|
24633
|
+
named(shortName),
|
|
24634
|
+
// rung 1
|
|
24635
|
+
2,
|
|
24636
|
+
["concat", typeText, clearances],
|
|
24637
|
+
3,
|
|
24638
|
+
alone(clearances),
|
|
24639
|
+
4,
|
|
24640
|
+
alone([
|
|
24641
|
+
"concat",
|
|
24642
|
+
clearance("verclr_m", "VERT CL "),
|
|
24643
|
+
clearance("verccl_m", "VERT CL ", " DOWN"),
|
|
24644
|
+
clearance("vercop_m", "VERT CL ", " UP")
|
|
24645
|
+
])
|
|
24646
|
+
];
|
|
24647
|
+
return [
|
|
24648
|
+
{
|
|
24649
|
+
id: "chrt-bridge-note-label",
|
|
24650
|
+
type: "symbol",
|
|
24651
|
+
source: sourceId,
|
|
24652
|
+
"source-layer": BRGNOTE_SOURCE_LAYER,
|
|
24653
|
+
minzoom: BRGNOTE_MINZOOM,
|
|
24654
|
+
layout: {
|
|
24655
|
+
"text-field": noteField,
|
|
24656
|
+
"text-font": ["Open Sans Regular"],
|
|
24657
|
+
// Fitted at build time against the land the note has to sit on, in px
|
|
24658
|
+
// at z15, then doubled per zoom — the same geographic sizing DRGNOTE
|
|
24659
|
+
// uses, and for the same reason: a note that keeps its proportion to
|
|
24660
|
+
// its own bridge is how the eye tells which crossing it describes.
|
|
24661
|
+
//
|
|
24662
|
+
// The zoom test is the DIRECT input of this interpolate. Nested any
|
|
24663
|
+
// deeper it is invalid in a paint or layout property and MapLibre
|
|
24664
|
+
// drops the whole layer, silently — which is exactly how CHRTland's
|
|
24665
|
+
// contours went unrendered on every client (see zoom-expression-guard).
|
|
24666
|
+
"text-size": [
|
|
24667
|
+
"interpolate",
|
|
24668
|
+
["exponential", 2],
|
|
24669
|
+
["zoom"],
|
|
24670
|
+
15,
|
|
24671
|
+
["to-number", ["coalesce", ["get", imperial ? "size_ft" : "size_m"], 4]],
|
|
24672
|
+
16,
|
|
24673
|
+
["*", 2, ["to-number", ["coalesce", ["get", imperial ? "size_ft" : "size_m"], 4]]]
|
|
24674
|
+
],
|
|
24675
|
+
"text-transform": "uppercase",
|
|
24676
|
+
"text-letter-spacing": 0.08,
|
|
24677
|
+
"text-line-height": 1.2,
|
|
24678
|
+
// Every break here is an explicit "\n" this expression chose. A wrap
|
|
24679
|
+
// on top of that would re-flow lines nothing measured.
|
|
24680
|
+
"text-max-width": 512,
|
|
24681
|
+
// NOT rotated. A dredge note lies along its channel because the
|
|
24682
|
+
// channel has a direction; a bridge note sits on the bank and reads
|
|
24683
|
+
// horizontally, as the paper chart sets it.
|
|
24684
|
+
"text-anchor": "center",
|
|
24685
|
+
"text-padding": 3,
|
|
24686
|
+
"text-allow-overlap": false,
|
|
24687
|
+
"text-ignore-placement": false,
|
|
24688
|
+
"text-optional": true
|
|
24689
|
+
},
|
|
24690
|
+
paint: {
|
|
24691
|
+
"text-color": resolveColor("CHBLK", palette),
|
|
24692
|
+
// Haloed against the land tint it sits on, not the water.
|
|
24693
|
+
"text-halo-color": resolveColor("LANDA", palette),
|
|
24694
|
+
"text-halo-width": 1
|
|
24695
|
+
},
|
|
24696
|
+
metadata: {
|
|
24697
|
+
"chrt:bridgeNote": true,
|
|
24698
|
+
"chrt:labelPriority": BRGNOTE_LABEL_PRIORITY
|
|
24699
|
+
}
|
|
24700
|
+
}
|
|
24701
|
+
];
|
|
24702
|
+
}
|
|
24545
24703
|
|
|
24546
24704
|
// src/atlas/feature-decimation.ts
|
|
24547
24705
|
function getGridSizeForZoom(zoom) {
|
|
@@ -28683,6 +28841,17 @@ function isExemptOpaqueFill(layer) {
|
|
|
28683
28841
|
}
|
|
28684
28842
|
return false;
|
|
28685
28843
|
}
|
|
28844
|
+
var GROUND_FILL_CLASSES = /* @__PURE__ */ new Set([
|
|
28845
|
+
...DOMINANCE_EXEMPT_FILL_CLASSES,
|
|
28846
|
+
"RIVERS"
|
|
28847
|
+
]);
|
|
28848
|
+
function isGroundFill(layer) {
|
|
28849
|
+
if (layer.type !== "fill") return false;
|
|
28850
|
+
for (const cls of GROUND_FILL_CLASSES) {
|
|
28851
|
+
if (layer.id.startsWith(`s52-${cls}-`)) return true;
|
|
28852
|
+
}
|
|
28853
|
+
return false;
|
|
28854
|
+
}
|
|
28686
28855
|
var FILL_FLOOR_FREE_BANDS = /* @__PURE__ */ new Set([
|
|
28687
28856
|
"1",
|
|
28688
28857
|
"2",
|
|
@@ -28690,10 +28859,10 @@ var FILL_FLOOR_FREE_BANDS = /* @__PURE__ */ new Set([
|
|
|
28690
28859
|
]);
|
|
28691
28860
|
function bandVariantMinzoom(layer, B) {
|
|
28692
28861
|
const classMinzoom = layer.minzoom ?? 0;
|
|
28693
|
-
if (
|
|
28694
|
-
return
|
|
28862
|
+
if (isGroundFill(layer) && FILL_FLOOR_FREE_BANDS.has(B)) {
|
|
28863
|
+
return 0;
|
|
28695
28864
|
}
|
|
28696
|
-
if (
|
|
28865
|
+
if (isGroundFill(layer)) {
|
|
28697
28866
|
return BAND_PRIORITY_RANGES[B].minzoom;
|
|
28698
28867
|
}
|
|
28699
28868
|
return Math.max(classMinzoom, BAND_PRIORITY_RANGES[B].minzoom);
|
|
@@ -30122,6 +30291,15 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
30122
30291
|
),
|
|
30123
30292
|
DRGNOTE_LABEL_PRIORITY
|
|
30124
30293
|
);
|
|
30294
|
+
spliceByLabelPriority(
|
|
30295
|
+
labelLayers,
|
|
30296
|
+
buildBridgeNoteLayers(
|
|
30297
|
+
sourceId,
|
|
30298
|
+
palette,
|
|
30299
|
+
opts.depthUnits ?? "meters"
|
|
30300
|
+
),
|
|
30301
|
+
BRGNOTE_LABEL_PRIORITY
|
|
30302
|
+
);
|
|
30125
30303
|
layers.push(...labelLayers);
|
|
30126
30304
|
} else {
|
|
30127
30305
|
const emitBand = (base, code) => bandFan === "legacy" ? makeBandVariants(base, code) : makeCollapsedBandVariant(base, code, isDominanceExempt(base));
|
|
@@ -30218,6 +30396,15 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
30218
30396
|
),
|
|
30219
30397
|
DRGNOTE_LABEL_PRIORITY
|
|
30220
30398
|
);
|
|
30399
|
+
spliceByLabelPriority(
|
|
30400
|
+
labelLayers,
|
|
30401
|
+
buildBridgeNoteLayers(
|
|
30402
|
+
sourceId,
|
|
30403
|
+
palette,
|
|
30404
|
+
opts.depthUnits ?? "meters"
|
|
30405
|
+
),
|
|
30406
|
+
BRGNOTE_LABEL_PRIORITY
|
|
30407
|
+
);
|
|
30221
30408
|
layers.push(...labelLayers);
|
|
30222
30409
|
}
|
|
30223
30410
|
const symbolSet = opts.symbolSet ?? "s52";
|