@chrtco/sdk 0.10.23 → 0.10.24
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 +81 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22431,13 +22431,23 @@ var HAS_OBJNAM = [
|
|
|
22431
22431
|
["has", "OBJNAM"],
|
|
22432
22432
|
["!=", ["coalesce", ["get", "OBJNAM"], ""], ""]
|
|
22433
22433
|
];
|
|
22434
|
+
var OBJNAM_TEXT = [
|
|
22435
|
+
"case",
|
|
22436
|
+
[
|
|
22437
|
+
"all",
|
|
22438
|
+
["has", "NOBJNM"],
|
|
22439
|
+
[">=", ["index-of", "?", ["coalesce", ["get", "OBJNAM"], ""]], 0]
|
|
22440
|
+
],
|
|
22441
|
+
["get", "NOBJNM"],
|
|
22442
|
+
["get", "OBJNAM"]
|
|
22443
|
+
];
|
|
22434
22444
|
function catalogueNamePairs(acronym) {
|
|
22435
22445
|
const names = s57NameTable(acronym);
|
|
22436
22446
|
return Object.keys(names).map(Number).sort((a, b) => a - b).map((code) => [String(code), names[code]]);
|
|
22437
22447
|
}
|
|
22438
22448
|
function buildLandmarkLabelExpression() {
|
|
22439
22449
|
const categoryExpr = listAttrCase("CATLMK", catalogueNamePairs("CATLMK"), "");
|
|
22440
|
-
const base = ["case", HAS_OBJNAM,
|
|
22450
|
+
const base = ["case", HAS_OBJNAM, OBJNAM_TEXT, categoryExpr];
|
|
22441
22451
|
const conspic = s57AbbrTable("CONVIS")[1] ?? "";
|
|
22442
22452
|
const conspicExpr = [
|
|
22443
22453
|
"case",
|
|
@@ -22456,7 +22466,7 @@ function buildHarbourFacilityLabelExpression() {
|
|
|
22456
22466
|
return [
|
|
22457
22467
|
"case",
|
|
22458
22468
|
HAS_OBJNAM,
|
|
22459
|
-
|
|
22469
|
+
OBJNAM_TEXT,
|
|
22460
22470
|
listAttrCase("CATHAF", catalogueNamePairs("CATHAF"), "")
|
|
22461
22471
|
];
|
|
22462
22472
|
}
|
|
@@ -23013,31 +23023,37 @@ function extractNavAidDesignation(objnam) {
|
|
|
23013
23023
|
return token;
|
|
23014
23024
|
}
|
|
23015
23025
|
function navAidDesignationTextExpression(objnam, colourPrefix) {
|
|
23016
|
-
const
|
|
23026
|
+
const name = ["var", "navAidName"];
|
|
23027
|
+
const len = ["length", name];
|
|
23017
23028
|
const tokenBranches = [];
|
|
23018
23029
|
for (let k = 1; k <= 4; k++) {
|
|
23019
23030
|
tokenBranches.push(
|
|
23020
23031
|
[
|
|
23021
23032
|
"all",
|
|
23022
23033
|
[">", len, k],
|
|
23023
|
-
["==", ["slice",
|
|
23034
|
+
["==", ["slice", name, ["-", len, k + 1], ["-", len, k]], " "]
|
|
23024
23035
|
],
|
|
23025
|
-
["slice",
|
|
23036
|
+
["slice", name, ["-", len, k]]
|
|
23026
23037
|
);
|
|
23027
23038
|
}
|
|
23028
23039
|
return [
|
|
23029
23040
|
"let",
|
|
23030
|
-
"
|
|
23031
|
-
|
|
23041
|
+
"navAidName",
|
|
23042
|
+
objnam,
|
|
23032
23043
|
[
|
|
23033
|
-
"
|
|
23044
|
+
"let",
|
|
23045
|
+
"desig",
|
|
23046
|
+
["case", ...tokenBranches, ""],
|
|
23034
23047
|
[
|
|
23035
|
-
"
|
|
23036
|
-
[
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
|
|
23048
|
+
"case",
|
|
23049
|
+
[
|
|
23050
|
+
"any",
|
|
23051
|
+
["==", ["var", "desig"], ""],
|
|
23052
|
+
["match", ["var", "desig"], [...NAV_DESIGNATION_STOPWORDS], true, false]
|
|
23053
|
+
],
|
|
23054
|
+
["concat", colourPrefix, name],
|
|
23055
|
+
["concat", colourPrefix, '"', ["var", "desig"], '"']
|
|
23056
|
+
]
|
|
23041
23057
|
]
|
|
23042
23058
|
];
|
|
23043
23059
|
}
|
|
@@ -23144,7 +23160,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23144
23160
|
const tierExpr = buildLandRegionTierExpression();
|
|
23145
23161
|
return {
|
|
23146
23162
|
type: "symbol",
|
|
23147
|
-
textField:
|
|
23163
|
+
textField: OBJNAM_TEXT,
|
|
23148
23164
|
// Tier-1 entry moved from z5 to z7: undersea-relief names without a
|
|
23149
23165
|
// generic keyword ("Three Dory", "Outer Fall") can't be demoted by
|
|
23150
23166
|
// pattern, so the overview/general bands stay clean by holding ALL
|
|
@@ -23213,7 +23229,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23213
23229
|
case "BOYLAT":
|
|
23214
23230
|
return {
|
|
23215
23231
|
type: "symbol",
|
|
23216
|
-
textField: ["coalesce", ["get", "_navAidLabel"],
|
|
23232
|
+
textField: ["coalesce", ["get", "_navAidLabel"], OBJNAM_TEXT],
|
|
23217
23233
|
textSize: NAV_AID_LABEL_TEXT_SIZE,
|
|
23218
23234
|
textFont: NAV_AID_LABEL_FONT,
|
|
23219
23235
|
textColor: DARK_BG,
|
|
@@ -23226,7 +23242,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23226
23242
|
case "BCNLAT":
|
|
23227
23243
|
return {
|
|
23228
23244
|
type: "symbol",
|
|
23229
|
-
textField: ["coalesce", ["get", "_navAidLabel"],
|
|
23245
|
+
textField: ["coalesce", ["get", "_navAidLabel"], OBJNAM_TEXT],
|
|
23230
23246
|
textSize: NAV_AID_LABEL_TEXT_SIZE,
|
|
23231
23247
|
textFont: NAV_AID_LABEL_FONT,
|
|
23232
23248
|
textColor: DARK_BG,
|
|
@@ -23240,7 +23256,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23240
23256
|
case "BCNCAR":
|
|
23241
23257
|
return {
|
|
23242
23258
|
type: "symbol",
|
|
23243
|
-
textField: ["coalesce", ["get", "_navAidLabel"],
|
|
23259
|
+
textField: ["coalesce", ["get", "_navAidLabel"], OBJNAM_TEXT],
|
|
23244
23260
|
textSize: NAV_AID_LABEL_TEXT_SIZE,
|
|
23245
23261
|
textFont: NAV_AID_LABEL_FONT,
|
|
23246
23262
|
textColor: DARK_BG,
|
|
@@ -23254,7 +23270,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23254
23270
|
case "BCNSPP":
|
|
23255
23271
|
return {
|
|
23256
23272
|
type: "symbol",
|
|
23257
|
-
textField: ["coalesce", ["get", "_navAidLabel"],
|
|
23273
|
+
textField: ["coalesce", ["get", "_navAidLabel"], OBJNAM_TEXT],
|
|
23258
23274
|
textSize: NAV_AID_LABEL_TEXT_SIZE,
|
|
23259
23275
|
textFont: NAV_AID_LABEL_FONT,
|
|
23260
23276
|
textColor: DARK_BG,
|
|
@@ -23268,7 +23284,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23268
23284
|
case "BOYSAW":
|
|
23269
23285
|
return {
|
|
23270
23286
|
type: "symbol",
|
|
23271
|
-
textField: ["coalesce", ["get", "_navAidLabel"],
|
|
23287
|
+
textField: ["coalesce", ["get", "_navAidLabel"], OBJNAM_TEXT],
|
|
23272
23288
|
textSize: NAV_AID_LABEL_TEXT_SIZE,
|
|
23273
23289
|
textFont: NAV_AID_LABEL_FONT,
|
|
23274
23290
|
textColor: DARK_BG,
|
|
@@ -23326,7 +23342,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23326
23342
|
const tierExpr = buildSeaAreaTierExpression();
|
|
23327
23343
|
return {
|
|
23328
23344
|
type: "symbol",
|
|
23329
|
-
textField:
|
|
23345
|
+
textField: OBJNAM_TEXT,
|
|
23330
23346
|
// Default tier (CATSEA=0, uncategorised: canyons, seamounts, fishing
|
|
23331
23347
|
// banks etc.) is suppressed at overview/general/coastal scales because
|
|
23332
23348
|
// it floods the overview with hundreds of small italic labels that
|
|
@@ -23448,7 +23464,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23448
23464
|
const tierExpr = buildLakeTierExpression();
|
|
23449
23465
|
return {
|
|
23450
23466
|
type: "symbol",
|
|
23451
|
-
textField:
|
|
23467
|
+
textField: OBJNAM_TEXT,
|
|
23452
23468
|
textSize: tieredSizeCurve(tierExpr, [
|
|
23453
23469
|
[7, [9, 0]],
|
|
23454
23470
|
[9, [11, 0]],
|
|
@@ -23469,7 +23485,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23469
23485
|
const tierExpr = buildRiverTierExpression();
|
|
23470
23486
|
return {
|
|
23471
23487
|
type: "symbol",
|
|
23472
|
-
textField:
|
|
23488
|
+
textField: OBJNAM_TEXT,
|
|
23473
23489
|
textSize: tieredSizeCurve(tierExpr, [
|
|
23474
23490
|
[7, [9, 0]],
|
|
23475
23491
|
[9, [11, 0]],
|
|
@@ -23489,7 +23505,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23489
23505
|
case "CANALS":
|
|
23490
23506
|
return {
|
|
23491
23507
|
type: "symbol",
|
|
23492
|
-
textField:
|
|
23508
|
+
textField: OBJNAM_TEXT,
|
|
23493
23509
|
textSize: [
|
|
23494
23510
|
"interpolate",
|
|
23495
23511
|
["linear"],
|
|
@@ -23513,7 +23529,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23513
23529
|
const tierExpr = buildLandAreaTierExpression();
|
|
23514
23530
|
return {
|
|
23515
23531
|
type: "symbol",
|
|
23516
|
-
textField:
|
|
23532
|
+
textField: OBJNAM_TEXT,
|
|
23517
23533
|
// Tier 2 is the SMALL island — the one the owner cannot identify.
|
|
23518
23534
|
// Its old curve peaked at 10 px and fell to 10 px, i.e. it never got
|
|
23519
23535
|
// its own scale: a name that only exists because you zoomed in was
|
|
@@ -23545,7 +23561,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23545
23561
|
const tierExpr = buildBuiltUpAreaTierExpression();
|
|
23546
23562
|
return {
|
|
23547
23563
|
type: "symbol",
|
|
23548
|
-
textField:
|
|
23564
|
+
textField: OBJNAM_TEXT,
|
|
23549
23565
|
textSize: tieredSizeCurve(tierExpr, [
|
|
23550
23566
|
[3, [11, 0, 0]],
|
|
23551
23567
|
[5, [13, 0, 0]],
|
|
@@ -23569,7 +23585,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23569
23585
|
case "BRIDGE":
|
|
23570
23586
|
return {
|
|
23571
23587
|
type: "symbol",
|
|
23572
|
-
textField:
|
|
23588
|
+
textField: OBJNAM_TEXT,
|
|
23573
23589
|
textSize: 9,
|
|
23574
23590
|
textColor: "#bfa88a",
|
|
23575
23591
|
textHaloColor: DARK_BG,
|
|
@@ -23588,7 +23604,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23588
23604
|
case "PILPNT":
|
|
23589
23605
|
return {
|
|
23590
23606
|
type: "symbol",
|
|
23591
|
-
textField:
|
|
23607
|
+
textField: OBJNAM_TEXT,
|
|
23592
23608
|
textSize: 8,
|
|
23593
23609
|
textColor: "#c8c0b0",
|
|
23594
23610
|
textHaloColor: DARK_BG,
|
|
@@ -23599,7 +23615,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23599
23615
|
case "MORFAC":
|
|
23600
23616
|
return {
|
|
23601
23617
|
type: "symbol",
|
|
23602
|
-
textField:
|
|
23618
|
+
textField: OBJNAM_TEXT,
|
|
23603
23619
|
textSize: 8,
|
|
23604
23620
|
textColor: "#c8c0b0",
|
|
23605
23621
|
textHaloColor: DARK_BG,
|
|
@@ -23610,7 +23626,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23610
23626
|
case "SLCONS":
|
|
23611
23627
|
return {
|
|
23612
23628
|
type: "symbol",
|
|
23613
|
-
textField:
|
|
23629
|
+
textField: OBJNAM_TEXT,
|
|
23614
23630
|
textSize: 8,
|
|
23615
23631
|
textColor: "#bfa88a",
|
|
23616
23632
|
textHaloColor: DARK_BG,
|
|
@@ -23625,7 +23641,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23625
23641
|
case "BUISGL":
|
|
23626
23642
|
return {
|
|
23627
23643
|
type: "symbol",
|
|
23628
|
-
textField:
|
|
23644
|
+
textField: OBJNAM_TEXT,
|
|
23629
23645
|
textSize: 8,
|
|
23630
23646
|
textColor: DARK_BG,
|
|
23631
23647
|
textHaloColor: "#c8c0b0",
|
|
@@ -23641,7 +23657,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23641
23657
|
const tierExpr = buildAirportTierExpression();
|
|
23642
23658
|
return {
|
|
23643
23659
|
type: "symbol",
|
|
23644
|
-
textField:
|
|
23660
|
+
textField: OBJNAM_TEXT,
|
|
23645
23661
|
textSize: tieredSizeCurve(tierExpr, [
|
|
23646
23662
|
[7, [9, 0]],
|
|
23647
23663
|
[9, [11, 0]],
|
|
@@ -23725,7 +23741,7 @@ function getLabelConfig(layerName, opts = {}) {
|
|
|
23725
23741
|
case "PRDARE":
|
|
23726
23742
|
return {
|
|
23727
23743
|
type: "symbol",
|
|
23728
|
-
textField:
|
|
23744
|
+
textField: OBJNAM_TEXT,
|
|
23729
23745
|
textSize: [
|
|
23730
23746
|
"interpolate",
|
|
23731
23747
|
["linear"],
|
|
@@ -27105,7 +27121,7 @@ function buildNavAidLabelExpression() {
|
|
|
27105
27121
|
// doesn't precompute `_navAidLabel`, so before this expression every
|
|
27106
27122
|
// production buoy label carried its full 30-40 glyph OBJNAM, the
|
|
27107
27123
|
// biggest single driver of Harbor/Approach label overprint (E3).
|
|
27108
|
-
navAidDesignationTextExpression(
|
|
27124
|
+
navAidDesignationTextExpression(OBJNAM_TEXT, colourPrefix),
|
|
27109
27125
|
""
|
|
27110
27126
|
];
|
|
27111
27127
|
}
|
|
@@ -27521,7 +27537,7 @@ function buildLayersForClass(objectClass, ct, sourceId = DEFAULT_REGION, opts =
|
|
|
27521
27537
|
"icon-allow-overlap": true,
|
|
27522
27538
|
"icon-ignore-placement": false,
|
|
27523
27539
|
"symbol-placement": "point",
|
|
27524
|
-
"text-field": ["case", ["has", "OBJNAM"],
|
|
27540
|
+
"text-field": ["case", ["has", "OBJNAM"], OBJNAM_TEXT, ""],
|
|
27525
27541
|
"text-size": ["interpolate", ["linear"], ["zoom"], 11, 9, 16, 11],
|
|
27526
27542
|
"text-anchor": "top",
|
|
27527
27543
|
"text-offset": [0, 1.4],
|
|
@@ -28238,6 +28254,18 @@ function buildLabelLayer2(objectClass, ct, sourceId = DEFAULT_REGION, depthUnits
|
|
|
28238
28254
|
["round", ["*", ["to-number", ["get", "VALDCO"]], 3.28084]],
|
|
28239
28255
|
"ft"
|
|
28240
28256
|
];
|
|
28257
|
+
} else if (objectClass === "UWTROC" || objectClass === "OBSTRN" || objectClass === "WRECKS") {
|
|
28258
|
+
const valsouFt = [
|
|
28259
|
+
"to-number",
|
|
28260
|
+
["coalesce", ["get", "VALSOU"], ["get", "valsou"], 0],
|
|
28261
|
+
0
|
|
28262
|
+
];
|
|
28263
|
+
textField = [
|
|
28264
|
+
"case",
|
|
28265
|
+
[">", valsouFt, 0],
|
|
28266
|
+
["concat", ["to-string", ["round", ["*", valsouFt, 3.28084]]], "ft"],
|
|
28267
|
+
""
|
|
28268
|
+
];
|
|
28241
28269
|
}
|
|
28242
28270
|
}
|
|
28243
28271
|
const labelPriority = getLabelPriority(objectClass);
|
|
@@ -29824,6 +29852,7 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
29824
29852
|
}
|
|
29825
29853
|
const symbolSet = opts.symbolSet ?? "s52";
|
|
29826
29854
|
const spriteBase = `${opts.tileBaseUrl ?? "https://tiles.chrt.co"}/v1/sprites`;
|
|
29855
|
+
const glyphsBase = `${opts.tileBaseUrl ?? "https://tiles.chrt.co"}/v1/glyphs`;
|
|
29827
29856
|
const isLndareFill = (l) => /^s52-LNDARE-fill-band\d+$/.test(l.id);
|
|
29828
29857
|
const isWaterBaseFill = (l) => /^s52-(DEPARE|DRGARE|UNSARE)-fill-band\d+$/.test(l.id);
|
|
29829
29858
|
const bandOf = (l) => {
|
|
@@ -29965,7 +29994,23 @@ function generateStyle(palette = "DAY", opts = {}) {
|
|
|
29965
29994
|
...symbolSet !== "s101" && {
|
|
29966
29995
|
sprite: `${spriteBase}/${symbolSet}-${palette.toLowerCase()}`
|
|
29967
29996
|
},
|
|
29968
|
-
|
|
29997
|
+
// ⚠ DEPLOY ORDER. This URL is baked into the style by callers on BOTH
|
|
29998
|
+
// sides: the tile-worker's /v1/styles route AND the app's own
|
|
29999
|
+
// `generateStyle` call in ChartCanvas.tsx, which ships from Railway on a
|
|
30000
|
+
// SEPARATE deploy from the Workers. The glyph objects must be in R2 and
|
|
30001
|
+
// the /v1/glyphs route live BEFORE any client asks for this URL — if the
|
|
30002
|
+
// frontend ships first, every label on the chart goes blank, not just the
|
|
30003
|
+
// ones with an ʻokina. Land the tile-worker deploy first, or revert this
|
|
30004
|
+
// one line to the openmaptiles URL to fall back.
|
|
30005
|
+
//
|
|
30006
|
+
// Self-hosted, beside the sprite sheets on the same host. Was
|
|
30007
|
+
// fonts.openmaptiles.org, whose 2013-vintage Open Sans has NO GLYPH for
|
|
30008
|
+
// U+02BB ʻOKINA (a CONSONANT in Hawaiian) or five other codepoints that
|
|
30009
|
+
// occur in NOAA names — MapLibre draws a missing glyph as nothing, so
|
|
30010
|
+
// "Island of Hawaiʻi" rendered with a hole in it. Our ranges keep every
|
|
30011
|
+
// upstream glyph byte-identical and composite only those six in from
|
|
30012
|
+
// Noto Sans; see scripts/generate-glyphs.mjs.
|
|
30013
|
+
glyphs: `${glyphsBase}/{fontstack}/{range}.pbf`,
|
|
29969
30014
|
layers: emitted
|
|
29970
30015
|
};
|
|
29971
30016
|
if (symbolSet === "s101") return applyS101SymbolSet(style);
|