@chrtco/sdk 0.10.43 → 0.10.45
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/CHANGELOG.md +12 -0
- package/dist/atlas/browser.cjs +135 -36
- package/dist/atlas/browser.cjs.map +1 -1
- package/dist/atlas/browser.d.cts +26 -0
- package/dist/atlas/browser.d.ts +26 -0
- package/dist/atlas/browser.js +135 -36
- package/dist/atlas/browser.js.map +1 -1
- package/dist/index.cjs +106 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +98 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,8 @@ __export(index_exports, {
|
|
|
66
66
|
DEFAULT_TILE_BASE_URL: () => DEFAULT_TILE_BASE_URL,
|
|
67
67
|
DEFAULT_TILE_REGION: () => DEFAULT_TILE_REGION,
|
|
68
68
|
DEFAULT_WATER_BODY_SETTINGS: () => DEFAULT_WATER_BODY_SETTINGS,
|
|
69
|
+
DEPARE_FILL_BRANCH_TOKENS: () => DEPARE_FILL_BRANCH_TOKENS,
|
|
70
|
+
DEPARE_FILL_FALLBACK_TOKEN: () => DEPARE_FILL_FALLBACK_TOKEN,
|
|
69
71
|
DRAPEABLE_LAYER_TYPES: () => DRAPEABLE_LAYER_TYPES,
|
|
70
72
|
INSPECT_CLASS_RANK: () => INSPECT_CLASS_RANK,
|
|
71
73
|
INSPECT_RANK_DEVIATIONS: () => INSPECT_RANK_DEVIATIONS,
|
|
@@ -89,6 +91,7 @@ __export(index_exports, {
|
|
|
89
91
|
NIGHT_MUTED_INK: () => NIGHT_MUTED_INK,
|
|
90
92
|
NON_SOLAS_DISCLAIMER: () => NON_SOLAS_DISCLAIMER,
|
|
91
93
|
NON_SOLAS_DISCLAIMER_SHORT: () => NON_SOLAS_DISCLAIMER_SHORT,
|
|
94
|
+
OPAQUE_SPLIT_OF: () => OPAQUE_SPLIT_OF,
|
|
92
95
|
OfflineError: () => OfflineError,
|
|
93
96
|
OfflineStyleError: () => OfflineStyleError,
|
|
94
97
|
PLACENAME_LAND_CLASSES: () => PLACENAME_LAND_CLASSES,
|
|
@@ -175,6 +178,8 @@ __export(index_exports, {
|
|
|
175
178
|
decodeNavAidProps: () => decodeNavAidProps,
|
|
176
179
|
depareColor: () => depareColor,
|
|
177
180
|
depareFillExpression: () => depareFillExpression,
|
|
181
|
+
depthAreaClassLayerId: () => depthAreaClassLayerId,
|
|
182
|
+
depthAreaSplitIds: () => depthAreaSplitIds,
|
|
178
183
|
deriveMarinerName: () => deriveMarinerName,
|
|
179
184
|
drapeHalves: () => drapeHalves,
|
|
180
185
|
drapedFirst: () => drapedFirst,
|
|
@@ -210,6 +215,7 @@ __export(index_exports, {
|
|
|
210
215
|
hazardColor: () => hazardColor,
|
|
211
216
|
hazardFillExpression: () => hazardFillExpression,
|
|
212
217
|
iconExpressionForFamily: () => iconExpressionForFamily,
|
|
218
|
+
isDepthAreaClassLayerId: () => isDepthAreaClassLayerId,
|
|
213
219
|
isDrapeable: () => isDrapeable,
|
|
214
220
|
isLabelLayerVisible: () => isLabelLayerVisible,
|
|
215
221
|
isNavAidLayer: () => isNavAidLayer,
|
|
@@ -227,6 +233,7 @@ __export(index_exports, {
|
|
|
227
233
|
lightsIconExpression: () => lightsIconExpression,
|
|
228
234
|
normalizeStyleMode: () => normalizeStyleMode,
|
|
229
235
|
normalizeTheme: () => normalizeTheme,
|
|
236
|
+
opaqueSplitBaseOf: () => opaqueSplitBaseOf,
|
|
230
237
|
paginate: () => paginate,
|
|
231
238
|
parseListCodes: () => parseListCodes,
|
|
232
239
|
parseSigseqTerms: () => parseSigseqTerms,
|
|
@@ -252,6 +259,7 @@ __export(index_exports, {
|
|
|
252
259
|
scaleSizeValue: () => scaleSizeValue,
|
|
253
260
|
scaminToMinZoom: () => scaminToMinZoom,
|
|
254
261
|
sectorLimitToArcBearing: () => sectorLimitToArcBearing,
|
|
262
|
+
splitOpaqueDepthAreas: () => splitOpaqueDepthAreas,
|
|
255
263
|
styleModeBand: () => styleModeBand,
|
|
256
264
|
terrainStackCount: () => terrainStackCount,
|
|
257
265
|
themeChrtGlyph: () => themeChrtGlyph,
|
|
@@ -5974,8 +5982,11 @@ function depareColor(props, ct = "DAY", safetyContourM = DEFAULT_SAFETY_CONTOUR_
|
|
|
5974
5982
|
if (drval1 < DEPARE_DEEP_CUT_M) return resolveColor("DEPMD", ct);
|
|
5975
5983
|
return resolveColor("DEPDW", ct);
|
|
5976
5984
|
}
|
|
5985
|
+
var DEPARE_FILL_BRANCH_TOKENS = ["DEPIT", "DEPVS", "DEPMS", "DEPMD"];
|
|
5986
|
+
var DEPARE_FILL_FALLBACK_TOKEN = "DEPDW";
|
|
5977
5987
|
function depareFillExpression(ct = "DAY", safetyContourM = DEFAULT_SAFETY_CONTOUR_M) {
|
|
5978
5988
|
const safety = effectiveSafetyContour(safetyContourM);
|
|
5989
|
+
const [it, vs, ms, md] = DEPARE_FILL_BRANCH_TOKENS;
|
|
5979
5990
|
return [
|
|
5980
5991
|
"case",
|
|
5981
5992
|
[
|
|
@@ -5983,14 +5994,14 @@ function depareFillExpression(ct = "DAY", safetyContourM = DEFAULT_SAFETY_CONTOU
|
|
|
5983
5994
|
["<", ["coalesce", ["get", "DRVAL1"], ["get", "drval1"], -1], 0],
|
|
5984
5995
|
["<=", ["coalesce", ["get", "DRVAL2"], ["get", "drval2"], 0], 0]
|
|
5985
5996
|
],
|
|
5986
|
-
resolveColor(
|
|
5997
|
+
resolveColor(it, ct),
|
|
5987
5998
|
["<", ["coalesce", ["get", "DRVAL1"], ["get", "drval1"], -1], DEPARE_SHALLOW_CUT_M],
|
|
5988
|
-
resolveColor(
|
|
5999
|
+
resolveColor(vs, ct),
|
|
5989
6000
|
["<", ["coalesce", ["get", "DRVAL1"], ["get", "drval1"], -1], safety],
|
|
5990
|
-
resolveColor(
|
|
6001
|
+
resolveColor(ms, ct),
|
|
5991
6002
|
["<", ["coalesce", ["get", "DRVAL1"], ["get", "drval1"], -1], DEPARE_DEEP_CUT_M],
|
|
5992
|
-
resolveColor(
|
|
5993
|
-
resolveColor(
|
|
6003
|
+
resolveColor(md, ct),
|
|
6004
|
+
resolveColor(DEPARE_FILL_FALLBACK_TOKEN, ct)
|
|
5994
6005
|
];
|
|
5995
6006
|
}
|
|
5996
6007
|
function listAttrString(attr) {
|
|
@@ -30062,6 +30073,11 @@ function baseInlandWaterLayers(opts = {}) {
|
|
|
30062
30073
|
];
|
|
30063
30074
|
}
|
|
30064
30075
|
|
|
30076
|
+
// src/atlas/tile-number.ts
|
|
30077
|
+
function tileNumber(property, fallback) {
|
|
30078
|
+
return ["to-number", ["coalesce", ["get", property], fallback], fallback];
|
|
30079
|
+
}
|
|
30080
|
+
|
|
30065
30081
|
// src/atlas/land-layers.ts
|
|
30066
30082
|
var LAND_SURFACE_MINZOOM = BAND_PRIORITY_RANGES["5"].minzoom;
|
|
30067
30083
|
var LAND_SURFACE_LAYERS = (id) => id === "chrtland-base" || id === "chrtland-cover" || id.startsWith("chrtland-contour") || id === "chrtland-hillshade" || id === "chrtland-water" || id.startsWith("chrtland-fade-");
|
|
@@ -30128,7 +30144,7 @@ var LAND_THEMES = {
|
|
|
30128
30144
|
exaggeration: 0.45
|
|
30129
30145
|
}
|
|
30130
30146
|
};
|
|
30131
|
-
var FITS = ["<=",
|
|
30147
|
+
var FITS = ["<=", tileNumber("min_z", 0), ["zoom"]];
|
|
30132
30148
|
var ANCHOR = ["coalesce", ["get", "anchor"], "top"];
|
|
30133
30149
|
var anchorOffset = (em) => [
|
|
30134
30150
|
"match",
|
|
@@ -30164,7 +30180,7 @@ function landLayers(opts = {}) {
|
|
|
30164
30180
|
type: "fill",
|
|
30165
30181
|
source: src,
|
|
30166
30182
|
"source-layer": "land_cover",
|
|
30167
|
-
filter: ["<=",
|
|
30183
|
+
filter: ["<=", tileNumber("min_z", 0), ["zoom"]],
|
|
30168
30184
|
paint: {
|
|
30169
30185
|
"fill-color": [
|
|
30170
30186
|
"match",
|
|
@@ -30199,10 +30215,10 @@ function landLayers(opts = {}) {
|
|
|
30199
30215
|
}
|
|
30200
30216
|
const isIndexContour = [
|
|
30201
30217
|
"any",
|
|
30202
|
-
["<=",
|
|
30203
|
-
["==",
|
|
30218
|
+
["<=", tileNumber("index_z", 99), ["zoom"]],
|
|
30219
|
+
["==", tileNumber("is_index", 0), 1]
|
|
30204
30220
|
];
|
|
30205
|
-
const contourVisible = ["<=",
|
|
30221
|
+
const contourVisible = ["<=", tileNumber("min_z", 0), ["zoom"]];
|
|
30206
30222
|
layers.push(L({
|
|
30207
30223
|
id: "chrtland-contour-index",
|
|
30208
30224
|
type: "line",
|
|
@@ -30232,7 +30248,7 @@ function landLayers(opts = {}) {
|
|
|
30232
30248
|
type: "fill",
|
|
30233
30249
|
source: src,
|
|
30234
30250
|
"source-layer": "land_water",
|
|
30235
|
-
filter: ["<=",
|
|
30251
|
+
filter: ["<=", tileNumber("min_z", 0), ["zoom"]],
|
|
30236
30252
|
paint: { "fill-color": inlandWaterColor(palette) }
|
|
30237
30253
|
}));
|
|
30238
30254
|
const d = FADE_PX / 2 / FADE_BANDS;
|
|
@@ -30273,7 +30289,7 @@ function landLayers(opts = {}) {
|
|
|
30273
30289
|
source: src,
|
|
30274
30290
|
"source-layer": "land_town",
|
|
30275
30291
|
minzoom: 6.5,
|
|
30276
|
-
filter: [">=",
|
|
30292
|
+
filter: [">=", tileNumber("prank", 0), 10],
|
|
30277
30293
|
layout: {
|
|
30278
30294
|
"text-field": [
|
|
30279
30295
|
"case",
|
|
@@ -30289,16 +30305,16 @@ function landLayers(opts = {}) {
|
|
|
30289
30305
|
6.5,
|
|
30290
30306
|
11.5,
|
|
30291
30307
|
9,
|
|
30292
|
-
["+", 10, ["*", 0.4,
|
|
30308
|
+
["+", 10, ["*", 0.4, tileNumber("prank", 10)]],
|
|
30293
30309
|
13,
|
|
30294
|
-
["+", 13, ["*", 0.5,
|
|
30310
|
+
["+", 13, ["*", 0.5, tileNumber("prank", 10)]]
|
|
30295
30311
|
],
|
|
30296
30312
|
"text-letter-spacing": ["case", ["==", ["get", "upcase"], true], 0.14, 0.02],
|
|
30297
30313
|
"text-offset": anchorOffset(0.75),
|
|
30298
30314
|
"text-anchor": ANCHOR,
|
|
30299
30315
|
"text-padding": 10,
|
|
30300
30316
|
"text-allow-overlap": false,
|
|
30301
|
-
"symbol-sort-key": ["*", -1,
|
|
30317
|
+
"symbol-sort-key": ["*", -1, tileNumber("pop", 0)]
|
|
30302
30318
|
},
|
|
30303
30319
|
paint: { "text-color": T.label, "text-halo-color": T.halo, "text-halo-width": 1.6 }
|
|
30304
30320
|
}));
|
|
@@ -30311,7 +30327,7 @@ function landLayers(opts = {}) {
|
|
|
30311
30327
|
filter: [
|
|
30312
30328
|
"all",
|
|
30313
30329
|
["==", ["get", "enc_dup"], true],
|
|
30314
|
-
["<",
|
|
30330
|
+
["<", tileNumber("prank", 0), 10]
|
|
30315
30331
|
],
|
|
30316
30332
|
layout: {
|
|
30317
30333
|
"text-field": ["get", "name"],
|
|
@@ -30323,7 +30339,7 @@ function landLayers(opts = {}) {
|
|
|
30323
30339
|
"text-allow-overlap": false,
|
|
30324
30340
|
// Within the tier, the bigger place wins the space: without this the
|
|
30325
30341
|
// tie broke on data order and "West Gloucester" beat Gloucester.
|
|
30326
|
-
"symbol-sort-key": ["*", -1,
|
|
30342
|
+
"symbol-sort-key": ["*", -1, tileNumber("pop", 0)]
|
|
30327
30343
|
},
|
|
30328
30344
|
paint: { "text-color": T.label, "text-halo-color": T.halo, "text-halo-width": 1.4 }
|
|
30329
30345
|
}));
|
|
@@ -30336,7 +30352,7 @@ function landLayers(opts = {}) {
|
|
|
30336
30352
|
filter: [
|
|
30337
30353
|
"all",
|
|
30338
30354
|
FITS,
|
|
30339
|
-
["<",
|
|
30355
|
+
["<", tileNumber("prank", 0), 10],
|
|
30340
30356
|
["!=", ["get", "enc_dup"], true]
|
|
30341
30357
|
],
|
|
30342
30358
|
layout: {
|
|
@@ -30363,7 +30379,7 @@ function landLayers(opts = {}) {
|
|
|
30363
30379
|
source: src,
|
|
30364
30380
|
"source-layer": "land_summit",
|
|
30365
30381
|
minzoom: 11.5,
|
|
30366
|
-
filter: ["all", FITS, [">=",
|
|
30382
|
+
filter: ["all", FITS, [">=", tileNumber("peak_m", 0), 40]],
|
|
30367
30383
|
layout: {
|
|
30368
30384
|
"text-field": ["concat", ["get", "name"], "\n", ["to-string", ["get", "peak_m"]], " m"],
|
|
30369
30385
|
"text-font": FONT,
|
|
@@ -31661,6 +31677,69 @@ function generateCustomStyle(config, opts = {}) {
|
|
|
31661
31677
|
return { style, palette, themeFellBack };
|
|
31662
31678
|
}
|
|
31663
31679
|
|
|
31680
|
+
// src/atlas/depth-area-opaque.ts
|
|
31681
|
+
var OPAQUE_SPLIT_OF = "chrt:opaqueSplitOf";
|
|
31682
|
+
function depthAreaClassLayerId(baseId, token) {
|
|
31683
|
+
return `chrt-${token.toLowerCase()}-of-${baseId.replace(/-band(\d)/g, "-b$1")}`;
|
|
31684
|
+
}
|
|
31685
|
+
function depthAreaSplitIds(baseId) {
|
|
31686
|
+
return [...DEPARE_FILL_BRANCH_TOKENS].reverse().map((token) => depthAreaClassLayerId(baseId, token));
|
|
31687
|
+
}
|
|
31688
|
+
var CLASS_LAYER_ID = new RegExp(
|
|
31689
|
+
`^chrt-(?:${DEPARE_FILL_BRANCH_TOKENS.map((t) => t.toLowerCase()).join("|")})-of-`
|
|
31690
|
+
);
|
|
31691
|
+
function isDepthAreaClassLayerId(id) {
|
|
31692
|
+
return CLASS_LAYER_ID.test(id);
|
|
31693
|
+
}
|
|
31694
|
+
function opaqueSplitBaseOf(layer) {
|
|
31695
|
+
const meta = layer.metadata;
|
|
31696
|
+
const base = meta?.[OPAQUE_SPLIT_OF];
|
|
31697
|
+
return typeof base === "string" ? base : null;
|
|
31698
|
+
}
|
|
31699
|
+
function exclusiveBranches(expression) {
|
|
31700
|
+
if (!Array.isArray(expression) || expression[0] !== "case") return null;
|
|
31701
|
+
if ((expression.length - 2) / 2 !== DEPARE_FILL_BRANCH_TOKENS.length) return null;
|
|
31702
|
+
const branches = [];
|
|
31703
|
+
const earlier = [];
|
|
31704
|
+
for (let i = 1; i < expression.length - 1; i += 2) {
|
|
31705
|
+
const colour = expression[i + 1];
|
|
31706
|
+
if (typeof colour !== "string") return null;
|
|
31707
|
+
branches.push({ when: [...earlier.map((c) => ["!", c]), expression[i]], colour });
|
|
31708
|
+
earlier.push(expression[i]);
|
|
31709
|
+
}
|
|
31710
|
+
const fallback = expression[expression.length - 1];
|
|
31711
|
+
if (typeof fallback !== "string") return null;
|
|
31712
|
+
return { branches, fallback };
|
|
31713
|
+
}
|
|
31714
|
+
function andFilter(base, terms) {
|
|
31715
|
+
if (Array.isArray(base) && base[0] === "all") return ["all", ...base.slice(1), ...terms];
|
|
31716
|
+
if (base === void 0) return ["all", ...terms];
|
|
31717
|
+
return ["all", base, ...terms];
|
|
31718
|
+
}
|
|
31719
|
+
function splitOpaqueDepthAreas(layers) {
|
|
31720
|
+
const out = [];
|
|
31721
|
+
for (const raw of layers) {
|
|
31722
|
+
const layer = raw;
|
|
31723
|
+
const paint = layer.paint ?? {};
|
|
31724
|
+
const split = layer.type === "fill" && layer.metadata?.["s52:objectClass"] === "DEPARE" && paint["fill-pattern"] === void 0 && (paint["fill-opacity"] === void 0 || paint["fill-opacity"] === 1) ? exclusiveBranches(paint["fill-color"]) : null;
|
|
31725
|
+
if (split === null) {
|
|
31726
|
+
out.push(raw);
|
|
31727
|
+
continue;
|
|
31728
|
+
}
|
|
31729
|
+
out.push({ ...layer, paint: { ...paint, "fill-color": split.fallback } });
|
|
31730
|
+
for (let k = split.branches.length - 1; k >= 0; k -= 1) {
|
|
31731
|
+
out.push({
|
|
31732
|
+
...layer,
|
|
31733
|
+
id: depthAreaClassLayerId(layer.id, DEPARE_FILL_BRANCH_TOKENS[k]),
|
|
31734
|
+
filter: andFilter(layer.filter, split.branches[k].when),
|
|
31735
|
+
paint: { ...paint, "fill-color": split.branches[k].colour },
|
|
31736
|
+
metadata: { ...layer.metadata ?? {}, [OPAQUE_SPLIT_OF]: layer.id }
|
|
31737
|
+
});
|
|
31738
|
+
}
|
|
31739
|
+
}
|
|
31740
|
+
return out;
|
|
31741
|
+
}
|
|
31742
|
+
|
|
31664
31743
|
// src/pagination.ts
|
|
31665
31744
|
async function* paginate(fetchPage, getItems, getTotalCount, options) {
|
|
31666
31745
|
const pageSize = options?.pageSize ?? 100;
|
|
@@ -32130,6 +32209,8 @@ var Chrt = class {
|
|
|
32130
32209
|
DEFAULT_TILE_BASE_URL,
|
|
32131
32210
|
DEFAULT_TILE_REGION,
|
|
32132
32211
|
DEFAULT_WATER_BODY_SETTINGS,
|
|
32212
|
+
DEPARE_FILL_BRANCH_TOKENS,
|
|
32213
|
+
DEPARE_FILL_FALLBACK_TOKEN,
|
|
32133
32214
|
DRAPEABLE_LAYER_TYPES,
|
|
32134
32215
|
INSPECT_CLASS_RANK,
|
|
32135
32216
|
INSPECT_RANK_DEVIATIONS,
|
|
@@ -32153,6 +32234,7 @@ var Chrt = class {
|
|
|
32153
32234
|
NIGHT_MUTED_INK,
|
|
32154
32235
|
NON_SOLAS_DISCLAIMER,
|
|
32155
32236
|
NON_SOLAS_DISCLAIMER_SHORT,
|
|
32237
|
+
OPAQUE_SPLIT_OF,
|
|
32156
32238
|
OfflineError,
|
|
32157
32239
|
OfflineStyleError,
|
|
32158
32240
|
PLACENAME_LAND_CLASSES,
|
|
@@ -32239,6 +32321,8 @@ var Chrt = class {
|
|
|
32239
32321
|
decodeNavAidProps,
|
|
32240
32322
|
depareColor,
|
|
32241
32323
|
depareFillExpression,
|
|
32324
|
+
depthAreaClassLayerId,
|
|
32325
|
+
depthAreaSplitIds,
|
|
32242
32326
|
deriveMarinerName,
|
|
32243
32327
|
drapeHalves,
|
|
32244
32328
|
drapedFirst,
|
|
@@ -32274,6 +32358,7 @@ var Chrt = class {
|
|
|
32274
32358
|
hazardColor,
|
|
32275
32359
|
hazardFillExpression,
|
|
32276
32360
|
iconExpressionForFamily,
|
|
32361
|
+
isDepthAreaClassLayerId,
|
|
32277
32362
|
isDrapeable,
|
|
32278
32363
|
isLabelLayerVisible,
|
|
32279
32364
|
isNavAidLayer,
|
|
@@ -32291,6 +32376,7 @@ var Chrt = class {
|
|
|
32291
32376
|
lightsIconExpression,
|
|
32292
32377
|
normalizeStyleMode,
|
|
32293
32378
|
normalizeTheme,
|
|
32379
|
+
opaqueSplitBaseOf,
|
|
32294
32380
|
paginate,
|
|
32295
32381
|
parseListCodes,
|
|
32296
32382
|
parseSigseqTerms,
|
|
@@ -32316,6 +32402,7 @@ var Chrt = class {
|
|
|
32316
32402
|
scaleSizeValue,
|
|
32317
32403
|
scaminToMinZoom,
|
|
32318
32404
|
sectorLimitToArcBearing,
|
|
32405
|
+
splitOpaqueDepthAreas,
|
|
32319
32406
|
styleModeBand,
|
|
32320
32407
|
terrainStackCount,
|
|
32321
32408
|
themeChrtGlyph,
|