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/SpriteLayer.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
|
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
|
+
* 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
|
import { EasingFunction } from './types';
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* name: maplibre-gl-layers
|
|
4
|
-
* version: 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:
|
|
9
|
+
* git.commit.hash: ce37eea48b788c36b4bf98cdfce83b95a85833ee
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
12
12
|
const UNLIMITED_SPRITE_SCALING_OPTIONS = {
|
|
@@ -21519,25 +21519,30 @@ const calculateDistanceAndBearingMeters = (from, to) => {
|
|
|
21519
21519
|
const clampSpritePixelSize = (width, height, spriteMinPixel, spriteMaxPixel) => {
|
|
21520
21520
|
const largest = Math.max(width, height);
|
|
21521
21521
|
if (!Number.isFinite(largest) || largest <= 0) {
|
|
21522
|
-
return { width, height };
|
|
21522
|
+
return { width, height, scaleAdjustment: 1 };
|
|
21523
21523
|
}
|
|
21524
21524
|
let nextWidth = width;
|
|
21525
21525
|
let nextHeight = height;
|
|
21526
|
+
let scaleAdjustment = 1;
|
|
21527
|
+
let adjustedLargest = largest;
|
|
21526
21528
|
if (spriteMinPixel > 0 && largest < spriteMinPixel) {
|
|
21527
21529
|
const factor = spriteMinPixel / largest;
|
|
21528
21530
|
nextWidth *= factor;
|
|
21529
21531
|
nextHeight *= factor;
|
|
21532
|
+
scaleAdjustment *= factor;
|
|
21533
|
+
adjustedLargest *= factor;
|
|
21530
21534
|
}
|
|
21531
|
-
if (spriteMaxPixel > 0 &&
|
|
21532
|
-
const factor = spriteMaxPixel /
|
|
21535
|
+
if (spriteMaxPixel > 0 && adjustedLargest > spriteMaxPixel) {
|
|
21536
|
+
const factor = spriteMaxPixel / adjustedLargest;
|
|
21533
21537
|
nextWidth *= factor;
|
|
21534
21538
|
nextHeight *= factor;
|
|
21539
|
+
scaleAdjustment *= factor;
|
|
21535
21540
|
}
|
|
21536
|
-
return { width: nextWidth, height: nextHeight };
|
|
21541
|
+
return { width: nextWidth, height: nextHeight, scaleAdjustment };
|
|
21537
21542
|
};
|
|
21538
21543
|
const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, effectivePixelsPerMeter, spriteMinPixel, spriteMaxPixel) => {
|
|
21539
21544
|
if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0 || effectivePixelsPerMeter <= 0) {
|
|
21540
|
-
return { width: 0, height: 0 };
|
|
21545
|
+
return { width: 0, height: 0, scaleAdjustment: 1 };
|
|
21541
21546
|
}
|
|
21542
21547
|
const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor * effectivePixelsPerMeter;
|
|
21543
21548
|
const rawWidth = ensureFinite(imageWidth * scaleFactor);
|
|
@@ -21549,10 +21554,10 @@ const calculateBillboardPixelDimensions = (imageWidth, imageHeight, baseMetersPe
|
|
|
21549
21554
|
spriteMaxPixel
|
|
21550
21555
|
);
|
|
21551
21556
|
};
|
|
21552
|
-
const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter) => {
|
|
21557
|
+
const calculateBillboardOffsetPixels = (offset, imageScale, zoomScaleFactor, effectivePixelsPerMeter, sizeScaleAdjustment = 1) => {
|
|
21553
21558
|
var _a, _b;
|
|
21554
21559
|
const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
|
|
21555
|
-
const offsetPixels = offsetMeters * effectivePixelsPerMeter;
|
|
21560
|
+
const offsetPixels = offsetMeters * effectivePixelsPerMeter * sizeScaleAdjustment;
|
|
21556
21561
|
const offsetRad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
|
|
21557
21562
|
return {
|
|
21558
21563
|
x: offsetPixels * Math.sin(offsetRad),
|
|
@@ -21579,11 +21584,12 @@ const calculateBillboardAnchorShiftPixels = (halfWidth, halfHeight, anchor, tota
|
|
|
21579
21584
|
const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerPixel, imageScale, zoomScaleFactor, options) => {
|
|
21580
21585
|
var _a, _b;
|
|
21581
21586
|
if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0 || baseMetersPerPixel <= 0) {
|
|
21582
|
-
return { width: 0, height: 0 };
|
|
21587
|
+
return { width: 0, height: 0, scaleAdjustment: 1 };
|
|
21583
21588
|
}
|
|
21584
21589
|
const scaleFactor = baseMetersPerPixel * imageScale * zoomScaleFactor;
|
|
21585
21590
|
let width = ensureFinite(imageWidth * scaleFactor);
|
|
21586
21591
|
let height = ensureFinite(imageHeight * scaleFactor);
|
|
21592
|
+
let scaleAdjustment = 1;
|
|
21587
21593
|
const effectivePixelsPerMeter = (options == null ? void 0 : options.effectivePixelsPerMeter) !== void 0 ? options.effectivePixelsPerMeter : 0;
|
|
21588
21594
|
const spriteMinPixel = (_a = options == null ? void 0 : options.spriteMinPixel) != null ? _a : 0;
|
|
21589
21595
|
const spriteMaxPixel = (_b = options == null ? void 0 : options.spriteMaxPixel) != null ? _b : 0;
|
|
@@ -21603,11 +21609,12 @@ const calculateSurfaceWorldDimensions = (imageWidth, imageHeight, baseMetersPerP
|
|
|
21603
21609
|
if (scale !== 1) {
|
|
21604
21610
|
width *= scale;
|
|
21605
21611
|
height *= scale;
|
|
21612
|
+
scaleAdjustment *= scale;
|
|
21606
21613
|
}
|
|
21607
21614
|
}
|
|
21608
21615
|
}
|
|
21609
21616
|
}
|
|
21610
|
-
return { width, height };
|
|
21617
|
+
return { width, height, scaleAdjustment };
|
|
21611
21618
|
};
|
|
21612
21619
|
const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, anchor, totalRotateDeg) => {
|
|
21613
21620
|
var _a, _b;
|
|
@@ -21626,7 +21633,7 @@ const calculateSurfaceAnchorShiftMeters = (halfWidthMeters, halfHeightMeters, an
|
|
|
21626
21633
|
const north = -anchorEast * sinR - anchorNorth * cosR;
|
|
21627
21634
|
return { east, north };
|
|
21628
21635
|
};
|
|
21629
|
-
const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor) => {
|
|
21636
|
+
const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor, sizeScaleAdjustment = 1) => {
|
|
21630
21637
|
var _a, _b;
|
|
21631
21638
|
const offsetMeters = ((_a = offset == null ? void 0 : offset.offsetMeters) != null ? _a : 0) * imageScale * zoomScaleFactor;
|
|
21632
21639
|
if (offsetMeters === 0) {
|
|
@@ -21634,8 +21641,8 @@ const calculateSurfaceOffsetMeters = (offset, imageScale, zoomScaleFactor) => {
|
|
|
21634
21641
|
}
|
|
21635
21642
|
const rad = ((_b = offset == null ? void 0 : offset.offsetDeg) != null ? _b : 0) * DEG2RAD;
|
|
21636
21643
|
return {
|
|
21637
|
-
east: offsetMeters * Math.sin(rad),
|
|
21638
|
-
north: offsetMeters * Math.cos(rad)
|
|
21644
|
+
east: offsetMeters * Math.sin(rad) * sizeScaleAdjustment,
|
|
21645
|
+
north: offsetMeters * Math.cos(rad) * sizeScaleAdjustment
|
|
21639
21646
|
};
|
|
21640
21647
|
};
|
|
21641
21648
|
const MIN_COS_LAT = 1e-6;
|
|
@@ -21783,7 +21790,8 @@ const calculateBillboardCenterPosition = (params) => {
|
|
|
21783
21790
|
offset,
|
|
21784
21791
|
imageScale,
|
|
21785
21792
|
zoomScaleFactor,
|
|
21786
|
-
effectivePixelsPerMeter
|
|
21793
|
+
effectivePixelsPerMeter,
|
|
21794
|
+
pixelDims.scaleAdjustment
|
|
21787
21795
|
);
|
|
21788
21796
|
const centerX = base.x + offsetShift.x;
|
|
21789
21797
|
const centerY = base.y - offsetShift.y;
|
|
@@ -21904,7 +21912,8 @@ const calculateSurfaceCenterPosition = (params) => {
|
|
|
21904
21912
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
21905
21913
|
offset,
|
|
21906
21914
|
imageScale,
|
|
21907
|
-
zoomScaleFactor
|
|
21915
|
+
zoomScaleFactor,
|
|
21916
|
+
worldDims.scaleAdjustment
|
|
21908
21917
|
);
|
|
21909
21918
|
const totalEast = anchorShiftMeters.east + offsetMeters.east;
|
|
21910
21919
|
const totalNorth = anchorShiftMeters.north + offsetMeters.north;
|
|
@@ -23435,7 +23444,8 @@ const createSpriteLayer = (options) => {
|
|
|
23435
23444
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
23436
23445
|
offsetDef,
|
|
23437
23446
|
imageScale,
|
|
23438
|
-
zoomScaleFactor
|
|
23447
|
+
zoomScaleFactor,
|
|
23448
|
+
surfaceCenter.worldDimensions.scaleAdjustment
|
|
23439
23449
|
);
|
|
23440
23450
|
const cornerDisplacements = calculateSurfaceCornerDisplacements({
|
|
23441
23451
|
worldWidthMeters: surfaceCenter.worldDimensions.width,
|
|
@@ -23643,7 +23653,8 @@ const createSpriteLayer = (options) => {
|
|
|
23643
23653
|
const offsetMeters = calculateSurfaceOffsetMeters(
|
|
23644
23654
|
offsetResolved,
|
|
23645
23655
|
imageScale,
|
|
23646
|
-
zoomScaleFactor
|
|
23656
|
+
zoomScaleFactor,
|
|
23657
|
+
worldDims.scaleAdjustment
|
|
23647
23658
|
);
|
|
23648
23659
|
const cornerDisplacements = calculateSurfaceCornerDisplacements({
|
|
23649
23660
|
worldWidthMeters: worldDims.width,
|