basemapkit 0.1.2 → 0.1.4

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.
@@ -1,4 +1,4 @@
1
- import { language_script_pairs as G, get_country_name as q, get_multiline_name as P } from "@protomaps/basemaps";
1
+ import { language_script_pairs as D, get_country_name as q, get_multiline_name as P } from "@protomaps/basemaps";
2
2
  const k = {
3
3
  aliceblue: [240, 248, 255],
4
4
  antiquewhite: [250, 235, 215],
@@ -223,7 +223,7 @@ y.get.hwb = function(n) {
223
223
  return null;
224
224
  };
225
225
  y.to.hex = function(...n) {
226
- return "#" + C(n[0]) + C(n[1]) + C(n[2]) + (n[3] < 1 ? C(Math.round(n[3] * 255)) : "");
226
+ return "#" + A(n[0]) + A(n[1]) + A(n[2]) + (n[3] < 1 ? A(Math.round(n[3] * 255)) : "");
227
227
  };
228
228
  y.to.rgb = function(...n) {
229
229
  return n.length < 4 || n[3] === 1 ? "rgb(" + Math.round(n[0]) + ", " + Math.round(n[1]) + ", " + Math.round(n[2]) + ")" : "rgba(" + Math.round(n[0]) + ", " + Math.round(n[1]) + ", " + Math.round(n[2]) + ", " + n[3] + ")";
@@ -245,7 +245,7 @@ y.to.keyword = function(...n) {
245
245
  function z(n, e, t) {
246
246
  return Math.min(Math.max(e, n), t);
247
247
  }
248
- function C(n) {
248
+ function A(n) {
249
249
  const e = Math.round(n).toString(16).toUpperCase();
250
250
  return e.length < 2 ? "0" + e : e;
251
251
  }
@@ -270,7 +270,7 @@ const c = {
270
270
  hcg: { channels: 3, labels: ["h", "c", "g"] },
271
271
  apple: { channels: 3, labels: ["r16", "g16", "b16"] },
272
272
  gray: { channels: 1, labels: ["gray"] }
273
- }, w = (6 / 29) ** 3;
273
+ }, v = (6 / 29) ** 3;
274
274
  function N(n) {
275
275
  const e = n > 31308e-7 ? 1.055 * n ** 0.4166666666666667 - 0.055 : n * 12.92;
276
276
  return Math.min(Math.max(0, e), 1);
@@ -381,7 +381,7 @@ c.rgb.xyz = function(n) {
381
381
  c.rgb.lab = function(n) {
382
382
  const e = c.rgb.xyz(n);
383
383
  let t = e[0], o = e[1], i = e[2];
384
- t /= 95.047, o /= 100, i /= 108.883, t = t > w ? t ** (1 / 3) : 7.787 * t + 16 / 116, o = o > w ? o ** (1 / 3) : 7.787 * o + 16 / 116, i = i > w ? i ** (1 / 3) : 7.787 * i + 16 / 116;
384
+ t /= 95.047, o /= 100, i /= 108.883, t = t > v ? t ** (1 / 3) : 7.787 * t + 16 / 116, o = o > v ? o ** (1 / 3) : 7.787 * o + 16 / 116, i = i > v ? i ** (1 / 3) : 7.787 * i + 16 / 116;
385
385
  const l = 116 * o - 16, r = 500 * (t - o), a = 200 * (o - i);
386
386
  return [l, r, a];
387
387
  };
@@ -480,7 +480,7 @@ c.xyz.rgb = function(n) {
480
480
  };
481
481
  c.xyz.lab = function(n) {
482
482
  let e = n[0], t = n[1], o = n[2];
483
- e /= 95.047, t /= 100, o /= 108.883, e = e > w ? e ** (1 / 3) : 7.787 * e + 16 / 116, t = t > w ? t ** (1 / 3) : 7.787 * t + 16 / 116, o = o > w ? o ** (1 / 3) : 7.787 * o + 16 / 116;
483
+ e /= 95.047, t /= 100, o /= 108.883, e = e > v ? e ** (1 / 3) : 7.787 * e + 16 / 116, t = t > v ? t ** (1 / 3) : 7.787 * t + 16 / 116, o = o > v ? o ** (1 / 3) : 7.787 * o + 16 / 116;
484
484
  const i = 116 * t - 16, l = 500 * (e - t), r = 200 * (t - o);
485
485
  return [i, l, r];
486
486
  };
@@ -507,7 +507,7 @@ c.lab.xyz = function(n) {
507
507
  let i, l, r;
508
508
  l = (e + 16) / 116, i = t / 500 + l, r = l - o / 200;
509
509
  const a = l ** 3, s = i ** 3, u = r ** 3;
510
- return l = a > w ? a : (l - 16 / 116) / 7.787, i = s > w ? s : (i - 16 / 116) / 7.787, r = u > w ? u : (r - 16 / 116) / 7.787, i *= 95.047, l *= 100, r *= 108.883, [i, l, r];
510
+ return l = a > v ? a : (l - 16 / 116) / 7.787, i = s > v ? s : (i - 16 / 116) / 7.787, r = u > v ? u : (r - 16 / 116) / 7.787, i *= 95.047, l *= 100, r *= 108.883, [i, l, r];
511
511
  };
512
512
  c.lab.lch = function(n) {
513
513
  const e = n[0], t = n[1], o = n[2];
@@ -748,7 +748,7 @@ const K = [
748
748
  ], I = {};
749
749
  for (const n of Object.keys(b))
750
750
  I[[...b[n].labels].sort().join("")] = n;
751
- const A = {};
751
+ const C = {};
752
752
  function h(n, e) {
753
753
  if (!(this instanceof h))
754
754
  return new h(n, e);
@@ -787,9 +787,9 @@ function h(n, e) {
787
787
  a.push(n[r[t]]);
788
788
  this.color = R(a);
789
789
  }
790
- if (A[this.model])
790
+ if (C[this.model])
791
791
  for (o = b[this.model].channels, t = 0; t < o; t++) {
792
- const i = A[this.model][t];
792
+ const i = C[this.model][t];
793
793
  i && (this.color[t] = i(this.color[t]));
794
794
  }
795
795
  this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
@@ -976,7 +976,7 @@ function an(n) {
976
976
  function d(n, e, t) {
977
977
  n = Array.isArray(n) ? n : [n];
978
978
  for (const o of n)
979
- (A[o] || (A[o] = []))[e] = t;
979
+ (C[o] || (C[o] = []))[e] = t;
980
980
  return n = n[0], function(o) {
981
981
  let i;
982
982
  return o !== void 0 ? (t && (o = t(o)), i = this[n](), i.color[e] = o, i) : (i = this[n]().color[e], t && (i = t(i)), i);
@@ -1030,16 +1030,7 @@ function un(n, e) {
1030
1030
  return n.map((t) => cn(t, e));
1031
1031
  }
1032
1032
  function pn(n, e, t = 127) {
1033
- const o = n - t, i = e >= 0 ? 1 + e * 2 : (
1034
- // Map [0, 1] to [1, 3]
1035
- 1 + e
1036
- );
1037
- let l;
1038
- if (e >= 0) {
1039
- const r = Math.abs(o) / t, a = i * (1 + r * e * 0.5);
1040
- l = t + o * a;
1041
- } else
1042
- l = t + o * i;
1033
+ const o = Math.max(-0.99, Math.min(0.99, e)), i = o < 0 ? o + 1 : 1 / (1 - o), l = t + i * (n - t);
1043
1034
  return Math.round(Math.max(0, Math.min(255, l)));
1044
1035
  }
1045
1036
  function dn(n, e, t = 127) {
@@ -1246,7 +1237,7 @@ const fn = `[
1246
1237
  "layout": {"visibility": "visible"},
1247
1238
  "paint": {
1248
1239
  "fill-opacity": ["interpolate", ["linear"], ["zoom"], 0, 1, 7, 1],
1249
- "fill-color": "rgba(170, 222, 156, 1)"
1240
+ "fill-color": "rgb(184, 224, 173)"
1250
1241
  }
1251
1242
  },
1252
1243
  {
@@ -1407,6 +1398,54 @@ const fn = `[
1407
1398
  "layout": {"visibility": "visible"},
1408
1399
  "paint": {"fill-color": "rgba(43, 63, 131, 0.07)"}
1409
1400
  },
1401
+ {
1402
+ "id": "landuse_nature_reserve_bg",
1403
+ "type": "line",
1404
+ "source": "__protomaps_source",
1405
+ "source-layer": "landuse",
1406
+ "minzoom": 8,
1407
+ "filter": ["all", ["==", "kind", "nature_reserve"]],
1408
+ "layout": {"visibility": "visible"},
1409
+ "paint": {
1410
+ "line-width": [
1411
+ "interpolate",
1412
+ ["exponential", 1.6],
1413
+ ["zoom"],
1414
+ 8,
1415
+ 5,
1416
+ 15,
1417
+ 20,
1418
+ 18,
1419
+ 30
1420
+ ],
1421
+ "line-color": "rgba(5, 109, 0, 0.19)",
1422
+ "line-opacity": {"stops": [[8, 0], [9, 0.4]]}
1423
+ }
1424
+ },
1425
+ {
1426
+ "id": "landuse_nature_reserve",
1427
+ "type": "line",
1428
+ "source": "__protomaps_source",
1429
+ "source-layer": "landuse",
1430
+ "minzoom": 8,
1431
+ "filter": ["all", ["==", "kind", "nature_reserve"]],
1432
+ "layout": {"visibility": "visible"},
1433
+ "paint": {
1434
+ "line-width": [
1435
+ "interpolate",
1436
+ ["exponential", 1.6],
1437
+ ["zoom"],
1438
+ 8,
1439
+ 1,
1440
+ 15,
1441
+ 3,
1442
+ 18,
1443
+ 5
1444
+ ],
1445
+ "line-color": "rgba(5, 109, 0, 0.19)",
1446
+ "line-opacity": {"stops": [[8, 0], [9, 1]]}
1447
+ }
1448
+ },
1410
1449
  {
1411
1450
  "id": "ferry",
1412
1451
  "type": "line",
@@ -1966,7 +2005,7 @@ const fn = `[
1966
2005
  20,
1967
2006
  6
1968
2007
  ],
1969
- "line-color": "rgba(0, 0, 0, 0.15)"
2008
+ "line-color": "rgba(0, 0, 0, 0.05)"
1970
2009
  }
1971
2010
  },
1972
2011
  {
@@ -1984,7 +2023,7 @@ const fn = `[
1984
2023
  ],
1985
2024
  "layout": {"visibility": "visible"},
1986
2025
  "paint": {
1987
- "line-dasharray": [2, 2],
2026
+ "line-dasharray": [3, 1.5],
1988
2027
  "line-width": [
1989
2028
  "interpolate",
1990
2029
  ["exponential", 1.6],
@@ -1994,7 +2033,7 @@ const fn = `[
1994
2033
  20,
1995
2034
  9
1996
2035
  ],
1997
- "line-color": "rgba(249, 247, 241, 1)"
2036
+ "line-color": "rgba(249, 247, 241, 0.6)"
1998
2037
  }
1999
2038
  },
2000
2039
  {
@@ -2561,8 +2600,8 @@ const fn = `[
2561
2600
  18,
2562
2601
  4
2563
2602
  ],
2564
- "line-color": "rgba(20, 116, 0, 1)",
2565
- "line-dasharray": [2, 1.5]
2603
+ "line-color": "rgba(20, 116, 0, 0.7)",
2604
+ "line-dasharray": [3, 1.5]
2566
2605
  }
2567
2606
  },
2568
2607
  {
@@ -3165,10 +3204,10 @@ const fn = `[
3165
3204
  }
3166
3205
  ]`;
3167
3206
  function Y(n, e) {
3168
- const t = G.filter((o) => o.lang === n);
3207
+ const t = D.filter((o) => o.lang === n);
3169
3208
  if (t.length === 0)
3170
3209
  throw new Error(
3171
- `The language "${n}". The languages available are: ${G.map((o) => o.lang).join(", ")}.`
3210
+ `The language "${n}". The languages available are: ${D.map((o) => o.lang).join(", ")}.`
3172
3211
  );
3173
3212
  if (e) {
3174
3213
  if (t.filter((i) => i.script === e).length)
@@ -3183,73 +3222,88 @@ function yn() {
3183
3222
  const n = Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];
3184
3223
  return Y(n, void 0) ? n : "en";
3185
3224
  }
3186
- const O = {
3187
- versatile: fn
3225
+ const E = {
3226
+ avenue: fn
3188
3227
  }, $ = {
3189
- "versatile-night": {
3190
- baseStyle: "versatile",
3228
+ "avenue-pop": {
3229
+ baseStyle: "avenue",
3230
+ colorEdit: {
3231
+ negate: !1,
3232
+ brightness: 0,
3233
+ brightnessShift: 0,
3234
+ exposure: 0,
3235
+ contrast: [0.4, 220],
3236
+ hueRotation: -8,
3237
+ saturation: -0.1,
3238
+ multiplyColor: ["#ff0000", 0],
3239
+ mixColor: ["#ff0000", 0.02]
3240
+ }
3241
+ },
3242
+ "avenue-saturated": {
3243
+ baseStyle: "avenue",
3244
+ colorEdit: {
3245
+ exposure: -1,
3246
+ saturation: 0.1
3247
+ }
3248
+ },
3249
+ "avenue-night": {
3250
+ baseStyle: "avenue",
3191
3251
  colorEdit: {
3192
3252
  brightness: -0.3,
3193
3253
  saturation: -0.8,
3194
3254
  multiplyColor: ["#171075", 0.6],
3195
- contrast: [1.6, 160]
3255
+ contrast: [0.8, 160]
3196
3256
  }
3197
3257
  },
3198
- "versatile-bright": {
3199
- baseStyle: "versatile",
3258
+ "avenue-bright": {
3259
+ baseStyle: "avenue",
3200
3260
  colorEdit: {
3201
3261
  exposure: 0.6,
3202
- saturation: -0.1,
3262
+ saturation: -0.25,
3203
3263
  hueRotation: 15,
3204
- contrast: [0.2, 220]
3264
+ contrast: [0.4, 220]
3205
3265
  }
3206
3266
  },
3207
- "versatile-bnw": {
3208
- baseStyle: "versatile",
3267
+ "avenue-bnw": {
3268
+ baseStyle: "avenue",
3209
3269
  colorEdit: {
3210
3270
  exposure: -1,
3211
3271
  saturation: -1,
3212
- contrast: [1.2, 160]
3272
+ contrast: [0.6, 160]
3213
3273
  }
3214
3274
  },
3215
- "versatile-blueprint": {
3216
- baseStyle: "versatile",
3275
+ "avenue-blueprint": {
3276
+ baseStyle: "avenue",
3217
3277
  colorEdit: {
3218
3278
  exposure: -0.7,
3219
3279
  saturation: -1,
3220
- contrast: [1.2, 160],
3280
+ contrast: [0.75, 160],
3221
3281
  mixColor: ["#3355bb", 0.15]
3222
3282
  }
3223
3283
  },
3224
- "versatile-warm": {
3225
- baseStyle: "versatile",
3284
+ "avenue-warm": {
3285
+ baseStyle: "avenue",
3226
3286
  colorEdit: {
3227
3287
  exposure: -0.7,
3228
- contrast: [-0.1, 110],
3229
- mixColor: ["#ff8800", 0.1]
3288
+ mixColor: ["#ff8800", 0.1],
3289
+ contrast: [0.1, 200]
3230
3290
  }
3231
3291
  },
3232
- "versatile-vintage": {
3233
- baseStyle: "versatile",
3292
+ "avenue-vintage": {
3293
+ baseStyle: "avenue",
3234
3294
  colorEdit: {
3235
3295
  exposure: -0.25,
3236
3296
  multiplyColor: ["#ff8800", 0.4],
3237
- hueRotation: -5
3238
- }
3239
- },
3240
- "versatile-saturated": {
3241
- baseStyle: "versatile",
3242
- colorEdit: {
3243
- exposure: -1,
3244
- saturation: 0.1
3297
+ hueRotation: -5,
3298
+ contrast: [0.2, 200]
3245
3299
  }
3246
3300
  }
3247
3301
  };
3248
3302
  function kn() {
3249
- return Object.keys(O).concat(Object.keys($));
3303
+ return Object.keys(E).concat(Object.keys($));
3250
3304
  }
3251
3305
  function xn(n, e) {
3252
- if (n in O)
3306
+ if (n in E)
3253
3307
  return U({
3254
3308
  ...e,
3255
3309
  baseStyleName: n
@@ -3275,9 +3329,9 @@ function U(n) {
3275
3329
  const g = yn();
3276
3330
  e = JSON.stringify(q(g)), t = JSON.stringify(P(g));
3277
3331
  }
3278
- if (!(n.baseStyleName in O))
3332
+ if (!(n.baseStyleName in E))
3279
3333
  throw new Error(`The base style ${n.baseStyleName} does not exist.`);
3280
- const l = O[n.baseStyleName].replaceAll('"<LANG>"', t).replaceAll('"<LANG_COUNTRY>"', e);
3334
+ const l = E[n.baseStyleName].replaceAll('"<LANG>"', t).replaceAll('"<LANG_COUNTRY>"', e);
3281
3335
  let r;
3282
3336
  if (typeof n.tilejson == "string")
3283
3337
  r = n.tilejson;
@@ -3292,22 +3346,23 @@ function U(n) {
3292
3346
  if (g.length) {
3293
3347
  const p = g[0];
3294
3348
  if (p.layout !== void 0) {
3295
- const v = p.layout;
3296
- v["text-field"] !== void 0 && (v["text-field"] = "");
3349
+ const w = p.layout;
3350
+ w["text-field"] !== void 0 && (w["text-field"] = "");
3297
3351
  }
3298
3352
  }
3299
3353
  a = a.filter((p) => p.id === "pois" || p.type !== "symbol" ? !0 : !(p.layout !== void 0 && p.layout["text-field"] !== void 0));
3300
3354
  }
3301
- const u = n.colorEdit ?? {}, _ = u.brightness ?? 0, m = u.hueRotation ?? 0, F = u.saturation ?? 0, D = u.negate ?? !1, E = u.brightnessShift ?? 0, j = u.exposure ?? 0;
3302
- return (_ !== 0 || m !== 0 || F !== 0 || D === !0 || u.multiplyColor !== void 0 || u.mixColor !== void 0 || E !== 0 || u.contrast !== void 0 || j !== 0) && T(a, (g) => {
3355
+ const u = n.colorEdit ?? {}, _ = u.brightness ?? 0, m = u.hueRotation ?? 0, F = u.saturation ?? 0, G = u.negate ?? !1, O = u.brightnessShift ?? 0, j = u.exposure ?? 0;
3356
+ return (_ !== 0 || m !== 0 || F !== 0 || G === !0 || u.multiplyColor !== void 0 || u.mixColor !== void 0 || O !== 0 || u.contrast !== void 0 || j !== 0) && T(a, (g) => {
3357
+ g === "#a6e085" && console.log("#a6e085");
3303
3358
  let p = h(g);
3304
- if (D && (p = p.negate()), m !== 0 && (p = p.rotate(m)), F !== 0 && (p = p.saturate(F)), _ > 0 ? p = p.lighten(_) : _ < 0 && (p = p.darken(_ * -1)), E !== 0) {
3359
+ if (G && (p = p.negate()), m !== 0 && (p = p.rotate(m)), F !== 0 && (p = p.saturate(F)), _ > 0 ? p = p.lighten(_) : _ < 0 && (p = p.darken(_ * -1)), O !== 0) {
3305
3360
  const M = p.hsl().array();
3306
- M[2] += E * 100, p = h.hsl(...M);
3361
+ M[2] += O * 100, p = h.hsl(...M);
3307
3362
  }
3308
3363
  Array.isArray(u.mixColor) && typeof u.mixColor[0] == "string" && typeof u.mixColor[1] == "number" && u.mixColor[1] !== 0 && (p = p.mix(h(u.mixColor[0]), u.mixColor[1]));
3309
- const v = p.rgb(), H = v.alpha();
3310
- let x = [v.red(), v.green(), v.blue()];
3364
+ const w = p.rgb(), H = w.alpha();
3365
+ let x = [w.red(), w.green(), w.blue()];
3311
3366
  if (j !== 0 && (x = un(x, j)), Array.isArray(u.contrast) && typeof u.contrast[0] == "number" && typeof u.contrast[1] == "number" && u.contrast[0] !== 0 && (x = dn(x, u.contrast[0], u.contrast[1])), Array.isArray(u.multiplyColor) && typeof u.multiplyColor[0] == "string" && typeof u.multiplyColor[1] == "number" && u.multiplyColor[1] !== 0) {
3312
3367
  const M = h(u.multiplyColor[0]);
3313
3368
  x = _n(