@vitessce/json 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-cHMwz5aU.js → deflate-B9yQXNA5.js} +1 -1
- package/dist/{index-l5IGfUA8.js → index-B31MphL5.js} +1482 -98
- package/dist/index.js +2 -1
- package/dist/{jpeg-BhdOlr-5.js → jpeg-DYOBxHhT.js} +1 -1
- package/dist/{lerc-6BfwN8Ff.js → lerc-CXBCb2wB.js} +1 -1
- package/dist/{lzw-RW2_bdBg.js → lzw-Cn4MHMg0.js} +1 -1
- package/dist/{packbits-Bma8MZki.js → packbits-3K31MqMe.js} +1 -1
- package/dist/{raw-CskuC7zl.js → raw-DrKGleEE.js} +1 -1
- package/dist/{webimage-CXVtM-OF.js → webimage-MBv_oDxF.js} +1 -1
- package/dist-tsc/json-loaders/AnnotationStoryJson.d.ts +11 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.d.ts.map +1 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.js +27 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.js.map +1 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.test.d.ts +2 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.test.d.ts.map +1 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.test.js +37 -0
- package/dist-tsc/json-loaders/AnnotationStoryJson.test.js.map +1 -0
- package/dist-tsc/json-loaders/index.d.ts +1 -0
- package/dist-tsc/json-loaders/index.js +1 -0
- package/dist-tsc/json-loaders/index.js.map +1 -1
- package/package.json +12 -12
- package/src/json-loaders/AnnotationStoryJson.js +28 -0
- package/src/json-loaders/AnnotationStoryJson.test.js +41 -0
- package/src/json-loaders/index.js +1 -0
|
@@ -95,7 +95,8 @@ const ViewType$1 = {
|
|
|
95
95
|
TREEMAP: "treemap",
|
|
96
96
|
SAMPLE_SET_PAIR_MANAGER: "sampleSetPairManager",
|
|
97
97
|
FEATURE_STATS_TABLE: "featureStatsTable",
|
|
98
|
-
SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector"
|
|
98
|
+
SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector",
|
|
99
|
+
ANNOTATION_CONTROLLER: "annotationController"
|
|
99
100
|
};
|
|
100
101
|
const DataType$2 = {
|
|
101
102
|
OBS_LABELS: "obsLabels",
|
|
@@ -116,7 +117,8 @@ const DataType$2 = {
|
|
|
116
117
|
COMPARISON_METADATA: "comparisonMetadata",
|
|
117
118
|
FEATURE_STATS: "featureStats",
|
|
118
119
|
FEATURE_SET_STATS: "featureSetStats",
|
|
119
|
-
OBS_SET_STATS: "obsSetStats"
|
|
120
|
+
OBS_SET_STATS: "obsSetStats",
|
|
121
|
+
ANNOTATION_STORY: "annotationStory"
|
|
120
122
|
};
|
|
121
123
|
const FileType$1 = {
|
|
122
124
|
// Joint file types
|
|
@@ -138,6 +140,7 @@ const FileType$1 = {
|
|
|
138
140
|
OBS_SETS_CSV: "obsSets.csv",
|
|
139
141
|
OBS_SETS_JSON: "obsSets.json",
|
|
140
142
|
SAMPLE_SETS_CSV: "sampleSets.csv",
|
|
143
|
+
ANNOTATION_STORY_JSON: "annotationStory.json",
|
|
141
144
|
// OME-Zarr
|
|
142
145
|
IMAGE_OME_ZARR: "image.ome-zarr",
|
|
143
146
|
OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
|
|
@@ -422,7 +425,15 @@ const CoordinationType$1 = {
|
|
|
422
425
|
FEATURE_POINT_FOLD_CHANGE_THRESHOLD: "featurePointFoldChangeThreshold",
|
|
423
426
|
FEATURE_LABEL_FOLD_CHANGE_THRESHOLD: "featureLabelFoldChangeThreshold",
|
|
424
427
|
// Treemap
|
|
425
|
-
HIERARCHY_LEVELS: "hierarchyLevels"
|
|
428
|
+
HIERARCHY_LEVELS: "hierarchyLevels",
|
|
429
|
+
// Annotation frames
|
|
430
|
+
ANNOTATION_STORY: "annotationStory",
|
|
431
|
+
ANNOTATION_FRAME_INDEX: "annotationFrameIndex",
|
|
432
|
+
ANNOTATION_SHAPES: "annotationShapes",
|
|
433
|
+
ANNOTATION_OVERLAY_VISIBLE: "annotationOverlayVisible",
|
|
434
|
+
ANNOTATION_TRANSITION_DURATION: "annotationTransitionDuration",
|
|
435
|
+
ANNOTATION_SEMANTIC_ZOOM: "annotationSemanticZoom",
|
|
436
|
+
ANNOTATION_EDITABLE: "annotationEditable"
|
|
426
437
|
};
|
|
427
438
|
({
|
|
428
439
|
// For new file types
|
|
@@ -438,6 +449,7 @@ const CoordinationType$1 = {
|
|
|
438
449
|
[FileType$1.OBS_SEGMENTATIONS_JSON]: DataType$2.OBS_SEGMENTATIONS,
|
|
439
450
|
[FileType$1.OBS_SETS_CSV]: DataType$2.OBS_SETS,
|
|
440
451
|
[FileType$1.OBS_SETS_JSON]: DataType$2.OBS_SETS,
|
|
452
|
+
[FileType$1.ANNOTATION_STORY_JSON]: DataType$2.ANNOTATION_STORY,
|
|
441
453
|
[FileType$1.IMAGE_OME_ZARR]: DataType$2.IMAGE,
|
|
442
454
|
[FileType$1.OBS_SEGMENTATIONS_OME_ZARR]: DataType$2.OBS_SEGMENTATIONS,
|
|
443
455
|
[FileType$1.OBS_FEATURE_MATRIX_ANNDATA_ZARR]: DataType$2.OBS_FEATURE_MATRIX,
|
|
@@ -560,7 +572,8 @@ const CoordinationType$1 = {
|
|
|
560
572
|
[DataType$2.OBS_SET_STATS]: [
|
|
561
573
|
CoordinationType$1.OBS_TYPE
|
|
562
574
|
// TODO: should sampleType, obsSetSelection, and/or sampleSetSelection be used here?
|
|
563
|
-
]
|
|
575
|
+
],
|
|
576
|
+
[DataType$2.ANNOTATION_STORY]: []
|
|
564
577
|
});
|
|
565
578
|
({
|
|
566
579
|
// For AnnData:
|
|
@@ -693,7 +706,9 @@ const CoordinationType$1 = {
|
|
|
693
706
|
CoordinationType$1.SPATIAL_TARGET_Z,
|
|
694
707
|
CoordinationType$1.SPATIAL_AXIS_FIXED,
|
|
695
708
|
CoordinationType$1.SPATIAL_ORBIT_AXIS,
|
|
696
|
-
CoordinationType$1.FEATURE_AGGREGATION_STRATEGY
|
|
709
|
+
CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
|
|
710
|
+
// Annotation shapes are specific to a view's coordinate system.
|
|
711
|
+
CoordinationType$1.ANNOTATION_SHAPES
|
|
697
712
|
];
|
|
698
713
|
({
|
|
699
714
|
[ViewType$1.NEUROGLANCER]: [
|
|
@@ -785,7 +800,14 @@ const CoordinationType$1 = {
|
|
|
785
800
|
CoordinationType$1.EMBEDDING_CONTOURS_FILLED,
|
|
786
801
|
CoordinationType$1.EMBEDDING_CONTOUR_PERCENTILES,
|
|
787
802
|
CoordinationType$1.CONTOUR_COLOR_ENCODING,
|
|
788
|
-
CoordinationType$1.CONTOUR_COLOR
|
|
803
|
+
CoordinationType$1.CONTOUR_COLOR,
|
|
804
|
+
CoordinationType$1.ANNOTATION_STORY,
|
|
805
|
+
CoordinationType$1.ANNOTATION_SHAPES,
|
|
806
|
+
CoordinationType$1.ANNOTATION_FRAME_INDEX,
|
|
807
|
+
CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
|
|
808
|
+
CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
|
|
809
|
+
CoordinationType$1.ANNOTATION_EDITABLE,
|
|
810
|
+
CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
|
|
789
811
|
],
|
|
790
812
|
[ViewType$1.DUAL_SCATTERPLOT]: [
|
|
791
813
|
CoordinationType$1.DATASET,
|
|
@@ -901,7 +923,14 @@ const CoordinationType$1 = {
|
|
|
901
923
|
CoordinationType$1.ADDITIONAL_OBS_SETS,
|
|
902
924
|
CoordinationType$1.MOLECULE_HIGHLIGHT,
|
|
903
925
|
CoordinationType$1.TOOLTIPS_VISIBLE,
|
|
904
|
-
CoordinationType$1.PHOTOMETRIC_INTERPRETATION
|
|
926
|
+
CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
|
|
927
|
+
CoordinationType$1.ANNOTATION_STORY,
|
|
928
|
+
CoordinationType$1.ANNOTATION_SHAPES,
|
|
929
|
+
CoordinationType$1.ANNOTATION_FRAME_INDEX,
|
|
930
|
+
CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
|
|
931
|
+
CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
|
|
932
|
+
CoordinationType$1.ANNOTATION_EDITABLE,
|
|
933
|
+
CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
|
|
905
934
|
],
|
|
906
935
|
[ViewType$1.SPATIAL_BETA]: [
|
|
907
936
|
CoordinationType$1.META_COORDINATION_SCOPES,
|
|
@@ -979,7 +1008,27 @@ const CoordinationType$1 = {
|
|
|
979
1008
|
CoordinationType$1.SPATIAL_CHANNEL_LABELS_ORIENTATION,
|
|
980
1009
|
CoordinationType$1.SPATIAL_CHANNEL_LABEL_SIZE,
|
|
981
1010
|
CoordinationType$1.SPATIAL_CHANNELS_SORT_ORDER,
|
|
982
|
-
CoordinationType$1.PHOTOMETRIC_INTERPRETATION
|
|
1011
|
+
CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
|
|
1012
|
+
CoordinationType$1.ANNOTATION_STORY,
|
|
1013
|
+
CoordinationType$1.ANNOTATION_SHAPES,
|
|
1014
|
+
CoordinationType$1.ANNOTATION_FRAME_INDEX,
|
|
1015
|
+
CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
|
|
1016
|
+
CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
|
|
1017
|
+
CoordinationType$1.ANNOTATION_EDITABLE,
|
|
1018
|
+
CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
|
|
1019
|
+
],
|
|
1020
|
+
[ViewType$1.ANNOTATION_CONTROLLER]: [
|
|
1021
|
+
CoordinationType$1.DATASET,
|
|
1022
|
+
CoordinationType$1.ANNOTATION_STORY,
|
|
1023
|
+
CoordinationType$1.ANNOTATION_FRAME_INDEX,
|
|
1024
|
+
CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
|
|
1025
|
+
CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
|
|
1026
|
+
CoordinationType$1.ANNOTATION_EDITABLE,
|
|
1027
|
+
CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
|
|
1028
|
+
// Note: the annotation controller also needs to read the coordination state
|
|
1029
|
+
// of all other views/coordination types via the full config.
|
|
1030
|
+
// Note: we get/set the CoordinationType.ANNOTATION_SHAPES from the full config,
|
|
1031
|
+
// as this info is view-specific rather than global to the story.
|
|
983
1032
|
],
|
|
984
1033
|
[ViewType$1.HEATMAP]: [
|
|
985
1034
|
CoordinationType$1.DATASET,
|
|
@@ -6128,7 +6177,7 @@ const latestFileDefSchema = z.object({
|
|
|
6128
6177
|
options: fileOptionsSchema.optional(),
|
|
6129
6178
|
requestInit: requestInit.optional(),
|
|
6130
6179
|
// New: file def can have coordinationValues.
|
|
6131
|
-
coordinationValues: z.record(z.
|
|
6180
|
+
coordinationValues: z.record(z.any()).optional()
|
|
6132
6181
|
});
|
|
6133
6182
|
const datasetsSchema1_0_13 = z.array(z.object({
|
|
6134
6183
|
uid: z.string(),
|
|
@@ -6159,7 +6208,8 @@ const configSchema1_0_16 = configSchema1_0_13.extend({
|
|
|
6159
6208
|
h: z.number().int().optional(),
|
|
6160
6209
|
// Updates coordinationScopes and coordinationScopesBy
|
|
6161
6210
|
coordinationScopes: componentCoordinationScopes.optional(),
|
|
6162
|
-
coordinationScopesBy: componentCoordinationScopesBy.optional()
|
|
6211
|
+
coordinationScopesBy: componentCoordinationScopesBy.optional(),
|
|
6212
|
+
coordinationValues: z.record(z.any()).optional()
|
|
6163
6213
|
}))
|
|
6164
6214
|
});
|
|
6165
6215
|
const configSchema1_0_17 = configSchema1_0_16.extend({
|
|
@@ -10292,6 +10342,124 @@ z.object({
|
|
|
10292
10342
|
radius: z.number(),
|
|
10293
10343
|
opacity: z.number()
|
|
10294
10344
|
});
|
|
10345
|
+
const shapeBaseObj = z.object({
|
|
10346
|
+
uid: z.string(),
|
|
10347
|
+
text: z.string().optional(),
|
|
10348
|
+
strokeColor: z.array(z.number()).length(3).optional(),
|
|
10349
|
+
strokeWidth: z.number().optional(),
|
|
10350
|
+
// SVG-style dash pattern, e.g. "10 5" or "10 20 30 10". "none" or omitted = solid.
|
|
10351
|
+
strokeDashArray: z.string().optional(),
|
|
10352
|
+
visible: z.boolean().optional()
|
|
10353
|
+
// TODO: define unit modes for x and y axes
|
|
10354
|
+
// ("pixels" vs "normalized" vs "physical" etc.)
|
|
10355
|
+
// TODO: a coordinate system identifier (e.g., "DeckGL" for now,
|
|
10356
|
+
// but a coordinate system from OME-NGFF/SpatialData eventually?)
|
|
10357
|
+
});
|
|
10358
|
+
const rectangleShapeObj = shapeBaseObj.extend({
|
|
10359
|
+
type: z.literal("rectangle"),
|
|
10360
|
+
// OME-XML field names verbatim (upper-left origin)
|
|
10361
|
+
x: z.number(),
|
|
10362
|
+
y: z.number(),
|
|
10363
|
+
width: z.number(),
|
|
10364
|
+
height: z.number(),
|
|
10365
|
+
fillColor: z.array(z.number()).length(3).optional(),
|
|
10366
|
+
fillOpacity: z.number().optional()
|
|
10367
|
+
});
|
|
10368
|
+
const lineShapeObj = shapeBaseObj.extend({
|
|
10369
|
+
type: z.literal("line"),
|
|
10370
|
+
// OME-XML field names verbatim
|
|
10371
|
+
x1: z.number(),
|
|
10372
|
+
y1: z.number(),
|
|
10373
|
+
x2: z.number(),
|
|
10374
|
+
y2: z.number(),
|
|
10375
|
+
markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
|
|
10376
|
+
markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional(),
|
|
10377
|
+
textPosition: z.enum(["start", "middle", "end"]).optional(),
|
|
10378
|
+
textBufferPx: z.number().optional()
|
|
10379
|
+
});
|
|
10380
|
+
const ellipseShapeObj = shapeBaseObj.extend({
|
|
10381
|
+
type: z.literal("ellipse"),
|
|
10382
|
+
// OME-XML field names verbatim (centre point + radii)
|
|
10383
|
+
x1: z.number(),
|
|
10384
|
+
y1: z.number(),
|
|
10385
|
+
radiusX: z.number(),
|
|
10386
|
+
radiusY: z.number(),
|
|
10387
|
+
fillColor: z.array(z.number()).length(3).optional(),
|
|
10388
|
+
fillOpacity: z.number().optional()
|
|
10389
|
+
});
|
|
10390
|
+
const polygonShapeObj = shapeBaseObj.extend({
|
|
10391
|
+
type: z.literal("polygon"),
|
|
10392
|
+
// OME-XML: array of [x, y] coordinate pairs, closed automatically
|
|
10393
|
+
points: z.array(z.tuple([z.number(), z.number()])),
|
|
10394
|
+
fillColor: z.array(z.number()).length(3).optional(),
|
|
10395
|
+
fillOpacity: z.number().optional()
|
|
10396
|
+
});
|
|
10397
|
+
const polylineShapeObj = shapeBaseObj.extend({
|
|
10398
|
+
type: z.literal("polyline"),
|
|
10399
|
+
// OME-XML: array of [x, y] coordinate pairs, open (not closed)
|
|
10400
|
+
points: z.array(z.tuple([z.number(), z.number()])),
|
|
10401
|
+
markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
|
|
10402
|
+
markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional()
|
|
10403
|
+
});
|
|
10404
|
+
const annotationShapeObj = z.discriminatedUnion("type", [
|
|
10405
|
+
rectangleShapeObj,
|
|
10406
|
+
lineShapeObj,
|
|
10407
|
+
ellipseShapeObj,
|
|
10408
|
+
polygonShapeObj,
|
|
10409
|
+
polylineShapeObj
|
|
10410
|
+
]);
|
|
10411
|
+
z.array(annotationShapeObj);
|
|
10412
|
+
const annotationFrameObj = z.object({
|
|
10413
|
+
uid: z.string(),
|
|
10414
|
+
title: z.string().optional(),
|
|
10415
|
+
description: z.string().optional(),
|
|
10416
|
+
descriptionType: z.enum(["text", "markdown"]).optional(),
|
|
10417
|
+
// A frame can define per-view: coordinationValues
|
|
10418
|
+
// (if the view's state should not be coordinated with other views)
|
|
10419
|
+
// or per-view coordinationScopes/coordinationScopesBy
|
|
10420
|
+
// (if at this frame, the view should be coordinated with other views).
|
|
10421
|
+
// We can also define a frame-level coordination space,
|
|
10422
|
+
// which will be merged with the global coordination space.
|
|
10423
|
+
// TODO: datasets
|
|
10424
|
+
// TODO: coordinationSpace
|
|
10425
|
+
layout: z.array(
|
|
10426
|
+
// Note: for now, we will infer view objects which have a uid
|
|
10427
|
+
// that is present in the global layout, and do NOT have x/y/w/h defined,
|
|
10428
|
+
// to mean that in this frame, the layout and set of views is unchanged
|
|
10429
|
+
// from the global layout.
|
|
10430
|
+
// This will allow each frame to omit the full list of views from the layout,
|
|
10431
|
+
// and only specify the views whose coordination state is changing in this frame.
|
|
10432
|
+
// If a frame includes a view with a uid that is not present
|
|
10433
|
+
// in the global layout, then that view will be added to the layout at this frame.
|
|
10434
|
+
// This frame should also define x/y/w/h for all views,
|
|
10435
|
+
// since it will otherwise be ambiguous how to layout the updated set of views
|
|
10436
|
+
// for this frame.
|
|
10437
|
+
z.object({
|
|
10438
|
+
// The view UID. If this view uid is not present in the global layout,
|
|
10439
|
+
// it will be added to the layout at this frame,
|
|
10440
|
+
// and will need to have its coordination values initialized to their defaults
|
|
10441
|
+
// for any that were not fully specified.
|
|
10442
|
+
uid: z.string(),
|
|
10443
|
+
coordinationValues: z.record(
|
|
10444
|
+
z.string(),
|
|
10445
|
+
// The coordination type name, e.g. "embeddingType"
|
|
10446
|
+
z.any()
|
|
10447
|
+
).optional()
|
|
10448
|
+
// TODO: support coordinationScopes/coordinationScopesBy for per-view coordination
|
|
10449
|
+
// at this frame.
|
|
10450
|
+
// TODO: view x/y/w/h once we support view layout changes per-frame.
|
|
10451
|
+
})
|
|
10452
|
+
).optional()
|
|
10453
|
+
});
|
|
10454
|
+
const annotationStoryObj = z.object({
|
|
10455
|
+
// TODO: schema version for the story schema?
|
|
10456
|
+
// Same as current Vitessce schema version?
|
|
10457
|
+
uid: z.string(),
|
|
10458
|
+
title: z.string().optional(),
|
|
10459
|
+
description: z.string().optional(),
|
|
10460
|
+
descriptionType: z.enum(["text", "markdown"]).optional(),
|
|
10461
|
+
frames: z.array(annotationFrameObj)
|
|
10462
|
+
});
|
|
10295
10463
|
const coordSchema = z.array(z.number()).length(2);
|
|
10296
10464
|
const cellsSchema = z.record(
|
|
10297
10465
|
z.object({
|
|
@@ -14076,11 +14244,11 @@ function requireConcaveman() {
|
|
|
14076
14244
|
while (node2) {
|
|
14077
14245
|
for (var i2 = 0; i2 < node2.children.length; i2++) {
|
|
14078
14246
|
var child = node2.children[i2];
|
|
14079
|
-
var
|
|
14080
|
-
if (
|
|
14247
|
+
var dist2 = node2.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
|
|
14248
|
+
if (dist2 > maxDist) continue;
|
|
14081
14249
|
queue.push({
|
|
14082
14250
|
node: child,
|
|
14083
|
-
dist
|
|
14251
|
+
dist: dist2
|
|
14084
14252
|
});
|
|
14085
14253
|
}
|
|
14086
14254
|
while (queue.length && !queue.peek().node.children) {
|
|
@@ -15559,6 +15727,24 @@ class ObsSetsJsonLoader extends JsonLoader {
|
|
|
15559
15727
|
}, url, coordinationValues));
|
|
15560
15728
|
}
|
|
15561
15729
|
}
|
|
15730
|
+
class AnnotationStoryJsonLoader extends JsonLoader {
|
|
15731
|
+
constructor(dataSource, params) {
|
|
15732
|
+
super(dataSource, params);
|
|
15733
|
+
this.schema = annotationStoryObj;
|
|
15734
|
+
}
|
|
15735
|
+
async load() {
|
|
15736
|
+
if (this.cachedResult) {
|
|
15737
|
+
return this.cachedResult;
|
|
15738
|
+
}
|
|
15739
|
+
const payload = await super.load();
|
|
15740
|
+
const { data: annotationStory, url } = payload;
|
|
15741
|
+
const coordinationValues = {
|
|
15742
|
+
annotationStory
|
|
15743
|
+
};
|
|
15744
|
+
this.cachedResult = new LoaderResult({ annotationStory }, url, coordinationValues);
|
|
15745
|
+
return this.cachedResult;
|
|
15746
|
+
}
|
|
15747
|
+
}
|
|
15562
15748
|
class CellsJsonAsObsEmbeddingLoader extends JsonLoader {
|
|
15563
15749
|
constructor(dataSource, params) {
|
|
15564
15750
|
super(dataSource, params);
|
|
@@ -16221,8 +16407,8 @@ class Vector extends MathArray {
|
|
|
16221
16407
|
distanceSquared(mathArray) {
|
|
16222
16408
|
let length2 = 0;
|
|
16223
16409
|
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
|
|
16224
|
-
const
|
|
16225
|
-
length2 +=
|
|
16410
|
+
const dist2 = this[i2] - mathArray[i2];
|
|
16411
|
+
length2 += dist2 * dist2;
|
|
16226
16412
|
}
|
|
16227
16413
|
return checkNumber(length2);
|
|
16228
16414
|
}
|
|
@@ -16543,6 +16729,12 @@ function multiply$4(out, a2, b) {
|
|
|
16543
16729
|
out[2] = a2[2] * b[2];
|
|
16544
16730
|
return out;
|
|
16545
16731
|
}
|
|
16732
|
+
function distance$3(a2, b) {
|
|
16733
|
+
var x = b[0] - a2[0];
|
|
16734
|
+
var y = b[1] - a2[1];
|
|
16735
|
+
var z2 = b[2] - a2[2];
|
|
16736
|
+
return Math.hypot(x, y, z2);
|
|
16737
|
+
}
|
|
16546
16738
|
function squaredLength$2(a2) {
|
|
16547
16739
|
var x = a2[0];
|
|
16548
16740
|
var y = a2[1];
|
|
@@ -16666,6 +16858,7 @@ function angle$2(a2, b) {
|
|
|
16666
16858
|
}
|
|
16667
16859
|
var sub$1 = subtract$1;
|
|
16668
16860
|
var mul$1 = multiply$4;
|
|
16861
|
+
var dist = distance$3;
|
|
16669
16862
|
var len = length$4;
|
|
16670
16863
|
var sqrLen = squaredLength$2;
|
|
16671
16864
|
(function() {
|
|
@@ -56648,7 +56841,7 @@ function noop$2() {
|
|
|
56648
56841
|
const getCursor = ({
|
|
56649
56842
|
isDragging
|
|
56650
56843
|
}) => isDragging ? "grabbing" : "grab";
|
|
56651
|
-
const defaultProps$
|
|
56844
|
+
const defaultProps$P = {
|
|
56652
56845
|
id: "",
|
|
56653
56846
|
width: "100%",
|
|
56654
56847
|
height: "100%",
|
|
@@ -56779,7 +56972,7 @@ class Deck {
|
|
|
56779
56972
|
this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
|
|
56780
56973
|
});
|
|
56781
56974
|
this.props = {
|
|
56782
|
-
...defaultProps$
|
|
56975
|
+
...defaultProps$P,
|
|
56783
56976
|
...props
|
|
56784
56977
|
};
|
|
56785
56978
|
props = this.props;
|
|
@@ -57281,7 +57474,7 @@ class Deck {
|
|
|
57281
57474
|
metrics.gpuMemory = memoryStats.get("GPU Memory").count;
|
|
57282
57475
|
}
|
|
57283
57476
|
}
|
|
57284
|
-
_defineProperty(Deck, "defaultProps", defaultProps$
|
|
57477
|
+
_defineProperty(Deck, "defaultProps", defaultProps$P);
|
|
57285
57478
|
_defineProperty(Deck, "VERSION", deckGlobal.VERSION);
|
|
57286
57479
|
class ShaderAttribute {
|
|
57287
57480
|
constructor(dataColumn, opts) {
|
|
@@ -60036,7 +60229,7 @@ const areViewportsEqual = memoize$1(({
|
|
|
60036
60229
|
return oldViewport.equals(viewport);
|
|
60037
60230
|
});
|
|
60038
60231
|
let pickingColorCache = new Uint8ClampedArray(0);
|
|
60039
|
-
const defaultProps$
|
|
60232
|
+
const defaultProps$O = {
|
|
60040
60233
|
data: {
|
|
60041
60234
|
type: "data",
|
|
60042
60235
|
value: EMPTY_ARRAY$1,
|
|
@@ -60911,7 +61104,7 @@ class Layer extends Component {
|
|
|
60911
61104
|
this.setNeedsUpdate();
|
|
60912
61105
|
}
|
|
60913
61106
|
}
|
|
60914
|
-
_defineProperty(Layer, "defaultProps", defaultProps$
|
|
61107
|
+
_defineProperty(Layer, "defaultProps", defaultProps$O);
|
|
60915
61108
|
_defineProperty(Layer, "layerName", "Layer");
|
|
60916
61109
|
const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
|
|
60917
61110
|
class CompositeLayer extends Layer {
|
|
@@ -61947,6 +62140,124 @@ const esm$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
61947
62140
|
project32,
|
|
61948
62141
|
shadow
|
|
61949
62142
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
62143
|
+
const dashShaders = {
|
|
62144
|
+
inject: {
|
|
62145
|
+
"vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
|
|
62146
|
+
"vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
|
|
62147
|
+
"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",
|
|
62148
|
+
"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"
|
|
62149
|
+
}
|
|
62150
|
+
};
|
|
62151
|
+
const offsetShaders = {
|
|
62152
|
+
inject: {
|
|
62153
|
+
"vs:#decl": "\nattribute float instanceOffsets;\n",
|
|
62154
|
+
"vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
|
|
62155
|
+
"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",
|
|
62156
|
+
"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"
|
|
62157
|
+
}
|
|
62158
|
+
};
|
|
62159
|
+
const defaultProps$N = {
|
|
62160
|
+
getDashArray: {
|
|
62161
|
+
type: "accessor",
|
|
62162
|
+
value: [0, 0]
|
|
62163
|
+
},
|
|
62164
|
+
getOffset: {
|
|
62165
|
+
type: "accessor",
|
|
62166
|
+
value: 0
|
|
62167
|
+
},
|
|
62168
|
+
dashJustified: false,
|
|
62169
|
+
dashGapPickable: false
|
|
62170
|
+
};
|
|
62171
|
+
class PathStyleExtension extends LayerExtension {
|
|
62172
|
+
constructor({
|
|
62173
|
+
dash = false,
|
|
62174
|
+
offset = false,
|
|
62175
|
+
highPrecisionDash = false
|
|
62176
|
+
} = {}) {
|
|
62177
|
+
super({
|
|
62178
|
+
dash: dash || highPrecisionDash,
|
|
62179
|
+
offset,
|
|
62180
|
+
highPrecisionDash
|
|
62181
|
+
});
|
|
62182
|
+
}
|
|
62183
|
+
isEnabled(layer) {
|
|
62184
|
+
return "pathTesselator" in layer.state;
|
|
62185
|
+
}
|
|
62186
|
+
getShaders(extension) {
|
|
62187
|
+
if (!extension.isEnabled(this)) {
|
|
62188
|
+
return null;
|
|
62189
|
+
}
|
|
62190
|
+
let result = {};
|
|
62191
|
+
if (extension.opts.dash) {
|
|
62192
|
+
result = mergeShaders(result, dashShaders);
|
|
62193
|
+
}
|
|
62194
|
+
if (extension.opts.offset) {
|
|
62195
|
+
result = mergeShaders(result, offsetShaders);
|
|
62196
|
+
}
|
|
62197
|
+
return result;
|
|
62198
|
+
}
|
|
62199
|
+
initializeState(context, extension) {
|
|
62200
|
+
const attributeManager = this.getAttributeManager();
|
|
62201
|
+
if (!attributeManager || !extension.isEnabled(this)) {
|
|
62202
|
+
return;
|
|
62203
|
+
}
|
|
62204
|
+
if (extension.opts.dash) {
|
|
62205
|
+
attributeManager.addInstanced({
|
|
62206
|
+
instanceDashArrays: {
|
|
62207
|
+
size: 2,
|
|
62208
|
+
accessor: "getDashArray"
|
|
62209
|
+
}
|
|
62210
|
+
});
|
|
62211
|
+
}
|
|
62212
|
+
if (extension.opts.highPrecisionDash) {
|
|
62213
|
+
attributeManager.addInstanced({
|
|
62214
|
+
instanceDashOffsets: {
|
|
62215
|
+
size: 1,
|
|
62216
|
+
accessor: "getPath",
|
|
62217
|
+
transform: extension.getDashOffsets.bind(this)
|
|
62218
|
+
}
|
|
62219
|
+
});
|
|
62220
|
+
}
|
|
62221
|
+
if (extension.opts.offset) {
|
|
62222
|
+
attributeManager.addInstanced({
|
|
62223
|
+
instanceOffsets: {
|
|
62224
|
+
size: 1,
|
|
62225
|
+
accessor: "getOffset"
|
|
62226
|
+
}
|
|
62227
|
+
});
|
|
62228
|
+
}
|
|
62229
|
+
}
|
|
62230
|
+
updateState(params, extension) {
|
|
62231
|
+
if (!extension.isEnabled(this)) {
|
|
62232
|
+
return;
|
|
62233
|
+
}
|
|
62234
|
+
const uniforms = {};
|
|
62235
|
+
if (extension.opts.dash) {
|
|
62236
|
+
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
62237
|
+
uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
|
|
62238
|
+
}
|
|
62239
|
+
this.state.model.setUniforms(uniforms);
|
|
62240
|
+
}
|
|
62241
|
+
getDashOffsets(path) {
|
|
62242
|
+
const result = [0];
|
|
62243
|
+
const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
|
|
62244
|
+
const isNested2 = Array.isArray(path[0]);
|
|
62245
|
+
const geometrySize = isNested2 ? path.length : path.length / positionSize;
|
|
62246
|
+
let p;
|
|
62247
|
+
let prevP;
|
|
62248
|
+
for (let i2 = 0; i2 < geometrySize - 1; i2++) {
|
|
62249
|
+
p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
|
|
62250
|
+
p = this.projectPosition(p);
|
|
62251
|
+
if (i2 > 0) {
|
|
62252
|
+
result[i2] = result[i2 - 1] + dist(prevP, p);
|
|
62253
|
+
}
|
|
62254
|
+
prevP = p;
|
|
62255
|
+
}
|
|
62256
|
+
return result;
|
|
62257
|
+
}
|
|
62258
|
+
}
|
|
62259
|
+
_defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
|
|
62260
|
+
_defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
|
|
61950
62261
|
const defaultProps$M = {
|
|
61951
62262
|
clipBounds: [0, 0, 1, 1]
|
|
61952
62263
|
};
|
|
@@ -117652,8 +117963,8 @@ function requireJs$b() {
|
|
|
117652
117963
|
var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
|
|
117653
117964
|
var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
|
|
117654
117965
|
var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
|
|
117655
|
-
var
|
|
117656
|
-
return
|
|
117966
|
+
var dist2 = delta * R;
|
|
117967
|
+
return dist2;
|
|
117657
117968
|
}
|
|
117658
117969
|
js$a.default = rhumbDistance;
|
|
117659
117970
|
return js$a;
|
|
@@ -117966,7 +118277,7 @@ function requireUtils$2() {
|
|
|
117966
118277
|
var x;
|
|
117967
118278
|
var y;
|
|
117968
118279
|
var segmentIdx;
|
|
117969
|
-
var
|
|
118280
|
+
var dist2;
|
|
117970
118281
|
if (coords.length > 1 && pointCoords.length) {
|
|
117971
118282
|
var lineCoordinates;
|
|
117972
118283
|
var pointCoordinate;
|
|
@@ -117983,17 +118294,17 @@ function requireUtils$2() {
|
|
|
117983
118294
|
if (lineCoordinates[n3][0] !== lineCoordinates[n3 - 1][0]) {
|
|
117984
118295
|
var slope = (lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1]) / (lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0]);
|
|
117985
118296
|
var inverseSlope = lineCoordinates[n3][1] - slope * lineCoordinates[n3][0];
|
|
117986
|
-
|
|
117987
|
-
} else
|
|
118297
|
+
dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
|
|
118298
|
+
} else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
|
|
117988
118299
|
var rl2 = Math.pow(lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1], 2) + Math.pow(lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0], 2);
|
|
117989
118300
|
var ln2 = Math.pow(lineCoordinates[n3][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3][0] - pointCoordinate[0], 2);
|
|
117990
118301
|
var lnm12 = Math.pow(lineCoordinates[n3 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3 - 1][0] - pointCoordinate[0], 2);
|
|
117991
|
-
var
|
|
117992
|
-
var calcrl2 = ln2 -
|
|
118302
|
+
var dist22 = Math.pow(dist2, 2);
|
|
118303
|
+
var calcrl2 = ln2 - dist22 + lnm12 - dist22;
|
|
117993
118304
|
if (calcrl2 > rl2) {
|
|
117994
|
-
|
|
118305
|
+
dist2 = Math.sqrt(Math.min(ln2, lnm12));
|
|
117995
118306
|
}
|
|
117996
|
-
if (minDist === null || minDist === void 0 || minDist >
|
|
118307
|
+
if (minDist === null || minDist === void 0 || minDist > dist2) {
|
|
117997
118308
|
if (calcrl2 > rl2) {
|
|
117998
118309
|
if (lnm12 < ln2) {
|
|
117999
118310
|
to = 0;
|
|
@@ -118003,10 +118314,10 @@ function requireUtils$2() {
|
|
|
118003
118314
|
to = 1;
|
|
118004
118315
|
}
|
|
118005
118316
|
} else {
|
|
118006
|
-
to = Math.sqrt(lnm12 -
|
|
118007
|
-
from = Math.sqrt(ln2 -
|
|
118317
|
+
to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
|
|
118318
|
+
from = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
|
|
118008
118319
|
}
|
|
118009
|
-
minDist =
|
|
118320
|
+
minDist = dist2;
|
|
118010
118321
|
segmentIdx = n3;
|
|
118011
118322
|
}
|
|
118012
118323
|
}
|
|
@@ -134945,22 +135256,22 @@ async function getDecoder(fileDirectory) {
|
|
|
134945
135256
|
const Decoder = await importFn();
|
|
134946
135257
|
return new Decoder(fileDirectory);
|
|
134947
135258
|
}
|
|
134948
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
134949
|
-
addDecoder(5, () => import("./lzw-
|
|
135259
|
+
addDecoder([void 0, 1], () => import("./raw-DrKGleEE.js").then((m) => m.default));
|
|
135260
|
+
addDecoder(5, () => import("./lzw-Cn4MHMg0.js").then((m) => m.default));
|
|
134950
135261
|
addDecoder(6, () => {
|
|
134951
135262
|
throw new Error("old style JPEG compression is not supported.");
|
|
134952
135263
|
});
|
|
134953
|
-
addDecoder(7, () => import("./jpeg-
|
|
134954
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
134955
|
-
addDecoder(32773, () => import("./packbits-
|
|
135264
|
+
addDecoder(7, () => import("./jpeg-DYOBxHhT.js").then((m) => m.default));
|
|
135265
|
+
addDecoder([8, 32946], () => import("./deflate-B9yQXNA5.js").then((m) => m.default));
|
|
135266
|
+
addDecoder(32773, () => import("./packbits-3K31MqMe.js").then((m) => m.default));
|
|
134956
135267
|
addDecoder(
|
|
134957
135268
|
34887,
|
|
134958
|
-
() => import("./lerc-
|
|
135269
|
+
() => import("./lerc-CXBCb2wB.js").then(async (m) => {
|
|
134959
135270
|
await m.zstd.init();
|
|
134960
135271
|
return m;
|
|
134961
135272
|
}).then((m) => m.default)
|
|
134962
135273
|
);
|
|
134963
|
-
addDecoder(50001, () => import("./webimage-
|
|
135274
|
+
addDecoder(50001, () => import("./webimage-MBv_oDxF.js").then((m) => m.default));
|
|
134964
135275
|
function copyNewSize(array, width, height, samplesPerPixel = 1) {
|
|
134965
135276
|
return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
|
|
134966
135277
|
}
|
|
@@ -138013,8 +138324,8 @@ function TreeDesc(dyn_tree, stat_desc) {
|
|
|
138013
138324
|
this.max_code = 0;
|
|
138014
138325
|
this.stat_desc = stat_desc;
|
|
138015
138326
|
}
|
|
138016
|
-
const d_code = (
|
|
138017
|
-
return
|
|
138327
|
+
const d_code = (dist2) => {
|
|
138328
|
+
return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
|
|
138018
138329
|
};
|
|
138019
138330
|
const put_short = (s2, w2) => {
|
|
138020
138331
|
s2.pending_buf[s2.pending++] = w2 & 255;
|
|
@@ -138148,7 +138459,7 @@ const tr_static_init = () => {
|
|
|
138148
138459
|
let bits;
|
|
138149
138460
|
let length2;
|
|
138150
138461
|
let code;
|
|
138151
|
-
let
|
|
138462
|
+
let dist2;
|
|
138152
138463
|
const bl_count = new Array(MAX_BITS + 1);
|
|
138153
138464
|
length2 = 0;
|
|
138154
138465
|
for (code = 0; code < LENGTH_CODES - 1; code++) {
|
|
@@ -138158,18 +138469,18 @@ const tr_static_init = () => {
|
|
|
138158
138469
|
}
|
|
138159
138470
|
}
|
|
138160
138471
|
_length_code[length2 - 1] = code;
|
|
138161
|
-
|
|
138472
|
+
dist2 = 0;
|
|
138162
138473
|
for (code = 0; code < 16; code++) {
|
|
138163
|
-
base_dist[code] =
|
|
138474
|
+
base_dist[code] = dist2;
|
|
138164
138475
|
for (n3 = 0; n3 < 1 << extra_dbits[code]; n3++) {
|
|
138165
|
-
_dist_code[
|
|
138476
|
+
_dist_code[dist2++] = code;
|
|
138166
138477
|
}
|
|
138167
138478
|
}
|
|
138168
|
-
|
|
138479
|
+
dist2 >>= 7;
|
|
138169
138480
|
for (; code < D_CODES; code++) {
|
|
138170
|
-
base_dist[code] =
|
|
138481
|
+
base_dist[code] = dist2 << 7;
|
|
138171
138482
|
for (n3 = 0; n3 < 1 << extra_dbits[code] - 7; n3++) {
|
|
138172
|
-
_dist_code[256 +
|
|
138483
|
+
_dist_code[256 + dist2++] = code;
|
|
138173
138484
|
}
|
|
138174
138485
|
}
|
|
138175
138486
|
for (bits = 0; bits <= MAX_BITS; bits++) {
|
|
@@ -138260,17 +138571,17 @@ const pqdownheap = (s2, tree, k) => {
|
|
|
138260
138571
|
s2.heap[k] = v;
|
|
138261
138572
|
};
|
|
138262
138573
|
const compress_block = (s2, ltree, dtree) => {
|
|
138263
|
-
let
|
|
138574
|
+
let dist2;
|
|
138264
138575
|
let lc;
|
|
138265
138576
|
let lx = 0;
|
|
138266
138577
|
let code;
|
|
138267
138578
|
let extra;
|
|
138268
138579
|
if (s2.last_lit !== 0) {
|
|
138269
138580
|
do {
|
|
138270
|
-
|
|
138581
|
+
dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
|
|
138271
138582
|
lc = s2.pending_buf[s2.l_buf + lx];
|
|
138272
138583
|
lx++;
|
|
138273
|
-
if (
|
|
138584
|
+
if (dist2 === 0) {
|
|
138274
138585
|
send_code(s2, lc, ltree);
|
|
138275
138586
|
} else {
|
|
138276
138587
|
code = _length_code[lc];
|
|
@@ -138280,13 +138591,13 @@ const compress_block = (s2, ltree, dtree) => {
|
|
|
138280
138591
|
lc -= base_length[code];
|
|
138281
138592
|
send_bits(s2, lc, extra);
|
|
138282
138593
|
}
|
|
138283
|
-
|
|
138284
|
-
code = d_code(
|
|
138594
|
+
dist2--;
|
|
138595
|
+
code = d_code(dist2);
|
|
138285
138596
|
send_code(s2, code, dtree);
|
|
138286
138597
|
extra = extra_dbits[code];
|
|
138287
138598
|
if (extra !== 0) {
|
|
138288
|
-
|
|
138289
|
-
send_bits(s2,
|
|
138599
|
+
dist2 -= base_dist[code];
|
|
138600
|
+
send_bits(s2, dist2, extra);
|
|
138290
138601
|
}
|
|
138291
138602
|
}
|
|
138292
138603
|
} while (lx < s2.last_lit);
|
|
@@ -138557,18 +138868,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
|
|
|
138557
138868
|
bi_windup(s2);
|
|
138558
138869
|
}
|
|
138559
138870
|
};
|
|
138560
|
-
const _tr_tally = (s2,
|
|
138561
|
-
s2.pending_buf[s2.d_buf + s2.last_lit * 2] =
|
|
138562
|
-
s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] =
|
|
138871
|
+
const _tr_tally = (s2, dist2, lc) => {
|
|
138872
|
+
s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
|
|
138873
|
+
s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
|
|
138563
138874
|
s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
|
|
138564
138875
|
s2.last_lit++;
|
|
138565
|
-
if (
|
|
138876
|
+
if (dist2 === 0) {
|
|
138566
138877
|
s2.dyn_ltree[lc * 2]++;
|
|
138567
138878
|
} else {
|
|
138568
138879
|
s2.matches++;
|
|
138569
|
-
|
|
138880
|
+
dist2--;
|
|
138570
138881
|
s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
|
|
138571
|
-
s2.dyn_dtree[d_code(
|
|
138882
|
+
s2.dyn_dtree[d_code(dist2) * 2]++;
|
|
138572
138883
|
}
|
|
138573
138884
|
return s2.last_lit === s2.lit_bufsize - 1;
|
|
138574
138885
|
};
|
|
@@ -140073,7 +140384,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140073
140384
|
let here;
|
|
140074
140385
|
let op;
|
|
140075
140386
|
let len2;
|
|
140076
|
-
let
|
|
140387
|
+
let dist2;
|
|
140077
140388
|
let from;
|
|
140078
140389
|
let from_source;
|
|
140079
140390
|
let input, output;
|
|
@@ -140139,7 +140450,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140139
140450
|
bits -= op;
|
|
140140
140451
|
op = here >>> 16 & 255;
|
|
140141
140452
|
if (op & 16) {
|
|
140142
|
-
|
|
140453
|
+
dist2 = here & 65535;
|
|
140143
140454
|
op &= 15;
|
|
140144
140455
|
if (bits < op) {
|
|
140145
140456
|
hold += input[_in++] << bits;
|
|
@@ -140149,8 +140460,8 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140149
140460
|
bits += 8;
|
|
140150
140461
|
}
|
|
140151
140462
|
}
|
|
140152
|
-
|
|
140153
|
-
if (
|
|
140463
|
+
dist2 += hold & (1 << op) - 1;
|
|
140464
|
+
if (dist2 > dmax) {
|
|
140154
140465
|
strm.msg = "invalid distance too far back";
|
|
140155
140466
|
state.mode = BAD;
|
|
140156
140467
|
break top;
|
|
@@ -140158,8 +140469,8 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140158
140469
|
hold >>>= op;
|
|
140159
140470
|
bits -= op;
|
|
140160
140471
|
op = _out - beg;
|
|
140161
|
-
if (
|
|
140162
|
-
op =
|
|
140472
|
+
if (dist2 > op) {
|
|
140473
|
+
op = dist2 - op;
|
|
140163
140474
|
if (op > whave) {
|
|
140164
140475
|
if (state.sane) {
|
|
140165
140476
|
strm.msg = "invalid distance too far back";
|
|
@@ -140176,7 +140487,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140176
140487
|
do {
|
|
140177
140488
|
output[_out++] = s_window[from++];
|
|
140178
140489
|
} while (--op);
|
|
140179
|
-
from = _out -
|
|
140490
|
+
from = _out - dist2;
|
|
140180
140491
|
from_source = output;
|
|
140181
140492
|
}
|
|
140182
140493
|
} else if (wnext < op) {
|
|
@@ -140194,7 +140505,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140194
140505
|
do {
|
|
140195
140506
|
output[_out++] = s_window[from++];
|
|
140196
140507
|
} while (--op);
|
|
140197
|
-
from = _out -
|
|
140508
|
+
from = _out - dist2;
|
|
140198
140509
|
from_source = output;
|
|
140199
140510
|
}
|
|
140200
140511
|
}
|
|
@@ -140205,7 +140516,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140205
140516
|
do {
|
|
140206
140517
|
output[_out++] = s_window[from++];
|
|
140207
140518
|
} while (--op);
|
|
140208
|
-
from = _out -
|
|
140519
|
+
from = _out - dist2;
|
|
140209
140520
|
from_source = output;
|
|
140210
140521
|
}
|
|
140211
140522
|
}
|
|
@@ -140222,7 +140533,7 @@ var inffast = function inflate_fast(strm, start) {
|
|
|
140222
140533
|
}
|
|
140223
140534
|
}
|
|
140224
140535
|
} else {
|
|
140225
|
-
from = _out -
|
|
140536
|
+
from = _out - dist2;
|
|
140226
140537
|
do {
|
|
140227
140538
|
output[_out++] = output[from++];
|
|
140228
140539
|
output[_out++] = output[from++];
|
|
@@ -140780,7 +141091,7 @@ const fixedtables = (state) => {
|
|
|
140780
141091
|
state.distbits = 5;
|
|
140781
141092
|
};
|
|
140782
141093
|
const updatewindow = (strm, src, end, copy2) => {
|
|
140783
|
-
let
|
|
141094
|
+
let dist2;
|
|
140784
141095
|
const state = strm.state;
|
|
140785
141096
|
if (state.window === null) {
|
|
140786
141097
|
state.wsize = 1 << state.wbits;
|
|
@@ -140793,23 +141104,23 @@ const updatewindow = (strm, src, end, copy2) => {
|
|
|
140793
141104
|
state.wnext = 0;
|
|
140794
141105
|
state.whave = state.wsize;
|
|
140795
141106
|
} else {
|
|
140796
|
-
|
|
140797
|
-
if (
|
|
140798
|
-
|
|
141107
|
+
dist2 = state.wsize - state.wnext;
|
|
141108
|
+
if (dist2 > copy2) {
|
|
141109
|
+
dist2 = copy2;
|
|
140799
141110
|
}
|
|
140800
|
-
state.window.set(src.subarray(end - copy2, end - copy2 +
|
|
140801
|
-
copy2 -=
|
|
141111
|
+
state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
|
|
141112
|
+
copy2 -= dist2;
|
|
140802
141113
|
if (copy2) {
|
|
140803
141114
|
state.window.set(src.subarray(end - copy2, end), 0);
|
|
140804
141115
|
state.wnext = copy2;
|
|
140805
141116
|
state.whave = state.wsize;
|
|
140806
141117
|
} else {
|
|
140807
|
-
state.wnext +=
|
|
141118
|
+
state.wnext += dist2;
|
|
140808
141119
|
if (state.wnext === state.wsize) {
|
|
140809
141120
|
state.wnext = 0;
|
|
140810
141121
|
}
|
|
140811
141122
|
if (state.whave < state.wsize) {
|
|
140812
|
-
state.whave +=
|
|
141123
|
+
state.whave += dist2;
|
|
140813
141124
|
}
|
|
140814
141125
|
}
|
|
140815
141126
|
}
|
|
@@ -145450,7 +145761,7 @@ function padColors({ colors, channelsVisible }) {
|
|
|
145450
145761
|
).reduce((acc, val) => acc.concat(val), []);
|
|
145451
145762
|
return paddedColors;
|
|
145452
145763
|
}
|
|
145453
|
-
const defaultProps$3$
|
|
145764
|
+
const defaultProps$3$2 = {
|
|
145454
145765
|
colors: { type: "array", value: null, compare: true },
|
|
145455
145766
|
opacity: { type: "number", value: 1, compare: true },
|
|
145456
145767
|
transparentColor: { type: "array", value: null, compare: true },
|
|
@@ -145467,9 +145778,9 @@ const ColorPaletteExtension = class extends LayerExtension {
|
|
|
145467
145778
|
const {
|
|
145468
145779
|
colors,
|
|
145469
145780
|
channelsVisible,
|
|
145470
|
-
opacity = defaultProps$3$
|
|
145471
|
-
transparentColor = defaultProps$3$
|
|
145472
|
-
useTransparentColor = defaultProps$3$
|
|
145781
|
+
opacity = defaultProps$3$2.opacity.value,
|
|
145782
|
+
transparentColor = defaultProps$3$2.transparentColor.value,
|
|
145783
|
+
useTransparentColor = defaultProps$3$2.useTransparentColor.value
|
|
145473
145784
|
} = this.props;
|
|
145474
145785
|
const paddedColors = padColors({
|
|
145475
145786
|
channelsVisible: channelsVisible || this.selections.map(() => true),
|
|
@@ -145485,7 +145796,7 @@ const ColorPaletteExtension = class extends LayerExtension {
|
|
|
145485
145796
|
}
|
|
145486
145797
|
};
|
|
145487
145798
|
ColorPaletteExtension.extensionName = "ColorPaletteExtension";
|
|
145488
|
-
ColorPaletteExtension.defaultProps = defaultProps$3$
|
|
145799
|
+
ColorPaletteExtension.defaultProps = defaultProps$3$2;
|
|
145489
145800
|
const fs$4 = `// lens bounds for ellipse
|
|
145490
145801
|
uniform float majorLensAxis;
|
|
145491
145802
|
uniform float minorLensAxis;
|
|
@@ -146780,7 +147091,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
|
|
|
146780
147091
|
};
|
|
146781
147092
|
MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
|
|
146782
147093
|
MultiscaleImageLayer.defaultProps = defaultProps$4;
|
|
146783
|
-
const defaultProps$3 = {
|
|
147094
|
+
const defaultProps$3$1 = {
|
|
146784
147095
|
pickable: { type: "boolean", value: true, compare: true },
|
|
146785
147096
|
loader: {
|
|
146786
147097
|
type: "object",
|
|
@@ -146867,7 +147178,7 @@ const OverviewLayer = class extends CompositeLayer {
|
|
|
146867
147178
|
}
|
|
146868
147179
|
};
|
|
146869
147180
|
OverviewLayer.layerName = "OverviewLayer";
|
|
146870
|
-
OverviewLayer.defaultProps = defaultProps$3;
|
|
147181
|
+
OverviewLayer.defaultProps = defaultProps$3$1;
|
|
146871
147182
|
function getPosition(boundingBox, position, length2) {
|
|
146872
147183
|
const viewWidth = boundingBox[2][0] - boundingBox[0][0];
|
|
146873
147184
|
const viewHeight = boundingBox[2][1] - boundingBox[0][1];
|
|
@@ -147855,7 +148166,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
|
|
|
147855
148166
|
}
|
|
147856
148167
|
return newArr;
|
|
147857
148168
|
}
|
|
147858
|
-
const defaultProps$
|
|
148169
|
+
const defaultProps$3 = {
|
|
147859
148170
|
hoveredCell: { type: "number", value: null, compare: true },
|
|
147860
148171
|
// We do not want to deep-compare cellColorData,
|
|
147861
148172
|
// as it is potentially a TypedArray with millions of elements.
|
|
@@ -147972,7 +148283,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
|
|
|
147972
148283
|
}
|
|
147973
148284
|
};
|
|
147974
148285
|
BitmaskLayer$1.layerName = "BitmaskLayer";
|
|
147975
|
-
BitmaskLayer$1.defaultProps = defaultProps$
|
|
148286
|
+
BitmaskLayer$1.defaultProps = defaultProps$3;
|
|
147976
148287
|
const vs = `
|
|
147977
148288
|
#define SHADER_NAME bitmask-layer-vertex-shader
|
|
147978
148289
|
|
|
@@ -148314,7 +148625,7 @@ function isEqualShallow(prevArr, nextArr) {
|
|
|
148314
148625
|
}
|
|
148315
148626
|
return prevArr === nextArr;
|
|
148316
148627
|
}
|
|
148317
|
-
const defaultProps$
|
|
148628
|
+
const defaultProps$2 = {
|
|
148318
148629
|
channelStrokeWidths: { type: "array", value: null, compare: true },
|
|
148319
148630
|
channelsFilled: { type: "array", value: null, compare: true },
|
|
148320
148631
|
channelOpacities: { type: "array", value: null, compare: true },
|
|
@@ -148578,7 +148889,7 @@ class BitmaskLayer2 extends XRLayer {
|
|
|
148578
148889
|
}
|
|
148579
148890
|
}
|
|
148580
148891
|
BitmaskLayer2.layerName = "BitmaskLayer";
|
|
148581
|
-
BitmaskLayer2.defaultProps = defaultProps$
|
|
148892
|
+
BitmaskLayer2.defaultProps = defaultProps$2;
|
|
148582
148893
|
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;
|
|
148583
148894
|
function clone(configObject) {
|
|
148584
148895
|
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 = {
|
|
@@ -151521,7 +151832,7 @@ function ringArea(coords) {
|
|
|
151521
151832
|
return total * FACTOR;
|
|
151522
151833
|
}
|
|
151523
151834
|
const DEFAULT_THRESHOLD = 1;
|
|
151524
|
-
const defaultProps = {
|
|
151835
|
+
const defaultProps$1 = {
|
|
151525
151836
|
// for text
|
|
151526
151837
|
obsSetPath: { type: "object" },
|
|
151527
151838
|
sampleSetPath: { type: "object" },
|
|
@@ -151616,9 +151927,9 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
151616
151927
|
const circlePoint = point(circleCoord);
|
|
151617
151928
|
polygonVertices.forEach((polyCoord) => {
|
|
151618
151929
|
const polyPoint = point(polyCoord);
|
|
151619
|
-
const
|
|
151620
|
-
if (
|
|
151621
|
-
minDist =
|
|
151930
|
+
const dist2 = distance$1(circlePoint, polyPoint);
|
|
151931
|
+
if (dist2 < minDist) {
|
|
151932
|
+
minDist = dist2;
|
|
151622
151933
|
minCirclePoint = circleCoord;
|
|
151623
151934
|
minCirclePointI = circlePointI;
|
|
151624
151935
|
minPolygonPoint = polyCoord;
|
|
@@ -151695,7 +152006,1077 @@ class ContourLayerWithText extends ContourLayer {
|
|
|
151695
152006
|
}
|
|
151696
152007
|
}
|
|
151697
152008
|
ContourLayerWithText.layerName = "ContourLayerWithText";
|
|
151698
|
-
ContourLayerWithText.defaultProps = defaultProps;
|
|
152009
|
+
ContourLayerWithText.defaultProps = defaultProps$1;
|
|
152010
|
+
const ARROW_SCREEN_PX = 14;
|
|
152011
|
+
const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
|
|
152012
|
+
const LABEL_FONT_WEIGHT = "bold";
|
|
152013
|
+
const LABEL_FONT_SIZE = 14;
|
|
152014
|
+
const RATIO_CLUSTER = 0.1;
|
|
152015
|
+
const RATIO_DOT = 0.3;
|
|
152016
|
+
const RATIO_GEO_FADE = 0.55;
|
|
152017
|
+
const RATIO_TIPS = 0.7;
|
|
152018
|
+
const RATIO_LABEL = 0.55;
|
|
152019
|
+
const RATIO_LABEL_FULL = 0.75;
|
|
152020
|
+
function textBgColor(strokeColor) {
|
|
152021
|
+
const [r2, g2, b] = strokeColor;
|
|
152022
|
+
const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
|
|
152023
|
+
return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
|
|
152024
|
+
}
|
|
152025
|
+
function parseDashArray(strokeDashArray) {
|
|
152026
|
+
if (!strokeDashArray || strokeDashArray === "none")
|
|
152027
|
+
return null;
|
|
152028
|
+
const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n3) => !Number.isNaN(n3) && n3 >= 0);
|
|
152029
|
+
return nums.length >= 2 ? [nums[0], nums[1]] : null;
|
|
152030
|
+
}
|
|
152031
|
+
function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
|
|
152032
|
+
const pts = [];
|
|
152033
|
+
for (let i2 = 0; i2 < numSegments; i2++) {
|
|
152034
|
+
const angle2 = 2 * Math.PI * i2 / numSegments;
|
|
152035
|
+
pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
|
|
152036
|
+
}
|
|
152037
|
+
return pts;
|
|
152038
|
+
}
|
|
152039
|
+
function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
|
|
152040
|
+
if (!inProgress || inProgress.vertices.length === 0)
|
|
152041
|
+
return null;
|
|
152042
|
+
const { type, vertices } = inProgress;
|
|
152043
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
|
|
152044
|
+
const previewColor = [...strokeColor, 160];
|
|
152045
|
+
const cursor = hoverCoord ?? vertices[vertices.length - 1];
|
|
152046
|
+
if (type === "rectangle" && vertices.length === 1) {
|
|
152047
|
+
const [ax, ay] = vertices[0];
|
|
152048
|
+
const [bx, by] = cursor;
|
|
152049
|
+
const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
|
|
152050
|
+
return new PathLayer({
|
|
152051
|
+
...base,
|
|
152052
|
+
id: "annotation-preview-rectangle",
|
|
152053
|
+
data: [{ path }],
|
|
152054
|
+
getPath: (d) => d.path,
|
|
152055
|
+
getColor: previewColor,
|
|
152056
|
+
getWidth: 1,
|
|
152057
|
+
widthUnits: "pixels",
|
|
152058
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152059
|
+
getDashArray: [8, 4]
|
|
152060
|
+
});
|
|
152061
|
+
}
|
|
152062
|
+
if (type === "line" && vertices.length === 1) {
|
|
152063
|
+
const path = [vertices[0], cursor];
|
|
152064
|
+
return new PathLayer({
|
|
152065
|
+
...base,
|
|
152066
|
+
id: "annotation-preview-line",
|
|
152067
|
+
data: [{ path }],
|
|
152068
|
+
getPath: (d) => d.path,
|
|
152069
|
+
getColor: previewColor,
|
|
152070
|
+
getWidth: 1,
|
|
152071
|
+
widthUnits: "pixels",
|
|
152072
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152073
|
+
getDashArray: [8, 4]
|
|
152074
|
+
});
|
|
152075
|
+
}
|
|
152076
|
+
if (type === "ellipse" && vertices.length === 1) {
|
|
152077
|
+
const [cx, cy] = vertices[0];
|
|
152078
|
+
const [ex, ey] = cursor;
|
|
152079
|
+
const rx = Math.abs(ex - cx);
|
|
152080
|
+
const ry = Math.abs(ey - cy);
|
|
152081
|
+
if (rx < 1 && ry < 1)
|
|
152082
|
+
return null;
|
|
152083
|
+
const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
|
|
152084
|
+
const path = [...pts, pts[0]];
|
|
152085
|
+
return new PathLayer({
|
|
152086
|
+
...base,
|
|
152087
|
+
id: "annotation-preview-ellipse",
|
|
152088
|
+
data: [{ path }],
|
|
152089
|
+
getPath: (d) => d.path,
|
|
152090
|
+
getColor: previewColor,
|
|
152091
|
+
getWidth: 1,
|
|
152092
|
+
widthUnits: "pixels",
|
|
152093
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152094
|
+
getDashArray: [8, 4]
|
|
152095
|
+
});
|
|
152096
|
+
}
|
|
152097
|
+
if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
|
|
152098
|
+
const path = [...vertices, cursor];
|
|
152099
|
+
if (type === "polygon" && vertices.length >= 2)
|
|
152100
|
+
path.push(vertices[0]);
|
|
152101
|
+
return new PathLayer({
|
|
152102
|
+
...base,
|
|
152103
|
+
id: `annotation-preview-${type}`,
|
|
152104
|
+
data: [{ path }],
|
|
152105
|
+
getPath: (d) => d.path,
|
|
152106
|
+
getColor: previewColor,
|
|
152107
|
+
getWidth: 1,
|
|
152108
|
+
widthUnits: "pixels",
|
|
152109
|
+
jointRounded: true,
|
|
152110
|
+
capRounded: true,
|
|
152111
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152112
|
+
getDashArray: [8, 4]
|
|
152113
|
+
});
|
|
152114
|
+
}
|
|
152115
|
+
return null;
|
|
152116
|
+
}
|
|
152117
|
+
function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
|
|
152118
|
+
const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
152119
|
+
if (len2 === 0)
|
|
152120
|
+
return null;
|
|
152121
|
+
const ux = dirX / len2;
|
|
152122
|
+
const uy = dirY / len2;
|
|
152123
|
+
const px = -uy;
|
|
152124
|
+
const py = ux;
|
|
152125
|
+
const half = dataSize * 0.55;
|
|
152126
|
+
return [
|
|
152127
|
+
[tipX + px * half, tipY + py * half],
|
|
152128
|
+
[tipX - px * half, tipY - py * half]
|
|
152129
|
+
];
|
|
152130
|
+
}
|
|
152131
|
+
function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
|
|
152132
|
+
const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
152133
|
+
if (len2 === 0)
|
|
152134
|
+
return null;
|
|
152135
|
+
const ux = dirX / len2;
|
|
152136
|
+
const uy = dirY / len2;
|
|
152137
|
+
const px = -uy;
|
|
152138
|
+
const py = ux;
|
|
152139
|
+
const halfBase = dataSize * 0.4;
|
|
152140
|
+
const bx = tipX - ux * dataSize;
|
|
152141
|
+
const by = tipY - uy * dataSize;
|
|
152142
|
+
return [
|
|
152143
|
+
[tipX, tipY],
|
|
152144
|
+
[bx + px * halfBase, by + py * halfBase],
|
|
152145
|
+
[bx - px * halfBase, by - py * halfBase]
|
|
152146
|
+
];
|
|
152147
|
+
}
|
|
152148
|
+
function fmtCommas(n3) {
|
|
152149
|
+
return Math.round(n3).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
152150
|
+
}
|
|
152151
|
+
function getMeasurementLabel(shape, physicalPixelSize, viewType = ViewType$1.SPATIAL) {
|
|
152152
|
+
const pps = physicalPixelSize;
|
|
152153
|
+
const px = pps?.x ?? 1;
|
|
152154
|
+
const py = pps?.y ?? 1;
|
|
152155
|
+
const unit2 = pps ? pps.unit ?? "" : null;
|
|
152156
|
+
const hasPhys = !!pps;
|
|
152157
|
+
const isEmbedding = viewType === ViewType$1.SCATTERPLOT;
|
|
152158
|
+
const fmtDist = (d) => {
|
|
152159
|
+
if (hasPhys)
|
|
152160
|
+
return `${d.toFixed(2)} ${unit2}`;
|
|
152161
|
+
if (isEmbedding)
|
|
152162
|
+
return d.toFixed(2);
|
|
152163
|
+
return `${fmtCommas(d)} px`;
|
|
152164
|
+
};
|
|
152165
|
+
const fmtArea = (a2) => {
|
|
152166
|
+
if (hasPhys)
|
|
152167
|
+
return `${a2.toFixed(2)} ${unit2}²`;
|
|
152168
|
+
if (isEmbedding)
|
|
152169
|
+
return a2.toFixed(2);
|
|
152170
|
+
return `${fmtCommas(a2)} px²`;
|
|
152171
|
+
};
|
|
152172
|
+
if (shape.type === "line") {
|
|
152173
|
+
const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
|
|
152174
|
+
const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
|
|
152175
|
+
const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
|
|
152176
|
+
return fmtDist(dist2);
|
|
152177
|
+
}
|
|
152178
|
+
if (shape.type === "rectangle") {
|
|
152179
|
+
return fmtArea(hasPhys ? Math.abs(shape.width ?? 0) * px * Math.abs(shape.height ?? 0) * py : Math.abs((shape.width ?? 0) * (shape.height ?? 0)));
|
|
152180
|
+
}
|
|
152181
|
+
if (shape.type === "ellipse") {
|
|
152182
|
+
const rx = Math.abs(shape.radiusX ?? 0);
|
|
152183
|
+
const ry = Math.abs(shape.radiusY ?? 0);
|
|
152184
|
+
return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
|
|
152185
|
+
}
|
|
152186
|
+
if (shape.type === "polygon" && shape.points?.length >= 3) {
|
|
152187
|
+
const pts = shape.points;
|
|
152188
|
+
let shoelace = 0;
|
|
152189
|
+
for (let i2 = 0; i2 < pts.length; i2++) {
|
|
152190
|
+
const [ax, ay] = pts[i2];
|
|
152191
|
+
const [bx, by] = pts[(i2 + 1) % pts.length];
|
|
152192
|
+
shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
|
|
152193
|
+
}
|
|
152194
|
+
return fmtArea(Math.abs(shoelace / 2));
|
|
152195
|
+
}
|
|
152196
|
+
if (shape.type === "polyline" && shape.points?.length >= 2) {
|
|
152197
|
+
let total = 0;
|
|
152198
|
+
for (let i2 = 0; i2 < shape.points.length - 1; i2++) {
|
|
152199
|
+
const [ax, ay] = shape.points[i2];
|
|
152200
|
+
const [bx, by] = shape.points[i2 + 1];
|
|
152201
|
+
total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
|
|
152202
|
+
}
|
|
152203
|
+
return fmtDist(total);
|
|
152204
|
+
}
|
|
152205
|
+
return null;
|
|
152206
|
+
}
|
|
152207
|
+
function pickBelowPerp(ux, uy) {
|
|
152208
|
+
const rp = [uy, -ux];
|
|
152209
|
+
const lp = [-uy, ux];
|
|
152210
|
+
return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
|
|
152211
|
+
}
|
|
152212
|
+
function readableAngle(deg) {
|
|
152213
|
+
let a2 = deg;
|
|
152214
|
+
if (a2 > 90)
|
|
152215
|
+
a2 -= 180;
|
|
152216
|
+
if (a2 < -90)
|
|
152217
|
+
a2 += 180;
|
|
152218
|
+
return a2;
|
|
152219
|
+
}
|
|
152220
|
+
function getShapeCentroid(shape) {
|
|
152221
|
+
if (shape.type === "rectangle") {
|
|
152222
|
+
return [(shape.x ?? 0) + (shape.width ?? 0) / 2, (shape.y ?? 0) + (shape.height ?? 0) / 2];
|
|
152223
|
+
}
|
|
152224
|
+
if (shape.type === "line") {
|
|
152225
|
+
return [((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2, ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2];
|
|
152226
|
+
}
|
|
152227
|
+
if (shape.type === "ellipse") {
|
|
152228
|
+
return [shape.x1 ?? 0, shape.y1 ?? 0];
|
|
152229
|
+
}
|
|
152230
|
+
if ((shape.type === "polygon" || shape.type === "polyline") && shape.points?.length >= 1) {
|
|
152231
|
+
const mx = shape.points.reduce((s2, p) => s2 + p[0], 0) / shape.points.length;
|
|
152232
|
+
const my = shape.points.reduce((s2, p) => s2 + p[1], 0) / shape.points.length;
|
|
152233
|
+
return [mx, my];
|
|
152234
|
+
}
|
|
152235
|
+
return [0, 0];
|
|
152236
|
+
}
|
|
152237
|
+
function computeClusters(shapeList, zoom, cellPx = 50) {
|
|
152238
|
+
const cellSize = cellPx / 2 ** Math.floor(zoom);
|
|
152239
|
+
const cells = /* @__PURE__ */ new Map();
|
|
152240
|
+
shapeList.forEach(({ shape }) => {
|
|
152241
|
+
const [cx, cy] = getShapeCentroid(shape);
|
|
152242
|
+
const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
|
|
152243
|
+
if (!cells.has(key)) {
|
|
152244
|
+
cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape.strokeColor ?? [255, 255, 255] });
|
|
152245
|
+
}
|
|
152246
|
+
const c = cells.get(key);
|
|
152247
|
+
c.sumX += cx;
|
|
152248
|
+
c.sumY += cy;
|
|
152249
|
+
c.count++;
|
|
152250
|
+
});
|
|
152251
|
+
return Array.from(cells.values()).map((c) => ({
|
|
152252
|
+
position: [c.sumX / c.count, c.sumY / c.count, 0],
|
|
152253
|
+
count: c.count,
|
|
152254
|
+
color: c.color
|
|
152255
|
+
}));
|
|
152256
|
+
}
|
|
152257
|
+
function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType$1.SPATIAL) {
|
|
152258
|
+
const selectionLayers = [];
|
|
152259
|
+
if (selectedShapeUid) {
|
|
152260
|
+
const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
|
|
152261
|
+
if (sel) {
|
|
152262
|
+
const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
|
|
152263
|
+
const haloColor = [255, 220, 50, 70];
|
|
152264
|
+
const haloWidth = Math.max(sStrokeWidth + 8, 10);
|
|
152265
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
|
|
152266
|
+
if (sType === "rectangle") {
|
|
152267
|
+
const { x, y, width, height } = sel;
|
|
152268
|
+
selectionLayers.push(new PathLayer({
|
|
152269
|
+
...base,
|
|
152270
|
+
id: `annotation-select-${sUid}`,
|
|
152271
|
+
data: [{
|
|
152272
|
+
path: [
|
|
152273
|
+
[x, y],
|
|
152274
|
+
[x + width, y],
|
|
152275
|
+
[x + width, y + height],
|
|
152276
|
+
[x, y + height],
|
|
152277
|
+
[x, y]
|
|
152278
|
+
]
|
|
152279
|
+
}],
|
|
152280
|
+
getPath: (d) => d.path,
|
|
152281
|
+
getColor: haloColor,
|
|
152282
|
+
getWidth: haloWidth,
|
|
152283
|
+
widthUnits: "pixels",
|
|
152284
|
+
jointRounded: true,
|
|
152285
|
+
capRounded: true
|
|
152286
|
+
}));
|
|
152287
|
+
}
|
|
152288
|
+
if (sType === "line") {
|
|
152289
|
+
const { x1: x12, y1: y12, x2, y2 } = sel;
|
|
152290
|
+
selectionLayers.push(new PathLayer({
|
|
152291
|
+
...base,
|
|
152292
|
+
id: `annotation-select-${sUid}`,
|
|
152293
|
+
data: [{ path: [[x12, y12], [x2, y2]] }],
|
|
152294
|
+
getPath: (d) => d.path,
|
|
152295
|
+
getColor: haloColor,
|
|
152296
|
+
getWidth: haloWidth,
|
|
152297
|
+
widthUnits: "pixels",
|
|
152298
|
+
capRounded: true
|
|
152299
|
+
}));
|
|
152300
|
+
}
|
|
152301
|
+
if (sType === "ellipse") {
|
|
152302
|
+
const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
|
|
152303
|
+
selectionLayers.push(new PathLayer({
|
|
152304
|
+
...base,
|
|
152305
|
+
id: `annotation-select-${sUid}`,
|
|
152306
|
+
data: [{ path: [...polygon2, polygon2[0]] }],
|
|
152307
|
+
getPath: (d) => d.path,
|
|
152308
|
+
getColor: haloColor,
|
|
152309
|
+
getWidth: haloWidth,
|
|
152310
|
+
widthUnits: "pixels",
|
|
152311
|
+
jointRounded: true
|
|
152312
|
+
}));
|
|
152313
|
+
}
|
|
152314
|
+
if (sType === "polygon" && sel.points?.length >= 3) {
|
|
152315
|
+
selectionLayers.push(new PathLayer({
|
|
152316
|
+
...base,
|
|
152317
|
+
id: `annotation-select-${sUid}`,
|
|
152318
|
+
data: [{ path: [...sel.points, sel.points[0]] }],
|
|
152319
|
+
getPath: (d) => d.path,
|
|
152320
|
+
getColor: haloColor,
|
|
152321
|
+
getWidth: haloWidth,
|
|
152322
|
+
widthUnits: "pixels",
|
|
152323
|
+
jointRounded: true
|
|
152324
|
+
}));
|
|
152325
|
+
}
|
|
152326
|
+
if (sType === "polyline" && sel.points?.length >= 2) {
|
|
152327
|
+
selectionLayers.push(new PathLayer({
|
|
152328
|
+
...base,
|
|
152329
|
+
id: `annotation-select-${sUid}`,
|
|
152330
|
+
data: [{ path: sel.points }],
|
|
152331
|
+
getPath: (d) => d.path,
|
|
152332
|
+
getColor: haloColor,
|
|
152333
|
+
getWidth: haloWidth,
|
|
152334
|
+
widthUnits: "pixels",
|
|
152335
|
+
jointRounded: true,
|
|
152336
|
+
capRounded: true
|
|
152337
|
+
}));
|
|
152338
|
+
}
|
|
152339
|
+
}
|
|
152340
|
+
}
|
|
152341
|
+
const layers = [];
|
|
152342
|
+
const dotShapes = [];
|
|
152343
|
+
const clusterDotShapes = [];
|
|
152344
|
+
shapes.forEach((shape, i2) => {
|
|
152345
|
+
const { uid: uid2, type, strokeColor = [255, 255, 255], strokeWidth = 3, strokeDashArray } = shape;
|
|
152346
|
+
const isSelected = uid2 === selectedShapeUid;
|
|
152347
|
+
let shapeOpacity = 1;
|
|
152348
|
+
let tipsOpacity = 1;
|
|
152349
|
+
let labelOpacity = 0;
|
|
152350
|
+
if (isSelected || !semanticZoom || authoredZoom === null) {
|
|
152351
|
+
tipsOpacity = 1;
|
|
152352
|
+
labelOpacity = 1;
|
|
152353
|
+
} else {
|
|
152354
|
+
const zoomRatio = 2 ** (zoom - authoredZoom);
|
|
152355
|
+
if (zoomRatio < RATIO_CLUSTER) {
|
|
152356
|
+
clusterDotShapes.push({ shape });
|
|
152357
|
+
return;
|
|
152358
|
+
}
|
|
152359
|
+
if (zoomRatio < RATIO_DOT) {
|
|
152360
|
+
dotShapes.push({ shape, alpha: 200 });
|
|
152361
|
+
return;
|
|
152362
|
+
}
|
|
152363
|
+
if (zoomRatio < RATIO_GEO_FADE) {
|
|
152364
|
+
const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
|
|
152365
|
+
shapeOpacity = t;
|
|
152366
|
+
dotShapes.push({ shape, alpha: Math.round((1 - t) * 200) });
|
|
152367
|
+
}
|
|
152368
|
+
tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(0, (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity);
|
|
152369
|
+
if (zoomRatio >= RATIO_LABEL_FULL) {
|
|
152370
|
+
labelOpacity = shapeOpacity;
|
|
152371
|
+
} else if (zoomRatio >= RATIO_LABEL) {
|
|
152372
|
+
labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
|
|
152373
|
+
}
|
|
152374
|
+
}
|
|
152375
|
+
const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
|
|
152376
|
+
const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
|
|
152377
|
+
const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
|
|
152378
|
+
const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
|
|
152379
|
+
const labelBgProps = shape.labelBackground ? {
|
|
152380
|
+
background: true,
|
|
152381
|
+
getBackgroundColor: textBgColor(strokeColor),
|
|
152382
|
+
backgroundPadding: [3, 1, 3, 2]
|
|
152383
|
+
} : {};
|
|
152384
|
+
const labelProps = { ...labelBgProps };
|
|
152385
|
+
const dashArray = parseDashArray(strokeDashArray);
|
|
152386
|
+
const dashExt = [new PathStyleExtension({ dash: true })];
|
|
152387
|
+
const getDash = dashArray ?? [0, 0];
|
|
152388
|
+
if (type === "rectangle") {
|
|
152389
|
+
const { x, y, width, height, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
152390
|
+
const filled = fillOpacity > 0;
|
|
152391
|
+
const rectPolygon = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];
|
|
152392
|
+
layers.push(new PolygonLayer({
|
|
152393
|
+
...base,
|
|
152394
|
+
id: `annotation-rect-${uid2}-${i2}`,
|
|
152395
|
+
data: [{ polygon: rectPolygon }],
|
|
152396
|
+
getPolygon: (d) => d.polygon,
|
|
152397
|
+
filled,
|
|
152398
|
+
stroked: true,
|
|
152399
|
+
getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
|
|
152400
|
+
getLineColor: strokeColor,
|
|
152401
|
+
getLineWidth: strokeWidth,
|
|
152402
|
+
lineWidthUnits: "pixels",
|
|
152403
|
+
...dashArray ? {
|
|
152404
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152405
|
+
getDashArray: dashArray
|
|
152406
|
+
} : {}
|
|
152407
|
+
}));
|
|
152408
|
+
if (shape.text && labelOpacity > 0) {
|
|
152409
|
+
layers.push(new TextLayer({
|
|
152410
|
+
...labelBase,
|
|
152411
|
+
...labelProps,
|
|
152412
|
+
id: `annotation-rect-text-${uid2}-${i2}`,
|
|
152413
|
+
data: [{ position: [x, y], text: shape.text }],
|
|
152414
|
+
getPosition: (d) => d.position,
|
|
152415
|
+
getText: (d) => d.text,
|
|
152416
|
+
getColor: strokeColor,
|
|
152417
|
+
getSize: LABEL_FONT_SIZE,
|
|
152418
|
+
sizeUnits: "pixels",
|
|
152419
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152420
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
152421
|
+
getPixelOffset: [3, -7],
|
|
152422
|
+
getTextAnchor: "start",
|
|
152423
|
+
getAlignmentBaseline: "bottom"
|
|
152424
|
+
}));
|
|
152425
|
+
}
|
|
152426
|
+
}
|
|
152427
|
+
if (type === "line") {
|
|
152428
|
+
const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape;
|
|
152429
|
+
const dx = x2 - x12;
|
|
152430
|
+
const dy = y2 - y12;
|
|
152431
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
152432
|
+
const ux = len2 > 0 ? dx / len2 : 0;
|
|
152433
|
+
const uy = len2 > 0 ? dy / len2 : 0;
|
|
152434
|
+
const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
|
|
152435
|
+
const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
|
|
152436
|
+
const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
|
|
152437
|
+
const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
|
|
152438
|
+
layers.push(new PathLayer({
|
|
152439
|
+
...base,
|
|
152440
|
+
id: `annotation-line-${uid2}-${i2}`,
|
|
152441
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152442
|
+
getDashArray: dashArray ?? [0, 0],
|
|
152443
|
+
data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
|
|
152444
|
+
getPath: (d) => d.path,
|
|
152445
|
+
getColor: strokeColor,
|
|
152446
|
+
getWidth: strokeWidth,
|
|
152447
|
+
widthUnits: "pixels",
|
|
152448
|
+
capRounded: true
|
|
152449
|
+
}));
|
|
152450
|
+
if (markerEnd === "Arrow" && tipsOpacity > 0) {
|
|
152451
|
+
const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
|
|
152452
|
+
if (head) {
|
|
152453
|
+
layers.push(new PolygonLayer({
|
|
152454
|
+
...tipsBase,
|
|
152455
|
+
id: `annotation-end-arrow-${uid2}-${i2}`,
|
|
152456
|
+
data: [{ polygon: head }],
|
|
152457
|
+
getPolygon: (d) => d.polygon,
|
|
152458
|
+
filled: true,
|
|
152459
|
+
stroked: false,
|
|
152460
|
+
getFillColor: strokeColor
|
|
152461
|
+
}));
|
|
152462
|
+
}
|
|
152463
|
+
}
|
|
152464
|
+
if (markerStart === "Arrow" && tipsOpacity > 0) {
|
|
152465
|
+
const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
|
|
152466
|
+
if (head) {
|
|
152467
|
+
layers.push(new PolygonLayer({
|
|
152468
|
+
...tipsBase,
|
|
152469
|
+
id: `annotation-start-arrow-${uid2}-${i2}`,
|
|
152470
|
+
data: [{ polygon: head }],
|
|
152471
|
+
getPolygon: (d) => d.polygon,
|
|
152472
|
+
filled: true,
|
|
152473
|
+
stroked: false,
|
|
152474
|
+
getFillColor: strokeColor
|
|
152475
|
+
}));
|
|
152476
|
+
}
|
|
152477
|
+
}
|
|
152478
|
+
if (markerEnd === "Tick" && tipsOpacity > 0) {
|
|
152479
|
+
const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
|
|
152480
|
+
if (tick) {
|
|
152481
|
+
layers.push(new PathLayer({
|
|
152482
|
+
...tipsBase,
|
|
152483
|
+
id: `annotation-end-tick-${uid2}-${i2}`,
|
|
152484
|
+
data: [{ path: tick }],
|
|
152485
|
+
getPath: (d) => d.path,
|
|
152486
|
+
getColor: strokeColor,
|
|
152487
|
+
getWidth: strokeWidth,
|
|
152488
|
+
widthUnits: "pixels",
|
|
152489
|
+
capRounded: true
|
|
152490
|
+
}));
|
|
152491
|
+
}
|
|
152492
|
+
}
|
|
152493
|
+
if (markerStart === "Tick" && tipsOpacity > 0) {
|
|
152494
|
+
const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
|
|
152495
|
+
if (tick) {
|
|
152496
|
+
layers.push(new PathLayer({
|
|
152497
|
+
...tipsBase,
|
|
152498
|
+
id: `annotation-start-tick-${uid2}-${i2}`,
|
|
152499
|
+
data: [{ path: tick }],
|
|
152500
|
+
getPath: (d) => d.path,
|
|
152501
|
+
getColor: strokeColor,
|
|
152502
|
+
getWidth: strokeWidth,
|
|
152503
|
+
widthUnits: "pixels",
|
|
152504
|
+
capRounded: true
|
|
152505
|
+
}));
|
|
152506
|
+
}
|
|
152507
|
+
}
|
|
152508
|
+
if (shape.text) {
|
|
152509
|
+
const pos = shape.textPosition ?? "start";
|
|
152510
|
+
let textX;
|
|
152511
|
+
let textY;
|
|
152512
|
+
if (pos === "start") {
|
|
152513
|
+
textX = x12;
|
|
152514
|
+
textY = y12;
|
|
152515
|
+
} else if (pos === "end") {
|
|
152516
|
+
textX = x2;
|
|
152517
|
+
textY = y2;
|
|
152518
|
+
} else {
|
|
152519
|
+
textX = (x12 + x2) / 2;
|
|
152520
|
+
textY = (y12 + y2) / 2;
|
|
152521
|
+
}
|
|
152522
|
+
let pixelOffset = [0, 0];
|
|
152523
|
+
let textAnchor = "middle";
|
|
152524
|
+
let alignmentBaseline = "center";
|
|
152525
|
+
if (pos !== "middle") {
|
|
152526
|
+
const dxT = x2 - x12;
|
|
152527
|
+
const dyT = y2 - y12;
|
|
152528
|
+
const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
|
|
152529
|
+
if (lenT > 0) {
|
|
152530
|
+
const uxT = dxT / lenT;
|
|
152531
|
+
const uyT = dyT / lenT;
|
|
152532
|
+
const sign2 = pos === "start" ? -1 : 1;
|
|
152533
|
+
const bufferPx = shape.textBufferPx ?? 8;
|
|
152534
|
+
const offsetX = sign2 * uxT * bufferPx;
|
|
152535
|
+
const offsetY = sign2 * uyT * bufferPx;
|
|
152536
|
+
pixelOffset = [offsetX, offsetY];
|
|
152537
|
+
const absX = Math.abs(offsetX);
|
|
152538
|
+
const absY = Math.abs(offsetY);
|
|
152539
|
+
if (absX >= absY) {
|
|
152540
|
+
textAnchor = offsetX > 0 ? "start" : "end";
|
|
152541
|
+
}
|
|
152542
|
+
if (absY >= absX) {
|
|
152543
|
+
alignmentBaseline = offsetY > 0 ? "top" : "bottom";
|
|
152544
|
+
}
|
|
152545
|
+
}
|
|
152546
|
+
} else if (len2 > 0) {
|
|
152547
|
+
const belowPerp = pickBelowPerp(ux, uy);
|
|
152548
|
+
const bufferPx = shape.textBufferPx ?? 14;
|
|
152549
|
+
pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
|
|
152550
|
+
textAnchor = "middle";
|
|
152551
|
+
alignmentBaseline = "center";
|
|
152552
|
+
}
|
|
152553
|
+
const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
|
|
152554
|
+
if (labelOpacity <= 0)
|
|
152555
|
+
return;
|
|
152556
|
+
layers.push(new TextLayer({
|
|
152557
|
+
...labelBase,
|
|
152558
|
+
...labelProps,
|
|
152559
|
+
id: `annotation-line-text-${uid2}-${i2}`,
|
|
152560
|
+
data: [{ position: [textX, textY], text: shape.text }],
|
|
152561
|
+
getPosition: (d) => d.position,
|
|
152562
|
+
getText: (d) => d.text,
|
|
152563
|
+
getColor: strokeColor,
|
|
152564
|
+
getSize: LABEL_FONT_SIZE,
|
|
152565
|
+
sizeUnits: "pixels",
|
|
152566
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152567
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
152568
|
+
getPixelOffset: pixelOffset,
|
|
152569
|
+
getTextAnchor: textAnchor,
|
|
152570
|
+
getAlignmentBaseline: alignmentBaseline,
|
|
152571
|
+
...middleAngle !== null && { getAngle: middleAngle }
|
|
152572
|
+
}));
|
|
152573
|
+
}
|
|
152574
|
+
}
|
|
152575
|
+
if (type === "ellipse") {
|
|
152576
|
+
const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
152577
|
+
const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
|
|
152578
|
+
const filled = fillOpacity > 0;
|
|
152579
|
+
layers.push(new PolygonLayer({
|
|
152580
|
+
...base,
|
|
152581
|
+
id: `annotation-ellipse-${uid2}-${i2}`,
|
|
152582
|
+
data: [{ polygon: polygon2 }],
|
|
152583
|
+
getPolygon: (d) => d.polygon,
|
|
152584
|
+
filled,
|
|
152585
|
+
stroked: true,
|
|
152586
|
+
getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
|
|
152587
|
+
getLineColor: strokeColor,
|
|
152588
|
+
getLineWidth: strokeWidth,
|
|
152589
|
+
lineWidthUnits: "pixels",
|
|
152590
|
+
...dashArray ? {
|
|
152591
|
+
extensions: [new PathStyleExtension({ dash: true })],
|
|
152592
|
+
getDashArray: dashArray
|
|
152593
|
+
} : {}
|
|
152594
|
+
}));
|
|
152595
|
+
if (shape.text && labelOpacity > 0) {
|
|
152596
|
+
layers.push(new TextLayer({
|
|
152597
|
+
...labelBase,
|
|
152598
|
+
...labelProps,
|
|
152599
|
+
id: `annotation-ellipse-text-${uid2}-${i2}`,
|
|
152600
|
+
data: [{ position: [x12, y12 - radiusY], text: shape.text }],
|
|
152601
|
+
getPosition: (d) => d.position,
|
|
152602
|
+
getText: (d) => d.text,
|
|
152603
|
+
getColor: strokeColor,
|
|
152604
|
+
getSize: LABEL_FONT_SIZE,
|
|
152605
|
+
sizeUnits: "pixels",
|
|
152606
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152607
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
152608
|
+
getPixelOffset: [0, -4],
|
|
152609
|
+
getTextAnchor: "middle",
|
|
152610
|
+
getAlignmentBaseline: "bottom"
|
|
152611
|
+
}));
|
|
152612
|
+
}
|
|
152613
|
+
}
|
|
152614
|
+
if (type === "polygon") {
|
|
152615
|
+
const { points, fillColor = strokeColor, fillOpacity = 0 } = shape;
|
|
152616
|
+
if (!points || points.length < 3)
|
|
152617
|
+
return;
|
|
152618
|
+
const closedPath = [...points, points[0]];
|
|
152619
|
+
if (fillOpacity > 0) {
|
|
152620
|
+
layers.push(new PolygonLayer({
|
|
152621
|
+
...base,
|
|
152622
|
+
id: `annotation-polygon-fill-${uid2}-${i2}`,
|
|
152623
|
+
data: [{ polygon: points }],
|
|
152624
|
+
getPolygon: (d) => d.polygon,
|
|
152625
|
+
stroked: false,
|
|
152626
|
+
filled: true,
|
|
152627
|
+
getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
|
|
152628
|
+
}));
|
|
152629
|
+
}
|
|
152630
|
+
layers.push(new PathLayer({
|
|
152631
|
+
...base,
|
|
152632
|
+
id: `annotation-polygon-${uid2}-${i2}`,
|
|
152633
|
+
extensions: dashExt,
|
|
152634
|
+
getDashArray: getDash,
|
|
152635
|
+
data: [{ path: closedPath }],
|
|
152636
|
+
getPath: (d) => d.path,
|
|
152637
|
+
getColor: strokeColor,
|
|
152638
|
+
getWidth: strokeWidth,
|
|
152639
|
+
widthUnits: "pixels",
|
|
152640
|
+
jointRounded: true
|
|
152641
|
+
}));
|
|
152642
|
+
if (shape.text && labelOpacity > 0) {
|
|
152643
|
+
const minX = Math.min(...points.map((p) => p[0]));
|
|
152644
|
+
const maxX = Math.max(...points.map((p) => p[0]));
|
|
152645
|
+
const minY = Math.min(...points.map((p) => p[1]));
|
|
152646
|
+
const topCenterX = (minX + maxX) / 2;
|
|
152647
|
+
layers.push(new TextLayer({
|
|
152648
|
+
...labelBase,
|
|
152649
|
+
...labelProps,
|
|
152650
|
+
id: `annotation-polygon-text-${uid2}-${i2}`,
|
|
152651
|
+
data: [{ position: [topCenterX, minY], text: shape.text }],
|
|
152652
|
+
getPosition: (d) => d.position,
|
|
152653
|
+
getText: (d) => d.text,
|
|
152654
|
+
getColor: strokeColor,
|
|
152655
|
+
getSize: LABEL_FONT_SIZE,
|
|
152656
|
+
sizeUnits: "pixels",
|
|
152657
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152658
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
152659
|
+
getPixelOffset: [0, -4],
|
|
152660
|
+
getTextAnchor: "middle",
|
|
152661
|
+
getAlignmentBaseline: "bottom"
|
|
152662
|
+
}));
|
|
152663
|
+
}
|
|
152664
|
+
}
|
|
152665
|
+
if (type === "polyline") {
|
|
152666
|
+
const { points, markerStart, markerEnd } = shape;
|
|
152667
|
+
if (!points || points.length < 2)
|
|
152668
|
+
return;
|
|
152669
|
+
let pathPoints = points;
|
|
152670
|
+
if (markerStart === "Arrow") {
|
|
152671
|
+
const [x02, y02] = points[0];
|
|
152672
|
+
const [x12, y12] = points[1];
|
|
152673
|
+
const dx = x02 - x12;
|
|
152674
|
+
const dy = y02 - y12;
|
|
152675
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
152676
|
+
if (len2 > 0) {
|
|
152677
|
+
const ux = dx / len2;
|
|
152678
|
+
const uy = dy / len2;
|
|
152679
|
+
pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
|
|
152680
|
+
}
|
|
152681
|
+
}
|
|
152682
|
+
if (markerEnd === "Arrow") {
|
|
152683
|
+
const last = pathPoints[pathPoints.length - 1];
|
|
152684
|
+
const prev = pathPoints[pathPoints.length - 2];
|
|
152685
|
+
const dx = last[0] - prev[0];
|
|
152686
|
+
const dy = last[1] - prev[1];
|
|
152687
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
152688
|
+
if (len2 > 0) {
|
|
152689
|
+
const ux = dx / len2;
|
|
152690
|
+
const uy = dy / len2;
|
|
152691
|
+
const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
|
|
152692
|
+
pathPoints = [...pathPoints.slice(0, -1), shortened];
|
|
152693
|
+
}
|
|
152694
|
+
}
|
|
152695
|
+
layers.push(new PathLayer({
|
|
152696
|
+
...base,
|
|
152697
|
+
id: `annotation-polyline-${uid2}-${i2}`,
|
|
152698
|
+
extensions: dashExt,
|
|
152699
|
+
getDashArray: getDash,
|
|
152700
|
+
data: [{ path: pathPoints }],
|
|
152701
|
+
getPath: (d) => d.path,
|
|
152702
|
+
getColor: strokeColor,
|
|
152703
|
+
getWidth: strokeWidth,
|
|
152704
|
+
widthUnits: "pixels",
|
|
152705
|
+
jointRounded: true,
|
|
152706
|
+
capRounded: true
|
|
152707
|
+
}));
|
|
152708
|
+
if (markerStart === "Arrow" && tipsOpacity > 0) {
|
|
152709
|
+
const [x02, y02] = points[0];
|
|
152710
|
+
const [x12, y12] = points[1];
|
|
152711
|
+
const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
|
|
152712
|
+
if (head) {
|
|
152713
|
+
layers.push(new PolygonLayer({
|
|
152714
|
+
...tipsBase,
|
|
152715
|
+
id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
|
|
152716
|
+
data: [{ polygon: head }],
|
|
152717
|
+
getPolygon: (d) => d.polygon,
|
|
152718
|
+
filled: true,
|
|
152719
|
+
stroked: false,
|
|
152720
|
+
getFillColor: strokeColor
|
|
152721
|
+
}));
|
|
152722
|
+
}
|
|
152723
|
+
}
|
|
152724
|
+
if (markerEnd === "Arrow" && tipsOpacity > 0) {
|
|
152725
|
+
const last = points[points.length - 1];
|
|
152726
|
+
const prev = points[points.length - 2];
|
|
152727
|
+
const dxArrow = last[0] - prev[0];
|
|
152728
|
+
const dyArrow = last[1] - prev[1];
|
|
152729
|
+
const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
|
|
152730
|
+
if (head) {
|
|
152731
|
+
layers.push(new PolygonLayer({
|
|
152732
|
+
...tipsBase,
|
|
152733
|
+
id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
|
|
152734
|
+
data: [{ polygon: head }],
|
|
152735
|
+
getPolygon: (d) => d.polygon,
|
|
152736
|
+
filled: true,
|
|
152737
|
+
stroked: false,
|
|
152738
|
+
getFillColor: strokeColor
|
|
152739
|
+
}));
|
|
152740
|
+
}
|
|
152741
|
+
}
|
|
152742
|
+
if (markerStart === "Tick" && tipsOpacity > 0) {
|
|
152743
|
+
const [x02, y02] = points[0];
|
|
152744
|
+
const [x12, y12] = points[1];
|
|
152745
|
+
const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
|
|
152746
|
+
if (tick) {
|
|
152747
|
+
layers.push(new PathLayer({
|
|
152748
|
+
...tipsBase,
|
|
152749
|
+
id: `annotation-polyline-start-tick-${uid2}-${i2}`,
|
|
152750
|
+
data: [{ path: tick }],
|
|
152751
|
+
getPath: (d) => d.path,
|
|
152752
|
+
getColor: strokeColor,
|
|
152753
|
+
getWidth: strokeWidth,
|
|
152754
|
+
widthUnits: "pixels",
|
|
152755
|
+
capRounded: true
|
|
152756
|
+
}));
|
|
152757
|
+
}
|
|
152758
|
+
}
|
|
152759
|
+
if (markerEnd === "Tick" && tipsOpacity > 0) {
|
|
152760
|
+
const last = points[points.length - 1];
|
|
152761
|
+
const prev = points[points.length - 2];
|
|
152762
|
+
const dxTick = last[0] - prev[0];
|
|
152763
|
+
const dyTick = last[1] - prev[1];
|
|
152764
|
+
const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
|
|
152765
|
+
if (tick) {
|
|
152766
|
+
layers.push(new PathLayer({
|
|
152767
|
+
...tipsBase,
|
|
152768
|
+
id: `annotation-polyline-end-tick-${uid2}-${i2}`,
|
|
152769
|
+
data: [{ path: tick }],
|
|
152770
|
+
getPath: (d) => d.path,
|
|
152771
|
+
getColor: strokeColor,
|
|
152772
|
+
getWidth: strokeWidth,
|
|
152773
|
+
widthUnits: "pixels",
|
|
152774
|
+
capRounded: true
|
|
152775
|
+
}));
|
|
152776
|
+
}
|
|
152777
|
+
}
|
|
152778
|
+
if (shape.text) {
|
|
152779
|
+
const pos = shape.textPosition ?? "start";
|
|
152780
|
+
const bufferPx = shape.textBufferPx ?? 8;
|
|
152781
|
+
let textPt;
|
|
152782
|
+
let dirX;
|
|
152783
|
+
let dirY;
|
|
152784
|
+
if (pos === "end") {
|
|
152785
|
+
const last = points[points.length - 1];
|
|
152786
|
+
const prev = points[points.length - 2];
|
|
152787
|
+
textPt = last;
|
|
152788
|
+
dirX = last[0] - prev[0];
|
|
152789
|
+
dirY = last[1] - prev[1];
|
|
152790
|
+
} else if (pos === "middle") {
|
|
152791
|
+
const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
|
|
152792
|
+
const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
|
|
152793
|
+
textPt = [mx, my];
|
|
152794
|
+
dirX = 0;
|
|
152795
|
+
dirY = 0;
|
|
152796
|
+
} else {
|
|
152797
|
+
[textPt] = points;
|
|
152798
|
+
dirX = points[0][0] - points[1][0];
|
|
152799
|
+
dirY = points[0][1] - points[1][1];
|
|
152800
|
+
}
|
|
152801
|
+
const [textX, textY] = textPt;
|
|
152802
|
+
const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
|
|
152803
|
+
let polylinePixelOffset = [0, 0];
|
|
152804
|
+
let polylineTextAnchor = "middle";
|
|
152805
|
+
let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
|
|
152806
|
+
if (lenT > 0) {
|
|
152807
|
+
const uxT = dirX / lenT;
|
|
152808
|
+
const uyT = dirY / lenT;
|
|
152809
|
+
const offX = uxT * bufferPx;
|
|
152810
|
+
const offY = uyT * bufferPx;
|
|
152811
|
+
polylinePixelOffset = [offX, offY];
|
|
152812
|
+
if (Math.abs(offX) >= Math.abs(offY)) {
|
|
152813
|
+
polylineTextAnchor = offX > 0 ? "start" : "end";
|
|
152814
|
+
}
|
|
152815
|
+
if (Math.abs(offY) >= Math.abs(offX)) {
|
|
152816
|
+
polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
|
|
152817
|
+
}
|
|
152818
|
+
}
|
|
152819
|
+
if (labelOpacity <= 0)
|
|
152820
|
+
return;
|
|
152821
|
+
layers.push(new TextLayer({
|
|
152822
|
+
...labelBase,
|
|
152823
|
+
...labelProps,
|
|
152824
|
+
id: `annotation-polyline-text-${uid2}-${i2}`,
|
|
152825
|
+
data: [{ position: [textX, textY], text: shape.text }],
|
|
152826
|
+
getPosition: (d) => d.position,
|
|
152827
|
+
getText: (d) => d.text,
|
|
152828
|
+
getColor: strokeColor,
|
|
152829
|
+
getSize: LABEL_FONT_SIZE,
|
|
152830
|
+
sizeUnits: "pixels",
|
|
152831
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152832
|
+
fontWeight: LABEL_FONT_WEIGHT,
|
|
152833
|
+
getPixelOffset: polylinePixelOffset,
|
|
152834
|
+
getTextAnchor: polylineTextAnchor,
|
|
152835
|
+
getAlignmentBaseline: polylineAlignmentBaseline
|
|
152836
|
+
}));
|
|
152837
|
+
}
|
|
152838
|
+
}
|
|
152839
|
+
});
|
|
152840
|
+
if (dotShapes.length > 0) {
|
|
152841
|
+
layers.push(new ScatterplotLayer({
|
|
152842
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
152843
|
+
id: "annotation-dots",
|
|
152844
|
+
data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
|
|
152845
|
+
position: getShapeCentroid(s2),
|
|
152846
|
+
color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
|
|
152847
|
+
})),
|
|
152848
|
+
getPosition: (d) => d.position,
|
|
152849
|
+
getFillColor: (d) => d.color,
|
|
152850
|
+
getRadius: 4,
|
|
152851
|
+
radiusUnits: "pixels",
|
|
152852
|
+
filled: true,
|
|
152853
|
+
stroked: false
|
|
152854
|
+
}));
|
|
152855
|
+
}
|
|
152856
|
+
if (clusterDotShapes.length > 0) {
|
|
152857
|
+
const clusters = computeClusters(clusterDotShapes, zoom);
|
|
152858
|
+
layers.push(new ScatterplotLayer({
|
|
152859
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
152860
|
+
id: "annotation-clusters",
|
|
152861
|
+
data: clusters,
|
|
152862
|
+
getPosition: (d) => d.position,
|
|
152863
|
+
getFillColor: (d) => [...d.color, 180],
|
|
152864
|
+
getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
|
|
152865
|
+
radiusUnits: "pixels",
|
|
152866
|
+
filled: true,
|
|
152867
|
+
stroked: true,
|
|
152868
|
+
getLineColor: (d) => [...d.color, 220],
|
|
152869
|
+
lineWidthMinPixels: 1.5
|
|
152870
|
+
}));
|
|
152871
|
+
const multiClusters = clusters.filter((c) => c.count > 1);
|
|
152872
|
+
if (multiClusters.length > 0) {
|
|
152873
|
+
layers.push(new TextLayer({
|
|
152874
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
152875
|
+
id: "annotation-cluster-counts",
|
|
152876
|
+
data: multiClusters,
|
|
152877
|
+
getPosition: (d) => d.position,
|
|
152878
|
+
getText: (d) => String(d.count),
|
|
152879
|
+
getColor: [255, 255, 255],
|
|
152880
|
+
getSize: 10,
|
|
152881
|
+
sizeUnits: "pixels",
|
|
152882
|
+
fontWeight: "bold",
|
|
152883
|
+
getTextAnchor: "middle",
|
|
152884
|
+
getAlignmentBaseline: "center"
|
|
152885
|
+
}));
|
|
152886
|
+
}
|
|
152887
|
+
}
|
|
152888
|
+
const measureLayers = [];
|
|
152889
|
+
shapes.forEach((shape) => {
|
|
152890
|
+
if (!shape.showMeasure)
|
|
152891
|
+
return;
|
|
152892
|
+
const mIsSelected = shape.uid === selectedShapeUid;
|
|
152893
|
+
const label = getMeasurementLabel(shape, physicalPixelSize, viewType);
|
|
152894
|
+
if (!label)
|
|
152895
|
+
return;
|
|
152896
|
+
const color = shape.strokeColor ?? [255, 255, 255];
|
|
152897
|
+
let mShapeOpacity = 1;
|
|
152898
|
+
let mLabelFactor = 0;
|
|
152899
|
+
if (mIsSelected || !semanticZoom || authoredZoom === null) {
|
|
152900
|
+
mLabelFactor = 1;
|
|
152901
|
+
} else {
|
|
152902
|
+
const mZoomRatio = 2 ** (zoom - authoredZoom);
|
|
152903
|
+
if (mZoomRatio < RATIO_DOT)
|
|
152904
|
+
return;
|
|
152905
|
+
if (mZoomRatio < RATIO_GEO_FADE) {
|
|
152906
|
+
mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
|
|
152907
|
+
}
|
|
152908
|
+
if (mZoomRatio >= RATIO_LABEL_FULL) {
|
|
152909
|
+
mLabelFactor = 1;
|
|
152910
|
+
} else if (mZoomRatio >= RATIO_LABEL) {
|
|
152911
|
+
mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
|
|
152912
|
+
}
|
|
152913
|
+
}
|
|
152914
|
+
const measureOpacity = mShapeOpacity * mLabelFactor;
|
|
152915
|
+
if (measureOpacity <= 0)
|
|
152916
|
+
return;
|
|
152917
|
+
const base = {
|
|
152918
|
+
coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
152919
|
+
opacity: measureOpacity,
|
|
152920
|
+
getText: (d) => d.text,
|
|
152921
|
+
getPosition: (d) => d.position,
|
|
152922
|
+
getColor: color,
|
|
152923
|
+
getSize: 13,
|
|
152924
|
+
sizeUnits: "pixels",
|
|
152925
|
+
fontFamily: LABEL_FONT_FAMILY,
|
|
152926
|
+
fontWeight: "bold",
|
|
152927
|
+
// 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
|
|
152928
|
+
// instead of deck.gl's default ASCII-only atlas.
|
|
152929
|
+
characterSet: "auto",
|
|
152930
|
+
...shape.measureBackground ? {
|
|
152931
|
+
background: true,
|
|
152932
|
+
getBackgroundColor: textBgColor(color),
|
|
152933
|
+
backgroundPadding: [3, 1, 3, 2]
|
|
152934
|
+
} : {}
|
|
152935
|
+
};
|
|
152936
|
+
if (shape.type === "line") {
|
|
152937
|
+
const mx = ((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2;
|
|
152938
|
+
const my = ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2;
|
|
152939
|
+
const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
|
|
152940
|
+
const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
|
|
152941
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
152942
|
+
if (len2 === 0)
|
|
152943
|
+
return;
|
|
152944
|
+
const perp = pickBelowPerp(dx / len2, dy / len2);
|
|
152945
|
+
const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
152946
|
+
measureLayers.push(new TextLayer({
|
|
152947
|
+
...base,
|
|
152948
|
+
id: `annotation-measure-${shape.uid}`,
|
|
152949
|
+
data: [{ position: [mx, my], text: label }],
|
|
152950
|
+
getAngle: -angle2,
|
|
152951
|
+
getTextAnchor: "middle",
|
|
152952
|
+
getAlignmentBaseline: "center",
|
|
152953
|
+
getPixelOffset: [perp[0] * 16, perp[1] * 16]
|
|
152954
|
+
}));
|
|
152955
|
+
} else if (shape.type === "polyline" && shape.points?.length >= 2) {
|
|
152956
|
+
const pts = shape.points;
|
|
152957
|
+
const mi = Math.floor((pts.length - 1) / 2);
|
|
152958
|
+
const [ax, ay] = pts[mi];
|
|
152959
|
+
const [bx, by] = pts[mi + 1];
|
|
152960
|
+
const dx = bx - ax;
|
|
152961
|
+
const dy = by - ay;
|
|
152962
|
+
const len2 = Math.sqrt(dx * dx + dy * dy);
|
|
152963
|
+
if (len2 === 0)
|
|
152964
|
+
return;
|
|
152965
|
+
const perp = pickBelowPerp(dx / len2, dy / len2);
|
|
152966
|
+
const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
|
|
152967
|
+
measureLayers.push(new TextLayer({
|
|
152968
|
+
...base,
|
|
152969
|
+
id: `annotation-measure-${shape.uid}`,
|
|
152970
|
+
data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
|
|
152971
|
+
getAngle: -angle2,
|
|
152972
|
+
getTextAnchor: "middle",
|
|
152973
|
+
getAlignmentBaseline: "center",
|
|
152974
|
+
getPixelOffset: [perp[0] * 16, perp[1] * 16]
|
|
152975
|
+
}));
|
|
152976
|
+
} else if (shape.type === "rectangle") {
|
|
152977
|
+
const x02 = shape.x ?? 0;
|
|
152978
|
+
const y02 = shape.y ?? 0;
|
|
152979
|
+
const w2 = shape.width ?? 0;
|
|
152980
|
+
const h = shape.height ?? 0;
|
|
152981
|
+
const rx = x02 + (w2 >= 0 ? w2 : 0);
|
|
152982
|
+
const ry = y02 + (h >= 0 ? h : 0);
|
|
152983
|
+
measureLayers.push(new TextLayer({
|
|
152984
|
+
...base,
|
|
152985
|
+
id: `annotation-measure-${shape.uid}`,
|
|
152986
|
+
data: [{ position: [rx, ry], text: label }],
|
|
152987
|
+
getTextAnchor: "end",
|
|
152988
|
+
getAlignmentBaseline: "bottom",
|
|
152989
|
+
getPixelOffset: [-6, -6]
|
|
152990
|
+
}));
|
|
152991
|
+
} else if (shape.type === "ellipse") {
|
|
152992
|
+
const cx = shape.x1 ?? 0;
|
|
152993
|
+
const cy = shape.y1 ?? 0;
|
|
152994
|
+
const ry = Math.abs(shape.radiusY ?? 0);
|
|
152995
|
+
measureLayers.push(new TextLayer({
|
|
152996
|
+
...base,
|
|
152997
|
+
id: `annotation-measure-${shape.uid}`,
|
|
152998
|
+
data: [{ position: [cx, cy + ry], text: label }],
|
|
152999
|
+
getTextAnchor: "middle",
|
|
153000
|
+
getAlignmentBaseline: "top",
|
|
153001
|
+
getPixelOffset: [0, 8]
|
|
153002
|
+
}));
|
|
153003
|
+
} else if (shape.type === "polygon" && shape.points?.length >= 3) {
|
|
153004
|
+
const xs = shape.points.map((p) => p[0]);
|
|
153005
|
+
const ys = shape.points.map((p) => p[1]);
|
|
153006
|
+
const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
|
|
153007
|
+
const maxY = Math.max(...ys);
|
|
153008
|
+
measureLayers.push(new TextLayer({
|
|
153009
|
+
...base,
|
|
153010
|
+
id: `annotation-measure-${shape.uid}`,
|
|
153011
|
+
data: [{ position: [cx, maxY], text: label }],
|
|
153012
|
+
getTextAnchor: "middle",
|
|
153013
|
+
getAlignmentBaseline: "top",
|
|
153014
|
+
getPixelOffset: [0, 8]
|
|
153015
|
+
}));
|
|
153016
|
+
}
|
|
153017
|
+
});
|
|
153018
|
+
return [...selectionLayers, ...layers, ...measureLayers];
|
|
153019
|
+
}
|
|
153020
|
+
const defaultProps = {
|
|
153021
|
+
// Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
|
|
153022
|
+
data: { type: "object", value: [], compare: true },
|
|
153023
|
+
// UID of the shape to highlight with a selection halo.
|
|
153024
|
+
selectedShapeUid: { type: "string", value: null },
|
|
153025
|
+
// { x, y, unit } used to format measurement labels in physical units.
|
|
153026
|
+
physicalPixelSize: { type: "object", value: null, compare: true },
|
|
153027
|
+
// The zoom level at which the shapes were authored (reference for semantic zoom).
|
|
153028
|
+
authoredZoom: { type: "number", value: null },
|
|
153029
|
+
// Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
|
|
153030
|
+
semanticZoom: { type: "boolean", value: true },
|
|
153031
|
+
// The view type in which the layer is rendered (affects measurement label formatting).
|
|
153032
|
+
viewType: { type: "string", value: ViewType$1.SPATIAL },
|
|
153033
|
+
// In-progress shape being drawn, as { type, vertices }.
|
|
153034
|
+
inProgressShape: { type: "object", value: null, compare: true },
|
|
153035
|
+
// Current mouse position (in data coordinates) while drawing.
|
|
153036
|
+
hoverCoord: { type: "array", value: null, compare: true },
|
|
153037
|
+
// Stroke color [r, g, b] of the in-progress shape preview.
|
|
153038
|
+
previewStrokeColor: { type: "color", value: [255, 255, 0] }
|
|
153039
|
+
};
|
|
153040
|
+
class AnnotationLayer extends CompositeLayer {
|
|
153041
|
+
// The semantic zoom and arrowhead sizes depend on the current zoom level,
|
|
153042
|
+
// so the sublayers must also be re-rendered when the viewport changes.
|
|
153043
|
+
// eslint-disable-next-line class-methods-use-this
|
|
153044
|
+
shouldUpdateState({ changeFlags }) {
|
|
153045
|
+
return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
|
|
153046
|
+
}
|
|
153047
|
+
/**
|
|
153048
|
+
* Prefix the sublayer ID with this layer's ID (so that multiple
|
|
153049
|
+
* AnnotationLayers can co-exist), and combine this layer's
|
|
153050
|
+
* opacity with the per-shape opacity of the sublayer.
|
|
153051
|
+
* Note: we avoid getSubLayerProps here, since it would
|
|
153052
|
+
* overwrite the sublayer extensions (e.g., PathStyleExtension)
|
|
153053
|
+
* and opacity values.
|
|
153054
|
+
* @param {object} layer A DeckGL layer instance.
|
|
153055
|
+
* @returns {object} The cloned layer instance.
|
|
153056
|
+
*/
|
|
153057
|
+
wrapSubLayer(layer) {
|
|
153058
|
+
const { id, opacity, pickable, visible } = this.props;
|
|
153059
|
+
return layer.clone({
|
|
153060
|
+
id: `${id}-${layer.id}`,
|
|
153061
|
+
opacity: layer.props.opacity * opacity,
|
|
153062
|
+
pickable,
|
|
153063
|
+
visible
|
|
153064
|
+
});
|
|
153065
|
+
}
|
|
153066
|
+
renderLayers() {
|
|
153067
|
+
const { data, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType, inProgressShape, hoverCoord, previewStrokeColor } = this.props;
|
|
153068
|
+
const zoom = this.context.viewport?.zoom ?? 0;
|
|
153069
|
+
const visibleShapes = (data ?? []).filter((shape) => shape.visible !== false);
|
|
153070
|
+
const annotationLayers = createAnnotationLayers(visibleShapes, zoom, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType);
|
|
153071
|
+
const previewLayer = createPreviewLayer(inProgressShape, hoverCoord, previewStrokeColor.slice(0, 3));
|
|
153072
|
+
return [
|
|
153073
|
+
...annotationLayers,
|
|
153074
|
+
...previewLayer ? [previewLayer] : []
|
|
153075
|
+
].map((layer) => this.wrapSubLayer(layer));
|
|
153076
|
+
}
|
|
153077
|
+
}
|
|
153078
|
+
AnnotationLayer.layerName = "AnnotationLayer";
|
|
153079
|
+
AnnotationLayer.defaultProps = defaultProps;
|
|
151699
153080
|
function filterSelection(loader, selection) {
|
|
151700
153081
|
if (!selection) {
|
|
151701
153082
|
return selection;
|
|
@@ -151709,8 +153090,8 @@ async function getSingleSelectionStats2D({ loader, selection }) {
|
|
|
151709
153090
|
const filteredSelection = filterSelection(loader, selection);
|
|
151710
153091
|
const raster = await data.getRaster({ selection: filteredSelection });
|
|
151711
153092
|
const selectionStats = getChannelStats(raster.data);
|
|
151712
|
-
const { domain, contrastLimits: slider } = selectionStats;
|
|
151713
|
-
return { domain, slider };
|
|
153093
|
+
const { domain, contrastLimits: slider, q1, q3 } = selectionStats;
|
|
153094
|
+
return { domain, slider, q1, q3 };
|
|
151714
153095
|
}
|
|
151715
153096
|
const getSingleSelectionStats = async ({ loader, selection, use3d }) => {
|
|
151716
153097
|
const getStats = getSingleSelectionStats2D;
|
|
@@ -151720,7 +153101,9 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
|
|
|
151720
153101
|
const stats = await Promise.all(selections.map((selection) => getSingleSelectionStats({ loader, selection, use3d })));
|
|
151721
153102
|
const domains = stats.map((stat) => stat.domain);
|
|
151722
153103
|
const sliders = stats.map((stat) => stat.slider);
|
|
151723
|
-
|
|
153104
|
+
const q1s = stats.map((stat) => stat.q1);
|
|
153105
|
+
const q3s = stats.map((stat) => stat.q3);
|
|
153106
|
+
return { domains, sliders, q1s, q3s };
|
|
151724
153107
|
};
|
|
151725
153108
|
function getSourceFromLoader(loader, level) {
|
|
151726
153109
|
const { data } = loader;
|
|
@@ -152344,6 +153727,7 @@ class RasterJsonAsObsSegmentationsLoader extends RasterLoader {
|
|
|
152344
153727
|
}
|
|
152345
153728
|
}
|
|
152346
153729
|
export {
|
|
153730
|
+
AnnotationStoryJsonLoader as A,
|
|
152347
153731
|
BaseDecoder as B,
|
|
152348
153732
|
CellsJsonAsObsEmbeddingLoader as C,
|
|
152349
153733
|
GenesJsonAsObsFeatureMatrixLoader as G,
|