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