maplibre-gl-layers 0.3.0 → 0.5.0

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,11 +1,11 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.3.0
3
+ * version: 0.5.0
4
4
  * description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/maplibre-gl-layers.git
8
- * git.commit.hash: fd90d1fd66e4ca9c0defa49e68ecaeb9c14fbd06
8
+ * git.commit.hash: ce37eea48b788c36b4bf98cdfce83b95a85833ee
9
9
  */
10
10
 
11
11
  import { Map as MapLibreMap } from 'maplibre-gl';
package/dist/easing.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: maplibre-gl-layers
3
- * version: 0.3.0
3
+ * version: 0.5.0
4
4
  * description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/maplibre-gl-layers.git
8
- * git.commit.hash: fd90d1fd66e4ca9c0defa49e68ecaeb9c14fbd06
8
+ * git.commit.hash: ce37eea48b788c36b4bf98cdfce83b95a85833ee
9
9
  */
10
10
 
11
11
  import { EasingFunction } from './types';
package/dist/index.cjs CHANGED
@@ -1,14 +1,32 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: maplibre-gl-layers
4
- * version: 0.3.0
4
+ * version: 0.5.0
5
5
  * description: MapLibre's layer extension library enabling the display, movement, and modification of large numbers of dynamic sprite images
6
6
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
7
7
  * license: MIT
8
8
  * repository.url: https://github.com/kekyo/maplibre-gl-layers.git
9
- * git.commit.hash: fd90d1fd66e4ca9c0defa49e68ecaeb9c14fbd06
9
+ * git.commit.hash: ce37eea48b788c36b4bf98cdfce83b95a85833ee
10
10
  */
11
11
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
12
+ const UNLIMITED_SPRITE_SCALING_OPTIONS = {
13
+ metersPerPixel: 1,
14
+ zoomMin: 0,
15
+ zoomMax: 30,
16
+ scaleMin: 1,
17
+ scaleMax: 1,
18
+ spriteMinPixel: 0,
19
+ spriteMaxPixel: 1e5
20
+ };
21
+ const STANDARD_SPRITE_SCALING_OPTIONS = {
22
+ metersPerPixel: 1,
23
+ zoomMin: 8,
24
+ zoomMax: 20,
25
+ scaleMin: 0.1,
26
+ scaleMax: 1,
27
+ spriteMinPixel: 24,
28
+ spriteMaxPixel: 100
29
+ };
12
30
  var maplibreGl$1 = { exports: {} };
13
31
  /**
14
32
  * MapLibre GL JS
@@ -21313,26 +21331,134 @@ const EARTH_RADIUS_METERS = 6378137;
21313
21331
  const DEG2RAD = Math.PI / 180;
21314
21332
  const RAD2DEG = 180 / Math.PI;
21315
21333
  const TILE_SIZE = 512;
21316
- const DEFAULT_SPRITE_SCALING_OPTIONS = {
21317
- metersPerPixel: 1,
21318
- zoomMin: 0,
21319
- zoomMax: 30,
21320
- scaleMin: 1,
21321
- scaleMax: 1,
21322
- spriteMinPixel: 0,
21323
- spriteMaxPixel: 1e4
21324
- };
21325
21334
  const resolveScalingOptions = (options) => {
21326
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
21327
- const base = DEFAULT_SPRITE_SCALING_OPTIONS;
21335
+ var _a, _b;
21336
+ const base = UNLIMITED_SPRITE_SCALING_OPTIONS;
21337
+ const warnings = [];
21338
+ const fallbackMetersPerPixel = Number.isFinite(base.metersPerPixel) && ((_a = base.metersPerPixel) != null ? _a : 0) > 0 ? base.metersPerPixel : 1;
21339
+ let metersPerPixel = (options == null ? void 0 : options.metersPerPixel) !== void 0 ? options.metersPerPixel : fallbackMetersPerPixel;
21340
+ if (!Number.isFinite(metersPerPixel) || metersPerPixel <= 0) {
21341
+ if ((options == null ? void 0 : options.metersPerPixel) !== void 0) {
21342
+ warnings.push(
21343
+ `metersPerPixel(${String(options.metersPerPixel)}) is invalid; using ${fallbackMetersPerPixel}`
21344
+ );
21345
+ }
21346
+ metersPerPixel = fallbackMetersPerPixel;
21347
+ }
21348
+ const fallbackZoomMin = Number.isFinite(base.zoomMin) ? base.zoomMin : 0;
21349
+ let zoomMin = (options == null ? void 0 : options.zoomMin) !== void 0 ? options.zoomMin : fallbackZoomMin;
21350
+ if (!Number.isFinite(zoomMin)) {
21351
+ if ((options == null ? void 0 : options.zoomMin) !== void 0) {
21352
+ warnings.push(
21353
+ `zoomMin(${String(options.zoomMin)}) is not finite; using ${fallbackZoomMin}`
21354
+ );
21355
+ }
21356
+ zoomMin = fallbackZoomMin;
21357
+ }
21358
+ const fallbackZoomMax = Number.isFinite(base.zoomMax) && base.zoomMax > fallbackZoomMin ? base.zoomMax : fallbackZoomMin;
21359
+ let zoomMax = (options == null ? void 0 : options.zoomMax) !== void 0 ? options.zoomMax : fallbackZoomMax;
21360
+ if (!Number.isFinite(zoomMax)) {
21361
+ if ((options == null ? void 0 : options.zoomMax) !== void 0) {
21362
+ warnings.push(
21363
+ `zoomMax(${String(options.zoomMax)}) is not finite; using ${fallbackZoomMax}`
21364
+ );
21365
+ }
21366
+ zoomMax = fallbackZoomMax;
21367
+ }
21368
+ if (zoomMax < zoomMin) {
21369
+ warnings.push(
21370
+ `zoomMax(${zoomMax}) < zoomMin(${zoomMin}); swapped values to maintain ascending order`
21371
+ );
21372
+ [zoomMin, zoomMax] = [zoomMax, zoomMin];
21373
+ }
21374
+ const fallbackScaleMin = Number.isFinite(base.scaleMin) ? base.scaleMin : 1;
21375
+ let scaleMin = (options == null ? void 0 : options.scaleMin) !== void 0 ? options.scaleMin : fallbackScaleMin;
21376
+ if (!Number.isFinite(scaleMin)) {
21377
+ if ((options == null ? void 0 : options.scaleMin) !== void 0) {
21378
+ warnings.push(
21379
+ `scaleMin(${String(options.scaleMin)}) is not finite; using ${fallbackScaleMin}`
21380
+ );
21381
+ }
21382
+ scaleMin = fallbackScaleMin;
21383
+ }
21384
+ if (scaleMin < 0) {
21385
+ warnings.push(`scaleMin(${scaleMin}) is negative; clamped to 0`);
21386
+ scaleMin = 0;
21387
+ }
21388
+ const fallbackScaleMax = Number.isFinite(base.scaleMax) ? base.scaleMax : 1;
21389
+ let scaleMax = (options == null ? void 0 : options.scaleMax) !== void 0 ? options.scaleMax : fallbackScaleMax;
21390
+ if (!Number.isFinite(scaleMax)) {
21391
+ if ((options == null ? void 0 : options.scaleMax) !== void 0) {
21392
+ warnings.push(
21393
+ `scaleMax(${String(options.scaleMax)}) is not finite; using ${fallbackScaleMax}`
21394
+ );
21395
+ }
21396
+ scaleMax = fallbackScaleMax;
21397
+ }
21398
+ if (scaleMax < 0) {
21399
+ warnings.push(`scaleMax(${scaleMax}) is negative; clamped to 0`);
21400
+ scaleMax = 0;
21401
+ }
21402
+ if (scaleMax < scaleMin) {
21403
+ warnings.push(
21404
+ `scaleMax(${scaleMax}) < scaleMin(${scaleMin}); swapped values to maintain ascending order`
21405
+ );
21406
+ [scaleMin, scaleMax] = [scaleMax, scaleMin];
21407
+ }
21408
+ const fallbackSpriteMin = Number.isFinite(base.spriteMinPixel) && base.spriteMinPixel >= 0 ? base.spriteMinPixel : 0;
21409
+ let spriteMinPixel = (options == null ? void 0 : options.spriteMinPixel) !== void 0 ? options.spriteMinPixel : fallbackSpriteMin;
21410
+ if (!Number.isFinite(spriteMinPixel)) {
21411
+ if ((options == null ? void 0 : options.spriteMinPixel) !== void 0) {
21412
+ warnings.push(
21413
+ `spriteMinPixel(${String(
21414
+ options.spriteMinPixel
21415
+ )}) is not finite; using ${fallbackSpriteMin}`
21416
+ );
21417
+ }
21418
+ spriteMinPixel = fallbackSpriteMin;
21419
+ } else if (spriteMinPixel < 0) {
21420
+ warnings.push(
21421
+ `spriteMinPixel(${spriteMinPixel}) is negative; clamped to 0`
21422
+ );
21423
+ spriteMinPixel = 0;
21424
+ }
21425
+ const fallbackSpriteMax = Number.isFinite(base.spriteMaxPixel) && base.spriteMaxPixel >= 0 ? base.spriteMaxPixel : 0;
21426
+ let spriteMaxPixel = (options == null ? void 0 : options.spriteMaxPixel) !== void 0 ? options.spriteMaxPixel : fallbackSpriteMax;
21427
+ if (!Number.isFinite(spriteMaxPixel)) {
21428
+ if ((options == null ? void 0 : options.spriteMaxPixel) !== void 0) {
21429
+ warnings.push(
21430
+ `spriteMaxPixel(${String(
21431
+ options.spriteMaxPixel
21432
+ )}) is not finite; using ${fallbackSpriteMax}`
21433
+ );
21434
+ }
21435
+ spriteMaxPixel = fallbackSpriteMax;
21436
+ } else if (spriteMaxPixel < 0) {
21437
+ warnings.push(
21438
+ `spriteMaxPixel(${spriteMaxPixel}) is negative; clamped to 0`
21439
+ );
21440
+ spriteMaxPixel = 0;
21441
+ }
21442
+ if (spriteMinPixel > 0 && spriteMaxPixel > 0 && spriteMaxPixel < spriteMinPixel) {
21443
+ warnings.push(
21444
+ `spriteMaxPixel(${spriteMaxPixel}) < spriteMinPixel(${spriteMinPixel}); swapped values to maintain ascending order`
21445
+ );
21446
+ [spriteMinPixel, spriteMaxPixel] = [spriteMaxPixel, spriteMinPixel];
21447
+ }
21448
+ if (warnings.length > 0 && typeof console !== "undefined") {
21449
+ const warn = (_b = console.warn) != null ? _b : null;
21450
+ if (typeof warn === "function") {
21451
+ warn(`[SpriteScalingOptions] ${warnings.join("; ")}`);
21452
+ }
21453
+ }
21328
21454
  return {
21329
- metersPerPixel: (_b = (_a = options == null ? void 0 : options.metersPerPixel) != null ? _a : base.metersPerPixel) != null ? _b : 1,
21330
- zoomMin: (_d = (_c = options == null ? void 0 : options.zoomMin) != null ? _c : base.zoomMin) != null ? _d : 0,
21331
- zoomMax: (_f = (_e = options == null ? void 0 : options.zoomMax) != null ? _e : base.zoomMax) != null ? _f : 24,
21332
- scaleMin: (_h = (_g = options == null ? void 0 : options.scaleMin) != null ? _g : base.scaleMin) != null ? _h : 1,
21333
- scaleMax: (_j = (_i = options == null ? void 0 : options.scaleMax) != null ? _i : base.scaleMax) != null ? _j : 1,
21334
- spriteMinPixel: (_l = (_k = options == null ? void 0 : options.spriteMinPixel) != null ? _k : base.spriteMinPixel) != null ? _l : 0,
21335
- spriteMaxPixel: (_n = (_m = options == null ? void 0 : options.spriteMaxPixel) != null ? _m : base.spriteMaxPixel) != null ? _n : 0
21455
+ metersPerPixel,
21456
+ zoomMin,
21457
+ zoomMax,
21458
+ scaleMin,
21459
+ scaleMax,
21460
+ spriteMinPixel,
21461
+ spriteMaxPixel
21336
21462
  };
21337
21463
  };
21338
21464
  const calculateZoomScaleFactor = (zoom, scaling) => {
@@ -21393,25 +21519,30 @@ const calculateDistanceAndBearingMeters = (from, to) => {
21393
21519
  const clampSpritePixelSize = (width, height, spriteMinPixel, spriteMaxPixel) => {
21394
21520
  const largest = Math.max(width, height);
21395
21521
  if (!Number.isFinite(largest) || largest <= 0) {
21396
- return { width, height };
21522
+ return { width, height, scaleAdjustment: 1 };
21397
21523
  }
21398
21524
  let nextWidth = width;
21399
21525
  let nextHeight = height;
21526
+ let scaleAdjustment = 1;
21527
+ let adjustedLargest = largest;
21400
21528
  if (spriteMinPixel > 0 && largest < spriteMinPixel) {
21401
21529
  const factor = spriteMinPixel / largest;
21402
21530
  nextWidth *= factor;
21403
21531
  nextHeight *= factor;
21532
+ scaleAdjustment *= factor;
21533
+ adjustedLargest *= factor;
21404
21534
  }
21405
- if (spriteMaxPixel > 0 && largest > spriteMaxPixel) {
21406
- const factor = spriteMaxPixel / largest;
21535
+ if (spriteMaxPixel > 0 && adjustedLargest > spriteMaxPixel) {
21536
+ const factor = spriteMaxPixel / adjustedLargest;
21407
21537
  nextWidth *= factor;
21408
21538
  nextHeight *= factor;
21539
+ scaleAdjustment *= factor;
21409
21540
  }
21410
- return { width: nextWidth, height: nextHeight };
21541
+ return { width: nextWidth, height: nextHeight, scaleAdjustment };
21411
21542
  };
21412
21543
  const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, effectivePixelsPerMeter, spriteMinPixel, spriteMaxPixel) => {
21413
21544
  if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0 || effectivePixelsPerMeter <= 0) {
21414
- return { width: 0, height: 0 };
21545
+ return { width: 0, height: 0, scaleAdjustment: 1 };
21415
21546
  }
21416
21547
  const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor * effectivePixelsPerMeter;
21417
21548
  const rawWidth = ensureFinite(imageWidth * scaleFactor);
@@ -21423,10 +21554,10 @@ const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPe
21423
21554
  spriteMaxPixel
21424
21555
  );
21425
21556
  };
21426
- const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter) => {
21557
+ const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter, sizeScaleAdjustment = 1) => {
21427
21558
  var _a, _b;
21428
21559
  const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
21429
- const offsetPixels = offsetMeters * effectivePixelsPerMeter;
21560
+ const offsetPixels = offsetMeters * effectivePixelsPerMeter * sizeScaleAdjustment;
21430
21561
  const offsetRad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
21431
21562
  return {
21432
21563
  x: offsetPixels * Math.sin(offsetRad),
@@ -21450,14 +21581,40 @@ const calculateBillboardAnchorShiftPixels = (halfWidth, halfHeight, anchor, tota
21450
21581
  const shiftY = -anchorX * sinR - anchorY * cosR;
21451
21582
  return { x: shiftX, y: shiftY };
21452
21583
  };
21453
- const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor) => {
21584
+ const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, options) => {
21585
+ var _a, _b;
21454
21586
  if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0) {
21455
- return { width: 0, height: 0 };
21587
+ return { width: 0, height: 0, scaleAdjustment: 1 };
21456
21588
  }
21457
21589
  const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor;
21458
- const width = ensureFinite(imageWidth * scaleFactor);
21459
- const height = ensureFinite(imageHeight * scaleFactor);
21460
- return { width, height };
21590
+ let width = ensureFinite(imageWidth * scaleFactor);
21591
+ let height = ensureFinite(imageHeight * scaleFactor);
21592
+ let scaleAdjustment = 1;
21593
+ const effectivePixelsPerMeter = (options == null ? void 0 : options.effectivePixelsPerMeter) !== void 0 ? options.effectivePixelsPerMeter : 0;
21594
+ const spriteMinPixel = (_a = options == null ? void 0 : options.spriteMinPixel) != null ? _a : 0;
21595
+ const spriteMaxPixel = (_b = options == null ? void 0 : options.spriteMaxPixel) != null ? _b : 0;
21596
+ if (effectivePixelsPerMeter > 0 && Number.isFinite(effectivePixelsPerMeter) && (spriteMinPixel > 0 || spriteMaxPixel > 0)) {
21597
+ const largestMeters = Math.max(width, height);
21598
+ if (largestMeters > 0 && Number.isFinite(largestMeters)) {
21599
+ const largestPixels = largestMeters * effectivePixelsPerMeter;
21600
+ if (Number.isFinite(largestPixels) && largestPixels > 0) {
21601
+ let scale = 1;
21602
+ if (spriteMinPixel > 0 && largestPixels < spriteMinPixel) {
21603
+ scale = spriteMinPixel / largestPixels;
21604
+ }
21605
+ const scaledLargest = largestPixels * scale;
21606
+ if (spriteMaxPixel > 0 && scaledLargest > spriteMaxPixel) {
21607
+ scale = spriteMaxPixel / largestPixels;
21608
+ }
21609
+ if (scale !== 1) {
21610
+ width *= scale;
21611
+ height *= scale;
21612
+ scaleAdjustment *= scale;
21613
+ }
21614
+ }
21615
+ }
21616
+ }
21617
+ return { width, height, scaleAdjustment };
21461
21618
  };
21462
21619
  const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, anchor, totalRotateDeg) => {
21463
21620
  var _a, _b;
@@ -21476,16 +21633,16 @@ const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, an
21476
21633
  const north = -anchorEast * sinR - anchorNorth * cosR;
21477
21634
  return { east, north };
21478
21635
  };
21479
- const calculateSurfaceOffsetMeters = (offset, imageScale) => {
21636
+ const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor, sizeScaleAdjustment = 1) => {
21480
21637
  var _a, _b;
21481
- const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale;
21638
+ const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
21482
21639
  if (offsetMeters === 0) {
21483
21640
  return { east: 0, north: 0 };
21484
21641
  }
21485
21642
  const rad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
21486
21643
  return {
21487
- east: offsetMeters * Math.sin(rad),
21488
- north: offsetMeters * Math.cos(rad)
21644
+ east: offsetMeters * Math.sin(rad) * sizeScaleAdjustment,
21645
+ north: offsetMeters * Math.cos(rad) * sizeScaleAdjustment
21489
21646
  };
21490
21647
  };
21491
21648
  const MIN_COS_LAT = 1e-6;
@@ -21633,7 +21790,8 @@ const calculateBillboardCenterPosition = (params) => {
21633
21790
  offset,
21634
21791
  imageScale,
21635
21792
  zoomScaleFactor,
21636
- effectivePixelsPerMeter
21793
+ effectivePixelsPerMeter,
21794
+ pixelDims.scaleAdjustment
21637
21795
  );
21638
21796
  const centerX = base.x + offsetShift.x;
21639
21797
  const centerY = base.y - offsetShift.y;
@@ -21696,6 +21854,9 @@ const calculateSurfaceCenterPosition = (params) => {
21696
21854
  totalRotateDeg,
21697
21855
  anchor,
21698
21856
  offset,
21857
+ effectivePixelsPerMeter = 0,
21858
+ spriteMinPixel = 0,
21859
+ spriteMaxPixel = 0,
21699
21860
  project,
21700
21861
  projectToClipSpace,
21701
21862
  drawingBufferWidth,
@@ -21733,7 +21894,12 @@ const calculateSurfaceCenterPosition = (params) => {
21733
21894
  imageHeight,
21734
21895
  baseMetersPerPixel,
21735
21896
  imageScale,
21736
- zoomScaleFactor
21897
+ zoomScaleFactor,
21898
+ {
21899
+ effectivePixelsPerMeter,
21900
+ spriteMinPixel,
21901
+ spriteMaxPixel
21902
+ }
21737
21903
  );
21738
21904
  const halfWidthMeters = worldDims.width / 2;
21739
21905
  const halfHeightMeters = worldDims.height / 2;
@@ -21743,7 +21909,12 @@ const calculateSurfaceCenterPosition = (params) => {
21743
21909
  anchor,
21744
21910
  totalRotateDeg
21745
21911
  );
21746
- const offsetMeters = calculateSurfaceOffsetMeters(offset, imageScale);
21912
+ const offsetMeters = calculateSurfaceOffsetMeters(
21913
+ offset,
21914
+ imageScale,
21915
+ zoomScaleFactor,
21916
+ worldDims.scaleAdjustment
21917
+ );
21747
21918
  const totalEast = anchorShiftMeters.east + offsetMeters.east;
21748
21919
  const totalNorth = anchorShiftMeters.north + offsetMeters.north;
21749
21920
  const displaced = applySurfaceDisplacement(
@@ -22075,6 +22246,35 @@ const resolveTextGlyphPadding = (padding) => {
22075
22246
  }
22076
22247
  return { top: 0, right: 0, bottom: 0, left: 0 };
22077
22248
  };
22249
+ const resolveBorderSides = (sides) => {
22250
+ if (!Array.isArray(sides) || sides.length === 0) {
22251
+ return { top: true, right: true, bottom: true, left: true };
22252
+ }
22253
+ let top = false;
22254
+ let right = false;
22255
+ let bottom = false;
22256
+ let left = false;
22257
+ for (const side of sides) {
22258
+ switch (side) {
22259
+ case "top":
22260
+ top = true;
22261
+ break;
22262
+ case "right":
22263
+ right = true;
22264
+ break;
22265
+ case "bottom":
22266
+ bottom = true;
22267
+ break;
22268
+ case "left":
22269
+ left = true;
22270
+ break;
22271
+ }
22272
+ }
22273
+ if (!top && !right && !bottom && !left) {
22274
+ return { top: true, right: true, bottom: true, left: true };
22275
+ }
22276
+ return { top, right, bottom, left };
22277
+ };
22078
22278
  const resolveTextAlign = (align) => {
22079
22279
  switch (align) {
22080
22280
  case "left":
@@ -22118,7 +22318,7 @@ const resolveTextGlyphOptions = (options, preferredLineHeight) => {
22118
22318
  DEFAULT_TEXT_GLYPH_FONT_SIZE
22119
22319
  );
22120
22320
  const resolvedFontSize = resolvePositiveFinite(
22121
- options == null ? void 0 : options.fontSizePixel,
22321
+ options == null ? void 0 : options.fontSizePixelHint,
22122
22322
  fallbackFontSize
22123
22323
  );
22124
22324
  return {
@@ -22133,6 +22333,7 @@ const resolveTextGlyphOptions = (options, preferredLineHeight) => {
22133
22333
  borderColor: options == null ? void 0 : options.borderColor,
22134
22334
  borderWidthPixel: resolveNonNegativeFinite(options == null ? void 0 : options.borderWidthPixel, 0),
22135
22335
  borderRadiusPixel: resolveNonNegativeFinite(options == null ? void 0 : options.borderRadiusPixel, 0),
22336
+ borderSides: resolveBorderSides(options == null ? void 0 : options.borderSides),
22136
22337
  textAlign: resolveTextAlign(options == null ? void 0 : options.textAlign),
22137
22338
  renderPixelRatio: resolveRenderPixelRatio(options == null ? void 0 : options.renderPixelRatio)
22138
22339
  };
@@ -22244,13 +22445,58 @@ const fillRoundedRect = (ctx, width, height, radius, color) => {
22244
22445
  ctx.fill();
22245
22446
  ctx.restore();
22246
22447
  };
22247
- const strokeRoundedRect = (ctx, width, height, radius, color, lineWidth) => {
22448
+ const strokeRoundedRect = (ctx, width, height, radius, color, lineWidth, sides) => {
22449
+ const { top, right, bottom, left } = sides;
22450
+ if (lineWidth <= 0 || !top && !right && !bottom && !left) {
22451
+ return;
22452
+ }
22248
22453
  ctx.save();
22249
- ctx.beginPath();
22250
- drawRoundedRectPath(ctx, 0, 0, width, height, radius);
22251
22454
  ctx.strokeStyle = color;
22252
22455
  ctx.lineWidth = lineWidth;
22253
- ctx.stroke();
22456
+ const cornerRadius = Math.max(0, Math.min(radius, width / 2, height / 2));
22457
+ const previousCap = ctx.lineCap;
22458
+ ctx.lineCap = cornerRadius === 0 ? "square" : "butt";
22459
+ if (top) {
22460
+ const startX = cornerRadius;
22461
+ const endX = width - cornerRadius;
22462
+ if (endX > startX) {
22463
+ ctx.beginPath();
22464
+ ctx.moveTo(startX, 0);
22465
+ ctx.lineTo(endX, 0);
22466
+ ctx.stroke();
22467
+ }
22468
+ }
22469
+ if (right) {
22470
+ const startY = cornerRadius;
22471
+ const endY = height - cornerRadius;
22472
+ if (endY > startY) {
22473
+ ctx.beginPath();
22474
+ ctx.moveTo(width, startY);
22475
+ ctx.lineTo(width, endY);
22476
+ ctx.stroke();
22477
+ }
22478
+ }
22479
+ if (bottom) {
22480
+ const startX = width - cornerRadius;
22481
+ const endX = cornerRadius;
22482
+ if (startX > endX) {
22483
+ ctx.beginPath();
22484
+ ctx.moveTo(startX, height);
22485
+ ctx.lineTo(endX, height);
22486
+ ctx.stroke();
22487
+ }
22488
+ }
22489
+ if (left) {
22490
+ const startY = height - cornerRadius;
22491
+ const endY = cornerRadius;
22492
+ if (startY > endY) {
22493
+ ctx.beginPath();
22494
+ ctx.moveTo(0, startY);
22495
+ ctx.lineTo(0, endY);
22496
+ ctx.stroke();
22497
+ }
22498
+ }
22499
+ ctx.lineCap = previousCap;
22254
22500
  ctx.restore();
22255
22501
  };
22256
22502
  const measureTextWidthWithSpacing = (ctx, text, letterSpacing) => {
@@ -22576,6 +22822,9 @@ const createSpriteLayer = (options) => {
22576
22822
  totalRotateDeg: totalRotDeg,
22577
22823
  anchor: img.anchor,
22578
22824
  offset: img.offset,
22825
+ effectivePixelsPerMeter,
22826
+ spriteMinPixel,
22827
+ spriteMaxPixel,
22579
22828
  projectToClipSpace,
22580
22829
  drawingBufferWidth,
22581
22830
  drawingBufferHeight,
@@ -23176,6 +23425,9 @@ const createSpriteLayer = (options) => {
23176
23425
  totalRotateDeg,
23177
23426
  anchor,
23178
23427
  offset: offsetDef,
23428
+ effectivePixelsPerMeter,
23429
+ spriteMinPixel,
23430
+ spriteMaxPixel,
23179
23431
  projectToClipSpace: (lng, lat, elevation) => projectLngLatToClipSpace(lng, lat, elevation, clipContext),
23180
23432
  drawingBufferWidth,
23181
23433
  drawingBufferHeight,
@@ -23191,7 +23443,9 @@ const createSpriteLayer = (options) => {
23191
23443
  }
23192
23444
  const offsetMeters = calculateSurfaceOffsetMeters(
23193
23445
  offsetDef,
23194
- imageScale
23446
+ imageScale,
23447
+ zoomScaleFactor,
23448
+ surfaceCenter.worldDimensions.scaleAdjustment
23195
23449
  );
23196
23450
  const cornerDisplacements = calculateSurfaceCornerDisplacements({
23197
23451
  worldWidthMeters: surfaceCenter.worldDimensions.width,
@@ -23386,14 +23640,21 @@ const createSpriteLayer = (options) => {
23386
23640
  imageResource.height,
23387
23641
  baseMetersPerPixel,
23388
23642
  imageScale,
23389
- zoomScaleFactor
23643
+ zoomScaleFactor,
23644
+ {
23645
+ effectivePixelsPerMeter,
23646
+ spriteMinPixel,
23647
+ spriteMaxPixel
23648
+ }
23390
23649
  );
23391
23650
  const totalRotateDeg = Number.isFinite(imageEntry.displayedRotateDeg) ? imageEntry.displayedRotateDeg : normaliseAngleDeg(
23392
23651
  ((_e = imageEntry.resolvedBaseRotateDeg) != null ? _e : 0) + ((_f = imageEntry.rotateDeg) != null ? _f : 0)
23393
23652
  );
23394
23653
  const offsetMeters = calculateSurfaceOffsetMeters(
23395
23654
  offsetResolved,
23396
- imageScale
23655
+ imageScale,
23656
+ zoomScaleFactor,
23657
+ worldDims.scaleAdjustment
23397
23658
  );
23398
23659
  const cornerDisplacements = calculateSurfaceCornerDisplacements({
23399
23660
  worldWidthMeters: worldDims.width,
@@ -23656,7 +23917,8 @@ const createSpriteLayer = (options) => {
23656
23917
  strokeHeight,
23657
23918
  strokeRadius,
23658
23919
  resolved.borderColor,
23659
- borderWidth
23920
+ borderWidth,
23921
+ resolved.borderSides
23660
23922
  );
23661
23923
  ctx.restore();
23662
23924
  }
@@ -24478,6 +24740,8 @@ const createSpriteLayer = (options) => {
24478
24740
  };
24479
24741
  return spriteLayout;
24480
24742
  };
24743
+ exports.STANDARD_SPRITE_SCALING_OPTIONS = STANDARD_SPRITE_SCALING_OPTIONS;
24744
+ exports.UNLIMITED_SPRITE_SCALING_OPTIONS = UNLIMITED_SPRITE_SCALING_OPTIONS;
24481
24745
  exports.applyAutoRotation = applyAutoRotation;
24482
24746
  exports.calculatePerspectiveRatio = calculatePerspectiveRatio;
24483
24747
  exports.cloneAnchor = cloneAnchor;