@vitessce/spatial-utils 3.2.1 → 3.2.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/{deflate-3240dc7e.js → deflate-90c1ea8c.js} +1 -1
- package/dist/{index-ca4e31e3.js → index-929e31b1.js} +118 -28
- package/dist/index.js +1 -1
- package/dist/{jpeg-76bff48f.js → jpeg-81916128.js} +1 -1
- package/dist/{lerc-1ad8fc7c.js → lerc-7dc5ecab.js} +1 -1
- package/dist/{lzw-c5e8dff0.js → lzw-5ac3b5e2.js} +1 -1
- package/dist/{packbits-ccf26149.js → packbits-4d0460ce.js} +1 -1
- package/dist/{raw-446b6beb.js → raw-97a0822f.js} +1 -1
- package/dist/{webimage-bf1c5425.js → webimage-2f02c049.js} +1 -1
- package/package.json +3 -3
|
@@ -133457,16 +133457,16 @@ function addDecoder(cases, importFn) {
|
|
|
133457
133457
|
}
|
|
133458
133458
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
133459
133459
|
}
|
|
133460
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
133461
|
-
addDecoder(5, () => import("./lzw-
|
|
133460
|
+
addDecoder([void 0, 1], () => import("./raw-97a0822f.js").then((m) => m.default));
|
|
133461
|
+
addDecoder(5, () => import("./lzw-5ac3b5e2.js").then((m) => m.default));
|
|
133462
133462
|
addDecoder(6, () => {
|
|
133463
133463
|
throw new Error("old style JPEG compression is not supported.");
|
|
133464
133464
|
});
|
|
133465
|
-
addDecoder(7, () => import("./jpeg-
|
|
133466
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
133467
|
-
addDecoder(32773, () => import("./packbits-
|
|
133468
|
-
addDecoder(34887, () => import("./lerc-
|
|
133469
|
-
addDecoder(50001, () => import("./webimage-
|
|
133465
|
+
addDecoder(7, () => import("./jpeg-81916128.js").then((m) => m.default));
|
|
133466
|
+
addDecoder([8, 32946], () => import("./deflate-90c1ea8c.js").then((m) => m.default));
|
|
133467
|
+
addDecoder(32773, () => import("./packbits-4d0460ce.js").then((m) => m.default));
|
|
133468
|
+
addDecoder(34887, () => import("./lerc-7dc5ecab.js").then((m) => m.default));
|
|
133469
|
+
addDecoder(50001, () => import("./webimage-2f02c049.js").then((m) => m.default));
|
|
133470
133470
|
function decodeRowAcc(row, stride) {
|
|
133471
133471
|
let length2 = row.length - stride;
|
|
133472
133472
|
let offset = 0;
|
|
@@ -142474,6 +142474,67 @@ function makeBoundingBox(viewState) {
|
|
|
142474
142474
|
viewport.unproject([0, viewport.height])
|
|
142475
142475
|
];
|
|
142476
142476
|
}
|
|
142477
|
+
const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
|
|
142478
|
+
const MIN_TARGET = TARGETS[0];
|
|
142479
|
+
const MAX_TARGET = TARGETS[TARGETS.length - 1];
|
|
142480
|
+
const SI_PREFIXES = [
|
|
142481
|
+
{ symbol: "Y", exponent: 24 },
|
|
142482
|
+
{ symbol: "Z", exponent: 21 },
|
|
142483
|
+
{ symbol: "E", exponent: 18 },
|
|
142484
|
+
{ symbol: "P", exponent: 15 },
|
|
142485
|
+
{ symbol: "T", exponent: 12 },
|
|
142486
|
+
{ symbol: "G", exponent: 9 },
|
|
142487
|
+
{ symbol: "M", exponent: 6 },
|
|
142488
|
+
{ symbol: "k", exponent: 3 },
|
|
142489
|
+
{ symbol: "h", exponent: 2 },
|
|
142490
|
+
{ symbol: "da", exponent: 1 },
|
|
142491
|
+
{ symbol: "", exponent: 0 },
|
|
142492
|
+
{ symbol: "d", exponent: -1 },
|
|
142493
|
+
{ symbol: "c", exponent: -2 },
|
|
142494
|
+
{ symbol: "m", exponent: -3 },
|
|
142495
|
+
{ symbol: "µ", exponent: -6 },
|
|
142496
|
+
{ symbol: "n", exponent: -9 },
|
|
142497
|
+
{ symbol: "p", exponent: -12 },
|
|
142498
|
+
{ symbol: "f", exponent: -15 },
|
|
142499
|
+
{ symbol: "a", exponent: -18 },
|
|
142500
|
+
{ symbol: "z", exponent: -21 },
|
|
142501
|
+
{ symbol: "y", exponent: -24 }
|
|
142502
|
+
];
|
|
142503
|
+
function sizeToMeters(size2, unit2) {
|
|
142504
|
+
if (!unit2 || unit2 === "m") {
|
|
142505
|
+
return size2;
|
|
142506
|
+
}
|
|
142507
|
+
if (unit2.length > 1) {
|
|
142508
|
+
let unitPrefix = unit2.substring(0, unit2.length - 1);
|
|
142509
|
+
if (unitPrefix === "u") {
|
|
142510
|
+
unitPrefix = "µ";
|
|
142511
|
+
}
|
|
142512
|
+
const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
|
|
142513
|
+
if (unitObj) {
|
|
142514
|
+
return size2 * 10 ** unitObj.exponent;
|
|
142515
|
+
}
|
|
142516
|
+
}
|
|
142517
|
+
throw new Error("Received unknown unit");
|
|
142518
|
+
}
|
|
142519
|
+
function snapValue(value) {
|
|
142520
|
+
let magnitude = 0;
|
|
142521
|
+
if (value < MIN_TARGET || value > MAX_TARGET) {
|
|
142522
|
+
magnitude = Math.floor(Math.log10(value));
|
|
142523
|
+
}
|
|
142524
|
+
let snappedUnit = SI_PREFIXES.find(
|
|
142525
|
+
(p) => p.exponent % 3 === 0 && p.exponent <= magnitude
|
|
142526
|
+
);
|
|
142527
|
+
let adjustedValue = value / 10 ** snappedUnit.exponent;
|
|
142528
|
+
if (adjustedValue > 500 && adjustedValue <= 1e3) {
|
|
142529
|
+
snappedUnit = SI_PREFIXES.find(
|
|
142530
|
+
(p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
|
|
142531
|
+
);
|
|
142532
|
+
adjustedValue = value / 10 ** snappedUnit.exponent;
|
|
142533
|
+
}
|
|
142534
|
+
const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
|
|
142535
|
+
const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
|
|
142536
|
+
return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
|
|
142537
|
+
}
|
|
142477
142538
|
const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
|
|
142478
142539
|
|
|
142479
142540
|
precision highp float;
|
|
@@ -143241,26 +143302,27 @@ const OverviewLayer = class extends CompositeLayer {
|
|
|
143241
143302
|
OverviewLayer.layerName = "OverviewLayer";
|
|
143242
143303
|
OverviewLayer.defaultProps = defaultProps$3;
|
|
143243
143304
|
function getPosition(boundingBox, position, length2) {
|
|
143244
|
-
const
|
|
143305
|
+
const viewWidth = boundingBox[2][0] - boundingBox[0][0];
|
|
143306
|
+
const viewHeight = boundingBox[2][1] - boundingBox[0][1];
|
|
143245
143307
|
switch (position) {
|
|
143246
143308
|
case "bottom-right": {
|
|
143247
|
-
const yCoord = boundingBox[2][1] -
|
|
143248
|
-
const xLeftCoord = boundingBox[2][0] -
|
|
143309
|
+
const yCoord = boundingBox[2][1] - viewHeight * length2;
|
|
143310
|
+
const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
|
|
143249
143311
|
return [yCoord, xLeftCoord];
|
|
143250
143312
|
}
|
|
143251
143313
|
case "top-right": {
|
|
143252
|
-
const yCoord =
|
|
143253
|
-
const xLeftCoord = boundingBox[2][0] -
|
|
143314
|
+
const yCoord = boundingBox[0][1] + viewHeight * length2;
|
|
143315
|
+
const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
|
|
143254
143316
|
return [yCoord, xLeftCoord];
|
|
143255
143317
|
}
|
|
143256
143318
|
case "top-left": {
|
|
143257
|
-
const yCoord =
|
|
143258
|
-
const xLeftCoord =
|
|
143319
|
+
const yCoord = boundingBox[0][1] + viewHeight * length2;
|
|
143320
|
+
const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
|
|
143259
143321
|
return [yCoord, xLeftCoord];
|
|
143260
143322
|
}
|
|
143261
143323
|
case "bottom-left": {
|
|
143262
|
-
const yCoord = boundingBox[2][1] -
|
|
143263
|
-
const xLeftCoord =
|
|
143324
|
+
const yCoord = boundingBox[2][1] - viewHeight * length2;
|
|
143325
|
+
const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
|
|
143264
143326
|
return [yCoord, xLeftCoord];
|
|
143265
143327
|
}
|
|
143266
143328
|
default: {
|
|
@@ -143278,11 +143340,12 @@ const defaultProps$2 = {
|
|
|
143278
143340
|
unit: { type: "string", value: "", compare: true },
|
|
143279
143341
|
size: { type: "number", value: 1, compare: true },
|
|
143280
143342
|
position: { type: "string", value: "bottom-right", compare: true },
|
|
143281
|
-
length: { type: "number", value: 0.085, compare: true }
|
|
143343
|
+
length: { type: "number", value: 0.085, compare: true },
|
|
143344
|
+
snap: { type: "boolean", value: false, compare: true }
|
|
143282
143345
|
};
|
|
143283
143346
|
const ScaleBarLayer = class extends CompositeLayer {
|
|
143284
143347
|
renderLayers() {
|
|
143285
|
-
const { id, unit: unit2, size: size2, position, viewState, length: length2 } = this.props;
|
|
143348
|
+
const { id, unit: unit2, size: size2, position, viewState, length: length2, snap } = this.props;
|
|
143286
143349
|
const boundingBox = makeBoundingBox(viewState);
|
|
143287
143350
|
const { zoom } = viewState;
|
|
143288
143351
|
const viewLength = boundingBox[2][0] - boundingBox[0][0];
|
|
@@ -143291,15 +143354,27 @@ const ScaleBarLayer = class extends CompositeLayer {
|
|
|
143291
143354
|
2 ** (-zoom + 1.5),
|
|
143292
143355
|
(boundingBox[2][1] - boundingBox[0][1]) * 7e-3
|
|
143293
143356
|
);
|
|
143294
|
-
|
|
143357
|
+
let adjustedBarLength = barLength;
|
|
143358
|
+
let displayNumber = (barLength * size2).toPrecision(5);
|
|
143359
|
+
let displayUnit = unit2;
|
|
143360
|
+
if (snap) {
|
|
143361
|
+
const meterSize = sizeToMeters(size2, unit2);
|
|
143362
|
+
const numUnits = barLength * meterSize;
|
|
143363
|
+
const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
|
|
143364
|
+
adjustedBarLength = snappedOrigUnits / meterSize;
|
|
143365
|
+
displayNumber = snappedNewUnits;
|
|
143366
|
+
displayUnit = `${snappedUnitPrefix}m`;
|
|
143367
|
+
}
|
|
143295
143368
|
const [yCoord, xLeftCoord] = getPosition(boundingBox, position, length2);
|
|
143369
|
+
const xRightCoord = xLeftCoord + barLength;
|
|
143370
|
+
const isLeft = position.endsWith("-left");
|
|
143296
143371
|
const lengthBar = new LineLayer({
|
|
143297
143372
|
id: `scale-bar-length-${id}`,
|
|
143298
143373
|
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
143299
143374
|
data: [
|
|
143300
143375
|
[
|
|
143301
|
-
[xLeftCoord, yCoord],
|
|
143302
|
-
[xLeftCoord +
|
|
143376
|
+
[isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
|
|
143377
|
+
[isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
|
|
143303
143378
|
]
|
|
143304
143379
|
],
|
|
143305
143380
|
getSourcePosition: (d) => d[0],
|
|
@@ -143312,8 +143387,14 @@ const ScaleBarLayer = class extends CompositeLayer {
|
|
|
143312
143387
|
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
143313
143388
|
data: [
|
|
143314
143389
|
[
|
|
143315
|
-
[
|
|
143316
|
-
|
|
143390
|
+
[
|
|
143391
|
+
isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
|
|
143392
|
+
yCoord - barHeight
|
|
143393
|
+
],
|
|
143394
|
+
[
|
|
143395
|
+
isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
|
|
143396
|
+
yCoord + barHeight
|
|
143397
|
+
]
|
|
143317
143398
|
]
|
|
143318
143399
|
],
|
|
143319
143400
|
getSourcePosition: (d) => d[0],
|
|
@@ -143326,8 +143407,14 @@ const ScaleBarLayer = class extends CompositeLayer {
|
|
|
143326
143407
|
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
143327
143408
|
data: [
|
|
143328
143409
|
[
|
|
143329
|
-
[
|
|
143330
|
-
|
|
143410
|
+
[
|
|
143411
|
+
isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
|
|
143412
|
+
yCoord - barHeight
|
|
143413
|
+
],
|
|
143414
|
+
[
|
|
143415
|
+
isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
|
|
143416
|
+
yCoord + barHeight
|
|
143417
|
+
]
|
|
143331
143418
|
]
|
|
143332
143419
|
],
|
|
143333
143420
|
getSourcePosition: (d) => d[0],
|
|
@@ -143340,8 +143427,11 @@ const ScaleBarLayer = class extends CompositeLayer {
|
|
|
143340
143427
|
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
143341
143428
|
data: [
|
|
143342
143429
|
{
|
|
143343
|
-
text:
|
|
143344
|
-
position: [
|
|
143430
|
+
text: `${displayNumber}${displayUnit}`,
|
|
143431
|
+
position: [
|
|
143432
|
+
isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
|
|
143433
|
+
yCoord + barHeight * 4
|
|
143434
|
+
]
|
|
143345
143435
|
}
|
|
143346
143436
|
],
|
|
143347
143437
|
getColor: [220, 220, 220, 255],
|
|
@@ -143350,7 +143440,7 @@ const ScaleBarLayer = class extends CompositeLayer {
|
|
|
143350
143440
|
sizeUnits: "meters",
|
|
143351
143441
|
sizeScale: 2 ** -zoom,
|
|
143352
143442
|
characterSet: [
|
|
143353
|
-
...
|
|
143443
|
+
...displayUnit.split(""),
|
|
143354
143444
|
...range(10).map((i2) => String(i2)),
|
|
143355
143445
|
".",
|
|
143356
143446
|
"e",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D, e, a, b, c, d, C, G, z, r, n, A, y, w, l, m, x, v, h, q, o, i, f, j, k, t, p, s, u } from "./index-
|
|
1
|
+
import { D, e, a, b, c, d, C, G, z, r, n, A, y, w, l, m, x, v, h, q, o, i, f, j, k, t, p, s, u } from "./index-929e31b1.js";
|
|
2
2
|
import "react";
|
|
3
3
|
export {
|
|
4
4
|
D as DEFAULT_CELLS_LAYER,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
|
|
2
|
-
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-
|
|
2
|
+
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-929e31b1.js";
|
|
3
3
|
import "react";
|
|
4
4
|
const LercParameters = {
|
|
5
5
|
Version: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/spatial-utils",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"lodash-es": "^4.17.21",
|
|
20
20
|
"math.gl": "^3.5.6",
|
|
21
21
|
"mathjs": "^9.2.0",
|
|
22
|
-
"@vitessce/gl": "3.2.
|
|
23
|
-
"@vitessce/utils": "3.2.
|
|
22
|
+
"@vitessce/gl": "3.2.2",
|
|
23
|
+
"@vitessce/utils": "3.2.2"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|