@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.cjs
CHANGED
|
@@ -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) {
|
|
@@ -28908,6 +29066,17 @@ function isExemptOpaqueFill(layer) {
|
|
|
28908
29066
|
}
|
|
28909
29067
|
return false;
|
|
28910
29068
|
}
|
|
29069
|
+
var GROUND_FILL_CLASSES = /* @__PURE__ */ new Set([
|
|
29070
|
+
...DOMINANCE_EXEMPT_FILL_CLASSES,
|
|
29071
|
+
"RIVERS"
|
|
29072
|
+
]);
|
|
29073
|
+
function isGroundFill(layer) {
|
|
29074
|
+
if (layer.type !== "fill") return false;
|
|
29075
|
+
for (const cls of GROUND_FILL_CLASSES) {
|
|
29076
|
+
if (layer.id.startsWith(`s52-${cls}-`)) return true;
|
|
29077
|
+
}
|
|
29078
|
+
return false;
|
|
29079
|
+
}
|
|
28911
29080
|
var FILL_FLOOR_FREE_BANDS = /* @__PURE__ */ new Set([
|
|
28912
29081
|
"1",
|
|
28913
29082
|
"2",
|
|
@@ -28915,10 +29084,10 @@ var FILL_FLOOR_FREE_BANDS = /* @__PURE__ */ new Set([
|
|
|
28915
29084
|
]);
|
|
28916
29085
|
function bandVariantMinzoom(layer, B) {
|
|
28917
29086
|
const classMinzoom = layer.minzoom ?? 0;
|
|
28918
|
-
if (
|
|
28919
|
-
return
|
|
29087
|
+
if (isGroundFill(layer) && FILL_FLOOR_FREE_BANDS.has(B)) {
|
|
29088
|
+
return 0;
|
|
28920
29089
|
}
|
|
28921
|
-
if (
|
|
29090
|
+
if (isGroundFill(layer)) {
|
|
28922
29091
|
return BAND_PRIORITY_RANGES[B].minzoom;
|
|
28923
29092
|
}
|
|
28924
29093
|
return Math.max(classMinzoom, BAND_PRIORITY_RANGES[B].minzoom);
|
|
@@ -30347,6 +30516,15 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
30347
30516
|
),
|
|
30348
30517
|
DRGNOTE_LABEL_PRIORITY
|
|
30349
30518
|
);
|
|
30519
|
+
spliceByLabelPriority(
|
|
30520
|
+
labelLayers,
|
|
30521
|
+
buildBridgeNoteLayers(
|
|
30522
|
+
sourceId,
|
|
30523
|
+
palette,
|
|
30524
|
+
opts.depthUnits ?? "meters"
|
|
30525
|
+
),
|
|
30526
|
+
BRGNOTE_LABEL_PRIORITY
|
|
30527
|
+
);
|
|
30350
30528
|
layers.push(...labelLayers);
|
|
30351
30529
|
} else {
|
|
30352
30530
|
const emitBand = (base, code) => bandFan === "legacy" ? makeBandVariants(base, code) : makeCollapsedBandVariant(base, code, isDominanceExempt(base));
|
|
@@ -30443,6 +30621,15 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
30443
30621
|
),
|
|
30444
30622
|
DRGNOTE_LABEL_PRIORITY
|
|
30445
30623
|
);
|
|
30624
|
+
spliceByLabelPriority(
|
|
30625
|
+
labelLayers,
|
|
30626
|
+
buildBridgeNoteLayers(
|
|
30627
|
+
sourceId,
|
|
30628
|
+
palette,
|
|
30629
|
+
opts.depthUnits ?? "meters"
|
|
30630
|
+
),
|
|
30631
|
+
BRGNOTE_LABEL_PRIORITY
|
|
30632
|
+
);
|
|
30446
30633
|
layers.push(...labelLayers);
|
|
30447
30634
|
}
|
|
30448
30635
|
const symbolSet = opts.symbolSet ?? "s52";
|