@chrtco/sdk 0.10.1 → 0.10.2

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 CHANGED
@@ -27478,6 +27478,34 @@ function makeCollapsedBandVariant(layer, B, isExempt) {
27478
27478
  delete collapsed.maxzoom;
27479
27479
  return [collapsed];
27480
27480
  }
27481
+ function collapsedOrientationGate(minzoom) {
27482
+ const clauses = [NOT_DOMINATED_FILTER];
27483
+ for (const D of BAND_DRAW_ORDER) {
27484
+ const dMaxzoom = dominatedVariantMaxzoom(D);
27485
+ if (dMaxzoom <= minzoom) continue;
27486
+ clauses.push(["all", dominatedByMinFilter(D), ["<", ["zoom"], dMaxzoom]]);
27487
+ }
27488
+ return ["any", ...clauses];
27489
+ }
27490
+ function makeCollapsedCrossBandLabel(label, isExempt) {
27491
+ const classMinzoom = label.minzoom ?? 0;
27492
+ const clauses = [];
27493
+ for (const B of BAND_DRAW_ORDER) {
27494
+ const floor = BAND_PRIORITY_RANGES[B].minzoom;
27495
+ const parts = [bandFilterExpression(B)];
27496
+ if (floor > 0) parts.push([">=", ["zoom"], floor]);
27497
+ if (!isExempt) {
27498
+ parts.push(collapsedDominanceGate(B, Math.max(classMinzoom, floor)));
27499
+ }
27500
+ clauses.push(parts.length === 1 ? parts[0] : ["all", ...parts]);
27501
+ }
27502
+ const collapsed = {
27503
+ ...label,
27504
+ filter: combineWithBandFilter(label.filter, ["any", ...clauses])
27505
+ };
27506
+ delete collapsed.maxzoom;
27507
+ return collapsed;
27508
+ }
27481
27509
 
27482
27510
  // src/atlas/style-generator.ts
27483
27511
  var META_LAYERS = /* @__PURE__ */ new Set([
@@ -27629,7 +27657,7 @@ var CELL_BAND_OPACITY_CURVE = {
27629
27657
  "5": [[11, 0.6], [13, 0.35], [18, 0.25]],
27630
27658
  "6": [[13, 0.75], [16, 0.55], [22, 0.45]]
27631
27659
  };
27632
- function fanOrientationLabelByCellBand(label) {
27660
+ function fanOrientationLabelByCellBand(label, bandFan) {
27633
27661
  const cellBandExpr = [
27634
27662
  "slice",
27635
27663
  ["coalesce", ["get", "_cell_id"], "??9???"],
@@ -27654,6 +27682,16 @@ function fanOrientationLabelByCellBand(label) {
27654
27682
  ...label.paint ?? {},
27655
27683
  "text-opacity": opacityExpr
27656
27684
  };
27685
+ if (bandFan === "collapsed") {
27686
+ variants.push({
27687
+ ...label,
27688
+ id: `${label.id}-cell${code}-notdom`,
27689
+ filter: combineWithBandFilter(cellFiltered, collapsedOrientationGate(minzoom)),
27690
+ minzoom,
27691
+ paint
27692
+ });
27693
+ continue;
27694
+ }
27657
27695
  variants.push({
27658
27696
  ...label,
27659
27697
  id: `${label.id}-cell${code}-notdom`,
@@ -27683,18 +27721,50 @@ function byLabelPriorityBottomUp(bundles) {
27683
27721
  (a, b) => getLabelPriority(b.objectClass) - getLabelPriority(a.objectClass)
27684
27722
  );
27685
27723
  }
27686
- function chartModeFilterForBand(layer, B, higherCascadeBands, lockedBounds, isRequestedBand) {
27687
- let filter = combineWithBandFilter(layer.filter, bandFilterExpression(B));
27724
+ function chartModeBandClauses(layer, B, higherCascadeBands, lockedBounds, isRequestedBand) {
27725
+ const parts = [bandFilterExpression(B)];
27688
27726
  if (!isDominanceExempt(layer)) {
27689
27727
  for (const D of higherCascadeBands) {
27690
- filter = combineWithBandFilter(filter, ["!", dominatedByMinFilter(D)]);
27728
+ parts.push(["!", dominatedByMinFilter(D)]);
27691
27729
  }
27692
27730
  }
27693
27731
  if (lockedBounds && isRequestedBand) {
27694
- filter = combineWithBandFilter(filter, withinBboxFilter(lockedBounds));
27732
+ parts.push(withinBboxFilter(lockedBounds));
27733
+ }
27734
+ return parts;
27735
+ }
27736
+ function chartModeFilterForBand(layer, B, higherCascadeBands, lockedBounds, isRequestedBand) {
27737
+ const [first, ...rest] = chartModeBandClauses(
27738
+ layer,
27739
+ B,
27740
+ higherCascadeBands,
27741
+ lockedBounds,
27742
+ isRequestedBand
27743
+ );
27744
+ let filter = combineWithBandFilter(layer.filter, first);
27745
+ for (const part of rest) {
27746
+ filter = combineWithBandFilter(filter, part);
27695
27747
  }
27696
27748
  return filter;
27697
27749
  }
27750
+ function makeCollapsedChartLabel(label, cascade, requestedSet, lockedBounds) {
27751
+ const clauses = cascade.map((B, i) => {
27752
+ const parts = chartModeBandClauses(
27753
+ label,
27754
+ B,
27755
+ cascade.slice(i + 1),
27756
+ lockedBounds,
27757
+ requestedSet.has(B)
27758
+ );
27759
+ return parts.length === 1 ? parts[0] : ["all", ...parts];
27760
+ });
27761
+ const collapsed = {
27762
+ ...label,
27763
+ filter: combineWithBandFilter(label.filter, ["any", ...clauses])
27764
+ };
27765
+ delete collapsed.maxzoom;
27766
+ return collapsed;
27767
+ }
27698
27768
  function generateStyle(palette = "DAY", opts = {}) {
27699
27769
  const sources = buildSources(opts);
27700
27770
  const sourceId = opts.region ?? DEFAULT_REGION;
@@ -27710,6 +27780,7 @@ function generateStyle(palette = "DAY", opts = {}) {
27710
27780
  const labelLayers = [];
27711
27781
  const chartCascade = opts.chartMode ? CHART_CASCADE_CODES[opts.chartMode.band] : null;
27712
27782
  const chartRequestedCodes = opts.chartMode ? CHART_BAND_CODES[opts.chartMode.band] : null;
27783
+ const bandFan = opts.bandFan ?? "collapsed";
27713
27784
  const lockedBounds = opts.chartMode?.lockedBounds;
27714
27785
  const bundles = [];
27715
27786
  for (const objectClass of orderedClasses) {
@@ -27763,6 +27834,12 @@ function generateStyle(palette = "DAY", opts = {}) {
27763
27834
  )
27764
27835
  );
27765
27836
  for (const { label } of chartLabelBundles) {
27837
+ if (bandFan === "collapsed") {
27838
+ labelLayers.push(
27839
+ makeCollapsedChartLabel(label, chartCascade, requestedSet, lockedBounds)
27840
+ );
27841
+ continue;
27842
+ }
27766
27843
  for (let i = 0; i < chartCascade.length; i++) {
27767
27844
  const B = chartCascade[i];
27768
27845
  const higher = chartCascade.slice(i + 1);
@@ -27785,7 +27862,6 @@ function generateStyle(palette = "DAY", opts = {}) {
27785
27862
  }
27786
27863
  layers.push(...labelLayers);
27787
27864
  } else {
27788
- const bandFan = opts.bandFan ?? "collapsed";
27789
27865
  const emitBand = (base, code) => bandFan === "legacy" ? makeBandVariants(base, code) : makeCollapsedBandVariant(base, code, isDominanceExempt(base));
27790
27866
  for (const code of BAND_DRAW_ORDER) {
27791
27867
  for (const { featureLayers } of regularBundles) {
@@ -27804,7 +27880,7 @@ function generateStyle(palette = "DAY", opts = {}) {
27804
27880
  for (const { objectClass, label } of bundles) {
27805
27881
  if (!label) continue;
27806
27882
  if (getLabelBehavior(objectClass) === "orientation-cross-band") {
27807
- labelLayers.push(...fanOrientationLabelByCellBand(label));
27883
+ labelLayers.push(...fanOrientationLabelByCellBand(label, bandFan));
27808
27884
  }
27809
27885
  }
27810
27886
  const featureLabelBundles = byLabelPriorityBottomUp(
@@ -27813,6 +27889,10 @@ function generateStyle(palette = "DAY", opts = {}) {
27813
27889
  )
27814
27890
  );
27815
27891
  for (const { label } of featureLabelBundles) {
27892
+ if (bandFan === "collapsed") {
27893
+ labelLayers.push(makeCollapsedCrossBandLabel(label, isDominanceExempt(label)));
27894
+ continue;
27895
+ }
27816
27896
  for (const code of BAND_DRAW_ORDER) {
27817
27897
  labelLayers.push(...emitBand(label, code));
27818
27898
  }