maplibre-gl-layers 0.4.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 +29 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +29 -18
- 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 +12 -7
- package/dist/numericInterpolation.d.ts +2 -2
- package/dist/rotationInterpolation.d.ts +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +6 -6
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,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
|
const UNLIMITED_SPRITE_SCALING_OPTIONS = {
|
|
11
11
|
metersPerPixel: 1,
|
|
@@ -21517,25 +21517,30 @@ const calculateDistanceAndBearingMeters = (from, to) => {
|
|
|
21517
21517
|
const clampSpritePixelSize = (width, height, spriteMinPixel, spriteMaxPixel) => {
|
|
21518
21518
|
const largest = Math.max(width, height);
|
|
21519
21519
|
if (!Number.isFinite(largest) || largest <= 0) {
|
|
21520
|
-
return { width, height };
|
|
21520
|
+
return { width, height, scaleAdjustment: 1 };
|
|
21521
21521
|
}
|
|
21522
21522
|
let nextWidth = width;
|
|
21523
21523
|
let nextHeight = height;
|
|
21524
|
+
let scaleAdjustment = 1;
|
|
21525
|
+
let adjustedLargest = largest;
|
|
21524
21526
|
if (spriteMinPixel > 0 && largest < spriteMinPixel) {
|
|
21525
21527
|
const factor = spriteMinPixel / largest;
|
|
21526
21528
|
nextWidth *= factor;
|
|
21527
21529
|
nextHeight *= factor;
|
|
21530
|
+
scaleAdjustment *= factor;
|
|
21531
|
+
adjustedLargest *= factor;
|
|
21528
21532
|
}
|
|
21529
|
-
if (spriteMaxPixel > 0 &&
|
|
21530
|
-
const factor = spriteMaxPixel /
|
|
21533
|
+
if (spriteMaxPixel > 0 && adjustedLargest > spriteMaxPixel) {
|
|
21534
|
+
const factor = spriteMaxPixel / adjustedLargest;
|
|
21531
21535
|
nextWidth *= factor;
|
|
21532
21536
|
nextHeight *= factor;
|
|
21537
|
+
scaleAdjustment *= factor;
|
|
21533
21538
|
}
|
|
21534
|
-
return { width: nextWidth, height: nextHeight };
|
|
21539
|
+
return { width: nextWidth, height: nextHeight, scaleAdjustment };
|
|
21535
21540
|
};
|
|
21536
21541
|
const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, effectivePixelsPerMeter, spriteMinPixel, spriteMaxPixel) => {
|
|
21537
21542
|
if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0 || effectivePixelsPerMeter <= 0) {
|
|
21538
|
-
return { width: 0, height: 0 };
|
|
21543
|
+
return { width: 0, height: 0, scaleAdjustment: 1 };
|
|
21539
21544
|
}
|
|
21540
21545
|
const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor * effectivePixelsPerMeter;
|
|
21541
21546
|
const rawWidth = ensureFinite(imageWidth * scaleFactor);
|
|
@@ -21547,10 +21552,10 @@ const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPe
|
|
|
21547
21552
|
spriteMaxPixel
|
|
21548
21553
|
);
|
|
21549
21554
|
};
|
|
21550
|
-
const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter) => {
|
|
21555
|
+
const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter, sizeScaleAdjustment = 1) => {
|
|
21551
21556
|
var _a, _b;
|
|
21552
21557
|
const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
|
|
21553
|
-
const offsetPixels = offsetMeters * effectivePixelsPerMeter;
|
|
21558
|
+
const offsetPixels = offsetMeters * effectivePixelsPerMeter * sizeScaleAdjustment;
|
|
21554
21559
|
const offsetRad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
|
|
21555
21560
|
return {
|
|
21556
21561
|
x: offsetPixels * Math.sin(offsetRad),
|
|
@@ -21577,11 +21582,12 @@ const calculateBillboardAnchorShiftPixels = (halfWidth, halfHeight, anchor, tota
|
|
|
21577
21582
|
const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, options) => {
|
|
21578
21583
|
var _a, _b;
|
|
21579
21584
|
if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0) {
|
|
21580
|
-
return { width: 0, height: 0 };
|
|
21585
|
+
return { width: 0, height: 0, scaleAdjustment: 1 };
|
|
21581
21586
|
}
|
|
21582
21587
|
const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor;
|
|
21583
21588
|
let width = ensureFinite(imageWidth * scaleFactor);
|
|
21584
21589
|
let height = ensureFinite(imageHeight * scaleFactor);
|
|
21590
|
+
let scaleAdjustment = 1;
|
|
21585
21591
|
const effectivePixelsPerMeter = (options == null ? void 0 : options.effectivePixelsPerMeter) !== void 0 ? options.effectivePixelsPerMeter : 0;
|
|
21586
21592
|
const spriteMinPixel = (_a = options == null ? void 0 : options.spriteMinPixel) != null ? _a : 0;
|
|
21587
21593
|
const spriteMaxPixel = (_b = options == null ? void 0 : options.spriteMaxPixel) != null ? _b : 0;
|
|
@@ -21601,11 +21607,12 @@ const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerP
|
|
|
21601
21607
|
if (scale !== 1) {
|
|
21602
21608
|
width *= scale;
|
|
21603
21609
|
height *= scale;
|
|
21610
|
+
scaleAdjustment *= scale;
|
|
21604
21611
|
}
|
|
21605
21612
|
}
|
|
21606
21613
|
}
|
|
21607
21614
|
}
|
|
21608
|
-
return { width, height };
|
|
21615
|
+
return { width, height, scaleAdjustment };
|
|
21609
21616
|
};
|
|
21610
21617
|
const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, anchor, totalRotateDeg) => {
|
|
21611
21618
|
var _a, _b;
|
|
@@ -21624,7 +21631,7 @@ const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, an
|
|
|
21624
21631
|
const north = -anchorEast * sinR - anchorNorth * cosR;
|
|
21625
21632
|
return { east, north };
|
|
21626
21633
|
};
|
|
21627
|
-
const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor) => {
|
|
21634
|
+
const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor, sizeScaleAdjustment = 1) => {
|
|
21628
21635
|
var _a, _b;
|
|
21629
21636
|
const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
|
|
21630
21637
|
if (offsetMeters === 0) {
|
|
@@ -21632,8 +21639,8 @@ const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor) => {
|
|
|
21632
21639
|
}
|
|
21633
21640
|
const rad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
|
|
21634
21641
|
return {
|
|
21635
|
-
east: offsetMeters * Math.sin(rad),
|
|
21636
|
-
north: offsetMeters * Math.cos(rad)
|
|
21642
|
+
east: offsetMeters * Math.sin(rad) * sizeScaleAdjustment,
|
|
21643
|
+
north: offsetMeters * Math.cos(rad) * sizeScaleAdjustment
|
|
21637
21644
|
};
|
|
21638
21645
|
};
|
|
21639
21646
|
const MIN_COS_LAT = 1e-6;
|
|
@@ -21781,7 +21788,8 @@ const calculateBillboardCenterPosition = (params) => {
|
|
|
21781
21788
|
offset,
|
|
21782
21789
|
imageScale,
|
|
21783
21790
|
zoomScaleFactor,
|
|
21784
|
-
effectivePixelsPerMeter
|
|
21791
|
+
effectivePixelsPerMeter,
|
|
21792
|
+
pixelDims.scaleAdjustment
|
|
21785
21793
|
);
|
|
21786
21794
|
const centerX = base.x + offsetShift.x;
|
|
21787
21795
|
const centerY = base.y - offsetShift.y;
|
|
@@ -21902,7 +21910,8 @@ const calculateSurfaceCenterPosition = (params) => {
|
|
|
21902
21910
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
21903
21911
|
offset,
|
|
21904
21912
|
imageScale,
|
|
21905
|
-
zoomScaleFactor
|
|
21913
|
+
zoomScaleFactor,
|
|
21914
|
+
worldDims.scaleAdjustment
|
|
21906
21915
|
);
|
|
21907
21916
|
const totalEast = anchorShiftMeters.east + offsetMeters.east;
|
|
21908
21917
|
const totalNorth = anchorShiftMeters.north + offsetMeters.north;
|
|
@@ -23433,7 +23442,8 @@ const createSpriteLayer = (options) => {
|
|
|
23433
23442
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
23434
23443
|
offsetDef,
|
|
23435
23444
|
imageScale,
|
|
23436
|
-
zoomScaleFactor
|
|
23445
|
+
zoomScaleFactor,
|
|
23446
|
+
surfaceCenter.worldDimensions.scaleAdjustment
|
|
23437
23447
|
);
|
|
23438
23448
|
const cornerDisplacements = calculateSurfaceCornerDisplacements({
|
|
23439
23449
|
worldWidthMeters: surfaceCenter.worldDimensions.width,
|
|
@@ -23641,7 +23651,8 @@ const createSpriteLayer = (options) => {
|
|
|
23641
23651
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
23642
23652
|
offsetResolved,
|
|
23643
23653
|
imageScale,
|
|
23644
|
-
zoomScaleFactor
|
|
23654
|
+
zoomScaleFactor,
|
|
23655
|
+
worldDims.scaleAdjustment
|
|
23645
23656
|
);
|
|
23646
23657
|
const cornerDisplacements = calculateSurfaceCornerDisplacements({
|
|
23647
23658
|
worldWidthMeters: worldDims.width,
|