@vitessce/image-utils 4.0.8 → 4.0.10
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-BQFeaum-.js → deflate-CYRafIfN.js} +1 -1
- package/dist/{index-DHVt4YuW.js → index-BNOGpz7O.js} +1281 -82
- package/dist/index.js +1 -1
- package/dist/{jpeg-BCdw6mfN.js → jpeg-DdRwUGtb.js} +1 -1
- package/dist/{lerc-CN2VddFY.js → lerc-CbvtcHx_.js} +1 -1
- package/dist/{lzw-BzOLEK38.js → lzw-Cj3FuoEM.js} +1 -1
- package/dist/{packbits-DogpBrl6.js → packbits-QWSBfY1A.js} +1 -1
- package/dist/{raw-D5prg-7v.js → raw-DqOqmksW.js} +1 -1
- package/dist/{webimage-DHzqGhbI.js → webimage-8chAb-F3.js} +1 -1
- package/package.json +5 -5
|
@@ -18,6 +18,10 @@ function _mergeNamespaces(n3, m) {
|
|
|
18
18
|
}
|
|
19
19
|
return Object.freeze(Object.defineProperty(n3, Symbol.toStringTag, { value: "Module" }));
|
|
20
20
|
}
|
|
21
|
+
const ViewType = {
|
|
22
|
+
SCATTERPLOT: "scatterplot",
|
|
23
|
+
SPATIAL: "spatial"
|
|
24
|
+
};
|
|
21
25
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
22
26
|
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
23
27
|
var root = freeGlobal || freeSelf || Function("return this")();
|
|
@@ -1230,8 +1234,8 @@ class Vector extends MathArray {
|
|
|
1230
1234
|
distanceSquared(mathArray) {
|
|
1231
1235
|
let length2 = 0;
|
|
1232
1236
|
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
|
|
1233
|
-
const
|
|
1234
|
-
length2 +=
|
|
1237
|
+
const dist2 = this[i2] - mathArray[i2];
|
|
1238
|
+
length2 += dist2 * dist2;
|
|
1235
1239
|
}
|
|
1236
1240
|
return checkNumber(length2);
|
|
1237
1241
|
}
|
|
@@ -1552,6 +1556,12 @@ function multiply$4(out, a2, b) {
|
|
|
1552
1556
|
out[2] = a2[2] * b[2];
|
|
1553
1557
|
return out;
|
|
1554
1558
|
}
|
|
1559
|
+
function distance$3(a2, b) {
|
|
1560
|
+
var x = b[0] - a2[0];
|
|
1561
|
+
var y = b[1] - a2[1];
|
|
1562
|
+
var z = b[2] - a2[2];
|
|
1563
|
+
return Math.hypot(x, y, z);
|
|
1564
|
+
}
|
|
1555
1565
|
function squaredLength$2(a2) {
|
|
1556
1566
|
var x = a2[0];
|
|
1557
1567
|
var y = a2[1];
|
|
@@ -1675,6 +1685,7 @@ function angle$2(a2, b) {
|
|
|
1675
1685
|
}
|
|
1676
1686
|
var sub$1 = subtract$1;
|
|
1677
1687
|
var mul$1 = multiply$4;
|
|
1688
|
+
var dist = distance$3;
|
|
1678
1689
|
var len = length$4;
|
|
1679
1690
|
var sqrLen = squaredLength$2;
|
|
1680
1691
|
(function() {
|
|
@@ -42240,7 +42251,7 @@ function noop$2() {
|
|
|
42240
42251
|
const getCursor = ({
|
|
42241
42252
|
isDragging
|
|
42242
42253
|
}) => isDragging ? "grabbing" : "grab";
|
|
42243
|
-
const defaultProps$
|
|
42254
|
+
const defaultProps$P = {
|
|
42244
42255
|
id: "",
|
|
42245
42256
|
width: "100%",
|
|
42246
42257
|
height: "100%",
|
|
@@ -42371,7 +42382,7 @@ class Deck {
|
|
|
42371
42382
|
this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
|
|
42372
42383
|
});
|
|
42373
42384
|
this.props = {
|
|
42374
|
-
...defaultProps$
|
|
42385
|
+
...defaultProps$P,
|
|
42375
42386
|
...props
|
|
42376
42387
|
};
|
|
42377
42388
|
props = this.props;
|
|
@@ -42873,7 +42884,7 @@ class Deck {
|
|
|
42873
42884
|
metrics.gpuMemory = memoryStats.get("GPU Memory").count;
|
|
42874
42885
|
}
|
|
42875
42886
|
}
|
|
42876
|
-
_defineProperty(Deck, "defaultProps", defaultProps$
|
|
42887
|
+
_defineProperty(Deck, "defaultProps", defaultProps$P);
|
|
42877
42888
|
_defineProperty(Deck, "VERSION", deckGlobal.VERSION);
|
|
42878
42889
|
class ShaderAttribute {
|
|
42879
42890
|
constructor(dataColumn, opts) {
|
|
@@ -45628,7 +45639,7 @@ const areViewportsEqual = memoize$1(({
|
|
|
45628
45639
|
return oldViewport.equals(viewport);
|
|
45629
45640
|
});
|
|
45630
45641
|
let pickingColorCache = new Uint8ClampedArray(0);
|
|
45631
|
-
const defaultProps$
|
|
45642
|
+
const defaultProps$O = {
|
|
45632
45643
|
data: {
|
|
45633
45644
|
type: "data",
|
|
45634
45645
|
value: EMPTY_ARRAY$1,
|
|
@@ -46503,7 +46514,7 @@ class Layer extends Component {
|
|
|
46503
46514
|
this.setNeedsUpdate();
|
|
46504
46515
|
}
|
|
46505
46516
|
}
|
|
46506
|
-
_defineProperty(Layer, "defaultProps", defaultProps$
|
|
46517
|
+
_defineProperty(Layer, "defaultProps", defaultProps$O);
|
|
46507
46518
|
_defineProperty(Layer, "layerName", "Layer");
|
|
46508
46519
|
const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
|
|
46509
46520
|
class CompositeLayer extends Layer {
|
|
@@ -47539,6 +47550,124 @@ const esm$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
47539
47550
|
project32,
|
|
47540
47551
|
shadow
|
|
47541
47552
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
47553
|
+
const dashShaders = {
|
|
47554
|
+
inject: {
|
|
47555
|
+
"vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
|
|
47556
|
+
"vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
|
|
47557
|
+
"fs:#decl": "\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n\nfloat round(float x) {\n return floor(x + 0.5);\n}\n",
|
|
47558
|
+
"fs:#main-start": "\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n } else {\n // caps are rounded, test the distance to solid ends\n float distToEnd = length(vec2(\n min(unitOffset - solidLength, unitLength - unitOffset),\n vPathPosition.x\n ));\n if (distToEnd > 1.0) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n }\n }\n }\n }\n"
|
|
47559
|
+
}
|
|
47560
|
+
};
|
|
47561
|
+
const offsetShaders = {
|
|
47562
|
+
inject: {
|
|
47563
|
+
"vs:#decl": "\nattribute float instanceOffsets;\n",
|
|
47564
|
+
"vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
|
|
47565
|
+
"vCornerOffset = offsetVec;": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;\n vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;\n",
|
|
47566
|
+
"fs:#main-start": "\n float isInside;\n isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);\n if (isInside == 0.0) {\n discard;\n }\n"
|
|
47567
|
+
}
|
|
47568
|
+
};
|
|
47569
|
+
const defaultProps$N = {
|
|
47570
|
+
getDashArray: {
|
|
47571
|
+
type: "accessor",
|
|
47572
|
+
value: [0, 0]
|
|
47573
|
+
},
|
|
47574
|
+
getOffset: {
|
|
47575
|
+
type: "accessor",
|
|
47576
|
+
value: 0
|
|
47577
|
+
},
|
|
47578
|
+
dashJustified: false,
|
|
47579
|
+
dashGapPickable: false
|
|
47580
|
+
};
|
|
47581
|
+
class PathStyleExtension extends LayerExtension {
|
|
47582
|
+
constructor({
|
|
47583
|
+
dash = false,
|
|
47584
|
+
offset = false,
|
|
47585
|
+
highPrecisionDash = false
|
|
47586
|
+
} = {}) {
|
|
47587
|
+
super({
|
|
47588
|
+
dash: dash || highPrecisionDash,
|
|
47589
|
+
offset,
|
|
47590
|
+
highPrecisionDash
|
|
47591
|
+
});
|
|
47592
|
+
}
|
|
47593
|
+
isEnabled(layer) {
|
|
47594
|
+
return "pathTesselator" in layer.state;
|
|
47595
|
+
}
|
|
47596
|
+
getShaders(extension) {
|
|
47597
|
+
if (!extension.isEnabled(this)) {
|
|
47598
|
+
return null;
|
|
47599
|
+
}
|
|
47600
|
+
let result = {};
|
|
47601
|
+
if (extension.opts.dash) {
|
|
47602
|
+
result = mergeShaders(result, dashShaders);
|
|
47603
|
+
}
|
|
47604
|
+
if (extension.opts.offset) {
|
|
47605
|
+
result = mergeShaders(result, offsetShaders);
|
|
47606
|
+
}
|
|
47607
|
+
return result;
|
|
47608
|
+
}
|
|
47609
|
+
initializeState(context, extension) {
|
|
47610
|
+
const attributeManager = this.getAttributeManager();
|
|
47611
|
+
if (!attributeManager || !extension.isEnabled(this)) {
|
|
47612
|
+
return;
|
|
47613
|
+
}
|
|
47614
|
+
if (extension.opts.dash) {
|
|
47615
|
+
attributeManager.addInstanced({
|
|
47616
|
+
instanceDashArrays: {
|
|
47617
|
+
size: 2,
|
|
47618
|
+
accessor: "getDashArray"
|
|
47619
|
+
}
|
|
47620
|
+
});
|
|
47621
|
+
}
|
|
47622
|
+
if (extension.opts.highPrecisionDash) {
|
|
47623
|
+
attributeManager.addInstanced({
|
|
47624
|
+
instanceDashOffsets: {
|
|
47625
|
+
size: 1,
|
|
47626
|
+
accessor: "getPath",
|
|
47627
|
+
transform: extension.getDashOffsets.bind(this)
|
|
47628
|
+
}
|
|
47629
|
+
});
|
|
47630
|
+
}
|
|
47631
|
+
if (extension.opts.offset) {
|
|
47632
|
+
attributeManager.addInstanced({
|
|
47633
|
+
instanceOffsets: {
|
|
47634
|
+
size: 1,
|
|
47635
|
+
accessor: "getOffset"
|
|
47636
|
+
}
|
|
47637
|
+
});
|
|
47638
|
+
}
|
|
47639
|
+
}
|
|
47640
|
+
updateState(params, extension) {
|
|
47641
|
+
if (!extension.isEnabled(this)) {
|
|
47642
|
+
return;
|
|
47643
|
+
}
|
|
47644
|
+
const uniforms = {};
|
|
47645
|
+
if (extension.opts.dash) {
|
|
47646
|
+
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
47647
|
+
uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
|
|
47648
|
+
}
|
|
47649
|
+
this.state.model.setUniforms(uniforms);
|
|
47650
|
+
}
|
|
47651
|
+
getDashOffsets(path) {
|
|
47652
|
+
const result = [0];
|
|
47653
|
+
const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
|
|
47654
|
+
const isNested2 = Array.isArray(path[0]);
|
|
47655
|
+
const geometrySize = isNested2 ? path.length : path.length / positionSize;
|
|
47656
|
+
let p;
|
|
47657
|
+
let prevP;
|
|
47658
|
+
for (let i2 = 0; i2 < geometrySize - 1; i2++) {
|
|
47659
|
+
p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
|
|
47660
|
+
p = this.projectPosition(p);
|
|
47661
|
+
if (i2 > 0) {
|
|
47662
|
+
result[i2] = result[i2 - 1] + dist(prevP, p);
|
|
47663
|
+
}
|
|
47664
|
+
prevP = p;
|
|
47665
|
+
}
|
|
47666
|
+
return result;
|
|
47667
|
+
}
|
|
47668
|
+
}
|
|
47669
|
+
_defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
|
|
47670
|
+
_defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
|
|
47542
47671
|
const defaultProps$M = {
|
|
47543
47672
|
clipBounds: [0, 0, 1, 1]
|
|
47544
47673
|
};
|
|
@@ -103650,8 +103779,8 @@ function requireJs$b() {
|
|
|
103650
103779
|
var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
|
|
103651
103780
|
var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
|
|
103652
103781
|
var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
|
|
103653
|
-
var
|
|
103654
|
-
return
|
|
103782
|
+
var dist2 = delta * R;
|
|
103783
|
+
return dist2;
|
|
103655
103784
|
}
|
|
103656
103785
|
js$a.default = rhumbDistance;
|
|
103657
103786
|
return js$a;
|
|
@@ -103964,7 +104093,7 @@ function requireUtils$2() {
|
|
|
103964
104093
|
var x;
|
|
103965
104094
|
var y;
|
|
103966
104095
|
var segmentIdx;
|
|
103967
|
-
var
|
|
104096
|
+
var dist2;
|
|
103968
104097
|
if (coords.length > 1 && pointCoords.length) {
|
|
103969
104098
|
var lineCoordinates;
|
|
103970
104099
|
var pointCoordinate;
|
|
@@ -103981,17 +104110,17 @@ function requireUtils$2() {
|
|
|
103981
104110
|
if (lineCoordinates[n3][0] !== lineCoordinates[n3 - 1][0]) {
|
|
103982
104111
|
var slope = (lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1]) / (lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0]);
|
|
103983
104112
|
var inverseSlope = lineCoordinates[n3][1] - slope * lineCoordinates[n3][0];
|
|
103984
|
-
|
|
103985
|
-
} else
|
|
104113
|
+
dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
|
|
104114
|
+
} else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
|
|
103986
104115
|
var rl2 = Math.pow(lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1], 2) + Math.pow(lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0], 2);
|
|
103987
104116
|
var ln2 = Math.pow(lineCoordinates[n3][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3][0] - pointCoordinate[0], 2);
|
|
103988
104117
|
var lnm12 = Math.pow(lineCoordinates[n3 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3 - 1][0] - pointCoordinate[0], 2);
|
|
103989
|
-
var
|
|
103990
|
-
var calcrl2 = ln2 -
|
|
104118
|
+
var dist22 = Math.pow(dist2, 2);
|
|
104119
|
+
var calcrl2 = ln2 - dist22 + lnm12 - dist22;
|
|
103991
104120
|
if (calcrl2 > rl2) {
|
|
103992
|
-
|
|
104121
|
+
dist2 = Math.sqrt(Math.min(ln2, lnm12));
|
|
103993
104122
|
}
|
|
103994
|
-
if (minDist === null || minDist === void 0 || minDist >
|
|
104123
|
+
if (minDist === null || minDist === void 0 || minDist > dist2) {
|
|
103995
104124
|
if (calcrl2 > rl2) {
|
|
103996
104125
|
if (lnm12 < ln2) {
|
|
103997
104126
|
to = 0;
|
|
@@ -104001,10 +104130,10 @@ function requireUtils$2() {
|
|
|
104001
104130
|
to = 1;
|
|
104002
104131
|
}
|
|
104003
104132
|
} else {
|
|
104004
|
-
to = Math.sqrt(lnm12 -
|
|
104005
|
-
from = Math.sqrt(ln2 -
|
|
104133
|
+
to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
|
|
104134
|
+
from = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
|
|
104006
104135
|
}
|
|
104007
|
-
minDist =
|
|
104136
|
+
minDist = dist2;
|
|
104008
104137
|
segmentIdx = n3;
|
|
104009
104138
|
}
|
|
104010
104139
|
}
|
|
@@ -120262,22 +120391,22 @@ function addDecoder(cases, importFn) {
|
|
|
120262
120391
|
}
|
|
120263
120392
|
cases.forEach((c) => registry$1.set(c, importFn));
|
|
120264
120393
|
}
|
|
120265
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
120266
|
-
addDecoder(5, () => import("./lzw-
|
|
120394
|
+
addDecoder([void 0, 1], () => import("./raw-DqOqmksW.js").then((m) => m.default));
|
|
120395
|
+
addDecoder(5, () => import("./lzw-Cj3FuoEM.js").then((m) => m.default));
|
|
120267
120396
|
addDecoder(6, () => {
|
|
120268
120397
|
throw new Error("old style JPEG compression is not supported.");
|
|
120269
120398
|
});
|
|
120270
|
-
addDecoder(7, () => import("./jpeg-
|
|
120271
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
120272
|
-
addDecoder(32773, () => import("./packbits-
|
|
120399
|
+
addDecoder(7, () => import("./jpeg-DdRwUGtb.js").then((m) => m.default));
|
|
120400
|
+
addDecoder([8, 32946], () => import("./deflate-CYRafIfN.js").then((m) => m.default));
|
|
120401
|
+
addDecoder(32773, () => import("./packbits-QWSBfY1A.js").then((m) => m.default));
|
|
120273
120402
|
addDecoder(
|
|
120274
120403
|
34887,
|
|
120275
|
-
() => import("./lerc-
|
|
120404
|
+
() => import("./lerc-CbvtcHx_.js").then(async (m) => {
|
|
120276
120405
|
await m.zstd.init();
|
|
120277
120406
|
return m;
|
|
120278
120407
|
}).then((m) => m.default)
|
|
120279
120408
|
);
|
|
120280
|
-
addDecoder(50001, () => import("./webimage-
|
|
120409
|
+
addDecoder(50001, () => import("./webimage-8chAb-F3.js").then((m) => m.default));
|
|
120281
120410
|
function decodeRowAcc(row, stride) {
|
|
120282
120411
|
let length2 = row.length - stride;
|
|
120283
120412
|
let offset = 0;
|
|
@@ -124278,8 +124407,8 @@ function TreeDesc(dyn_tree, stat_desc) {
|
|
|
124278
124407
|
this.max_code = 0;
|
|
124279
124408
|
this.stat_desc = stat_desc;
|
|
124280
124409
|
}
|
|
124281
|
-
const d_code = (
|
|
124282
|
-
return
|
|
124410
|
+
const d_code = (dist2) => {
|
|
124411
|
+
return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
|
|
124283
124412
|
};
|
|
124284
124413
|
const put_short = (s2, w2) => {
|
|
124285
124414
|
s2.pending_buf[s2.pending++] = w2 & 255;
|
|
@@ -124413,7 +124542,7 @@ const tr_static_init = () => {
|
|
|
124413
124542
|
let bits;
|
|
124414
124543
|
let length2;
|
|
124415
124544
|
let code;
|
|
124416
|
-
let
|
|
124545
|
+
let dist2;
|
|
124417
124546
|
const bl_count = new Array(MAX_BITS + 1);
|
|
124418
124547
|
length2 = 0;
|
|
124419
124548
|
for (code = 0; code < LENGTH_CODES - 1; code++) {
|
|
@@ -124423,18 +124552,18 @@ const tr_static_init = () => {
|
|
|
124423
124552
|
}
|
|
124424
124553
|
}
|
|
124425
124554
|
_length_code[length2 - 1] = code;
|
|
124426
|
-
|
|
124555
|
+
dist2 = 0;
|
|
124427
124556
|
for (code = 0; code < 16; code++) {
|
|
124428
|
-
base_dist[code] =
|
|
124557
|
+
base_dist[code] = dist2;
|
|
124429
124558
|
for (n3 = 0; n3 < 1 << extra_dbits[code]; n3++) {
|
|
124430
|
-
_dist_code[
|
|
124559
|
+
_dist_code[dist2++] = code;
|
|
124431
124560
|
}
|
|
124432
124561
|
}
|
|
124433
|
-
|
|
124562
|
+
dist2 >>= 7;
|
|
124434
124563
|
for (; code < D_CODES; code++) {
|
|
124435
|
-
base_dist[code] =
|
|
124564
|
+
base_dist[code] = dist2 << 7;
|
|
124436
124565
|
for (n3 = 0; n3 < 1 << extra_dbits[code] - 7; n3++) {
|
|
124437
|
-
_dist_code[256 +
|
|
124566
|
+
_dist_code[256 + dist2++] = code;
|
|
124438
124567
|
}
|
|
124439
124568
|
}
|
|
124440
124569
|
for (bits = 0; bits <= MAX_BITS; bits++) {
|
|
@@ -124525,17 +124654,17 @@ const pqdownheap = (s2, tree, k) => {
|
|
|
124525
124654
|
s2.heap[k] = v;
|
|
124526
124655
|
};
|
|
124527
124656
|
const compress_block = (s2, ltree, dtree) => {
|
|
124528
|
-
let
|
|
124657
|
+
let dist2;
|
|
124529
124658
|
let lc;
|
|
124530
124659
|
let lx = 0;
|
|
124531
124660
|
let code;
|
|
124532
124661
|
let extra;
|
|
124533
124662
|
if (s2.last_lit !== 0) {
|
|
124534
124663
|
do {
|
|
124535
|
-
|
|
124664
|
+
dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
|
|
124536
124665
|
lc = s2.pending_buf[s2.l_buf + lx];
|
|
124537
124666
|
lx++;
|
|
124538
|
-
if (
|
|
124667
|
+
if (dist2 === 0) {
|
|
124539
124668
|
send_code(s2, lc, ltree);
|
|
124540
124669
|
} else {
|
|
124541
124670
|
code = _length_code[lc];
|
|
@@ -124545,13 +124674,13 @@ const compress_block = (s2, ltree, dtree) => {
|
|
|
124545
124674
|
lc -= base_length[code];
|
|
124546
124675
|
send_bits(s2, lc, extra);
|
|
124547
124676
|
}
|
|
124548
|
-
|
|
124549
|
-
code = d_code(
|
|
124677
|
+
dist2--;
|
|
124678
|
+
code = d_code(dist2);
|
|
124550
124679
|
send_code(s2, code, dtree);
|
|
124551
124680
|
extra = extra_dbits[code];
|
|
124552
124681
|
if (extra !== 0) {
|
|
124553
|
-
|
|
124554
|
-
send_bits(s2,
|
|
124682
|
+
dist2 -= base_dist[code];
|
|
124683
|
+
send_bits(s2, dist2, extra);
|
|
124555
124684
|
}
|
|
124556
124685
|
}
|
|
124557
124686
|
} while (lx < s2.last_lit);
|
|
@@ -124822,18 +124951,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
|
|
|
124822
124951
|
bi_windup(s2);
|
|
124823
124952
|
}
|
|
124824
124953
|
};
|
|
124825
|
-
const _tr_tally = (s2,
|
|
124826
|
-
s2.pending_buf[s2.d_buf + s2.last_lit * 2] =
|
|
124827
|
-
s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] =
|
|
124954
|
+
const _tr_tally = (s2, dist2, lc) => {
|
|
124955
|
+
s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
|
|
124956
|
+
s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
|
|
124828
124957
|
s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
|
|
124829
124958
|
s2.last_lit++;
|
|
124830
|
-
if (
|
|
124959
|
+
if (dist2 === 0) {
|
|
124831
124960
|
s2.dyn_ltree[lc * 2]++;
|
|
124832
124961
|
} else {
|
|
124833
124962
|
s2.matches++;
|
|
124834
|
-
|
|
124963
|
+
dist2--;
|
|
124835
124964
|
s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
|
|
124836
|
-
s2.dyn_dtree[d_code(
|
|
124965
|
+
s2.dyn_dtree[d_code(dist2) * 2]++;
|
|
124837
124966
|
}
|
|
124838
124967
|
return s2.last_lit === s2.lit_bufsize - 1;
|
|
124839
124968
|
};
|
|
@@ -126338,7 +126467,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126338
126467
|
let here;
|
|
126339
126468
|
let op;
|
|
126340
126469
|
let len2;
|
|
126341
|
-
let
|
|
126470
|
+
let dist2;
|
|
126342
126471
|
let from;
|
|
126343
126472
|
let from_source;
|
|
126344
126473
|
let input, output;
|
|
@@ -126404,7 +126533,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126404
126533
|
bits -= op;
|
|
126405
126534
|
op = here >>> 16 & 255;
|
|
126406
126535
|
if (op & 16) {
|
|
126407
|
-
|
|
126536
|
+
dist2 = here & 65535;
|
|
126408
126537
|
op &= 15;
|
|
126409
126538
|
if (bits < op) {
|
|
126410
126539
|
hold += input[_in++] << bits;
|
|
@@ -126414,8 +126543,8 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126414
126543
|
bits += 8;
|
|
126415
126544
|
}
|
|
126416
126545
|
}
|
|
126417
|
-
|
|
126418
|
-
if (
|
|
126546
|
+
dist2 += hold & (1 << op) - 1;
|
|
126547
|
+
if (dist2 > dmax) {
|
|
126419
126548
|
strm.msg = "invalid distance too far back";
|
|
126420
126549
|
state.mode = BAD;
|
|
126421
126550
|
break top;
|
|
@@ -126423,8 +126552,8 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126423
126552
|
hold >>>= op;
|
|
126424
126553
|
bits -= op;
|
|
126425
126554
|
op = _out - beg;
|
|
126426
|
-
if (
|
|
126427
|
-
op =
|
|
126555
|
+
if (dist2 > op) {
|
|
126556
|
+
op = dist2 - op;
|
|
126428
126557
|
if (op > whave) {
|
|
126429
126558
|
if (state.sane) {
|
|
126430
126559
|
strm.msg = "invalid distance too far back";
|
|
@@ -126441,7 +126570,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126441
126570
|
do {
|
|
126442
126571
|
output[_out++] = s_window[from++];
|
|
126443
126572
|
} while (--op);
|
|
126444
|
-
from = _out -
|
|
126573
|
+
from = _out - dist2;
|
|
126445
126574
|
from_source = output;
|
|
126446
126575
|
}
|
|
126447
126576
|
} else if (wnext < op) {
|
|
@@ -126459,7 +126588,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126459
126588
|
do {
|
|
126460
126589
|
output[_out++] = s_window[from++];
|
|
126461
126590
|
} while (--op);
|
|
126462
|
-
from = _out -
|
|
126591
|
+
from = _out - dist2;
|
|
126463
126592
|
from_source = output;
|
|
126464
126593
|
}
|
|
126465
126594
|
}
|
|
@@ -126470,7 +126599,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126470
126599
|
do {
|
|
126471
126600
|
output[_out++] = s_window[from++];
|
|
126472
126601
|
} while (--op);
|
|
126473
|
-
from = _out -
|
|
126602
|
+
from = _out - dist2;
|
|
126474
126603
|
from_source = output;
|
|
126475
126604
|
}
|
|
126476
126605
|
}
|
|
@@ -126487,7 +126616,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
126487
126616
|
}
|
|
126488
126617
|
}
|
|
126489
126618
|
} else {
|
|
126490
|
-
from = _out -
|
|
126619
|
+
from = _out - dist2;
|
|
126491
126620
|
do {
|
|
126492
126621
|
output[_out++] = output[from++];
|
|
126493
126622
|
output[_out++] = output[from++];
|
|
@@ -127045,7 +127174,7 @@ const fixedtables = (state) => {
|
|
|
127045
127174
|
state.distbits = 5;
|
|
127046
127175
|
};
|
|
127047
127176
|
const updatewindow = (strm, src, end, copy2) => {
|
|
127048
|
-
let
|
|
127177
|
+
let dist2;
|
|
127049
127178
|
const state = strm.state;
|
|
127050
127179
|
if (state.window === null) {
|
|
127051
127180
|
state.wsize = 1 << state.wbits;
|
|
@@ -127058,23 +127187,23 @@ const updatewindow = (strm, src, end, copy2) => {
|
|
|
127058
127187
|
state.wnext = 0;
|
|
127059
127188
|
state.whave = state.wsize;
|
|
127060
127189
|
} else {
|
|
127061
|
-
|
|
127062
|
-
if (
|
|
127063
|
-
|
|
127190
|
+
dist2 = state.wsize - state.wnext;
|
|
127191
|
+
if (dist2 > copy2) {
|
|
127192
|
+
dist2 = copy2;
|
|
127064
127193
|
}
|
|
127065
|
-
state.window.set(src.subarray(end - copy2, end - copy2 +
|
|
127066
|
-
copy2 -=
|
|
127194
|
+
state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
|
|
127195
|
+
copy2 -= dist2;
|
|
127067
127196
|
if (copy2) {
|
|
127068
127197
|
state.window.set(src.subarray(end - copy2, end), 0);
|
|
127069
127198
|
state.wnext = copy2;
|
|
127070
127199
|
state.whave = state.wsize;
|
|
127071
127200
|
} else {
|
|
127072
|
-
state.wnext +=
|
|
127201
|
+
state.wnext += dist2;
|
|
127073
127202
|
if (state.wnext === state.wsize) {
|
|
127074
127203
|
state.wnext = 0;
|
|
127075
127204
|
}
|
|
127076
127205
|
if (state.whave < state.wsize) {
|
|
127077
|
-
state.whave +=
|
|
127206
|
+
state.whave += dist2;
|
|
127078
127207
|
}
|
|
127079
127208
|
}
|
|
127080
127209
|
}
|
|
@@ -131066,7 +131195,7 @@ function padColors({ colors, channelsVisible }) {
|
|
|
131066
131195
|
).reduce((acc, val) => acc.concat(val), []);
|
|
131067
131196
|
return paddedColors;
|
|
131068
131197
|
}
|
|
131069
|
-
const defaultProps$3$
|
|
131198
|
+
const defaultProps$3$2 = {
|
|
131070
131199
|
colors: { type: "array", value: null, compare: true },
|
|
131071
131200
|
opacity: { type: "number", value: 1, compare: true },
|
|
131072
131201
|
transparentColor: { type: "array", value: null, compare: true },
|
|
@@ -131083,9 +131212,9 @@ const ColorPaletteExtension = class extends LayerExtension {
|
|
|
131083
131212
|
const {
|
|
131084
131213
|
colors,
|
|
131085
131214
|
channelsVisible,
|
|
131086
|
-
opacity = defaultProps$3$
|
|
131087
|
-
transparentColor = defaultProps$3$
|
|
131088
|
-
useTransparentColor = defaultProps$3$
|
|
131215
|
+
opacity = defaultProps$3$2.opacity.value,
|
|
131216
|
+
transparentColor = defaultProps$3$2.transparentColor.value,
|
|
131217
|
+
useTransparentColor = defaultProps$3$2.useTransparentColor.value
|
|
131089
131218
|
} = this.props;
|
|
131090
131219
|
const paddedColors = padColors({
|
|
131091
131220
|
channelsVisible: channelsVisible || this.selections.map(() => true),
|
|
@@ -131101,7 +131230,7 @@ const ColorPaletteExtension = class extends LayerExtension {
|
|
|
131101
131230
|
}
|
|
131102
131231
|
};
|
|
131103
131232
|
ColorPaletteExtension.extensionName = "ColorPaletteExtension";
|
|
131104
|
-
ColorPaletteExtension.defaultProps = defaultProps$3$
|
|
131233
|
+
ColorPaletteExtension.defaultProps = defaultProps$3$2;
|
|
131105
131234
|
const fs$4 = `// lens bounds for ellipse
|
|
131106
131235
|
uniform float majorLensAxis;
|
|
131107
131236
|
uniform float minorLensAxis;
|
|
@@ -132396,7 +132525,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
|
|
|
132396
132525
|
};
|
|
132397
132526
|
MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
|
|
132398
132527
|
MultiscaleImageLayer.defaultProps = defaultProps$4;
|
|
132399
|
-
const defaultProps$3 = {
|
|
132528
|
+
const defaultProps$3$1 = {
|
|
132400
132529
|
pickable: { type: "boolean", value: true, compare: true },
|
|
132401
132530
|
loader: {
|
|
132402
132531
|
type: "object",
|
|
@@ -132483,7 +132612,7 @@ const OverviewLayer = class extends CompositeLayer {
|
|
|
132483
132612
|
}
|
|
132484
132613
|
};
|
|
132485
132614
|
OverviewLayer.layerName = "OverviewLayer";
|
|
132486
|
-
OverviewLayer.defaultProps = defaultProps$3;
|
|
132615
|
+
OverviewLayer.defaultProps = defaultProps$3$1;
|
|
132487
132616
|
function getPosition(boundingBox, position, length2) {
|
|
132488
132617
|
const viewWidth = boundingBox[2][0] - boundingBox[0][0];
|
|
132489
132618
|
const viewHeight = boundingBox[2][1] - boundingBox[0][1];
|
|
@@ -133471,7 +133600,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
|
|
|
133471
133600
|
}
|
|
133472
133601
|
return newArr;
|
|
133473
133602
|
}
|
|
133474
|
-
const defaultProps$
|
|
133603
|
+
const defaultProps$3 = {
|
|
133475
133604
|
hoveredCell: { type: "number", value: null, compare: true },
|
|
133476
133605
|
// We do not want to deep-compare cellColorData,
|
|
133477
133606
|
// as it is potentially a TypedArray with millions of elements.
|
|
@@ -133588,7 +133717,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
|
|
|
133588
133717
|
}
|
|
133589
133718
|
};
|
|
133590
133719
|
BitmaskLayer$1.layerName = "BitmaskLayer";
|
|
133591
|
-
BitmaskLayer$1.defaultProps = defaultProps$
|
|
133720
|
+
BitmaskLayer$1.defaultProps = defaultProps$3;
|
|
133592
133721
|
const vs = `
|
|
133593
133722
|
#define SHADER_NAME bitmask-layer-vertex-shader
|
|
133594
133723
|
|
|
@@ -133930,7 +134059,7 @@ function isEqualShallow(prevArr, nextArr) {
|
|
|
133930
134059
|
}
|
|
133931
134060
|
return prevArr === nextArr;
|
|
133932
134061
|
}
|
|
133933
|
-
const defaultProps$
|
|
134062
|
+
const defaultProps$2 = {
|
|
133934
134063
|
channelStrokeWidths: { type: "array", value: null, compare: true },
|
|
133935
134064
|
channelsFilled: { type: "array", value: null, compare: true },
|
|
133936
134065
|
channelOpacities: { type: "array", value: null, compare: true },
|
|
@@ -134194,7 +134323,7 @@ class BitmaskLayer2 extends XRLayer {
|
|
|
134194
134323
|
}
|
|
134195
134324
|
}
|
|
134196
134325
|
BitmaskLayer2.layerName = "BitmaskLayer";
|
|
134197
|
-
BitmaskLayer2.defaultProps = defaultProps$
|
|
134326
|
+
BitmaskLayer2.defaultProps = defaultProps$2;
|
|
134198
134327
|
var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
|
|
134199
134328
|
function clone(configObject) {
|
|
134200
134329
|
var div2, convertBase2, parseNumeric, P2 = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
|
|
@@ -137137,7 +137266,7 @@ function ringArea(coords) {
|
|
|
137137
137266
|
return total * FACTOR;
|
|
137138
137267
|
}
|
|
137139
137268
|
const DEFAULT_THRESHOLD = 1;
|
|
137140
|
-
const defaultProps = {
|
|
137269
|
+
const defaultProps$1 = {
|
|
137141
137270
|
// for text
|
|
137142
137271
|
obsSetPath: { type: "object" },
|
|
137143
137272
|
sampleSetPath: { type: "object" },
|
|
@@ -137232,9 +137361,9 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
137232
137361
|
const circlePoint = point(circleCoord);
|
|
137233
137362
|
polygonVertices.forEach((polyCoord) => {
|
|
137234
137363
|
const polyPoint = point(polyCoord);
|
|
137235
|
-
const
|
|
137236
|
-
if (
|
|
137237
|
-
minDist =
|
|
137364
|
+
const dist2 = distance$1(circlePoint, polyPoint);
|
|
137365
|
+
if (dist2 < minDist) {
|
|
137366
|
+
minDist = dist2;
|
|
137238
137367
|
minCirclePoint = circleCoord;
|
|
137239
137368
|
minCirclePointI = circlePointI;
|
|
137240
137369
|
minPolygonPoint = polyCoord;
|
|
@@ -137311,7 +137440,1077 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
137311
137440
|
}
|
|
137312
137441
|
}
|
|
137313
137442
|
ContourLayerWithText.layerName = "ContourLayerWithText";
|
|
137314
|
-
ContourLayerWithText.defaultProps = defaultProps;
|
|
137443
|
+
ContourLayerWithText.defaultProps = defaultProps$1;
|
|
137444
|
+
const ARROW_SCREEN_PX = 14;
|
|
137445
|
+
const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
|
|
137446
|
+
const LABEL_FONT_WEIGHT = "bold";
|
|
137447
|
+
const LABEL_FONT_SIZE = 14;
|
|
137448
|
+
const RATIO_CLUSTER = 0.1;
|
|
137449
|
+
const RATIO_DOT = 0.3;
|
|
137450
|
+
const RATIO_GEO_FADE = 0.55;
|
|
137451
|
+
const RATIO_TIPS = 0.7;
|
|
137452
|
+
const RATIO_LABEL = 0.55;
|
|
137453
|
+
const RATIO_LABEL_FULL = 0.75;
|
|
137454
|
+
function textBgColor(strokeColor) {
|
|
137455
|
+
const [r2, g2, b] = strokeColor;
|
|
137456
|
+
const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
|
|
137457
|
+
return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
|
|
137458
|
+
}
|
|
137459
|
+
function parseDashArray(strokeDashArray) {
|
|
137460
|
+
if (!strokeDashArray || strokeDashArray === "none")
|
|
137461
|
+
return null;
|
|
137462
|
+
const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n3) => !Number.isNaN(n3) && n3 >= 0);
|
|
137463
|
+
return nums.length >= 2 ? [nums[0], nums[1]] : null;
|
|
137464
|
+
}
|
|
137465
|
+
function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
|
|
137466
|
+
const pts = [];
|
|
137467
|
+
for (let i2 = 0; i2 < numSegments; i2++) {
|
|
137468
|
+
const angle2 = 2 * Math.PI * i2 / numSegments;
|
|
137469
|
+
pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
|
|
137470
|
+
}
|
|
137471
|
+
return pts;
|
|
137472
|
+
}
|
|
137473
|
+
function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
|
|
137474
|
+
if (!inProgress || inProgress.vertices.length === 0)
|
|
137475
|
+
return null;
|
|
137476
|
+
const { type, vertices } = inProgress;
|
|
137477
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
|
|
137478
|
+
const previewColor = [...strokeColor, 160];
|
|
137479
|
+
const cursor = hoverCoord ?? vertices[vertices.length - 1];
|
|
137480
|
+
if (type === "rectangle" && vertices.length === 1) {
|
|
137481
|
+
const [ax, ay] = vertices[0];
|
|
137482
|
+
const [bx, by] = cursor;
|
|
137483
|
+
const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
|
|
137484
|
+
return new PathLayer({
|
|
137485
|
+
...base,
|
|
137486
|
+
id: "annotation-preview-rectangle",
|
|
137487
|
+
data: [{ path }],
|
|
137488
|
+
getPath: (d) => d.path,
|
|
137489
|
+
getColor: previewColor,
|
|
137490
|
+
getWidth: 1,
|
|
137491
|
+
widthUnits: "pixels",
|
|
137492
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137493
|
+
getDashArray: [8, 4]
|
|
137494
|
+
});
|
|
137495
|
+
}
|
|
137496
|
+
if (type === "line" && vertices.length === 1) {
|
|
137497
|
+
const path = [vertices[0], cursor];
|
|
137498
|
+
return new PathLayer({
|
|
137499
|
+
...base,
|
|
137500
|
+
id: "annotation-preview-line",
|
|
137501
|
+
data: [{ path }],
|
|
137502
|
+
getPath: (d) => d.path,
|
|
137503
|
+
getColor: previewColor,
|
|
137504
|
+
getWidth: 1,
|
|
137505
|
+
widthUnits: "pixels",
|
|
137506
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137507
|
+
getDashArray: [8, 4]
|
|
137508
|
+
});
|
|
137509
|
+
}
|
|
137510
|
+
if (type === "ellipse" && vertices.length === 1) {
|
|
137511
|
+
const [cx, cy] = vertices[0];
|
|
137512
|
+
const [ex, ey] = cursor;
|
|
137513
|
+
const rx = Math.abs(ex - cx);
|
|
137514
|
+
const ry = Math.abs(ey - cy);
|
|
137515
|
+
if (rx < 1 && ry < 1)
|
|
137516
|
+
return null;
|
|
137517
|
+
const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
|
|
137518
|
+
const path = [...pts, pts[0]];
|
|
137519
|
+
return new PathLayer({
|
|
137520
|
+
...base,
|
|
137521
|
+
id: "annotation-preview-ellipse",
|
|
137522
|
+
data: [{ path }],
|
|
137523
|
+
getPath: (d) => d.path,
|
|
137524
|
+
getColor: previewColor,
|
|
137525
|
+
getWidth: 1,
|
|
137526
|
+
widthUnits: "pixels",
|
|
137527
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137528
|
+
getDashArray: [8, 4]
|
|
137529
|
+
});
|
|
137530
|
+
}
|
|
137531
|
+
if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
|
|
137532
|
+
const path = [...vertices, cursor];
|
|
137533
|
+
if (type === "polygon" && vertices.length >= 2)
|
|
137534
|
+
path.push(vertices[0]);
|
|
137535
|
+
return new PathLayer({
|
|
137536
|
+
...base,
|
|
137537
|
+
id: `annotation-preview-${type}`,
|
|
137538
|
+
data: [{ path }],
|
|
137539
|
+
getPath: (d) => d.path,
|
|
137540
|
+
getColor: previewColor,
|
|
137541
|
+
getWidth: 1,
|
|
137542
|
+
widthUnits: "pixels",
|
|
137543
|
+
jointRounded: true,
|
|
137544
|
+
capRounded: true,
|
|
137545
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137546
|
+
getDashArray: [8, 4]
|
|
137547
|
+
});
|
|
137548
|
+
}
|
|
137549
|
+
return null;
|
|
137550
|
+
}
|
|
137551
|
+
function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
|
|
137552
|
+
const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
137553
|
+
if (len2 === 0)
|
|
137554
|
+
return null;
|
|
137555
|
+
const ux = dirX / len2;
|
|
137556
|
+
const uy = dirY / len2;
|
|
137557
|
+
const px = -uy;
|
|
137558
|
+
const py = ux;
|
|
137559
|
+
const half = dataSize * 0.55;
|
|
137560
|
+
return [
|
|
137561
|
+
[tipX + px * half, tipY + py * half],
|
|
137562
|
+
[tipX - px * half, tipY - py * half]
|
|
137563
|
+
];
|
|
137564
|
+
}
|
|
137565
|
+
function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
|
|
137566
|
+
const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
137567
|
+
if (len2 === 0)
|
|
137568
|
+
return null;
|
|
137569
|
+
const ux = dirX / len2;
|
|
137570
|
+
const uy = dirY / len2;
|
|
137571
|
+
const px = -uy;
|
|
137572
|
+
const py = ux;
|
|
137573
|
+
const halfBase = dataSize * 0.4;
|
|
137574
|
+
const bx = tipX - ux * dataSize;
|
|
137575
|
+
const by = tipY - uy * dataSize;
|
|
137576
|
+
return [
|
|
137577
|
+
[tipX, tipY],
|
|
137578
|
+
[bx + px * halfBase, by + py * halfBase],
|
|
137579
|
+
[bx - px * halfBase, by - py * halfBase]
|
|
137580
|
+
];
|
|
137581
|
+
}
|
|
137582
|
+
function fmtCommas(n3) {
|
|
137583
|
+
return Math.round(n3).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
137584
|
+
}
|
|
137585
|
+
function getMeasurementLabel(shape, physicalPixelSize, viewType = ViewType.SPATIAL) {
|
|
137586
|
+
const pps = physicalPixelSize;
|
|
137587
|
+
const px = pps?.x ?? 1;
|
|
137588
|
+
const py = pps?.y ?? 1;
|
|
137589
|
+
const unit2 = pps ? pps.unit ?? "" : null;
|
|
137590
|
+
const hasPhys = !!pps;
|
|
137591
|
+
const isEmbedding = viewType === ViewType.SCATTERPLOT;
|
|
137592
|
+
const fmtDist = (d) => {
|
|
137593
|
+
if (hasPhys)
|
|
137594
|
+
return `${d.toFixed(2)} ${unit2}`;
|
|
137595
|
+
if (isEmbedding)
|
|
137596
|
+
return d.toFixed(2);
|
|
137597
|
+
return `${fmtCommas(d)} px`;
|
|
137598
|
+
};
|
|
137599
|
+
const fmtArea = (a2) => {
|
|
137600
|
+
if (hasPhys)
|
|
137601
|
+
return `${a2.toFixed(2)} ${unit2}²`;
|
|
137602
|
+
if (isEmbedding)
|
|
137603
|
+
return a2.toFixed(2);
|
|
137604
|
+
return `${fmtCommas(a2)} px²`;
|
|
137605
|
+
};
|
|
137606
|
+
if (shape.type === "line") {
|
|
137607
|
+
const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
|
|
137608
|
+
const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
|
|
137609
|
+
const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
|
|
137610
|
+
return fmtDist(dist2);
|
|
137611
|
+
}
|
|
137612
|
+
if (shape.type === "rectangle") {
|
|
137613
|
+
return fmtArea(hasPhys ? Math.abs(shape.width ?? 0) * px * Math.abs(shape.height ?? 0) * py : Math.abs((shape.width ?? 0) * (shape.height ?? 0)));
|
|
137614
|
+
}
|
|
137615
|
+
if (shape.type === "ellipse") {
|
|
137616
|
+
const rx = Math.abs(shape.radiusX ?? 0);
|
|
137617
|
+
const ry = Math.abs(shape.radiusY ?? 0);
|
|
137618
|
+
return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
|
|
137619
|
+
}
|
|
137620
|
+
if (shape.type === "polygon" && shape.points?.length >= 3) {
|
|
137621
|
+
const pts = shape.points;
|
|
137622
|
+
let shoelace = 0;
|
|
137623
|
+
for (let i2 = 0; i2 < pts.length; i2++) {
|
|
137624
|
+
const [ax, ay] = pts[i2];
|
|
137625
|
+
const [bx, by] = pts[(i2 + 1) % pts.length];
|
|
137626
|
+
shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
|
|
137627
|
+
}
|
|
137628
|
+
return fmtArea(Math.abs(shoelace / 2));
|
|
137629
|
+
}
|
|
137630
|
+
if (shape.type === "polyline" && shape.points?.length >= 2) {
|
|
137631
|
+
let total = 0;
|
|
137632
|
+
for (let i2 = 0; i2 < shape.points.length - 1; i2++) {
|
|
137633
|
+
const [ax, ay] = shape.points[i2];
|
|
137634
|
+
const [bx, by] = shape.points[i2 + 1];
|
|
137635
|
+
total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
|
|
137636
|
+
}
|
|
137637
|
+
return fmtDist(total);
|
|
137638
|
+
}
|
|
137639
|
+
return null;
|
|
137640
|
+
}
|
|
137641
|
+
function pickBelowPerp(ux, uy) {
|
|
137642
|
+
const rp = [uy, -ux];
|
|
137643
|
+
const lp = [-uy, ux];
|
|
137644
|
+
return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
|
|
137645
|
+
}
|
|
137646
|
+
function readableAngle(deg) {
|
|
137647
|
+
let a2 = deg;
|
|
137648
|
+
if (a2 > 90)
|
|
137649
|
+
a2 -= 180;
|
|
137650
|
+
if (a2 < -90)
|
|
137651
|
+
a2 += 180;
|
|
137652
|
+
return a2;
|
|
137653
|
+
}
|
|
137654
|
+
function getShapeCentroid(shape) {
|
|
137655
|
+
if (shape.type === "rectangle") {
|
|
137656
|
+
return [(shape.x ?? 0) + (shape.width ?? 0) / 2, (shape.y ?? 0) + (shape.height ?? 0) / 2];
|
|
137657
|
+
}
|
|
137658
|
+
if (shape.type === "line") {
|
|
137659
|
+
return [((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2, ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2];
|
|
137660
|
+
}
|
|
137661
|
+
if (shape.type === "ellipse") {
|
|
137662
|
+
return [shape.x1 ?? 0, shape.y1 ?? 0];
|
|
137663
|
+
}
|
|
137664
|
+
if ((shape.type === "polygon" || shape.type === "polyline") && shape.points?.length >= 1) {
|
|
137665
|
+
const mx = shape.points.reduce((s2, p) => s2 + p[0], 0) / shape.points.length;
|
|
137666
|
+
const my = shape.points.reduce((s2, p) => s2 + p[1], 0) / shape.points.length;
|
|
137667
|
+
return [mx, my];
|
|
137668
|
+
}
|
|
137669
|
+
return [0, 0];
|
|
137670
|
+
}
|
|
137671
|
+
function computeClusters(shapeList, zoom, cellPx = 50) {
|
|
137672
|
+
const cellSize = cellPx / 2 ** Math.floor(zoom);
|
|
137673
|
+
const cells = /* @__PURE__ */ new Map();
|
|
137674
|
+
shapeList.forEach(({ shape }) => {
|
|
137675
|
+
const [cx, cy] = getShapeCentroid(shape);
|
|
137676
|
+
const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
|
|
137677
|
+
if (!cells.has(key)) {
|
|
137678
|
+
cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape.strokeColor ?? [255, 255, 255] });
|
|
137679
|
+
}
|
|
137680
|
+
const c = cells.get(key);
|
|
137681
|
+
c.sumX += cx;
|
|
137682
|
+
c.sumY += cy;
|
|
137683
|
+
c.count++;
|
|
137684
|
+
});
|
|
137685
|
+
return Array.from(cells.values()).map((c) => ({
|
|
137686
|
+
position: [c.sumX / c.count, c.sumY / c.count, 0],
|
|
137687
|
+
count: c.count,
|
|
137688
|
+
color: c.color
|
|
137689
|
+
}));
|
|
137690
|
+
}
|
|
137691
|
+
function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType.SPATIAL) {
|
|
137692
|
+
const selectionLayers = [];
|
|
137693
|
+
if (selectedShapeUid) {
|
|
137694
|
+
const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
|
|
137695
|
+
if (sel) {
|
|
137696
|
+
const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
|
|
137697
|
+
const haloColor = [255, 220, 50, 70];
|
|
137698
|
+
const haloWidth = Math.max(sStrokeWidth + 8, 10);
|
|
137699
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
|
|
137700
|
+
if (sType === "rectangle") {
|
|
137701
|
+
const { x, y, width, height } = sel;
|
|
137702
|
+
selectionLayers.push(new PathLayer({
|
|
137703
|
+
...base,
|
|
137704
|
+
id: `annotation-select-${sUid}`,
|
|
137705
|
+
data: [{
|
|
137706
|
+
path: [
|
|
137707
|
+
[x, y],
|
|
137708
|
+
[x + width, y],
|
|
137709
|
+
[x + width, y + height],
|
|
137710
|
+
[x, y + height],
|
|
137711
|
+
[x, y]
|
|
137712
|
+
]
|
|
137713
|
+
}],
|
|
137714
|
+
getPath: (d) => d.path,
|
|
137715
|
+
getColor: haloColor,
|
|
137716
|
+
getWidth: haloWidth,
|
|
137717
|
+
widthUnits: "pixels",
|
|
137718
|
+
jointRounded: true,
|
|
137719
|
+
capRounded: true
|
|
137720
|
+
}));
|
|
137721
|
+
}
|
|
137722
|
+
if (sType === "line") {
|
|
137723
|
+
const { x1: x12, y1: y12, x2, y2 } = sel;
|
|
137724
|
+
selectionLayers.push(new PathLayer({
|
|
137725
|
+
...base,
|
|
137726
|
+
id: `annotation-select-${sUid}`,
|
|
137727
|
+
data: [{ path: [[x12, y12], [x2, y2]] }],
|
|
137728
|
+
getPath: (d) => d.path,
|
|
137729
|
+
getColor: haloColor,
|
|
137730
|
+
getWidth: haloWidth,
|
|
137731
|
+
widthUnits: "pixels",
|
|
137732
|
+
capRounded: true
|
|
137733
|
+
}));
|
|
137734
|
+
}
|
|
137735
|
+
if (sType === "ellipse") {
|
|
137736
|
+
const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
|
|
137737
|
+
selectionLayers.push(new PathLayer({
|
|
137738
|
+
...base,
|
|
137739
|
+
id: `annotation-select-${sUid}`,
|
|
137740
|
+
data: [{ path: [...polygon2, polygon2[0]] }],
|
|
137741
|
+
getPath: (d) => d.path,
|
|
137742
|
+
getColor: haloColor,
|
|
137743
|
+
getWidth: haloWidth,
|
|
137744
|
+
widthUnits: "pixels",
|
|
137745
|
+
jointRounded: true
|
|
137746
|
+
}));
|
|
137747
|
+
}
|
|
137748
|
+
if (sType === "polygon" && sel.points?.length >= 3) {
|
|
137749
|
+
selectionLayers.push(new PathLayer({
|
|
137750
|
+
...base,
|
|
137751
|
+
id: `annotation-select-${sUid}`,
|
|
137752
|
+
data: [{ path: [...sel.points, sel.points[0]] }],
|
|
137753
|
+
getPath: (d) => d.path,
|
|
137754
|
+
getColor: haloColor,
|
|
137755
|
+
getWidth: haloWidth,
|
|
137756
|
+
widthUnits: "pixels",
|
|
137757
|
+
jointRounded: true
|
|
137758
|
+
}));
|
|
137759
|
+
}
|
|
137760
|
+
if (sType === "polyline" && sel.points?.length >= 2) {
|
|
137761
|
+
selectionLayers.push(new PathLayer({
|
|
137762
|
+
...base,
|
|
137763
|
+
id: `annotation-select-${sUid}`,
|
|
137764
|
+
data: [{ path: sel.points }],
|
|
137765
|
+
getPath: (d) => d.path,
|
|
137766
|
+
getColor: haloColor,
|
|
137767
|
+
getWidth: haloWidth,
|
|
137768
|
+
widthUnits: "pixels",
|
|
137769
|
+
jointRounded: true,
|
|
137770
|
+
capRounded: true
|
|
137771
|
+
}));
|
|
137772
|
+
}
|
|
137773
|
+
}
|
|
137774
|
+
}
|
|
137775
|
+
const layers = [];
|
|
137776
|
+
const dotShapes = [];
|
|
137777
|
+
const clusterDotShapes = [];
|
|
137778
|
+
shapes.forEach((shape, i2) => {
|
|
137779
|
+
const { uid: uid2, type, strokeColor = [255, 255, 255], strokeWidth = 3, strokeDashArray } = shape;
|
|
137780
|
+
const isSelected = uid2 === selectedShapeUid;
|
|
137781
|
+
let shapeOpacity = 1;
|
|
137782
|
+
let tipsOpacity = 1;
|
|
137783
|
+
let labelOpacity = 0;
|
|
137784
|
+
if (isSelected || !semanticZoom || authoredZoom === null) {
|
|
137785
|
+
tipsOpacity = 1;
|
|
137786
|
+
labelOpacity = 1;
|
|
137787
|
+
} else {
|
|
137788
|
+
const zoomRatio = 2 ** (zoom - authoredZoom);
|
|
137789
|
+
if (zoomRatio < RATIO_CLUSTER) {
|
|
137790
|
+
clusterDotShapes.push({ shape });
|
|
137791
|
+
return;
|
|
137792
|
+
}
|
|
137793
|
+
if (zoomRatio < RATIO_DOT) {
|
|
137794
|
+
dotShapes.push({ shape, alpha: 200 });
|
|
137795
|
+
return;
|
|
137796
|
+
}
|
|
137797
|
+
if (zoomRatio < RATIO_GEO_FADE) {
|
|
137798
|
+
const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
|
|
137799
|
+
shapeOpacity = t;
|
|
137800
|
+
dotShapes.push({ shape, alpha: Math.round((1 - t) * 200) });
|
|
137801
|
+
}
|
|
137802
|
+
tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(0, (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity);
|
|
137803
|
+
if (zoomRatio >= RATIO_LABEL_FULL) {
|
|
137804
|
+
labelOpacity = shapeOpacity;
|
|
137805
|
+
} else if (zoomRatio >= RATIO_LABEL) {
|
|
137806
|
+
labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
|
|
137807
|
+
}
|
|
137808
|
+
}
|
|
137809
|
+
const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
|
|
137810
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
|
|
137811
|
+
const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
|
|
137812
|
+
const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
|
|
137813
|
+
const labelBgProps = shape.labelBackground ? {
|
|
137814
|
+
background: true,
|
|
137815
|
+
getBackgroundColor: textBgColor(strokeColor),
|
|
137816
|
+
backgroundPadding: [3, 1, 3, 2]
|
|
137817
|
+
} : {};
|
|
137818
|
+
const labelProps = { ...labelBgProps };
|
|
137819
|
+
const dashArray = parseDashArray(strokeDashArray);
|
|
137820
|
+
const dashExt = [new PathStyleExtension({ dash: true })];
|
|
137821
|
+
const getDash = dashArray ?? [0, 0];
|
|
137822
|
+
if (type === "rectangle") {
|
|
137823
|
+
const { x, y, width, height, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
137824
|
+
const filled = fillOpacity > 0;
|
|
137825
|
+
const rectPolygon = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];
|
|
137826
|
+
layers.push(new PolygonLayer({
|
|
137827
|
+
...base,
|
|
137828
|
+
id: `annotation-rect-${uid2}-${i2}`,
|
|
137829
|
+
data: [{ polygon: rectPolygon }],
|
|
137830
|
+
getPolygon: (d) => d.polygon,
|
|
137831
|
+
filled,
|
|
137832
|
+
stroked: true,
|
|
137833
|
+
getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
|
|
137834
|
+
getLineColor: strokeColor,
|
|
137835
|
+
getLineWidth: strokeWidth,
|
|
137836
|
+
lineWidthUnits: "pixels",
|
|
137837
|
+
...dashArray ? {
|
|
137838
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137839
|
+
getDashArray: dashArray
|
|
137840
|
+
} : {}
|
|
137841
|
+
}));
|
|
137842
|
+
if (shape.text && labelOpacity > 0) {
|
|
137843
|
+
layers.push(new TextLayer({
|
|
137844
|
+
...labelBase,
|
|
137845
|
+
...labelProps,
|
|
137846
|
+
id: `annotation-rect-text-${uid2}-${i2}`,
|
|
137847
|
+
data: [{ position: [x, y], text: shape.text }],
|
|
137848
|
+
getPosition: (d) => d.position,
|
|
137849
|
+
getText: (d) => d.text,
|
|
137850
|
+
getColor: strokeColor,
|
|
137851
|
+
getSize: LABEL_FONT_SIZE,
|
|
137852
|
+
sizeUnits: "pixels",
|
|
137853
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
137854
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
137855
|
+
getPixelOffset: [3, -7],
|
|
137856
|
+
getTextAnchor: "start",
|
|
137857
|
+
getAlignmentBaseline: "bottom"
|
|
137858
|
+
}));
|
|
137859
|
+
}
|
|
137860
|
+
}
|
|
137861
|
+
if (type === "line") {
|
|
137862
|
+
const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape;
|
|
137863
|
+
const dx = x2 - x12;
|
|
137864
|
+
const dy = y2 - y12;
|
|
137865
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
137866
|
+
const ux = len2 > 0 ? dx / len2 : 0;
|
|
137867
|
+
const uy = len2 > 0 ? dy / len2 : 0;
|
|
137868
|
+
const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
|
|
137869
|
+
const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
|
|
137870
|
+
const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
|
|
137871
|
+
const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
|
|
137872
|
+
layers.push(new PathLayer({
|
|
137873
|
+
...base,
|
|
137874
|
+
id: `annotation-line-${uid2}-${i2}`,
|
|
137875
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
137876
|
+
getDashArray: dashArray ?? [0, 0],
|
|
137877
|
+
data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
|
|
137878
|
+
getPath: (d) => d.path,
|
|
137879
|
+
getColor: strokeColor,
|
|
137880
|
+
getWidth: strokeWidth,
|
|
137881
|
+
widthUnits: "pixels",
|
|
137882
|
+
capRounded: true
|
|
137883
|
+
}));
|
|
137884
|
+
if (markerEnd === "Arrow" && tipsOpacity > 0) {
|
|
137885
|
+
const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
|
|
137886
|
+
if (head) {
|
|
137887
|
+
layers.push(new PolygonLayer({
|
|
137888
|
+
...tipsBase,
|
|
137889
|
+
id: `annotation-end-arrow-${uid2}-${i2}`,
|
|
137890
|
+
data: [{ polygon: head }],
|
|
137891
|
+
getPolygon: (d) => d.polygon,
|
|
137892
|
+
filled: true,
|
|
137893
|
+
stroked: false,
|
|
137894
|
+
getFillColor: strokeColor
|
|
137895
|
+
}));
|
|
137896
|
+
}
|
|
137897
|
+
}
|
|
137898
|
+
if (markerStart === "Arrow" && tipsOpacity > 0) {
|
|
137899
|
+
const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
|
|
137900
|
+
if (head) {
|
|
137901
|
+
layers.push(new PolygonLayer({
|
|
137902
|
+
...tipsBase,
|
|
137903
|
+
id: `annotation-start-arrow-${uid2}-${i2}`,
|
|
137904
|
+
data: [{ polygon: head }],
|
|
137905
|
+
getPolygon: (d) => d.polygon,
|
|
137906
|
+
filled: true,
|
|
137907
|
+
stroked: false,
|
|
137908
|
+
getFillColor: strokeColor
|
|
137909
|
+
}));
|
|
137910
|
+
}
|
|
137911
|
+
}
|
|
137912
|
+
if (markerEnd === "Tick" && tipsOpacity > 0) {
|
|
137913
|
+
const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
|
|
137914
|
+
if (tick) {
|
|
137915
|
+
layers.push(new PathLayer({
|
|
137916
|
+
...tipsBase,
|
|
137917
|
+
id: `annotation-end-tick-${uid2}-${i2}`,
|
|
137918
|
+
data: [{ path: tick }],
|
|
137919
|
+
getPath: (d) => d.path,
|
|
137920
|
+
getColor: strokeColor,
|
|
137921
|
+
getWidth: strokeWidth,
|
|
137922
|
+
widthUnits: "pixels",
|
|
137923
|
+
capRounded: true
|
|
137924
|
+
}));
|
|
137925
|
+
}
|
|
137926
|
+
}
|
|
137927
|
+
if (markerStart === "Tick" && tipsOpacity > 0) {
|
|
137928
|
+
const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
|
|
137929
|
+
if (tick) {
|
|
137930
|
+
layers.push(new PathLayer({
|
|
137931
|
+
...tipsBase,
|
|
137932
|
+
id: `annotation-start-tick-${uid2}-${i2}`,
|
|
137933
|
+
data: [{ path: tick }],
|
|
137934
|
+
getPath: (d) => d.path,
|
|
137935
|
+
getColor: strokeColor,
|
|
137936
|
+
getWidth: strokeWidth,
|
|
137937
|
+
widthUnits: "pixels",
|
|
137938
|
+
capRounded: true
|
|
137939
|
+
}));
|
|
137940
|
+
}
|
|
137941
|
+
}
|
|
137942
|
+
if (shape.text) {
|
|
137943
|
+
const pos = shape.textPosition ?? "start";
|
|
137944
|
+
let textX;
|
|
137945
|
+
let textY;
|
|
137946
|
+
if (pos === "start") {
|
|
137947
|
+
textX = x12;
|
|
137948
|
+
textY = y12;
|
|
137949
|
+
} else if (pos === "end") {
|
|
137950
|
+
textX = x2;
|
|
137951
|
+
textY = y2;
|
|
137952
|
+
} else {
|
|
137953
|
+
textX = (x12 + x2) / 2;
|
|
137954
|
+
textY = (y12 + y2) / 2;
|
|
137955
|
+
}
|
|
137956
|
+
let pixelOffset = [0, 0];
|
|
137957
|
+
let textAnchor = "middle";
|
|
137958
|
+
let alignmentBaseline = "center";
|
|
137959
|
+
if (pos !== "middle") {
|
|
137960
|
+
const dxT = x2 - x12;
|
|
137961
|
+
const dyT = y2 - y12;
|
|
137962
|
+
const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
|
|
137963
|
+
if (lenT > 0) {
|
|
137964
|
+
const uxT = dxT / lenT;
|
|
137965
|
+
const uyT = dyT / lenT;
|
|
137966
|
+
const sign2 = pos === "start" ? -1 : 1;
|
|
137967
|
+
const bufferPx = shape.textBufferPx ?? 8;
|
|
137968
|
+
const offsetX = sign2 * uxT * bufferPx;
|
|
137969
|
+
const offsetY = sign2 * uyT * bufferPx;
|
|
137970
|
+
pixelOffset = [offsetX, offsetY];
|
|
137971
|
+
const absX = Math.abs(offsetX);
|
|
137972
|
+
const absY = Math.abs(offsetY);
|
|
137973
|
+
if (absX >= absY) {
|
|
137974
|
+
textAnchor = offsetX > 0 ? "start" : "end";
|
|
137975
|
+
}
|
|
137976
|
+
if (absY >= absX) {
|
|
137977
|
+
alignmentBaseline = offsetY > 0 ? "top" : "bottom";
|
|
137978
|
+
}
|
|
137979
|
+
}
|
|
137980
|
+
} else if (len2 > 0) {
|
|
137981
|
+
const belowPerp = pickBelowPerp(ux, uy);
|
|
137982
|
+
const bufferPx = shape.textBufferPx ?? 14;
|
|
137983
|
+
pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
|
|
137984
|
+
textAnchor = "middle";
|
|
137985
|
+
alignmentBaseline = "center";
|
|
137986
|
+
}
|
|
137987
|
+
const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
|
|
137988
|
+
if (labelOpacity <= 0)
|
|
137989
|
+
return;
|
|
137990
|
+
layers.push(new TextLayer({
|
|
137991
|
+
...labelBase,
|
|
137992
|
+
...labelProps,
|
|
137993
|
+
id: `annotation-line-text-${uid2}-${i2}`,
|
|
137994
|
+
data: [{ position: [textX, textY], text: shape.text }],
|
|
137995
|
+
getPosition: (d) => d.position,
|
|
137996
|
+
getText: (d) => d.text,
|
|
137997
|
+
getColor: strokeColor,
|
|
137998
|
+
getSize: LABEL_FONT_SIZE,
|
|
137999
|
+
sizeUnits: "pixels",
|
|
138000
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
138001
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
138002
|
+
getPixelOffset: pixelOffset,
|
|
138003
|
+
getTextAnchor: textAnchor,
|
|
138004
|
+
getAlignmentBaseline: alignmentBaseline,
|
|
138005
|
+
...middleAngle !== null && { getAngle: middleAngle }
|
|
138006
|
+
}));
|
|
138007
|
+
}
|
|
138008
|
+
}
|
|
138009
|
+
if (type === "ellipse") {
|
|
138010
|
+
const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
138011
|
+
const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
|
|
138012
|
+
const filled = fillOpacity > 0;
|
|
138013
|
+
layers.push(new PolygonLayer({
|
|
138014
|
+
...base,
|
|
138015
|
+
id: `annotation-ellipse-${uid2}-${i2}`,
|
|
138016
|
+
data: [{ polygon: polygon2 }],
|
|
138017
|
+
getPolygon: (d) => d.polygon,
|
|
138018
|
+
filled,
|
|
138019
|
+
stroked: true,
|
|
138020
|
+
getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
|
|
138021
|
+
getLineColor: strokeColor,
|
|
138022
|
+
getLineWidth: strokeWidth,
|
|
138023
|
+
lineWidthUnits: "pixels",
|
|
138024
|
+
...dashArray ? {
|
|
138025
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
138026
|
+
getDashArray: dashArray
|
|
138027
|
+
} : {}
|
|
138028
|
+
}));
|
|
138029
|
+
if (shape.text && labelOpacity > 0) {
|
|
138030
|
+
layers.push(new TextLayer({
|
|
138031
|
+
...labelBase,
|
|
138032
|
+
...labelProps,
|
|
138033
|
+
id: `annotation-ellipse-text-${uid2}-${i2}`,
|
|
138034
|
+
data: [{ position: [x12, y12 - radiusY], text: shape.text }],
|
|
138035
|
+
getPosition: (d) => d.position,
|
|
138036
|
+
getText: (d) => d.text,
|
|
138037
|
+
getColor: strokeColor,
|
|
138038
|
+
getSize: LABEL_FONT_SIZE,
|
|
138039
|
+
sizeUnits: "pixels",
|
|
138040
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
138041
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
138042
|
+
getPixelOffset: [0, -4],
|
|
138043
|
+
getTextAnchor: "middle",
|
|
138044
|
+
getAlignmentBaseline: "bottom"
|
|
138045
|
+
}));
|
|
138046
|
+
}
|
|
138047
|
+
}
|
|
138048
|
+
if (type === "polygon") {
|
|
138049
|
+
const { points, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
138050
|
+
if (!points || points.length < 3)
|
|
138051
|
+
return;
|
|
138052
|
+
const closedPath = [...points, points[0]];
|
|
138053
|
+
if (fillOpacity > 0) {
|
|
138054
|
+
layers.push(new PolygonLayer({
|
|
138055
|
+
...base,
|
|
138056
|
+
id: `annotation-polygon-fill-${uid2}-${i2}`,
|
|
138057
|
+
data: [{ polygon: points }],
|
|
138058
|
+
getPolygon: (d) => d.polygon,
|
|
138059
|
+
stroked: false,
|
|
138060
|
+
filled: true,
|
|
138061
|
+
getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
|
|
138062
|
+
}));
|
|
138063
|
+
}
|
|
138064
|
+
layers.push(new PathLayer({
|
|
138065
|
+
...base,
|
|
138066
|
+
id: `annotation-polygon-${uid2}-${i2}`,
|
|
138067
|
+
extensions: dashExt,
|
|
138068
|
+
getDashArray: getDash,
|
|
138069
|
+
data: [{ path: closedPath }],
|
|
138070
|
+
getPath: (d) => d.path,
|
|
138071
|
+
getColor: strokeColor,
|
|
138072
|
+
getWidth: strokeWidth,
|
|
138073
|
+
widthUnits: "pixels",
|
|
138074
|
+
jointRounded: true
|
|
138075
|
+
}));
|
|
138076
|
+
if (shape.text && labelOpacity > 0) {
|
|
138077
|
+
const minX = Math.min(...points.map((p) => p[0]));
|
|
138078
|
+
const maxX = Math.max(...points.map((p) => p[0]));
|
|
138079
|
+
const minY = Math.min(...points.map((p) => p[1]));
|
|
138080
|
+
const topCenterX = (minX + maxX) / 2;
|
|
138081
|
+
layers.push(new TextLayer({
|
|
138082
|
+
...labelBase,
|
|
138083
|
+
...labelProps,
|
|
138084
|
+
id: `annotation-polygon-text-${uid2}-${i2}`,
|
|
138085
|
+
data: [{ position: [topCenterX, minY], text: shape.text }],
|
|
138086
|
+
getPosition: (d) => d.position,
|
|
138087
|
+
getText: (d) => d.text,
|
|
138088
|
+
getColor: strokeColor,
|
|
138089
|
+
getSize: LABEL_FONT_SIZE,
|
|
138090
|
+
sizeUnits: "pixels",
|
|
138091
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
138092
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
138093
|
+
getPixelOffset: [0, -4],
|
|
138094
|
+
getTextAnchor: "middle",
|
|
138095
|
+
getAlignmentBaseline: "bottom"
|
|
138096
|
+
}));
|
|
138097
|
+
}
|
|
138098
|
+
}
|
|
138099
|
+
if (type === "polyline") {
|
|
138100
|
+
const { points, markerStart, markerEnd } = shape;
|
|
138101
|
+
if (!points || points.length < 2)
|
|
138102
|
+
return;
|
|
138103
|
+
let pathPoints = points;
|
|
138104
|
+
if (markerStart === "Arrow") {
|
|
138105
|
+
const [x02, y02] = points[0];
|
|
138106
|
+
const [x12, y12] = points[1];
|
|
138107
|
+
const dx = x02 - x12;
|
|
138108
|
+
const dy = y02 - y12;
|
|
138109
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
138110
|
+
if (len2 > 0) {
|
|
138111
|
+
const ux = dx / len2;
|
|
138112
|
+
const uy = dy / len2;
|
|
138113
|
+
pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
|
|
138114
|
+
}
|
|
138115
|
+
}
|
|
138116
|
+
if (markerEnd === "Arrow") {
|
|
138117
|
+
const last = pathPoints[pathPoints.length - 1];
|
|
138118
|
+
const prev = pathPoints[pathPoints.length - 2];
|
|
138119
|
+
const dx = last[0] - prev[0];
|
|
138120
|
+
const dy = last[1] - prev[1];
|
|
138121
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
138122
|
+
if (len2 > 0) {
|
|
138123
|
+
const ux = dx / len2;
|
|
138124
|
+
const uy = dy / len2;
|
|
138125
|
+
const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
|
|
138126
|
+
pathPoints = [...pathPoints.slice(0, -1), shortened];
|
|
138127
|
+
}
|
|
138128
|
+
}
|
|
138129
|
+
layers.push(new PathLayer({
|
|
138130
|
+
...base,
|
|
138131
|
+
id: `annotation-polyline-${uid2}-${i2}`,
|
|
138132
|
+
extensions: dashExt,
|
|
138133
|
+
getDashArray: getDash,
|
|
138134
|
+
data: [{ path: pathPoints }],
|
|
138135
|
+
getPath: (d) => d.path,
|
|
138136
|
+
getColor: strokeColor,
|
|
138137
|
+
getWidth: strokeWidth,
|
|
138138
|
+
widthUnits: "pixels",
|
|
138139
|
+
jointRounded: true,
|
|
138140
|
+
capRounded: true
|
|
138141
|
+
}));
|
|
138142
|
+
if (markerStart === "Arrow" && tipsOpacity > 0) {
|
|
138143
|
+
const [x02, y02] = points[0];
|
|
138144
|
+
const [x12, y12] = points[1];
|
|
138145
|
+
const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
|
|
138146
|
+
if (head) {
|
|
138147
|
+
layers.push(new PolygonLayer({
|
|
138148
|
+
...tipsBase,
|
|
138149
|
+
id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
|
|
138150
|
+
data: [{ polygon: head }],
|
|
138151
|
+
getPolygon: (d) => d.polygon,
|
|
138152
|
+
filled: true,
|
|
138153
|
+
stroked: false,
|
|
138154
|
+
getFillColor: strokeColor
|
|
138155
|
+
}));
|
|
138156
|
+
}
|
|
138157
|
+
}
|
|
138158
|
+
if (markerEnd === "Arrow" && tipsOpacity > 0) {
|
|
138159
|
+
const last = points[points.length - 1];
|
|
138160
|
+
const prev = points[points.length - 2];
|
|
138161
|
+
const dxArrow = last[0] - prev[0];
|
|
138162
|
+
const dyArrow = last[1] - prev[1];
|
|
138163
|
+
const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
|
|
138164
|
+
if (head) {
|
|
138165
|
+
layers.push(new PolygonLayer({
|
|
138166
|
+
...tipsBase,
|
|
138167
|
+
id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
|
|
138168
|
+
data: [{ polygon: head }],
|
|
138169
|
+
getPolygon: (d) => d.polygon,
|
|
138170
|
+
filled: true,
|
|
138171
|
+
stroked: false,
|
|
138172
|
+
getFillColor: strokeColor
|
|
138173
|
+
}));
|
|
138174
|
+
}
|
|
138175
|
+
}
|
|
138176
|
+
if (markerStart === "Tick" && tipsOpacity > 0) {
|
|
138177
|
+
const [x02, y02] = points[0];
|
|
138178
|
+
const [x12, y12] = points[1];
|
|
138179
|
+
const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
|
|
138180
|
+
if (tick) {
|
|
138181
|
+
layers.push(new PathLayer({
|
|
138182
|
+
...tipsBase,
|
|
138183
|
+
id: `annotation-polyline-start-tick-${uid2}-${i2}`,
|
|
138184
|
+
data: [{ path: tick }],
|
|
138185
|
+
getPath: (d) => d.path,
|
|
138186
|
+
getColor: strokeColor,
|
|
138187
|
+
getWidth: strokeWidth,
|
|
138188
|
+
widthUnits: "pixels",
|
|
138189
|
+
capRounded: true
|
|
138190
|
+
}));
|
|
138191
|
+
}
|
|
138192
|
+
}
|
|
138193
|
+
if (markerEnd === "Tick" && tipsOpacity > 0) {
|
|
138194
|
+
const last = points[points.length - 1];
|
|
138195
|
+
const prev = points[points.length - 2];
|
|
138196
|
+
const dxTick = last[0] - prev[0];
|
|
138197
|
+
const dyTick = last[1] - prev[1];
|
|
138198
|
+
const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
|
|
138199
|
+
if (tick) {
|
|
138200
|
+
layers.push(new PathLayer({
|
|
138201
|
+
...tipsBase,
|
|
138202
|
+
id: `annotation-polyline-end-tick-${uid2}-${i2}`,
|
|
138203
|
+
data: [{ path: tick }],
|
|
138204
|
+
getPath: (d) => d.path,
|
|
138205
|
+
getColor: strokeColor,
|
|
138206
|
+
getWidth: strokeWidth,
|
|
138207
|
+
widthUnits: "pixels",
|
|
138208
|
+
capRounded: true
|
|
138209
|
+
}));
|
|
138210
|
+
}
|
|
138211
|
+
}
|
|
138212
|
+
if (shape.text) {
|
|
138213
|
+
const pos = shape.textPosition ?? "start";
|
|
138214
|
+
const bufferPx = shape.textBufferPx ?? 8;
|
|
138215
|
+
let textPt;
|
|
138216
|
+
let dirX;
|
|
138217
|
+
let dirY;
|
|
138218
|
+
if (pos === "end") {
|
|
138219
|
+
const last = points[points.length - 1];
|
|
138220
|
+
const prev = points[points.length - 2];
|
|
138221
|
+
textPt = last;
|
|
138222
|
+
dirX = last[0] - prev[0];
|
|
138223
|
+
dirY = last[1] - prev[1];
|
|
138224
|
+
} else if (pos === "middle") {
|
|
138225
|
+
const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
|
|
138226
|
+
const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
|
|
138227
|
+
textPt = [mx, my];
|
|
138228
|
+
dirX = 0;
|
|
138229
|
+
dirY = 0;
|
|
138230
|
+
} else {
|
|
138231
|
+
[textPt] = points;
|
|
138232
|
+
dirX = points[0][0] - points[1][0];
|
|
138233
|
+
dirY = points[0][1] - points[1][1];
|
|
138234
|
+
}
|
|
138235
|
+
const [textX, textY] = textPt;
|
|
138236
|
+
const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
138237
|
+
let polylinePixelOffset = [0, 0];
|
|
138238
|
+
let polylineTextAnchor = "middle";
|
|
138239
|
+
let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
|
|
138240
|
+
if (lenT > 0) {
|
|
138241
|
+
const uxT = dirX / lenT;
|
|
138242
|
+
const uyT = dirY / lenT;
|
|
138243
|
+
const offX = uxT * bufferPx;
|
|
138244
|
+
const offY = uyT * bufferPx;
|
|
138245
|
+
polylinePixelOffset = [offX, offY];
|
|
138246
|
+
if (Math.abs(offX) >= Math.abs(offY)) {
|
|
138247
|
+
polylineTextAnchor = offX > 0 ? "start" : "end";
|
|
138248
|
+
}
|
|
138249
|
+
if (Math.abs(offY) >= Math.abs(offX)) {
|
|
138250
|
+
polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
|
|
138251
|
+
}
|
|
138252
|
+
}
|
|
138253
|
+
if (labelOpacity <= 0)
|
|
138254
|
+
return;
|
|
138255
|
+
layers.push(new TextLayer({
|
|
138256
|
+
...labelBase,
|
|
138257
|
+
...labelProps,
|
|
138258
|
+
id: `annotation-polyline-text-${uid2}-${i2}`,
|
|
138259
|
+
data: [{ position: [textX, textY], text: shape.text }],
|
|
138260
|
+
getPosition: (d) => d.position,
|
|
138261
|
+
getText: (d) => d.text,
|
|
138262
|
+
getColor: strokeColor,
|
|
138263
|
+
getSize: LABEL_FONT_SIZE,
|
|
138264
|
+
sizeUnits: "pixels",
|
|
138265
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
138266
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
138267
|
+
getPixelOffset: polylinePixelOffset,
|
|
138268
|
+
getTextAnchor: polylineTextAnchor,
|
|
138269
|
+
getAlignmentBaseline: polylineAlignmentBaseline
|
|
138270
|
+
}));
|
|
138271
|
+
}
|
|
138272
|
+
}
|
|
138273
|
+
});
|
|
138274
|
+
if (dotShapes.length > 0) {
|
|
138275
|
+
layers.push(new ScatterplotLayer({
|
|
138276
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
138277
|
+
id: "annotation-dots",
|
|
138278
|
+
data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
|
|
138279
|
+
position: getShapeCentroid(s2),
|
|
138280
|
+
color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
|
|
138281
|
+
})),
|
|
138282
|
+
getPosition: (d) => d.position,
|
|
138283
|
+
getFillColor: (d) => d.color,
|
|
138284
|
+
getRadius: 4,
|
|
138285
|
+
radiusUnits: "pixels",
|
|
138286
|
+
filled: true,
|
|
138287
|
+
stroked: false
|
|
138288
|
+
}));
|
|
138289
|
+
}
|
|
138290
|
+
if (clusterDotShapes.length > 0) {
|
|
138291
|
+
const clusters = computeClusters(clusterDotShapes, zoom);
|
|
138292
|
+
layers.push(new ScatterplotLayer({
|
|
138293
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
138294
|
+
id: "annotation-clusters",
|
|
138295
|
+
data: clusters,
|
|
138296
|
+
getPosition: (d) => d.position,
|
|
138297
|
+
getFillColor: (d) => [...d.color, 180],
|
|
138298
|
+
getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
|
|
138299
|
+
radiusUnits: "pixels",
|
|
138300
|
+
filled: true,
|
|
138301
|
+
stroked: true,
|
|
138302
|
+
getLineColor: (d) => [...d.color, 220],
|
|
138303
|
+
lineWidthMinPixels: 1.5
|
|
138304
|
+
}));
|
|
138305
|
+
const multiClusters = clusters.filter((c) => c.count > 1);
|
|
138306
|
+
if (multiClusters.length > 0) {
|
|
138307
|
+
layers.push(new TextLayer({
|
|
138308
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
138309
|
+
id: "annotation-cluster-counts",
|
|
138310
|
+
data: multiClusters,
|
|
138311
|
+
getPosition: (d) => d.position,
|
|
138312
|
+
getText: (d) => String(d.count),
|
|
138313
|
+
getColor: [255, 255, 255],
|
|
138314
|
+
getSize: 10,
|
|
138315
|
+
sizeUnits: "pixels",
|
|
138316
|
+
fontWeight: "bold",
|
|
138317
|
+
getTextAnchor: "middle",
|
|
138318
|
+
getAlignmentBaseline: "center"
|
|
138319
|
+
}));
|
|
138320
|
+
}
|
|
138321
|
+
}
|
|
138322
|
+
const measureLayers = [];
|
|
138323
|
+
shapes.forEach((shape) => {
|
|
138324
|
+
if (!shape.showMeasure)
|
|
138325
|
+
return;
|
|
138326
|
+
const mIsSelected = shape.uid === selectedShapeUid;
|
|
138327
|
+
const label = getMeasurementLabel(shape, physicalPixelSize, viewType);
|
|
138328
|
+
if (!label)
|
|
138329
|
+
return;
|
|
138330
|
+
const color = shape.strokeColor ?? [255, 255, 255];
|
|
138331
|
+
let mShapeOpacity = 1;
|
|
138332
|
+
let mLabelFactor = 0;
|
|
138333
|
+
if (mIsSelected || !semanticZoom || authoredZoom === null) {
|
|
138334
|
+
mLabelFactor = 1;
|
|
138335
|
+
} else {
|
|
138336
|
+
const mZoomRatio = 2 ** (zoom - authoredZoom);
|
|
138337
|
+
if (mZoomRatio < RATIO_DOT)
|
|
138338
|
+
return;
|
|
138339
|
+
if (mZoomRatio < RATIO_GEO_FADE) {
|
|
138340
|
+
mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
|
|
138341
|
+
}
|
|
138342
|
+
if (mZoomRatio >= RATIO_LABEL_FULL) {
|
|
138343
|
+
mLabelFactor = 1;
|
|
138344
|
+
} else if (mZoomRatio >= RATIO_LABEL) {
|
|
138345
|
+
mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
|
|
138346
|
+
}
|
|
138347
|
+
}
|
|
138348
|
+
const measureOpacity = mShapeOpacity * mLabelFactor;
|
|
138349
|
+
if (measureOpacity <= 0)
|
|
138350
|
+
return;
|
|
138351
|
+
const base = {
|
|
138352
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
138353
|
+
opacity: measureOpacity,
|
|
138354
|
+
getText: (d) => d.text,
|
|
138355
|
+
getPosition: (d) => d.position,
|
|
138356
|
+
getColor: color,
|
|
138357
|
+
getSize: 13,
|
|
138358
|
+
sizeUnits: "pixels",
|
|
138359
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
138360
|
+
fontWeight: "bold",
|
|
138361
|
+
// 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
|
|
138362
|
+
// instead of deck.gl's default ASCII-only atlas.
|
|
138363
|
+
characterSet: "auto",
|
|
138364
|
+
...shape.measureBackground ? {
|
|
138365
|
+
background: true,
|
|
138366
|
+
getBackgroundColor: textBgColor(color),
|
|
138367
|
+
backgroundPadding: [3, 1, 3, 2]
|
|
138368
|
+
} : {}
|
|
138369
|
+
};
|
|
138370
|
+
if (shape.type === "line") {
|
|
138371
|
+
const mx = ((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2;
|
|
138372
|
+
const my = ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2;
|
|
138373
|
+
const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
|
|
138374
|
+
const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
|
|
138375
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
138376
|
+
if (len2 === 0)
|
|
138377
|
+
return;
|
|
138378
|
+
const perp = pickBelowPerp(dx / len2, dy / len2);
|
|
138379
|
+
const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
138380
|
+
measureLayers.push(new TextLayer({
|
|
138381
|
+
...base,
|
|
138382
|
+
id: `annotation-measure-${shape.uid}`,
|
|
138383
|
+
data: [{ position: [mx, my], text: label }],
|
|
138384
|
+
getAngle: -angle2,
|
|
138385
|
+
getTextAnchor: "middle",
|
|
138386
|
+
getAlignmentBaseline: "center",
|
|
138387
|
+
getPixelOffset: [perp[0] * 16, perp[1] * 16]
|
|
138388
|
+
}));
|
|
138389
|
+
} else if (shape.type === "polyline" && shape.points?.length >= 2) {
|
|
138390
|
+
const pts = shape.points;
|
|
138391
|
+
const mi = Math.floor((pts.length - 1) / 2);
|
|
138392
|
+
const [ax, ay] = pts[mi];
|
|
138393
|
+
const [bx, by] = pts[mi + 1];
|
|
138394
|
+
const dx = bx - ax;
|
|
138395
|
+
const dy = by - ay;
|
|
138396
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
138397
|
+
if (len2 === 0)
|
|
138398
|
+
return;
|
|
138399
|
+
const perp = pickBelowPerp(dx / len2, dy / len2);
|
|
138400
|
+
const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
138401
|
+
measureLayers.push(new TextLayer({
|
|
138402
|
+
...base,
|
|
138403
|
+
id: `annotation-measure-${shape.uid}`,
|
|
138404
|
+
data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
|
|
138405
|
+
getAngle: -angle2,
|
|
138406
|
+
getTextAnchor: "middle",
|
|
138407
|
+
getAlignmentBaseline: "center",
|
|
138408
|
+
getPixelOffset: [perp[0] * 16, perp[1] * 16]
|
|
138409
|
+
}));
|
|
138410
|
+
} else if (shape.type === "rectangle") {
|
|
138411
|
+
const x02 = shape.x ?? 0;
|
|
138412
|
+
const y02 = shape.y ?? 0;
|
|
138413
|
+
const w2 = shape.width ?? 0;
|
|
138414
|
+
const h = shape.height ?? 0;
|
|
138415
|
+
const rx = x02 + (w2 >= 0 ? w2 : 0);
|
|
138416
|
+
const ry = y02 + (h >= 0 ? h : 0);
|
|
138417
|
+
measureLayers.push(new TextLayer({
|
|
138418
|
+
...base,
|
|
138419
|
+
id: `annotation-measure-${shape.uid}`,
|
|
138420
|
+
data: [{ position: [rx, ry], text: label }],
|
|
138421
|
+
getTextAnchor: "end",
|
|
138422
|
+
getAlignmentBaseline: "bottom",
|
|
138423
|
+
getPixelOffset: [-6, -6]
|
|
138424
|
+
}));
|
|
138425
|
+
} else if (shape.type === "ellipse") {
|
|
138426
|
+
const cx = shape.x1 ?? 0;
|
|
138427
|
+
const cy = shape.y1 ?? 0;
|
|
138428
|
+
const ry = Math.abs(shape.radiusY ?? 0);
|
|
138429
|
+
measureLayers.push(new TextLayer({
|
|
138430
|
+
...base,
|
|
138431
|
+
id: `annotation-measure-${shape.uid}`,
|
|
138432
|
+
data: [{ position: [cx, cy + ry], text: label }],
|
|
138433
|
+
getTextAnchor: "middle",
|
|
138434
|
+
getAlignmentBaseline: "top",
|
|
138435
|
+
getPixelOffset: [0, 8]
|
|
138436
|
+
}));
|
|
138437
|
+
} else if (shape.type === "polygon" && shape.points?.length >= 3) {
|
|
138438
|
+
const xs = shape.points.map((p) => p[0]);
|
|
138439
|
+
const ys = shape.points.map((p) => p[1]);
|
|
138440
|
+
const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
|
|
138441
|
+
const maxY = Math.max(...ys);
|
|
138442
|
+
measureLayers.push(new TextLayer({
|
|
138443
|
+
...base,
|
|
138444
|
+
id: `annotation-measure-${shape.uid}`,
|
|
138445
|
+
data: [{ position: [cx, maxY], text: label }],
|
|
138446
|
+
getTextAnchor: "middle",
|
|
138447
|
+
getAlignmentBaseline: "top",
|
|
138448
|
+
getPixelOffset: [0, 8]
|
|
138449
|
+
}));
|
|
138450
|
+
}
|
|
138451
|
+
});
|
|
138452
|
+
return [...selectionLayers, ...layers, ...measureLayers];
|
|
138453
|
+
}
|
|
138454
|
+
const defaultProps = {
|
|
138455
|
+
// Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
|
|
138456
|
+
data: { type: "object", value: [], compare: true },
|
|
138457
|
+
// UID of the shape to highlight with a selection halo.
|
|
138458
|
+
selectedShapeUid: { type: "string", value: null },
|
|
138459
|
+
// { x, y, unit } used to format measurement labels in physical units.
|
|
138460
|
+
physicalPixelSize: { type: "object", value: null, compare: true },
|
|
138461
|
+
// The zoom level at which the shapes were authored (reference for semantic zoom).
|
|
138462
|
+
authoredZoom: { type: "number", value: null },
|
|
138463
|
+
// Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
|
|
138464
|
+
semanticZoom: { type: "boolean", value: true },
|
|
138465
|
+
// The view type in which the layer is rendered (affects measurement label formatting).
|
|
138466
|
+
viewType: { type: "string", value: ViewType.SPATIAL },
|
|
138467
|
+
// In-progress shape being drawn, as { type, vertices }.
|
|
138468
|
+
inProgressShape: { type: "object", value: null, compare: true },
|
|
138469
|
+
// Current mouse position (in data coordinates) while drawing.
|
|
138470
|
+
hoverCoord: { type: "array", value: null, compare: true },
|
|
138471
|
+
// Stroke color [r, g, b] of the in-progress shape preview.
|
|
138472
|
+
previewStrokeColor: { type: "color", value: [255, 255, 0] }
|
|
138473
|
+
};
|
|
138474
|
+
class AnnotationLayer extends CompositeLayer {
|
|
138475
|
+
// The semantic zoom and arrowhead sizes depend on the current zoom level,
|
|
138476
|
+
// so the sublayers must also be re-rendered when the viewport changes.
|
|
138477
|
+
// eslint-disable-next-line class-methods-use-this
|
|
138478
|
+
shouldUpdateState({ changeFlags }) {
|
|
138479
|
+
return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
|
|
138480
|
+
}
|
|
138481
|
+
/**
|
|
138482
|
+
* Prefix the sublayer ID with this layer's ID (so that multiple
|
|
138483
|
+
* AnnotationLayers can co-exist), and combine this layer's
|
|
138484
|
+
* opacity with the per-shape opacity of the sublayer.
|
|
138485
|
+
* Note: we avoid getSubLayerProps here, since it would
|
|
138486
|
+
* overwrite the sublayer extensions (e.g., PathStyleExtension)
|
|
138487
|
+
* and opacity values.
|
|
138488
|
+
* @param {object} layer A DeckGL layer instance.
|
|
138489
|
+
* @returns {object} The cloned layer instance.
|
|
138490
|
+
*/
|
|
138491
|
+
wrapSubLayer(layer) {
|
|
138492
|
+
const { id, opacity, pickable, visible } = this.props;
|
|
138493
|
+
return layer.clone({
|
|
138494
|
+
id: `${id}-${layer.id}`,
|
|
138495
|
+
opacity: layer.props.opacity * opacity,
|
|
138496
|
+
pickable,
|
|
138497
|
+
visible
|
|
138498
|
+
});
|
|
138499
|
+
}
|
|
138500
|
+
renderLayers() {
|
|
138501
|
+
const { data, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType, inProgressShape, hoverCoord, previewStrokeColor } = this.props;
|
|
138502
|
+
const zoom = this.context.viewport?.zoom ?? 0;
|
|
138503
|
+
const visibleShapes = (data ?? []).filter((shape) => shape.visible !== false);
|
|
138504
|
+
const annotationLayers = createAnnotationLayers(visibleShapes, zoom, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType);
|
|
138505
|
+
const previewLayer = createPreviewLayer(inProgressShape, hoverCoord, previewStrokeColor.slice(0, 3));
|
|
138506
|
+
return [
|
|
138507
|
+
...annotationLayers,
|
|
138508
|
+
...previewLayer ? [previewLayer] : []
|
|
138509
|
+
].map((layer) => this.wrapSubLayer(layer));
|
|
138510
|
+
}
|
|
138511
|
+
}
|
|
138512
|
+
AnnotationLayer.layerName = "AnnotationLayer";
|
|
138513
|
+
AnnotationLayer.defaultProps = defaultProps;
|
|
137315
138514
|
class InternMap extends Map {
|
|
137316
138515
|
constructor(entries, key = keyof) {
|
|
137317
138516
|
super();
|