@arcgis/core 5.2.0-next.86 → 5.2.0-next.87
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0993e51d3a9701ed2198.js +1 -0
- package/assets/esri/core/workers/chunks/114ba901fd319ce87dc6.js +1 -0
- package/assets/esri/core/workers/chunks/{3aeb934ebdab1d8c4608.js → 12a3b55195ce3244259d.js} +1 -1
- package/assets/esri/core/workers/chunks/{7c3d46201b11a45f79d0.js → 39c0a3eb6a870953d530.js} +74 -107
- package/assets/esri/core/workers/chunks/3b009c05eaec5a7048a8.js +1 -0
- package/assets/esri/core/workers/chunks/3b376318df4ff8519370.js +1 -0
- package/assets/esri/core/workers/chunks/{a0da026a06de379b8f39.js → 3de20165796fa4f76728.js} +1 -1
- package/assets/esri/core/workers/chunks/414093fa4957d17bf551.js +1 -0
- package/assets/esri/core/workers/chunks/{4ec306e5c11808b96e07.js → 48b31b8534e7bfe42976.js} +1 -1
- package/assets/esri/core/workers/chunks/48f6af09436723f2d861.js +1 -0
- package/assets/esri/core/workers/chunks/5536cee0dfc183584a9b.js +1 -0
- package/assets/esri/core/workers/chunks/6561c01c67db1f4c546e.js +1 -0
- package/assets/esri/core/workers/chunks/68705692335d57522030.js +1 -0
- package/assets/esri/core/workers/chunks/{ed5e9718c4dcad1156f7.js → 6f2a9259240769c7cd6e.js} +1 -1
- package/assets/esri/core/workers/chunks/7b2174b19d06c16715f0.js +1 -0
- package/assets/esri/core/workers/chunks/{b015b8c7a073dbc4a3ad.js → 820c530b8765ecb1f36e.js} +1 -1
- package/assets/esri/core/workers/chunks/830daaca32352da6eebe.js +1 -0
- package/assets/esri/core/workers/chunks/8c2921081ca3e7fd0385.js +1 -0
- package/assets/esri/core/workers/chunks/9407db0584c730591161.js +1 -0
- package/assets/esri/core/workers/chunks/9658b46a7111cda53b0d.js +1 -0
- package/assets/esri/core/workers/chunks/974bcaf2a059b8cfb153.js +1 -0
- package/assets/esri/core/workers/chunks/9c7fc1c97125ea2a7b7e.js +1 -0
- package/assets/esri/core/workers/chunks/9ee6e8a6b9bfda758c21.js +1 -0
- package/assets/esri/core/workers/chunks/b3c518ca8679fbe16ece.js +1 -0
- package/assets/esri/core/workers/chunks/b61b7005edd9ced925e9.js +1 -0
- package/assets/esri/core/workers/chunks/c1a7c475ce0c59ffa75a.js +1 -0
- package/assets/esri/core/workers/chunks/{3da39efc5f68f15c105f.js → c2b2942456f1b10d0e96.js} +1 -1
- package/assets/esri/core/workers/chunks/c5dc2743c7116d0bc0d8.js +1 -0
- package/assets/esri/core/workers/chunks/c68cc3b9c170b8de22dc.js +1 -0
- package/assets/esri/core/workers/chunks/d56603e1d0031f3c5f3b.js +1 -0
- package/assets/esri/core/workers/chunks/e474106292834633e7d4.js +1 -0
- package/assets/esri/core/workers/chunks/{d09491b340af3b779505.js → f988d5a6dcc15fe34797.js} +1 -1
- package/assets/esri/core/workers/chunks/fbd02e8277fe2252ecd2.js +1 -0
- package/assets/esri/themes/base/widgets/_BuildingDisciplinesTree.scss +1 -1
- package/assets/esri/themes/base/widgets/_Daylight.scss +2 -2
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -1
- package/assets/esri/themes/base/widgets/_Sketch.scss +1 -1
- package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +1 -1
- package/assets/esri/themes/base/widgets/_Slider.scss +1 -1
- package/assets/esri/themes/base/widgets/_SnappingControls.scss +1 -1
- package/assets/esri/themes/base/widgets/_TimezonePicker.scss +1 -1
- package/chunks/EmissionComposite.glsl.js +2 -2
- package/chunks/GlobalIllumination.glsl.js +69 -102
- package/chunks/RibbonLine.glsl.js +202 -141
- package/config.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/geometry/operators/projectOperator.d.ts +1 -1
- package/geometry/operators/shapePreservingProjectOperator.d.ts +15 -1
- package/geometry/operators/support/GeographicTransformation.d.ts +4 -3
- package/geometry/operators/support/GeographicTransformationStep.d.ts +2 -1
- package/geometry/operators/support/geographicTransformationUtils.d.ts +22 -15
- package/geometry/operators/types.d.ts +2 -1
- package/geometry/support/convexPolyhedron.js +2 -0
- package/geometry/support/frustum.js +1 -1
- package/kernel.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/support/mediaUtils.js +1 -1
- package/package.json +3 -3
- package/popup/FeatureContentCollection.js +1 -1
- package/support/actions/ActionBase.d.ts +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/polygonUtils.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/state/utils/ropePullUtils.js +2 -0
- package/views/3d/support/ElevationAgnosticVisibility.js +2 -0
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/sphericalTileUtils.js +2 -0
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatCovariance.glsl.js +9 -3
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatEvaluation.glsl.js +5 -8
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +39 -51
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/popupAdapter.js +1 -1
- package/assets/esri/core/workers/chunks/05acc17cb66fa6c08845.js +0 -1
- package/assets/esri/core/workers/chunks/11224af8b037ccbf252c.js +0 -1
- package/assets/esri/core/workers/chunks/17a10916114754f1f216.js +0 -1
- package/assets/esri/core/workers/chunks/1b4e050a3884fc6fa6cf.js +0 -1
- package/assets/esri/core/workers/chunks/2f652b330a9978a68e83.js +0 -1
- package/assets/esri/core/workers/chunks/33d6ca59eeb88e739c81.js +0 -1
- package/assets/esri/core/workers/chunks/3cecf627827f5d9213a9.js +0 -1
- package/assets/esri/core/workers/chunks/40ec85b7813a396ee490.js +0 -1
- package/assets/esri/core/workers/chunks/5903dceb172897e5675b.js +0 -1
- package/assets/esri/core/workers/chunks/5e5a05abcb41915802f6.js +0 -1
- package/assets/esri/core/workers/chunks/62f37d1075390a177ae9.js +0 -1
- package/assets/esri/core/workers/chunks/73cb944b87ffce33bb49.js +0 -1
- package/assets/esri/core/workers/chunks/86de2d1f13915ab7a51d.js +0 -1
- package/assets/esri/core/workers/chunks/9b5e890fb0ab29f3a3f1.js +0 -1
- package/assets/esri/core/workers/chunks/ad29b77843a7d93d9f8a.js +0 -1
- package/assets/esri/core/workers/chunks/b812f817c465c64e8c63.js +0 -1
- package/assets/esri/core/workers/chunks/b94b36581842749863f0.js +0 -1
- package/assets/esri/core/workers/chunks/bc6e488f5fbd50f9f3d0.js +0 -1
- package/assets/esri/core/workers/chunks/c229325f41f10fe7f732.js +0 -1
- package/assets/esri/core/workers/chunks/ca6652c6304ad0e37e8f.js +0 -1
- package/assets/esri/core/workers/chunks/d4d2a0d882fef463e7bc.js +0 -1
- package/assets/esri/core/workers/chunks/da45d9576b8d66131623.js +0 -1
- package/assets/esri/core/workers/chunks/e76662562e03eef52ba4.js +0 -1
- package/assets/esri/core/workers/chunks/f1d0208c6b09c1c4b248.js +0 -1
- package/assets/esri/core/workers/chunks/f3680b71d496839de72c.js +0 -1
|
@@ -25,7 +25,8 @@ export default class GeographicTransformationStep extends GeographicTransformati
|
|
|
25
25
|
*/
|
|
26
26
|
accessor isInverse: boolean;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Returns `true` if the step is usable and equation-based, `false` if the step is grid-based.
|
|
29
|
+
* For `null` and `undefined` values, the usability of the transformation step cannot be determined directly. Use [isTransformationUsable()](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/geographicTransformationUtils/#isTransformationUsable) to determine the usability.
|
|
29
30
|
*
|
|
30
31
|
* @since 5.2
|
|
31
32
|
*/
|
|
@@ -31,16 +31,18 @@ export function isLoaded(): boolean;
|
|
|
31
31
|
export function load(): Promise<void>;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Returns the default
|
|
34
|
+
* Returns the default geographic transformation used to convert a geometry
|
|
35
35
|
* from the input spatial reference to the output spatial reference.
|
|
36
36
|
* The default transformation is used when projecting geometries using the [projectOperator](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/projectOperator/)
|
|
37
37
|
* where the datum transformation is required but not specified in the operator's `geographicTransformation` parameter.
|
|
38
38
|
*
|
|
39
|
+
* By default, only usable transformations are returned.
|
|
40
|
+
*
|
|
39
41
|
* > [!WARNING]
|
|
40
42
|
* >
|
|
41
43
|
* > **Known Limitations**
|
|
42
44
|
* >
|
|
43
|
-
* >
|
|
45
|
+
* > Grid-based datum transformations are not supported in the SDK.
|
|
44
46
|
* > Geographic transformations are returned with their maximum number of [GeographicTransformation.steps](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/GeographicTransformation/#steps).
|
|
45
47
|
* > Currently, the number of steps is limited to 2.
|
|
46
48
|
*
|
|
@@ -49,9 +51,10 @@ export function load(): Promise<void>;
|
|
|
49
51
|
* @param outSpatialReference - The spatial reference to which you are converting the geometries.
|
|
50
52
|
* @param areaOfInterestExtent - An extent used to determine the suitability of the returned transformation.
|
|
51
53
|
* The extent's spatial reference should be the same as `inSpatialReference`.
|
|
52
|
-
* @param returnUnusable -
|
|
54
|
+
* @param returnUnusable - Set `returnUnusable` to `true` to inspect transformation usability before attempting projection.
|
|
55
|
+
* When set to `true`, the function may return an unusable grid-based transformation.
|
|
53
56
|
* @returns Returns the default geographic transformation for the given parameters.
|
|
54
|
-
* If no transformation is required or there are no
|
|
57
|
+
* If no transformation is required or there are no usable transformations, then `null` is returned.
|
|
55
58
|
* @example
|
|
56
59
|
* const cs1 = new SpatialReference({
|
|
57
60
|
* wkid: 4272 //PE_GCS_ED_1950
|
|
@@ -78,26 +81,28 @@ export function load(): Promise<void>;
|
|
|
78
81
|
export function getTransformation(inSpatialReference: SpatialReference, outSpatialReference: SpatialReference, areaOfInterestExtent?: Extent | null, returnUnusable?: boolean): GeographicTransformation | null | undefined;
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
|
-
* Returns a list of all
|
|
82
|
-
* to the
|
|
83
|
-
* most suitable
|
|
84
|
+
* Returns a list of all geographic transformations for converting geometries from the input spatial reference
|
|
85
|
+
* to the output spatial reference. The list is sorted by suitability in descending order, with the
|
|
86
|
+
* most suitable transformation appearing first.
|
|
87
|
+
*
|
|
88
|
+
* By default, only usable transformations are returned.
|
|
84
89
|
*
|
|
85
90
|
* > [!WARNING]
|
|
86
91
|
* >
|
|
87
92
|
* > **Known Limitations**
|
|
88
93
|
* >
|
|
89
|
-
* >
|
|
94
|
+
* > Grid-based datum transformations are not supported in the SDK.
|
|
90
95
|
* > Geographic transformations are returned with their maximum number of [GeographicTransformation.steps](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/support/GeographicTransformation/#steps).
|
|
91
|
-
* >
|
|
96
|
+
* > Currently, number of steps is limited to 2.
|
|
92
97
|
*
|
|
93
98
|
* @param inSpatialReference - The spatial reference that the geometries are currently using.
|
|
94
99
|
* @param outSpatialReference - The spatial reference to which you are converting the geometries to.
|
|
95
100
|
* @param areaOfInterestExtent - An extent used to help pick the correct transform.
|
|
96
101
|
* The extent's spatial reference should be the same as `inSpatialReference`.
|
|
97
|
-
* @param returnUnusable -
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* The list will be empty if the provided extent lies out of the area of use for the input spatial reference, or if no transformation is required, or there are no
|
|
102
|
+
* @param returnUnusable - Set `returnUnusable` to `true` to inspect transformation usability before attempting projection.
|
|
103
|
+
* When set to `true`, the function may return unusable grid-based transformations.
|
|
104
|
+
* @returns Returns an array containing the matching geographic transformations.
|
|
105
|
+
* The list will be empty if the provided extent lies out of the area of use for the input spatial reference, or if no transformation is required, or there are no usable transformations.
|
|
101
106
|
* @example
|
|
102
107
|
* const cs1 = new SpatialReference({
|
|
103
108
|
* wkid: 4272 //PE_GCS_ED_1950
|
|
@@ -129,9 +134,11 @@ export function getTransformation(inSpatialReference: SpatialReference, outSpati
|
|
|
129
134
|
export function getTransformations(inSpatialReference: SpatialReference, outSpatialReference: SpatialReference, areaOfInterestExtent?: Extent | null, returnUnusable?: boolean): GeographicTransformation[];
|
|
130
135
|
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
137
|
+
* Returns `true` if the geographic transformation or transformation step is usable and equation-based, `false` if they are grid-based.
|
|
138
|
+
* If the transform's `isUsable` property is `null` or `undefined`, it will be updated to reflect the usability status.
|
|
133
139
|
*
|
|
134
|
-
* @param transform -
|
|
140
|
+
* @param transform - The geographic transformation or transformation step to check for usability.
|
|
141
|
+
* @returns Returns `true` if the transformation can be used, otherwise returns `false`.
|
|
135
142
|
* @since 5.2
|
|
136
143
|
*/
|
|
137
144
|
export function isTransformationUsable(transform: GeographicTransformation | GeographicTransformationStep): boolean;
|
|
@@ -55,7 +55,8 @@ export interface ProjectOptions {
|
|
|
55
55
|
*/
|
|
56
56
|
areaOfInterestExtent?: Extent | null;
|
|
57
57
|
/**
|
|
58
|
-
* The geographic transformation used to transform the geometries.
|
|
58
|
+
* The equation-based geographic transformation used to transform the geometries.
|
|
59
|
+
* Grid-based transformations are not supported.
|
|
59
60
|
* Specify this parameter to project a geometry when the default transformation is not appropriate for your requirements.
|
|
60
61
|
*
|
|
61
62
|
* @since 5.0
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{signedDistance as t}from"./plane.js";function n(n,r,o=r.length){for(let f=0;f<o;++f){const o=r[f];let e=!0;for(const r of n){if(t(r,o)>0){e=!1;break}}if(e)return!0}return!1}function r(t,n,r){const o={t0:0,t1:1};for(const e of t){if(!f(e,n,r,o))return!1}return o.t0<o.t1}function o(t,n,r,o){const e={t0:0,t1:1};for(const i of n){if(!f(t[i],r,o,e))return!1}return e.t0<e.t1}function f(n,r,o,f){let{t0:e,t1:i}=f;const u=t(n,r),c=t(n,o);if(u>=0&&c>=0)return!1;if(u<0&&c>=0){const t=-u/(c-u);if(t<e)return!1;t<i&&(i=t)}else if(u>=0&&c<0){const t=u/(u-c);if(t>i)return!1;t>e&&(e=t)}return f.t0=e,f.t1=i,!0}export{r as edgeIntersectsPolyhedron,o as edgeIntersectsPolyhedronAtIndices,n as isAnyVertexInPolyhedron};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{ObjectStack as t}from"../../core/ObjectStack.js";import{multiply as r,invert as o}from"../../core/libs/gl-matrix-2/math/mat4.js";import{transformMat4 as n,set as e}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as
|
|
2
|
+
import{ObjectStack as t}from"../../core/ObjectStack.js";import{multiply as r,invert as o}from"../../core/libs/gl-matrix-2/math/mat4.js";import{transformMat4 as n,set as e}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as i}from"../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as c}from"../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as u,width as a,depth as s,height as m}from"./aaBoundingBox.js";import{fromRay as l,fromLineSegmentAndDirection as p,create as b}from"./clipRay.js";import{edgeIntersectsPolyhedronAtIndices as j}from"./convexPolyhedron.js";import{create as g,fromPoints as h,signedDistance as x,clip as M,clipInfinite as v,copy as d}from"./plane.js";import{sm4d as y,sv4d as k}from"./vectorStacks.js";function B(t){return t?[g(t[0]),g(t[1]),g(t[2]),g(t[3]),g(t[4]),g(t[5])]:[g(),g(),g(),g(),g(),g()]}function S(){return[f(),f(),f(),f(),f(),f(),f(),f()]}function w(t,r){for(let o=0;o<N;o++)d(t[o],r[o]);return t}function O(t,n,f,c=W){const u=r(y.get(),n,t);o(u,u);for(let r=0;r<Q;++r){const t=i(k.get(),T[r],u);e(c[r],t[0]/t[3],t[1]/t[3],t[2]/t[3])}P(f,c)}function P(t,r){h(r[4],r[0],r[3],t[0]),h(r[1],r[5],r[6],t[1]),h(r[4],r[5],r[1],t[2]),h(r[3],r[2],r[6],t[3]),h(r[0],r[1],r[2],t[4]),h(r[5],r[4],r[7],t[5])}function R(t,r){return q(t,r.center,r.radius)}function q(t,r,o){for(let n=0;n<N;n++){const e=t[n];if(e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3]>=o)return!1}return!0}function z(t,r,o){for(const n of V)if(A(t[n],r,o))return!0;return!1}function A(t,r,o){for(let n=0;n<o;++n)if(x(t,r[n])<=0)return!1;return!0}function C(t,r,o){const n=u(r,X),e=a(r)/2,f=s(r)/2,i=m(r)/2;return o?E(t,n,e,f,i,o):D(t,n,e,f,i)}function D(t,r,o,n,e){for(let f=0;f<N;f++){const i=t[f];if(i[0]*r[0]+i[1]*r[1]+i[2]*r[2]+i[3]-(Math.abs(i[0])*o+Math.abs(i[1])*n+Math.abs(i[2])*e)>0)return!1}return!0}function E(t,r,o,e,f,i){const c=n(Y,r,i);for(let n=0;n<N;n++){const r=t[n];if(r[0]*c[0]+r[1]*c[1]+r[2]*c[2]+r[3]-(Math.abs(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])*o+Math.abs(r[0]*i[4]+r[1]*i[5]+r[2]*i[6])*e+Math.abs(r[0]*i[8]+r[1]*i[9]+r[2]*i[10])*f)>0)return!1}return!0}function F(t,r){return K(t,l(r,U.get()))}function G(t,r){for(let o=0;o<N;o++){const n=t[o];if(!v(n,r))return!1}return!0}function H(t,r,o){return K(t,p(r,o,U.get()))}function I(t,r,o){return j(t,V,r,o)}function J(t,r){for(let o=0;o<N;o++){if(x(t[o],r)>0)return!1}return!0}function K(t,r){for(let o=0;o<N;o++)if(!M(t[o],r))return!1;return!0}const L={bottom:[5,1,0,4],near:[0,1,2,3],far:[5,4,7,6],right:[1,5,6,2],left:[4,0,3,7],top:[7,3,2,6]},N=6,Q=8,T=[c(-1,-1,-1,1),c(1,-1,-1,1),c(1,1,-1,1),c(-1,1,-1,1),c(-1,-1,1,1),c(1,-1,1,1),c(1,1,1,1),c(-1,1,1,1)],U=new t(b),V=[0,1,2,3,5],W=S(),X=f(),Y=f();export{P as computePlanes,w as copy,B as create,S as createPoints,I as edgeIntersectsFrustum,O as fromMatrix,G as intersectClipRay,H as intersectsLineSegment,J as intersectsPoint,F as intersectsRay,R as intersectsSphere,q as intersectsSphereCenterRadius,C as intersectsTransformedAabb,z as isConvexHullOutsideOfFrustum,N as numPlanes,Q as numPoints,L as planePointIndices};
|
package/kernel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let r,s=e;function i(o){r=o}function t(e){const s=r?.findCredential(e);return s?.token?o(e,"token",s.token):e}s="5.2.0-next.
|
|
2
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let r,s=e;function i(o){r=o}function t(e){const s=r?.findCredential(e);return s?.token?o(e,"token",s.token):e}s="5.2.0-next.87",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,s as fullVersion,r as id,i as setId,e as version};
|
package/layers/LinkChartLayer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import i from"../core/Collection.js";import{deprecated as a}from"../core/deprecate.js";import n from"../core/Error.js";import o from"../core/Logger.js";import{getOrCreateMapValue as s}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as l,isAbortError as h,createAbortError as d}from"../core/promiseUtils.js";import{watch as p,sync as c}from"../core/reactiveUtils.js";import{property as u,subclass as y}from"../core/accessorSupport/decorators.js";import{idToName as g}from"../core/accessorSupport/PropertyOrigin.js";import m from"../geometry/Extent.js";import f from"../geometry/Point.js";import L from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import k from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as C,systemDestinationIdFieldName as T,systemLayoutGeometryFieldName as v,systemAggregationCountFieldName as E}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as N}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as S}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import D from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{getTitleFromServerUrl as x,getUserKGSPrivileges as I,createCapabilitiesFromKnowledgeGraph as _,initializeLayersFromClientData as R}from"./knowledgeGraph/layerUtils.js";import A from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as j,getRelationshipEndNodeIds as P}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as G}from"./mixins/BlendLayer.js";import{OperationalLayer as U}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as F}from"./mixins/ScaleRangeLayer.js";import{url as z}from"./support/commonProperties.js";import{LCChronologicalLayout as O,LCSimpleLayout as B,LCSmartTreeLayout as H,LCRadialTreeLayout as Q,LCHierarchicalLayout as V,LCCommunityLayout as W,LCForceDirectedLayout as $,load as K}from"../libs/linkchartlayout/LinkChartLayout.js";import J from"../linkChart/LayoutSettings.js";import Z from"../linkChart/RootedLayoutSettings.js";import{getCreationDatesForResources as q}from"../linkChart/utils.js";import{fetchKnowledgeGraph as X}from"../rest/knowledgeGraphService.js";import{timeZoneProperty as Y}from"../time/timeZoneUtils.js";let ee=class extends(U(G(F(r(k))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(i.ofType(D)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new m({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(i.ofType(D)),this.type="link-chart",this.userHasEditingPrivileges=!0,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new n("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(p(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),c))}normalizeCtorArgs(e){if(!e)return{};const{url:t,dataPreloadedInLocalCache:i,initializationLinkChartConfig:a}=e;let{title:n}=e;return!n&&e?.url&&(n=x(e.url)),{url:t,title:n,dataPreloadedInLocalCache:i,initializationLinkChartConfig:a}}_initializeLayerProperties(e){const t=new Set;let i=[],a=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new n("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(i=e.knowledgeGraph.dataModel.entityTypes??[],a=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((n,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return o.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),a.push(r)):"entity"===r.type?t.has(s)||(t.add(s),i.push(r)):(o.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(i=e.knowledgeGraph.dataModel.entityTypes??[],a=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new S({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=i,this.memberRelationshipTypes=a,this.dataManager=s}load(e){const i=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await R(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(i=>{t.push(i.refreshCachedQueryEngine()),e.push(new Promise(e=>{i.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(a=>{X(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const o=this.linkChart?.linkChartProperties;6===o?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,q([o.entitiesUrl??"",o.relationshipsUrl??""],this.linkChart?.portalItem?.itemUrl??"").then(e=>{this.linkChart?.linkChartProperties?.setCreationDatesForResources?.(e)},()=>{}),this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:o?.entitiesUrl,relationshipsUrl:o?.relationshipsUrl},{signal:e?.signal}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:o?.layoutSettings??void 0,layoutMode:j(o.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}));const{edit:r,fullEdit:h,updateItem:d}=await I(n.serviceDefinition.serviceItemId,this.url,e);if(this._set("userHasEditingPrivileges",r),this._set("userHasFullEditingPrivileges",h),this._set("userHasUpdateItemPrivileges",d),this.read({dateFieldsTimeReference:n.serviceDefinition.dateFieldsTimeReference},{origin:"service"}),this.dataPreloadedInLocalCache){const e=A.getInstance();for(const[t,i]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const a of i.members?.values()??[]){const i=e.readFromStoreById(`${t}__${a.id}`);if(i){s(this.dataManager.sublayerCaches,t,()=>new Map).set(a.id,i)}}await i()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{l(e),await i()}))}a(null)})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):o.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}get sublayerCapabilities(){return _(this.knowledgeGraph)}async addRecords(e,t){let i=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(i=await P(e,this.dataManager.knowledgeGraph));const a=e.concat(i).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));a.length>0&&(this.membershipModified=!0),await this._handleNewRecords(a,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new n("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new n("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),s(this.sublayerIdsCache,e,()=>new Set);const i=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),i.geometryType?this.layers.push(i):this.tables.push(i),await R(this,[e]),this._refreshNamedTypes(),i}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:i=!1,overrideMembershipCheck:a=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const l of e)(a||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(l.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(l.typeName)?.members?.has(l.id))&&n.push(l);if(t){const e=new Set,t=[];for(const i of n)if(this.dataManager.nodeConnectionsLookup.has(i.id))for(const t of this.dataManager.nodeConnectionsLookup.get(i.id))e.add(t);for(const i of e)if(this.dataManager.memberIdTypeLookup.has(i))for(const e of this.dataManager.memberIdTypeLookup.get(i))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:i,typeName:e});n=n.concat(t)}const o=this._currentLinkChartConfig.layoutSettings?.rootedLayoutSettings?.rootEntities;if(o?.length){const e=new Set(n.map(({id:e})=>e)),t=o.filter(({id:t})=>!e.has(t));if(t.length!==o.length){this._currentLinkChartConfig.layoutSettings.rootedLayoutSettings.rootEntities=t;const e=this.linkChart?.linkChartProperties;e?.layoutSettings?.rootedLayoutSettings&&(e.layoutSettings.rootedLayoutSettings.rootEntities=t)}}this.dataManager.removeFromLayer(n);for(const l of n)this.sublayerIdsCache.get(l.typeName)?.delete(l.id),this.dataManager.relationshipTypeNames.has(l.typeName)?this.relationshipLinkChartDiagramLookup.delete(l.id):this.entityLinkChartDiagramLookup.delete(l.id);const s=i?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedEntityLocations:s}),n.length>0&&(this.membershipModified=!0);const r=[];return this.layers.forEach(e=>{r.push(e.refreshCachedQueryEngine())}),await Promise.all(r),this._refreshNamedTypes(),n}async expand(e,t){let i=[];try{const a=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);i=a.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(i,t),a.length>0&&(this.membershipModified=!0),l(t?.signal)}catch(a){throw h(a)&&i.length>0&&await this.removeRecords(i,{overrideMembershipCheck:!0}),a}return{records:i}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new i,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new i,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const i=s(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:a})=>{if(i.add(e),a){const i="coords"in a&&"lengths"in a?a:b(a);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,i):this.entityLinkChartDiagramLookup.set(e,i)}})})}async calculateLinkChartLayout(e="organic-standard",t){const i=[],a=[],r=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{i.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{a.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const h=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(i.length),g=new Float64Array(i.length),k=new Float64Array(i.length),N=new Float64Array(i.length),S=new Float64Array(i.length),D=new Uint32Array(a.length),x=new Uint32Array(a.length),I=new Float64Array(a.length),_=new Float64Array(a.length),R=[],A="organic-standard";let j=!1;const P=new m({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let G,U="organic-standard",F=0,z=0;const J=O.apply;switch(U="geographic-organic-standard"===e?A:e,U){case"organic-standard":G=$.apply;break;case"organic-community":G=W.apply;break;case"hierarchical-bottom-to-top":G=V.apply;break;case"radial-root-centric":G=Q.apply;break;case"tree-left-to-right":G=H.apply;break;default:G=B.apply}let Z=!1;const q=new Set(t?.layoutSettings?.rootedLayoutSettings?.rootEntities?.map(({id:e})=>e));i.forEach(({typeName:i,feature:a})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedEntityLocations?.has(a.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(i)?y[F]=2:y[F]=0;const n=t.lockedEntityLocations.get(a.attributes[M]);g[F]=n.x,k[F]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(i)){y[F]=2;let e=null;const t=a.attributes[this.dataManager.geographicLookup.get(i).name],n=this.dataManager.geographicLookup.get(i)?.geometryType;switch(n){case"esriGeometryPoint":g[F]=t?.x,k[F]=t?.y;break;case"esriGeometryPolygon":{const i=t?w(t):null;e=i?f.fromJSON(i):null,null!=e?.x&&null!=e?.y?(g[F]=e.x,k[F]=e.y):y[F]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(g[F]=e.x,k[F]=e.y):y[F]=1;break;default:y[F]=1}(null==g[F]||null==k[F]||Number.isNaN(g[F])||Number.isNaN(k[F]))&&(y[F]=1,g[F]=0,k[F]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!Z&&t?.lockedEntityLocations?.has(a.attributes[M])&&(Z=!0);const e=t?.timeInfoByTypeName?.get(i),n=e?.startField,o=n&&e?.startField?a.attributes[n]:null;N[F]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?a.attributes[s]:null;S[F]=r?new Date(r).getTime():NaN,g[F]=0,k[F]=0,y[F]=1}else y[F]=1,g[F]=0,k[F]=0;q.has(a.attributes[M])&&(y[F]|=4),u.set(a.attributes[M],F),R[F]={feature:a,typeName:i},F++}),Z&&o.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;a.forEach(i=>{const a=i.feature.attributes[C],n=i.feature.attributes[T],o=u.get(a),s=u.get(n),l=t?.timeInfoByTypeName?.get(i.typeName),h=t?.timeInfoByTypeName?l?.startField:null,d=h?i.feature.attributes[h]:null,p=l?.endField,c=p?i.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=a+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const l=Y.get(t),h=l?.has(i.typeName);h||(D[z]=o,x[z]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(I[z]=d?new Date(d).getTime():NaN,_[z]=c?new Date(c).getTime():NaN),void 0===l?Y.set(t,new Map([[i.typeName,z]])):l.set(i.typeName,z),z++),r.push(i)}else X=!0,this.relationshipLinkChartDiagramLookup.set(a,null)}),X&&o.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const ee=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),te=this._convertValidatedOrganicSettingsToCalculationSettings(ee);await K();let ie=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let i;({status:ie,links:ae,graphics:i}=J(()=>t?.signal?.aborted??!1,y,g,k,N,S,D.subarray(0,z),x.subarray(0,z),I.subarray(0,z),_.subarray(0,z),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===ie&&(this.chronologicalAuxiliaryGraphics=i)}else({status:ie,links:ae}=G(()=>t?.signal?.aborted??!1,y,g,k,D.subarray(0,z),x.subarray(0,z),te.computationBudgetTime,te.idealEdgeLengthMultiplier,te.repulsionRadiusMultiplier));if(l(t?.signal),1===ie)throw new n("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===ie)throw d();for(let n=0;n<R.length;n++){if(k[n]>84.9999?k[n]=84.9999:k[n]<-84.9999&&(k[n]=-84.9999),g[n]>179.9999?g[n]=179.9999:g[n]<-179.9999&&(g[n]=-179.9999),R[n].feature.attributes[v]=new f(g[n],k[n]),h.has(R[n].typeName)){const e=h.get(R[n].typeName);e?.set(R[n].feature.attributes[M],R[n].feature)}else{const e=new Map;e.set(R[n].feature.attributes[M],R[n].feature),h.set(R[n].typeName,e)}c.set(R[n].feature.attributes[M],R[n].feature);const e=b(R[n].feature.attributes[v]);this.entityLinkChartDiagramLookup.set(R[n].feature.attributes[M],R[n].feature.attributes[v]?e:null);const t=s(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,R[n].typeName,()=>({useAllData:!1,members:new Map}));s(t.members,R[n].feature.attributes[M],()=>({id:R[n].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=R[n].feature.attributes[v];const{x:i,y:a}=R[n].feature.attributes[v];if(j)P.xmin=Math.min(P.xmin,i),P.xmax=Math.max(P.xmax,i),P.ymin=Math.min(P.ymin,a),P.ymax=Math.max(P.ymax,a);else{const e=1e-7;P.xmin=i-e,P.xmax=i+e,P.ymin=a-e,P.ymax=a+e,j=!0}}if(this.linkChartExtent.xmin=P.xmin,this.linkChartExtent.xmax=P.xmax,this.linkChartExtent.ymin=P.ymin,this.linkChartExtent.ymax=P.ymax,!ae)throw new n("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ne=new Map,oe=new Map,se=new Map,re=new Set;for(let n=0;n<r.length;n++){const i=[],a=r[n],l=a.feature.attributes[C],h=a.feature.attributes[T];let d=l+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(a.typeName),i=t?.timeInfoByTypeName?e?.startField:null,n=i?a.feature.attributes[i]:null,o=e?.endField;d+="-"+n+"-"+(o?a.feature.attributes[o]:null)}const y=Y.get(d).get(a.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!re.has(y)){if(re.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],a=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[a[0]-e[0],a[1]-e[1]],o=[a[0]+n[1],a[1]-n[0]],s=[a[0]-n[1],a[1]+n[0]];i.push(e),i.push(o),i.push(t),i.push(s),i.push(e)}else{if(0!==ae.types[y]){o.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)i.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=R[u.get(l)]?.feature.attributes[v],t=R[u.get(h)]?.feature.attributes[v];i[0][0]===e.x&&i[0][1]===e.y||(i[0]=[e.x,e.y]),i[i.length-1][0]===t.x&&i[i.length-1][1]===t.y||(i[i.length-1]=[t.x,t.y])}for(let e=1;e<i.length-1;e++)i[e][1]>85.5?i[e][1]=85.5:i[e][1]<-85.5&&(i[e][1]=-85.5),i[e][0]>179.9999?i[e][0]=179.9999:i[e][0]<-179.9999&&(i[e][0]=-179.9999);ne.has(d)?ne.get(d).push(i):ne.set(d,[i])}const m=ne.get(d);oe.has(d)||(oe.set(d,new Map),se.set(d,new Map));const f=oe.get(d),w=se.get(d);f.has(a.typeName)||(f.set(a.typeName,m.shift()),w.set(a.typeName,0));const k=f.get(a.typeName);w.set(a.typeName,w.get(a.typeName)+1);const E=new L({paths:[k]});if(a.feature.attributes[v]=E,p.has(a.typeName)){const e=p.get(a.typeName);e?.set(a.feature.attributes[M],a.feature)}else{const e=new Map;e.set(a.feature.attributes[M],a.feature),p.set(a.typeName,e)}c.set(a.feature.attributes[M],a.feature);const N=b(a.feature.attributes[v]);this.relationshipLinkChartDiagramLookup.set(a.feature.attributes[M],a.feature.attributes[v]?N:null);const S=s(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,a.typeName,()=>({useAllData:!1,members:new Map}));s(S.members,a.feature.attributes[M],()=>({id:a.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=N}for(const n of r)n.feature.attributes[E]=se.get(n.feature.attributes[C]+"-"+n.feature.attributes[T])?.get(n.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:h,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){let{lockedNodeLocations:i,lockedEntityLocations:n,rootEntityIds:s,...r}=t??{};!n&&i?(a(o.getLogger(this),"lockedNodeLocations is deprecated in 5.0. Use lockedEntityLocations instead.",{replacement:"Use lockedEntityLocations instead.",version:"5.0"}),n=i):n&&i&&a(o.getLogger(this),"Both lockedNodeLocations (deprecated in 5.0) and lockedEntityLocations are defined. Use lockedEntityLocations only instead.",{replacement:"Use lockedEntityLocations instead.",version:"5.0"});const l=r.layoutSettings?.rootedLayoutSettings?.rootEntities;if(!l&&s){a(o.getLogger(this),"rootEntityIds is deprecated in 5.1. Use layoutSettings.rootedLayoutSettings.rootEntities instead.",{replacement:"Use layoutSettings.rootedLayoutSettings.rootEntities instead.",version:"5.1"});const e=[];for(const t of s){const i=this.dataManager.memberIdTypeLookup.get(t),a=Array.from(i??[]).find(e=>this.dataManager.entityTypeNames.has(e));a&&e.push({id:t,typeName:a})}r.layoutSettings=r.layoutSettings??new J,r.layoutSettings.rootedLayoutSettings=r.layoutSettings.rootedLayoutSettings??new Z,r.layoutSettings.rootedLayoutSettings.rootEntities=e}else l&&s&&a(o.getLogger(this),"Both rootEntityIds (deprecated in 5.1) and layoutSettings.rootedLayoutSettings.rootEntities are defined. Use layoutSettings.rootedLayoutSettings.rootEntities only instead.",{replacement:"Use layoutSettings.rootedLayoutSettings.rootEntities instead.",version:"5.1"});const h=[];await this._calculateLayoutWithSublayerTimeInfo(e,{...r,lockedEntityLocations:n}),this.layers.forEach(e=>{h.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(h),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,i]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||i?.members?.forEach(t=>{const i=t.linkChartLocation;let a;const n=t.id;i&&(a="x"in i?{x:i.x,y:i.y}:{x:i.coords[0],y:i.coords[1]},e.set(n,new f({x:a.x,y:a.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let i=[];try{let a=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(a=a.concat(Array.from(t.keys())))}i=await this.dataManager.getRelationshipsBetweenNodes(e,a,t),await this._handleNewRecords(i,t),l(t)}catch(a){throw h(a)&&this.removeRecords(i),a}return{records:i}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let i=[];try{let a=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(a=a.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}i=await this.dataManager.getRelationshipsFromNodes(e,n,a,t),await this._handleNewRecords(i,t),i.length>0&&(this.membershipModified=!0),l(t)}catch(a){throw h(a)&&this.removeRecords(i),a}return{records:i}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const i=new Map;this.layers.forEach(e=>{i.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:i,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const i=new Set,a=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),i.add(r.typeName));s(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),a.push(r)}this.dataManager.addToLayer(a);for(const s of i){const e=this._graphTypeLookup.get(s);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(s):this.dataManager.relationshipTypeNames.add(s),t.geometryType?this.layers.push(t):this.tables.push(t)}}await R(this,Array.from(i),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const o={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedEntityLocations:new Map};for(const[s,r]of this.entityLinkChartDiagramLookup.entries())r&&o.lockedEntityLocations.set(s,new f(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,o)}_createSublayers(e,t,i){e.forEach(e=>{const a=this._createSublayer(e);i(a)&&t.push(a),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const i=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);i&&(t.objectType=i,t.read({title:i.name},{origin:"service"}),this._updateSublayerCaches(i))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const i=e.linkChartLocation;let a;const n=e.id;if(!i)return;a="x"in i?{x:i.x,y:i.y}:{x:i.coords[0],y:i.coords[1]};const o=b(a);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>a.x&&(this.linkChartExtent.xmin=a.x),this.linkChartExtent.xmax<a.x&&(this.linkChartExtent.xmax=a.x),this.linkChartExtent.ymin>a.y&&(this.linkChartExtent.ymin=a.y),this.linkChartExtent.ymax<a.y&&(this.linkChartExtent.ymax=a.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]),i=this.relationshipLinkChartDiagramLookup.get(e.attributes[T]);if(t&&i){const a=b(new L({paths:[[[t.coords[0],t.coords[1]],[i.coords[0],i.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],a)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedEntityLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedEntityLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const i=e=>"number"==typeof e&&!isNaN(e),a=e=>i(e)&&e>=1,n=e=>i(e)&&e>=1,s=e=>Object.values(N).includes(e),r=e=>i(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return n(h)?l.computationBudgetTime=h:h&&o.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&a(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,o.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&o.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?o.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&o.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===N.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===N.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new D({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){if(t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e){const t=[];e.forEach(e=>{e.parent=this,t.push(this._createVisibleRefreshHandle(e))}),this.addHandles([...t,e.on("after-add",({item:e})=>{e.parent=this,this.addHandles(this._createVisibleRefreshHandle(e),"sublayers-owner")}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner")}}_createVisibleRefreshHandle(e){return p(()=>e.visible,(t,i)=>{!0===t&&!1===i&&e.emit("refresh",{dataChanged:!0})})}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),a=new Set((e.entityTypes??[]).map(e=>e.name)),n=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const i of this.layers)!i.graphType&&t.has(i.graphTypeName)&&(i.graphType=a.has(i.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?a.has(e.graphTypeName):n.has(e.graphTypeName)));this.setAtOrigin("layers",e,g(this.originIdOf("layers")))}else this.layers=new i;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],i=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of i)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const a=[];for(const n of this._originalInclusionList.namedTypeDefinitions.keys())i.includes(n)||(o.getLogger(this).warn(`A named type, ${n}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),a.push(n));for(const n of a)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([u(z)],ee.prototype,"url",void 0),e([u()],ee.prototype,"dataPreloadedInLocalCache",void 0),e([u()],ee.prototype,"initializationLinkChartConfig",void 0),e([u()],ee.prototype,"membershipModified",void 0),e([u()],ee.prototype,"dataManager",void 0),e([u()],ee.prototype,"initializationInclusionModeDefinition",null),e([u()],ee.prototype,"knowledgeGraph",void 0),e([u({type:i.ofType(D),json:{write:{ignoreOrigin:!0}}})],ee.prototype,"layers",void 0),e([u({readOnly:!0})],ee.prototype,"linkChart",null),e([u()],ee.prototype,"entityLinkChartDiagramLookup",void 0),e([u()],ee.prototype,"relationshipLinkChartDiagramLookup",void 0),e([u()],ee.prototype,"linkChartExtent",void 0),e([u()],ee.prototype,"memberEntityTypes",void 0),e([u()],ee.prototype,"memberRelationshipTypes",void 0),e([u({type:["LinkChartLayer"]})],ee.prototype,"operationalLayerType",void 0),e([u()],ee.prototype,"sublayerCapabilities",null),e([u()],ee.prototype,"sublayerIdsCache",void 0),e([u({type:i.ofType(D),json:{write:{ignoreOrigin:!0}}})],ee.prototype,"tables",void 0),e([u({json:{read:!1}})],ee.prototype,"type",void 0),e([u({readOnly:!0})],ee.prototype,"userHasEditingPrivileges",void 0),e([u({readOnly:!0})],ee.prototype,"userHasFullEditingPrivileges",void 0),e([u({readOnly:!0})],ee.prototype,"userHasUpdateItemPrivileges",void 0),e([u({json:{read:!1}})],ee.prototype,"chronologicalAuxiliaryGraphics",void 0),e([u(Y("dateFieldsTimeReference"))],ee.prototype,"dateFieldsTimeZone",void 0),ee=e([y("esri.layers.LinkChartLayer")],ee);const te=ee;export{te as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import i from"../core/Collection.js";import{deprecated as a}from"../core/deprecate.js";import n from"../core/Error.js";import o from"../core/Logger.js";import{getOrCreateMapValue as s}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as l,isAbortError as h,createAbortError as d}from"../core/promiseUtils.js";import{watch as p,sync as c}from"../core/reactiveUtils.js";import{property as u,subclass as y}from"../core/accessorSupport/decorators.js";import{idToName as g}from"../core/accessorSupport/PropertyOrigin.js";import m from"../geometry/Extent.js";import f from"../geometry/Point.js";import L from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import k from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as C,systemDestinationIdFieldName as T,systemLayoutGeometryFieldName as v,systemAggregationCountFieldName as E}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as N}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as S}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import D from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{getTitleFromServerUrl as x,getUserKGSPrivileges as I,createCapabilitiesFromKnowledgeGraph as _,initializeLayersFromClientData as R}from"./knowledgeGraph/layerUtils.js";import A from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as j,getRelationshipEndNodeIds as P}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as G}from"./mixins/BlendLayer.js";import{OperationalLayer as U}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as F}from"./mixins/ScaleRangeLayer.js";import{url as z}from"./support/commonProperties.js";import{LCChronologicalLayout as O,LCSimpleLayout as B,LCSmartTreeLayout as H,LCRadialTreeLayout as Q,LCHierarchicalLayout as V,LCCommunityLayout as W,LCForceDirectedLayout as $,load as K}from"../libs/linkchartlayout/LinkChartLayout.js";import J from"../linkChart/LayoutSettings.js";import Z from"../linkChart/RootedLayoutSettings.js";import{getCreationDatesForResources as q}from"../linkChart/utils.js";import{fetchKnowledgeGraph as X}from"../rest/knowledgeGraphService.js";import{timeZoneProperty as Y}from"../time/timeZoneUtils.js";let ee=class extends(U(G(F(r(k))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(i.ofType(D)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new m({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(i.ofType(D)),this.type="link-chart",this.userHasEditingPrivileges=!0,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new n("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(p(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),c))}normalizeCtorArgs(e){if(!e)return{};const{url:t,dataPreloadedInLocalCache:i,initializationLinkChartConfig:a}=e;let{title:n}=e;return!n&&e?.url&&(n=x(e.url)),{url:t,title:n,dataPreloadedInLocalCache:i,initializationLinkChartConfig:a}}_initializeLayerProperties(e){const t=new Set;let i=[],a=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new n("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(i=e.knowledgeGraph.dataModel.entityTypes??[],a=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((n,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return o.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),a.push(r)):"entity"===r.type?t.has(s)||(t.add(s),i.push(r)):(o.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(i=e.knowledgeGraph.dataModel.entityTypes??[],a=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new S({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=i,this.memberRelationshipTypes=a,this.dataManager=s}load(e){const i=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await R(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(i=>{t.push(i.refreshCachedQueryEngine()),e.push(new Promise(e=>{i.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(a=>{X(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const o=this.linkChart?.linkChartProperties;6===o?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,q([o.entitiesUrl??"",o.relationshipsUrl??""],this.linkChart?.portalItem?.itemUrl??"").then(e=>{this.linkChart?.linkChartProperties?.setCreationDatesForResources?.(e)},()=>{}),this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:o?.entitiesUrl,relationshipsUrl:o?.relationshipsUrl},{signal:e?.signal}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:o?.layoutSettings??void 0,layoutMode:j(o.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}));const{edit:r,fullEdit:h,updateItem:d}=await I(n.serviceDefinition.serviceItemId,this.url,e);if(this._set("userHasEditingPrivileges",r),this._set("userHasFullEditingPrivileges",h),this._set("userHasUpdateItemPrivileges",d),this.read({dateFieldsTimeReference:n.serviceDefinition.dateFieldsTimeReference},{origin:"service"}),this.dataPreloadedInLocalCache){const e=A.getInstance();for(const[t,i]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const a of i.members?.values()??[]){const i=e.readFromStoreById(`${t}__${a.id}`);if(i){s(this.dataManager.sublayerCaches,t,()=>new Map).set(a.id,i)}}await i()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{l(e),await i()}))}a(null)}).catch(()=>{})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):o.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}get sublayerCapabilities(){return _(this.knowledgeGraph)}async addRecords(e,t){let i=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(i=await P(e,this.dataManager.knowledgeGraph));const a=e.concat(i).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));a.length>0&&(this.membershipModified=!0),await this._handleNewRecords(a,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new n("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new n("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),s(this.sublayerIdsCache,e,()=>new Set);const i=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),i.geometryType?this.layers.push(i):this.tables.push(i),await R(this,[e]),this._refreshNamedTypes(),i}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:i=!1,overrideMembershipCheck:a=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const l of e)(a||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(l.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(l.typeName)?.members?.has(l.id))&&n.push(l);if(t){const e=new Set,t=[];for(const i of n)if(this.dataManager.nodeConnectionsLookup.has(i.id))for(const t of this.dataManager.nodeConnectionsLookup.get(i.id))e.add(t);for(const i of e)if(this.dataManager.memberIdTypeLookup.has(i))for(const e of this.dataManager.memberIdTypeLookup.get(i))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:i,typeName:e});n=n.concat(t)}const o=this._currentLinkChartConfig.layoutSettings?.rootedLayoutSettings?.rootEntities;if(o?.length){const e=new Set(n.map(({id:e})=>e)),t=o.filter(({id:t})=>!e.has(t));if(t.length!==o.length){this._currentLinkChartConfig.layoutSettings.rootedLayoutSettings.rootEntities=t;const e=this.linkChart?.linkChartProperties;e?.layoutSettings?.rootedLayoutSettings&&(e.layoutSettings.rootedLayoutSettings.rootEntities=t)}}this.dataManager.removeFromLayer(n);for(const l of n)this.sublayerIdsCache.get(l.typeName)?.delete(l.id),this.dataManager.relationshipTypeNames.has(l.typeName)?this.relationshipLinkChartDiagramLookup.delete(l.id):this.entityLinkChartDiagramLookup.delete(l.id);const s=i?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedEntityLocations:s}),n.length>0&&(this.membershipModified=!0);const r=[];return this.layers.forEach(e=>{r.push(e.refreshCachedQueryEngine())}),await Promise.all(r),this._refreshNamedTypes(),n}async expand(e,t){let i=[];try{const a=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);i=a.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(i,t),a.length>0&&(this.membershipModified=!0),l(t?.signal)}catch(a){throw h(a)&&i.length>0&&await this.removeRecords(i,{overrideMembershipCheck:!0}),a}return{records:i}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new i,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new i,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const i=s(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:a})=>{if(i.add(e),a){const i="coords"in a&&"lengths"in a?a:b(a);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,i):this.entityLinkChartDiagramLookup.set(e,i)}})})}async calculateLinkChartLayout(e="organic-standard",t){const i=[],a=[],r=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{i.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{a.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const h=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(i.length),g=new Float64Array(i.length),k=new Float64Array(i.length),N=new Float64Array(i.length),S=new Float64Array(i.length),D=new Uint32Array(a.length),x=new Uint32Array(a.length),I=new Float64Array(a.length),_=new Float64Array(a.length),R=[],A="organic-standard";let j=!1;const P=new m({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let G,U="organic-standard",F=0,z=0;const J=O.apply;switch(U="geographic-organic-standard"===e?A:e,U){case"organic-standard":G=$.apply;break;case"organic-community":G=W.apply;break;case"hierarchical-bottom-to-top":G=V.apply;break;case"radial-root-centric":G=Q.apply;break;case"tree-left-to-right":G=H.apply;break;default:G=B.apply}let Z=!1;const q=new Set(t?.layoutSettings?.rootedLayoutSettings?.rootEntities?.map(({id:e})=>e));i.forEach(({typeName:i,feature:a})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedEntityLocations?.has(a.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(i)?y[F]=2:y[F]=0;const n=t.lockedEntityLocations.get(a.attributes[M]);g[F]=n.x,k[F]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(i)){y[F]=2;let e=null;const t=a.attributes[this.dataManager.geographicLookup.get(i).name],n=this.dataManager.geographicLookup.get(i)?.geometryType;switch(n){case"esriGeometryPoint":g[F]=t?.x,k[F]=t?.y;break;case"esriGeometryPolygon":{const i=t?w(t):null;e=i?f.fromJSON(i):null,null!=e?.x&&null!=e?.y?(g[F]=e.x,k[F]=e.y):y[F]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(g[F]=e.x,k[F]=e.y):y[F]=1;break;default:y[F]=1}(null==g[F]||null==k[F]||Number.isNaN(g[F])||Number.isNaN(k[F]))&&(y[F]=1,g[F]=0,k[F]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!Z&&t?.lockedEntityLocations?.has(a.attributes[M])&&(Z=!0);const e=t?.timeInfoByTypeName?.get(i),n=e?.startField,o=n&&e?.startField?a.attributes[n]:null;N[F]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?a.attributes[s]:null;S[F]=r?new Date(r).getTime():NaN,g[F]=0,k[F]=0,y[F]=1}else y[F]=1,g[F]=0,k[F]=0;q.has(a.attributes[M])&&(y[F]|=4),u.set(a.attributes[M],F),R[F]={feature:a,typeName:i},F++}),Z&&o.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;a.forEach(i=>{const a=i.feature.attributes[C],n=i.feature.attributes[T],o=u.get(a),s=u.get(n),l=t?.timeInfoByTypeName?.get(i.typeName),h=t?.timeInfoByTypeName?l?.startField:null,d=h?i.feature.attributes[h]:null,p=l?.endField,c=p?i.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=a+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const l=Y.get(t),h=l?.has(i.typeName);h||(D[z]=o,x[z]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(I[z]=d?new Date(d).getTime():NaN,_[z]=c?new Date(c).getTime():NaN),void 0===l?Y.set(t,new Map([[i.typeName,z]])):l.set(i.typeName,z),z++),r.push(i)}else X=!0,this.relationshipLinkChartDiagramLookup.set(a,null)}),X&&o.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const ee=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),te=this._convertValidatedOrganicSettingsToCalculationSettings(ee);await K();let ie=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let i;({status:ie,links:ae,graphics:i}=J(()=>t?.signal?.aborted??!1,y,g,k,N,S,D.subarray(0,z),x.subarray(0,z),I.subarray(0,z),_.subarray(0,z),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===ie&&(this.chronologicalAuxiliaryGraphics=i)}else({status:ie,links:ae}=G(()=>t?.signal?.aborted??!1,y,g,k,D.subarray(0,z),x.subarray(0,z),te.computationBudgetTime,te.idealEdgeLengthMultiplier,te.repulsionRadiusMultiplier));if(l(t?.signal),1===ie)throw new n("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===ie)throw d();for(let n=0;n<R.length;n++){if(k[n]>84.9999?k[n]=84.9999:k[n]<-84.9999&&(k[n]=-84.9999),g[n]>179.9999?g[n]=179.9999:g[n]<-179.9999&&(g[n]=-179.9999),R[n].feature.attributes[v]=new f(g[n],k[n]),h.has(R[n].typeName)){const e=h.get(R[n].typeName);e?.set(R[n].feature.attributes[M],R[n].feature)}else{const e=new Map;e.set(R[n].feature.attributes[M],R[n].feature),h.set(R[n].typeName,e)}c.set(R[n].feature.attributes[M],R[n].feature);const e=b(R[n].feature.attributes[v]);this.entityLinkChartDiagramLookup.set(R[n].feature.attributes[M],R[n].feature.attributes[v]?e:null);const t=s(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,R[n].typeName,()=>({useAllData:!1,members:new Map}));s(t.members,R[n].feature.attributes[M],()=>({id:R[n].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=R[n].feature.attributes[v];const{x:i,y:a}=R[n].feature.attributes[v];if(j)P.xmin=Math.min(P.xmin,i),P.xmax=Math.max(P.xmax,i),P.ymin=Math.min(P.ymin,a),P.ymax=Math.max(P.ymax,a);else{const e=1e-7;P.xmin=i-e,P.xmax=i+e,P.ymin=a-e,P.ymax=a+e,j=!0}}if(this.linkChartExtent.xmin=P.xmin,this.linkChartExtent.xmax=P.xmax,this.linkChartExtent.ymin=P.ymin,this.linkChartExtent.ymax=P.ymax,!ae)throw new n("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ne=new Map,oe=new Map,se=new Map,re=new Set;for(let n=0;n<r.length;n++){const i=[],a=r[n],l=a.feature.attributes[C],h=a.feature.attributes[T];let d=l+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(a.typeName),i=t?.timeInfoByTypeName?e?.startField:null,n=i?a.feature.attributes[i]:null,o=e?.endField;d+="-"+n+"-"+(o?a.feature.attributes[o]:null)}const y=Y.get(d).get(a.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!re.has(y)){if(re.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],a=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[a[0]-e[0],a[1]-e[1]],o=[a[0]+n[1],a[1]-n[0]],s=[a[0]-n[1],a[1]+n[0]];i.push(e),i.push(o),i.push(t),i.push(s),i.push(e)}else{if(0!==ae.types[y]){o.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)i.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=R[u.get(l)]?.feature.attributes[v],t=R[u.get(h)]?.feature.attributes[v];i[0][0]===e.x&&i[0][1]===e.y||(i[0]=[e.x,e.y]),i[i.length-1][0]===t.x&&i[i.length-1][1]===t.y||(i[i.length-1]=[t.x,t.y])}for(let e=1;e<i.length-1;e++)i[e][1]>85.5?i[e][1]=85.5:i[e][1]<-85.5&&(i[e][1]=-85.5),i[e][0]>179.9999?i[e][0]=179.9999:i[e][0]<-179.9999&&(i[e][0]=-179.9999);ne.has(d)?ne.get(d).push(i):ne.set(d,[i])}const m=ne.get(d);oe.has(d)||(oe.set(d,new Map),se.set(d,new Map));const f=oe.get(d),w=se.get(d);f.has(a.typeName)||(f.set(a.typeName,m.shift()),w.set(a.typeName,0));const k=f.get(a.typeName);w.set(a.typeName,w.get(a.typeName)+1);const E=new L({paths:[k]});if(a.feature.attributes[v]=E,p.has(a.typeName)){const e=p.get(a.typeName);e?.set(a.feature.attributes[M],a.feature)}else{const e=new Map;e.set(a.feature.attributes[M],a.feature),p.set(a.typeName,e)}c.set(a.feature.attributes[M],a.feature);const N=b(a.feature.attributes[v]);this.relationshipLinkChartDiagramLookup.set(a.feature.attributes[M],a.feature.attributes[v]?N:null);const S=s(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,a.typeName,()=>({useAllData:!1,members:new Map}));s(S.members,a.feature.attributes[M],()=>({id:a.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=N}for(const n of r)n.feature.attributes[E]=se.get(n.feature.attributes[C]+"-"+n.feature.attributes[T])?.get(n.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:h,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){let{lockedNodeLocations:i,lockedEntityLocations:n,rootEntityIds:s,...r}=t??{};!n&&i?(a(o.getLogger(this),"lockedNodeLocations is deprecated in 5.0. Use lockedEntityLocations instead.",{replacement:"Use lockedEntityLocations instead.",version:"5.0"}),n=i):n&&i&&a(o.getLogger(this),"Both lockedNodeLocations (deprecated in 5.0) and lockedEntityLocations are defined. Use lockedEntityLocations only instead.",{replacement:"Use lockedEntityLocations instead.",version:"5.0"});const l=r.layoutSettings?.rootedLayoutSettings?.rootEntities;if(!l&&s){a(o.getLogger(this),"rootEntityIds is deprecated in 5.1. Use layoutSettings.rootedLayoutSettings.rootEntities instead.",{replacement:"Use layoutSettings.rootedLayoutSettings.rootEntities instead.",version:"5.1"});const e=[];for(const t of s){const i=this.dataManager.memberIdTypeLookup.get(t),a=Array.from(i??[]).find(e=>this.dataManager.entityTypeNames.has(e));a&&e.push({id:t,typeName:a})}r.layoutSettings=r.layoutSettings??new J,r.layoutSettings.rootedLayoutSettings=r.layoutSettings.rootedLayoutSettings??new Z,r.layoutSettings.rootedLayoutSettings.rootEntities=e}else l&&s&&a(o.getLogger(this),"Both rootEntityIds (deprecated in 5.1) and layoutSettings.rootedLayoutSettings.rootEntities are defined. Use layoutSettings.rootedLayoutSettings.rootEntities only instead.",{replacement:"Use layoutSettings.rootedLayoutSettings.rootEntities instead.",version:"5.1"});const h=[];await this._calculateLayoutWithSublayerTimeInfo(e,{...r,lockedEntityLocations:n}),this.layers.forEach(e=>{h.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(h),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,i]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||i?.members?.forEach(t=>{const i=t.linkChartLocation;let a;const n=t.id;i&&(a="x"in i?{x:i.x,y:i.y}:{x:i.coords[0],y:i.coords[1]},e.set(n,new f({x:a.x,y:a.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let i=[];try{let a=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(a=a.concat(Array.from(t.keys())))}i=await this.dataManager.getRelationshipsBetweenNodes(e,a,t),await this._handleNewRecords(i,t),l(t)}catch(a){throw h(a)&&this.removeRecords(i),a}return{records:i}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let i=[];try{let a=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(a=a.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}i=await this.dataManager.getRelationshipsFromNodes(e,n,a,t),await this._handleNewRecords(i,t),i.length>0&&(this.membershipModified=!0),l(t)}catch(a){throw h(a)&&this.removeRecords(i),a}return{records:i}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const i=new Map;this.layers.forEach(e=>{i.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:i,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const i=new Set,a=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),i.add(r.typeName));s(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),a.push(r)}this.dataManager.addToLayer(a);for(const s of i){const e=this._graphTypeLookup.get(s);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(s):this.dataManager.relationshipTypeNames.add(s),t.geometryType?this.layers.push(t):this.tables.push(t)}}await R(this,Array.from(i),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const o={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedEntityLocations:new Map};for(const[s,r]of this.entityLinkChartDiagramLookup.entries())r&&o.lockedEntityLocations.set(s,new f(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,o)}_createSublayers(e,t,i){e.forEach(e=>{const a=this._createSublayer(e);i(a)&&t.push(a),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const i=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);i&&(t.objectType=i,t.read({title:i.name},{origin:"service"}),this._updateSublayerCaches(i))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const i=e.linkChartLocation;let a;const n=e.id;if(!i)return;a="x"in i?{x:i.x,y:i.y}:{x:i.coords[0],y:i.coords[1]};const o=b(a);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>a.x&&(this.linkChartExtent.xmin=a.x),this.linkChartExtent.xmax<a.x&&(this.linkChartExtent.xmax=a.x),this.linkChartExtent.ymin>a.y&&(this.linkChartExtent.ymin=a.y),this.linkChartExtent.ymax<a.y&&(this.linkChartExtent.ymax=a.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]),i=this.relationshipLinkChartDiagramLookup.get(e.attributes[T]);if(t&&i){const a=b(new L({paths:[[[t.coords[0],t.coords[1]],[i.coords[0],i.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],a)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedEntityLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedEntityLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const i=e=>"number"==typeof e&&!isNaN(e),a=e=>i(e)&&e>=1,n=e=>i(e)&&e>=1,s=e=>Object.values(N).includes(e),r=e=>i(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return n(h)?l.computationBudgetTime=h:h&&o.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&a(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,o.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&o.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?o.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&o.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===N.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===N.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new D({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){if(t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e){const t=[];e.forEach(e=>{e.parent=this,t.push(this._createVisibleRefreshHandle(e))}),this.addHandles([...t,e.on("after-add",({item:e})=>{e.parent=this,this.addHandles(this._createVisibleRefreshHandle(e),"sublayers-owner")}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner")}}_createVisibleRefreshHandle(e){return p(()=>e.visible,(t,i)=>{!0===t&&!1===i&&e.emit("refresh",{dataChanged:!0})})}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),a=new Set((e.entityTypes??[]).map(e=>e.name)),n=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const i of this.layers)!i.graphType&&t.has(i.graphTypeName)&&(i.graphType=a.has(i.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?a.has(e.graphTypeName):n.has(e.graphTypeName)));this.setAtOrigin("layers",e,g(this.originIdOf("layers")))}else this.layers=new i;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],i=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of i)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const a=[];for(const n of this._originalInclusionList.namedTypeDefinitions.keys())i.includes(n)||(o.getLogger(this).warn(`A named type, ${n}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),a.push(n));for(const n of a)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([u(z)],ee.prototype,"url",void 0),e([u()],ee.prototype,"dataPreloadedInLocalCache",void 0),e([u()],ee.prototype,"initializationLinkChartConfig",void 0),e([u()],ee.prototype,"membershipModified",void 0),e([u()],ee.prototype,"dataManager",void 0),e([u()],ee.prototype,"initializationInclusionModeDefinition",null),e([u()],ee.prototype,"knowledgeGraph",void 0),e([u({type:i.ofType(D),json:{write:{ignoreOrigin:!0}}})],ee.prototype,"layers",void 0),e([u({readOnly:!0})],ee.prototype,"linkChart",null),e([u()],ee.prototype,"entityLinkChartDiagramLookup",void 0),e([u()],ee.prototype,"relationshipLinkChartDiagramLookup",void 0),e([u()],ee.prototype,"linkChartExtent",void 0),e([u()],ee.prototype,"memberEntityTypes",void 0),e([u()],ee.prototype,"memberRelationshipTypes",void 0),e([u({type:["LinkChartLayer"]})],ee.prototype,"operationalLayerType",void 0),e([u()],ee.prototype,"sublayerCapabilities",null),e([u()],ee.prototype,"sublayerIdsCache",void 0),e([u({type:i.ofType(D),json:{write:{ignoreOrigin:!0}}})],ee.prototype,"tables",void 0),e([u({json:{read:!1}})],ee.prototype,"type",void 0),e([u({readOnly:!0})],ee.prototype,"userHasEditingPrivileges",void 0),e([u({readOnly:!0})],ee.prototype,"userHasFullEditingPrivileges",void 0),e([u({readOnly:!0})],ee.prototype,"userHasUpdateItemPrivileges",void 0),e([u({json:{read:!1}})],ee.prototype,"chronologicalAuxiliaryGraphics",void 0),e([u(Y("dateFieldsTimeReference"))],ee.prototype,"dateFieldsTimeZone",void 0),ee=e([y("esri.layers.LinkChartLayer")],ee);const te=ee;export{te as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{createScreenPoint as e}from"../../core/screenUtils.js";import{nameToId as n}from"../../core/accessorSupport/PropertyOrigin.js";import t from"../../geometry/Extent.js";import o from"../../geometry/Point.js";import{getInfo as r}from"../../geometry/support/spatialReferenceUtils.js";import i from"./ControlPoint.js";import s from"./ControlPointsGeoreference.js";import a from"./CornersGeoreference.js";import c from"./ExtentAndRotationGeoreference.js";const p
|
|
2
|
+
import{createScreenPoint as e}from"../../core/screenUtils.js";import{nameToId as n}from"../../core/accessorSupport/PropertyOrigin.js";import t from"../../geometry/Extent.js";import o from"../../geometry/Point.js";import{getInfo as r}from"../../geometry/support/spatialReferenceUtils.js";import i from"./ControlPoint.js";import s from"./ControlPointsGeoreference.js";import a from"./CornersGeoreference.js";import c from"./ExtentAndRotationGeoreference.js";const p=.05,l=.5;async function y(e,n){e.loaded||await e.load();const{contentWidth:a,contentHeight:c}=e,{spatialReference:y}=n,m=r(y);let f=!1;if(m){const e=m.valid[1]-m.valid[0];n.width>e&&(n=new t({xmin:m.valid[0],ymin:n.ymin,xmax:m.valid[1],ymax:n.ymax,spatialReference:n.spatialReference}),f=!0)}const u=n.expand(l),{center:w,width:P,height:d}=u,x=a/c,g=f||x>1,h=a*p,R=c*p,j=g?P:d*x,v=g?P/x:d,b=w.x-j/2,O=w.x+j/2,k=w.y+v/2,C=w.y-v/2;return new s({controlPoints:[new i({sourcePoint:{x:h,y:c-R},mapPoint:new o({x:b,y:C,spatialReference:y})}),new i({sourcePoint:{x:h,y:R},mapPoint:new o({x:b,y:k,spatialReference:y})}),new i({sourcePoint:{x:a-h,y:R},mapPoint:new o({x:O,y:k,spatialReference:y})}),new i({sourcePoint:{x:a-h,y:c-R},mapPoint:new o({x:O,y:C,spatialReference:y})})],width:a,height:c})}function m(e){const n=e.georeference;if("control-points"!==n.type)return null;const t={wkid:0},{width:r,height:i}=n,a=n.controlPoints;return new s({controlPoints:a.map(e=>{const{x:n,y:r}=e.sourcePoint;return{sourcePoint:{x:n,y:r},mapPoint:new o({x:n,y:i-r,spatialReference:t})}}),width:r,height:i})}function f(e){return"media"===e?.type}function u(e,t){const o=n(t);return f(e)&&!!e.portalItem&&null!=o&&o>3}function w(n,t,r){if(!n||"control-points"===n.type)return n;const{coords:a}=n;if(5!==a?.rings[0]?.length)return null;const[c,p,l,y]=a.rings[0],{spatialReference:m}=a;return new s({controlPoints:[new i({mapPoint:new o({x:c[0],y:c[1],spatialReference:m}),sourcePoint:e(0,r)}),new i({mapPoint:new o({x:p[0],y:p[1],spatialReference:m}),sourcePoint:e(0,0)}),new i({mapPoint:new o({x:l[0],y:l[1],spatialReference:m}),sourcePoint:e(t,0)}),new i({mapPoint:new o({x:y[0],y:y[1],spatialReference:m}),sourcePoint:e(t,r)})],width:t,height:r})}function P(e,n,t){return{enabled:!u(t?.layer,t?.origin),ignoreOrigin:!0}}const d={json:{name:"url",type:String,write:{overridePolicy:P}}},x={readOnly:!0,json:{read:!1,write:{target:"mediaType",overridePolicy:P}}},g={types:{key:"type",base:null,typeMap:{"control-points":s,corners:a,"extent-and-rotation":c}},json:{types:{key:"type",base:null,typeMap:{"control-points":s}},write:{overridePolicy:()=>({enabled:!0,ignoreOrigin:!0})}}};export{y as createDefaultControlPointsGeoreference,m as createLocalModeControlPointsGeoreference,u as isWritingLayerFromItemToWebDocument,d as mediaElementUrlProperty,g as mediaGeoreferenceProperty,x as mediaTypeProperty,w as toControlPointsGeoreference};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.87",
|
|
4
4
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ArcGIS",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@amcharts/amcharts5": "~5.20.2",
|
|
23
|
+
"@arcgis/toolkit": "5.2.0-next.87",
|
|
23
24
|
"@esri/arcgis-html-sanitizer": "~4.1.0",
|
|
24
25
|
"@esri/calcite-components": "^5.2.0-next.52",
|
|
25
26
|
"@vaadin/grid": "~25.2.8",
|
|
26
27
|
"@zip.js/zip.js": "~2.8.51",
|
|
27
28
|
"luxon": "~3.7.2",
|
|
28
29
|
"marked": "~18.0.10",
|
|
29
|
-
"tslib": "^2.8.1"
|
|
30
|
-
"@arcgis/toolkit": "5.2.0-next.86"
|
|
30
|
+
"tslib": "^2.8.1"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import r from"../core/Error.js";import{EventedAccessor as s}from"../core/Evented.js";import a from"../core/Logger.js";import{abortMaybe as n}from"../core/maybe.js";import{debounce as o,isAbortError as l,logOnError as h}from"../core/promiseUtils.js";import u from"../core/ReactiveSet.js";import{watch as c,when as p,sync as d}from"../core/reactiveUtils.js";import{addMany as g}from"../core/SetUtils.js";import{property as m,subclass as f}from"../core/accessorSupport/decorators.js";import y from"../geometry/Point.js";import{initializeProjection as _,project as F}from"../geometry/projectionUtils.js";import v from"../geometry/SpatialReference.js";import{geographicToWebMercator as w}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as C}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as b}from"../layers/LayerConstants.js";import{ActionsCollection as I,zoomToAggregatedFeatures as P,browseAggregatedFeatures as S,zoomToFeature as A}from"./actions.js";import{getSelectedTarget as L}from"./actionUtils.js";import j from"./FeatureContent.js";import x from"./support/FeatureAbilities.js";import{getDisplayedSymbol as E}from"../symbols/support/symbolUtils.js";import{system as R}from"../time/constants.js";import{highlightsSupported as O}from"../views/support/layerViewUtils.js";import{GoTo as U}from"../widgets/support/GoTo.js";const T="location-scale-handle",H=()=>[A.clone()],M=()=>[P.clone(),S.clone()];let V=null;function D(e,t){switch(e){case"building-scene":case"map-image":case"tile":case"imagery":return!0;case"imagery-tile":return"2d"===t;default:return!1}}let Z=class extends(U(s)){constructor(e){super(e),this._pendingPromises=new u,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new x,this._featureStreamVersion=0,this._activeFeatureStream=null,this._fetchingFeatureStream=!1,this.actions=new I,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureItems=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=o(async e=>{this._cancelLocationUpdate();const t=new AbortController,{signal:i}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:i}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([c(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),c(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureItems],()=>this._setGraphicOnFeatureItems()),c(()=>this.featureItems,()=>this._featureItemsChange()),c(()=>[this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureItems()),p(()=>!this.waitingForResult,()=>this._waitingForResultChange(),d),p(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return this.open&&!this.waitingForResult}get allActions(){const e=this._get("allActions")||new I;e.removeAll();const{actions:i,defaultActions:r,defaultPopupTemplateEnabled:s,includeDefaultActions:a,selectedFeature:n}=this,o=a?r.concat(i):i,l=n&&("function"==typeof n.getEffectivePopupTemplate&&n.getEffectivePopupTemplate(s)||n.popupTemplate),h=l?.actions,u=l?.overwriteActions?h:h?.concat(o)??o;return u?.filter(t).forEach(t=>e.add(t)),e}set content(e){this.promises=[],this._set("content",e)}get defaultActions(){const e=this._get("defaultActions")||new I;return e.removeAll(),e.addMany(this.selectedFeature?.isAggregate?M():H()),e}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get("featureStream")||null}set featureStream(e){if(this._get("featureStream")===e)return;if(this._set("featureStream",e),this._cancelFeatureStream(),!e)return;this.promises=[];const t=this._featureStreamVersion;this._setFetchingFeatureStream(!0),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})}get initialDisplayMode(){return this._get("initialDisplayMode")||"feature"}set initialDisplayMode(e){this._set("initialDisplayMode",e),this._syncSelectedFeatureIndex(this.features)}set location(e){const t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?w(e):e;this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){const e=this._get("promises")||[];return e.length>0&&i(a.getLogger(this),"promises",{replacement:"featureStream",warnOnce:!0}),e}set promises(e){Array.isArray(e)&&e.length>0&&i(a.getLogger(this),"promises",{replacement:"featureStream",warnOnce:!0}),this._get("promises")!==e&&(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),e=e.slice(),g(this._pendingPromises,e),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get selectedFeature(){return-1===this.selectedFeatureIndex?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureItem(){return this.featureItems[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.view?this.view.ready?"ready":"disabled":this.map?"ready":"disabled"}get timeZone(){return this.view?.timeZone??R}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureItems.some(e=>e.waitingForContent)}get waitingForResult(){return(!!this._fetchFeaturesController||this._fetchingFeatureStream||this.pendingPromisesCount>0)&&0===this.featureCount}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,heading:null,location:null,activeFeature:null})}async fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new r("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screen point/screen area and view.",{screenPoint:e,view:i});const s=i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal});this.featureStream=s}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_syncSelectedFeatureIndex(e){const{pendingPromisesCount:t,promiseCount:i,selectedFeatureIndex:r}=this,s=i&&e.length;"list"!==this.initialDisplayMode?s&&t&&-1===r?this.selectedFeatureIndex=0:s&&-1!==r||(this.selectedFeatureIndex=e.length?0:-1):(!s||s&&t===i)&&(this.selectedFeatureIndex=-1)}_centerAtLocation(){const{view:e}=this,t=L(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:s}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:s}}).catch(e=>{l(e)||a.getLogger(this).error(e)}):Promise.reject(new r("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:r}=this;r&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this._centerAtLocation()}_selectedFeatureIndexChange(){"list"!==this.initialDisplayMode&&(this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null)}_featureItemsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureItems(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:r,featureItems:s}=this;if(null==i)return;const a=((i-1)*r+t)%t,n=Math.min(a+r,s.length);for(let o=a;o<n;o++){const t=s[o];t&&(t.graphic??=e[o])}}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;const s=C(e)?.type;if("map-image"!==s&&"imagery"!==s&&"imagery-tile"!==s||(e.symbol=await E(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await(import("../geometry/operators/labelPointOperator.js"));return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this._centerAtLocation();const e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.open=!1)}_destroyFeatureItems(){this.featureItems.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureItems",[])}_updateFeatureItems(){const e=this.selectedFeature,t=this.features,i=this.featureItems,r=this.view,s=this.spatialReference,a=this.map,n=this.timeZone,o=this.location,l=this.featureItemAbilities??this._defaultFeatureAbilities;if(!t?.length)return void this._destroyFeatureItems();const h=[],u=new Map,c=new Set;i.forEach(e=>{const t=e?.graphic;e&&t&&u.set(t,e)}),t.forEach((t,p)=>{if(!t)return;const d=i[p];if(d&&!c.has(d)&&(null==d.graphic||d.graphic===t))return d.abilities=l,h[p]=d,void c.add(d);const g=u.get(t);if(g&&!c.has(g))return g.abilities=l,h[p]=g,void c.add(g);const m=new j({abilities:l,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s,graphic:t===e?t:null,location:o,map:a,view:r,timeZone:n});h[p]=m,c.add(m)}),i.forEach(e=>{!e||c.has(e)||e.destroyed||e.destroy()}),this._set("featureItems",h)}async _getScreenPoint(e,t){const{spatialReference:i,view:r}=this;if(!r)return null;await r.when();const s=e?.spatialReference;return s&&i?(await _(s,i,null,t),r.toScreen(e)):null}_cancelCenterAtLocation(){this._centerAtLocationController=n(this._centerAtLocationController)}_cancelFeatureStream(){this._featureStreamVersion++,this._setFetchingFeatureStream(!1);const e=this._activeFeatureStream;this._activeFeatureStream=null,this._get("featureStream")===e&&this._set("featureStream",null),e?.return&&e.return(void 0).catch(()=>{})}_cancelFetchingFeatures(){this._fetchFeaturesController=n(this._fetchFeaturesController)}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:i,signal:s}){const{view:a}=this,n=t??await this._getScreenPoint(e??this.location,{signal:s});if(!a||!n)throw new r("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:n,view:a});return a.fetchPopupFeatures(n,{pointerType:i?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:s})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:i}){this._cancelFetchingFeatures();const r=new AbortController,{signal:s}=r;this._fetchFeaturesController=r;const a=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:s,event:i});return a.catch(()=>{}).finally(()=>{this._fetchFeaturesController===r&&(this._fetchFeaturesController=null)}),a}async _fetchFeaturesAndOpen(e){const{mapPoint:t,screenPoint:i}=e;let r;this.removeHandles(T),this.addHandles([c(()=>this.view?.scale,()=>h(this._debouncedLocationUpdate(t),a.getLogger(this))),p(()=>!this.open,()=>{this.removeHandles(T)},{once:!0})],T),this._setFetchingFeatureStream(!0);try{r=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:i,event:e})}catch(s){throw this._setFetchingFeatureStream(!1),s}return{location:t??void 0,featureStream:r}}async _locationUpdate(e,t){const{spatialReference:i}=this,r=this.selectedFeature?.geometry?.type,s=this.location??e;if(r&&"mesh"!==r&&i&&s&&this.selectedFeature){if("point"===r){const e=await(import("../geometry/operators/labelPointOperator.js"));return void(this.location=e.execute(this.selectedFeature.geometry))}try{const e=this.selectedFeature;let r=e.geometry;const a=this._getHighlightLayer(e),n=e.getObjectId();if(!a||!this.view)return;if(n){const e=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!e||!("queryFeatures"in e))return;const s=e.createQuery();s.outSpatialReference=i,s.objectIds=[n],s.returnGeometry=!0;const{features:o}=await e.queryFeatures(s,t);r=o[0]?.geometry}if(!r||"mesh"===r.type)return;r=F(r,i),V??=await Promise.all([import("../geometry/operators/intersectsOperator.js"),import("../geometry/operators/proximityOperator.js")]);const[o,l]=V;if(!o.execute(r,s)){const t=l.getNearestCoordinate(r,s).coordinate??s;this.selectedFeature===e&&(this.location=t)}}catch(n){l(n)||a.getLogger(this).error(n)}}}_cancelLocationUpdate(){this._locationUpdateController=n(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const t=C(e),{layer:i}=e;return t&&"layer"in t&&t.layer?t.layer:"map-notes"===t?.type||"subtype-group"===t?.type?t:i??t}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(D(t.type,i))return e;const r=e.getObjectId();if(null!=r)return r;const s="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||b:null,a=e.attributes;return a&&s&&a[s]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:r,view:s,open:a}=this;if(!s||!r||!a)return;const n=this._getHighlightLayer(i);if(!n)return;const o=this._getHighlightLayerView(s,n);if(!o)return;this._highlightPromises[e]=o;const l=await o;if(!(l&&O(l)&&this._highlightPromises[e]===o&&this[t]&&this.highlightEnabled))return;const h=l.highlight(this._getHighlightTarget(i,n,s.type));this.addHandles(h,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}async _consumeFeatureStream(e,t){try{for await(const i of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([i])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setFetchingFeatureStream(!1))}}_setFetchingFeatureStream(e){this._fetchingFeatureStream!==e&&(this._fetchingFeatureStream=e)}_updateFeatures(e){const{features:t}=this,i=new Set(t),r=e.filter(e=>!i.has(e));r?.length&&(this.features=t.concat(r))}};e([m()],Z.prototype,"_fetchFeaturesController",void 0),e([m()],Z.prototype,"_fetchingFeatureStream",void 0),e([m({type:I})],Z.prototype,"actions",void 0),e([m({readOnly:!0})],Z.prototype,"active",null),e([m()],Z.prototype,"activeFeature",void 0),e([m({readOnly:!0})],Z.prototype,"allActions",null),e([m()],Z.prototype,"aggregatedFeaturesEnabled",void 0),e([m({value:null})],Z.prototype,"content",null),e([m({type:I,readOnly:!0})],Z.prototype,"defaultActions",null),e([m({type:Boolean})],Z.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"effectiveHeading",null),e([m({readOnly:!0})],Z.prototype,"featureCount",null),e([m()],Z.prototype,"featurePage",void 0),e([m({value:[]})],Z.prototype,"features",null),e([m()],Z.prototype,"featureStream",null),e([m()],Z.prototype,"featuresPerPage",void 0),e([m()],Z.prototype,"featureMenuOpen",void 0),e([m({type:x})],Z.prototype,"featureItemAbilities",void 0),e([m({readOnly:!0})],Z.prototype,"featureItems",void 0),e([m()],Z.prototype,"heading",void 0),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"includeDefaultActions",void 0),e([m({value:"feature"})],Z.prototype,"initialDisplayMode",null),e([m({type:y})],Z.prototype,"location",null),e([m()],Z.prototype,"map",null),e([m()],Z.prototype,"open",void 0),e([m({readOnly:!0})],Z.prototype,"pendingPromisesCount",null),e([m({readOnly:!0})],Z.prototype,"promiseCount",null),e([m()],Z.prototype,"promises",null),e([m({value:null,readOnly:!0})],Z.prototype,"selectedFeature",null),e([m({value:-1})],Z.prototype,"selectedFeatureIndex",null),e([m({readOnly:!0})],Z.prototype,"selectedFeatureItem",null),e([m({type:v})],Z.prototype,"spatialReference",null),e([m({readOnly:!0})],Z.prototype,"state",null),e([m()],Z.prototype,"timeZone",null),e([m()],Z.prototype,"updateLocationEnabled",void 0),e([m()],Z.prototype,"view",void 0),e([m({readOnly:!0})],Z.prototype,"waitingForContents",null),e([m({readOnly:!0})],Z.prototype,"waitingForResult",null),e([m()],Z.prototype,"zoomFactor",void 0),Z=e([f("esri.popup.FeatureContentCollection")],Z);const G=Z;export{G as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import r from"../core/Error.js";import{EventedAccessor as s}from"../core/Evented.js";import a from"../core/Logger.js";import{abortMaybe as o}from"../core/maybe.js";import{debounce as n,logOnError as l,isAbortError as u}from"../core/promiseUtils.js";import h from"../core/ReactiveSet.js";import{watch as c,when as p,sync as d}from"../core/reactiveUtils.js";import{addMany as g}from"../core/SetUtils.js";import{property as m,subclass as f}from"../core/accessorSupport/decorators.js";import y from"../geometry/Point.js";import{project as _}from"../geometry/projectionUtils.js";import F from"../geometry/SpatialReference.js";import{geographicToWebMercator as v}from"../geometry/support/webMercatorUtils.js";import{getGraphicLayer as w}from"../graphic/graphicOriginUtils.js";import{fallbackObjectIDAttribute as b}from"../layers/LayerConstants.js";import{ActionsCollection as I,zoomToAggregatedFeatures as C,browseAggregatedFeatures as S,zoomToFeature as A}from"./actions.js";import{getSelectedTarget as P}from"./actionUtils.js";import L from"./FeatureContent.js";import j from"./support/FeatureAbilities.js";import{getDisplayedSymbol as x}from"../symbols/support/symbolUtils.js";import{system as E}from"../time/constants.js";import{highlightsSupported as R}from"../views/support/layerViewUtils.js";import{GoTo as O}from"../widgets/support/GoTo.js";const U=()=>[A.clone()],T=()=>[C.clone(),S.clone()];let M=null;function H(e,t){switch(e){case"building-scene":case"map-image":case"tile":case"imagery":return!0;case"imagery-tile":return"2d"===t;default:return!1}}let V=class extends(O(s)){constructor(e){super(e),this._pendingPromises=new h,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._defaultFeatureAbilities=new j,this._featureStreamVersion=0,this._activeFeatureStream=null,this._fetchingFeatureStream=!1,this.actions=new I,this.activeFeature=null,this.aggregatedFeaturesEnabled=!1,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureItemAbilities=null,this.featureItems=[],this.heading=null,this.highlightEnabled=!0,this.includeDefaultActions=!0,this.open=!1,this.updateLocationEnabled=!1,this.view=null,this.zoomFactor=4,this._debouncedLocationUpdate=n(async()=>{this._cancelLocationUpdate();const e=new AbortController,{signal:t}=e;this._locationUpdateController=e,await this._locationUpdate({signal:t}).catch(()=>{}).finally(()=>{this._locationUpdateController===e&&(this._locationUpdateController=null)})})}initialize(){this.addHandles([c(()=>this.view?.scale,()=>{this.open&&l(this._debouncedLocationUpdate(),a.getLogger(this))}),c(()=>[this.highlightEnabled,this.selectedFeature,this.open,this.view],()=>this._highlightSelectedFeature()),c(()=>[this.highlightEnabled,this.activeFeature,this.open,this.view],()=>this._highlightActiveFeature()),c(()=>this.location,e=>this._locationChange(e)),c(()=>this.selectedFeature,e=>this._selectedFeatureChange(e)),c(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),c(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureItems],()=>this._setGraphicOnFeatureItems()),c(()=>this.featureItems,()=>this._featureItemsChange()),c(()=>[this.featureItemAbilities?.attachmentsContent,this.featureItemAbilities?.chartAnimation,this.featureItemAbilities?.customContent,this.featureItemAbilities?.expressionContent,this.featureItemAbilities?.fieldsContent,this.featureItemAbilities?.mediaContent,this.featureItemAbilities?.relationshipContent,this.featureItemAbilities?.textContent,this.featureItemAbilities?.utilityNetworkAssociationsContent,this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureItems()),p(()=>!this.waitingForResult,()=>this._waitingForResultChange(),d),p(()=>!this.open,()=>this.aggregatedFeaturesEnabled=!1)])}destroy(){this._cancelLocationUpdate(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.aggregatedFeaturesEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return this.open&&!this.waitingForResult}get allActions(){const e=this._get("allActions")||new I;e.removeAll();const{actions:i,defaultActions:r,defaultPopupTemplateEnabled:s,includeDefaultActions:a,selectedFeature:o}=this,n=a?r.concat(i):i,l=o&&("function"==typeof o.getEffectivePopupTemplate&&o.getEffectivePopupTemplate(s)||o.popupTemplate),u=l?.actions,h=l?.overwriteActions?u:u?.concat(n)??n;return h?.filter(t).forEach(t=>e.add(t)),e}set content(e){this.promises=[],this._set("content",e)}get defaultActions(){const e=this._get("defaultActions")||new I;return e.removeAll(),e.addMany(this.selectedFeature?.isAggregate?T():U()),e}get effectiveHeading(){return this.selectedFeatureItem?.heading??this.heading}get featureCount(){return this.features.length}set features(e){if(this._get("features")===e)return;const t=e||[];this._set("features",t),this._syncSelectedFeatureIndex(t)}get featureStream(){return this._get("featureStream")||null}set featureStream(e){if(this._get("featureStream")===e)return;if(this._set("featureStream",e),this._cancelFeatureStream(),!e)return;this.promises=[];const t=this._featureStreamVersion;this._setFetchingFeatureStream(!0),this._activeFeatureStream=e,this._consumeFeatureStream(e,t).catch(()=>{})}get initialDisplayMode(){return this._get("initialDisplayMode")||"feature"}set initialDisplayMode(e){this._set("initialDisplayMode",e),this._syncSelectedFeatureIndex(this.features)}set location(e){const t=e?.spatialReference?.isWGS84&&this.spatialReference?.isWebMercator?v(e):e;this._set("location",t)}get map(){return this.view?.map??null}set map(e){this._override("map",e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){const e=this._get("promises")||[];return e.length>0&&i(a.getLogger(this),"promises",{replacement:"featureStream",warnOnce:!0}),e}set promises(e){Array.isArray(e)&&e.length>0&&i(a.getLogger(this),"promises",{replacement:"featureStream",warnOnce:!0}),this._get("promises")!==e&&(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],Array.isArray(e)&&e.length?(this._set("promises",e),e=e.slice(),g(this._pendingPromises,e),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())):this._set("promises",[]))}get selectedFeature(){return-1===this.selectedFeatureIndex?null:this.features[this.selectedFeatureIndex]??null}get selectedFeatureIndex(){const e=this._get("selectedFeatureIndex");return"number"==typeof e?e:-1}set selectedFeatureIndex(e){const{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set("selectedFeatureIndex",e)}get selectedFeatureItem(){return this.featureItems[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.view?this.view.ready?"ready":"disabled":this.map?"ready":"disabled"}get timeZone(){return this.view?.timeZone??E}set timeZone(e){this._overrideIfSome("timeZone",e)}get waitingForContents(){return this.featureItems.some(e=>e.waitingForContent)}get waitingForResult(){return(this._fetchingFeatureStream||this.pendingPromisesCount>0)&&0===this.featureCount}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,heading:null,location:null,activeFeature:null})}async fetchFeatures(e,t){const{view:i}=this;if(!i||!e)throw new r("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screen point/screen area and view.",{screenPoint:e,view:i});const s=i.fetchPopupFeatures(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal});this.featureStream=s}next(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount)}previous(){this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount)}_syncSelectedFeatureIndex(e){const{pendingPromisesCount:t,promiseCount:i,selectedFeatureIndex:r}=this,s=i&&e.length;"list"!==this.initialDisplayMode?s&&t&&-1===r?this.selectedFeatureIndex=0:s&&-1!==r||(this.selectedFeatureIndex=e.length?0:-1):(!s||s&&t===i)&&(this.selectedFeatureIndex=-1)}_centerAtLocation(){const{view:e}=this,t=P(this);this._cancelCenterAtLocation();const i=new AbortController,{signal:s}=i;return this._centerAtLocationController=i,t&&e?this.callGoTo({target:{target:t,scale:e.scale},options:{signal:s}}).catch(e=>{u(e)||a.getLogger(this).error(e)}):Promise.reject(new r("center-at-location:invalid-target-or-view","Cannot center at a location without a target and view.",{target:t,view:e}))}_getRoundRobinIndex(e,t){return(e+t)%t}_locationChange(e){const{selectedFeature:t,updateLocationEnabled:i,view:r}=this;r&&!this._locationUpdateController&&i&&e&&(!t||t.geometry)&&this._centerAtLocation()}_selectedFeatureIndexChange(){"list"!==this.initialDisplayMode&&(this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null)}_featureItemsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureItems(){const{features:e,featureCount:t,featurePage:i,featuresPerPage:r,featureItems:s}=this;if(null==i)return;const a=((i-1)*r+t)%t,o=Math.min(a+r,s.length);for(let n=a;n<o;n++){const t=s[n];t&&(t.graphic??=e[n])}}async _selectedFeatureChange(e){const{location:t,updateLocationEnabled:i,view:r}=this;if(this.aggregatedFeaturesEnabled=!1,!e||!r)return;const s=w(e)?.type;if("map-image"!==s&&"imagery"!==s&&"imagery-tile"!==s||(e.symbol=await x(e)),(i||!t)&&e.geometry){if("point"===e.geometry.type)return void(this.location=e.geometry);const t=await(import("../geometry/operators/labelPointOperator.js"));return void(this.location=t.execute(e.geometry))}if(i&&!e.geometry){await this._centerAtLocation();const e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.open=!1)}_destroyFeatureItems(){this.featureItems.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("featureItems",[])}_updateFeatureItems(){const e=this.selectedFeature,t=this.features,i=this.featureItems,r=this.view,s=this.spatialReference,a=this.map,o=this.timeZone,n=this.location,l=this.featureItemAbilities??this._defaultFeatureAbilities;if(!t?.length)return void this._destroyFeatureItems();const u=[],h=new Map,c=new Set;i.forEach(e=>{const t=e?.graphic;e&&t&&h.set(t,e)}),t.forEach((t,p)=>{if(!t)return;const d=i[p];if(d&&!c.has(d)&&(null==d.graphic||d.graphic===t))return d.abilities=l,u[p]=d,void c.add(d);const g=h.get(t);if(g&&!c.has(g))return g.abilities=l,u[p]=g,void c.add(g);const m=new L({abilities:l,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:s,graphic:t===e?t:null,location:n,map:a,view:r,timeZone:o});u[p]=m,c.add(m)}),i.forEach(e=>{!e||c.has(e)||e.destroyed||e.destroy()}),this._set("featureItems",u)}_cancelCenterAtLocation(){this._centerAtLocationController=o(this._centerAtLocationController)}_cancelFeatureStream(){this._featureStreamVersion++,this._setFetchingFeatureStream(!1);const e=this._activeFeatureStream;this._activeFeatureStream=null,this._get("featureStream")===e&&this._set("featureStream",null),e?.return&&e.return(void 0).catch(()=>{})}async _locationUpdate(e){const{spatialReference:t}=this,i=this.selectedFeature,r=i?.geometry?.type,s=this.location;if(r&&"mesh"!==r&&t&&s&&i){if("point"===r){const t=await(import("../geometry/operators/labelPointOperator.js"));if(e?.signal?.aborted||this.selectedFeature!==i||!i.geometry)return;return void(this.location=t.execute(i.geometry))}try{let r=i.geometry;const a=this._getHighlightLayer(i),o=i.getObjectId();if(!a||!this.view)return;if(null!=o){const i=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!i||!("queryFeatures"in i))return;const s=i.createQuery();s.outSpatialReference=t,s.objectIds=[o],s.returnGeometry=!0;const{features:n}=await i.queryFeatures(s,e);if(e?.signal?.aborted)return;r=n[0]?.geometry}if(!r||"mesh"===r.type)return;r=_(r,t),M??=await Promise.all([import("../geometry/operators/intersectsOperator.js"),import("../geometry/operators/proximityOperator.js")]);const[n,l]=M;if(!n.execute(r,s)){const e=l.getNearestCoordinate(r,s).coordinate??s;this.selectedFeature===i&&(this.location=e)}}catch(o){u(o)||a.getLogger(this).error(o)}}}_cancelLocationUpdate(){this._locationUpdateController=o(this._locationUpdateController)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){const t=w(e),{layer:i}=e;return t&&"layer"in t&&t.layer?t.layer:"map-notes"===t?.type||"subtype-group"===t?.type?t:i??t}_getHighlightLayerView(e,t){return"subtype-sublayer"===t.type&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,i){if(H(t.type,i))return e;const r=e.getObjectId();if(null!=r)return r;const s="imagery"===t.type?void 0:"objectIdField"in t?t.objectIdField||b:null,a=e.attributes;return a&&s&&a[s]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);const i=this[t];if(!i)return;const{highlightEnabled:r,view:s,open:a}=this;if(!s||!r||!a)return;const o=this._getHighlightLayer(i);if(!o)return;const n=this._getHighlightLayerView(s,o);if(!n)return;this._highlightPromises[e]=n;const l=await n;if(!(l&&R(l)&&this._highlightPromises[e]===n&&this[t]&&this.highlightEnabled))return;const u=l.highlight(this._getHighlightTarget(i,o,s.type));this.addHandles(u,e)}async _highlightActiveFeature(){return this._highlightFeature("highlight-active-feature","activeFeature")}async _highlightSelectedFeature(){return this._highlightFeature("highlight-selected-feature","selectedFeature")}async _consumeFeatureStream(e,t){try{for await(const i of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([i])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setFetchingFeatureStream(!1))}}_setFetchingFeatureStream(e){this._fetchingFeatureStream!==e&&(this._fetchingFeatureStream=e)}_updateFeatures(e){const{features:t}=this,i=new Set(t),r=e.filter(e=>!i.has(e));r?.length&&(this.features=t.concat(r))}};e([m()],V.prototype,"_fetchingFeatureStream",void 0),e([m({type:I})],V.prototype,"actions",void 0),e([m({readOnly:!0})],V.prototype,"active",null),e([m()],V.prototype,"activeFeature",void 0),e([m({readOnly:!0})],V.prototype,"allActions",null),e([m()],V.prototype,"aggregatedFeaturesEnabled",void 0),e([m({value:null})],V.prototype,"content",null),e([m({type:I,readOnly:!0})],V.prototype,"defaultActions",null),e([m({type:Boolean})],V.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],V.prototype,"effectiveHeading",null),e([m({readOnly:!0})],V.prototype,"featureCount",null),e([m()],V.prototype,"featurePage",void 0),e([m({value:[]})],V.prototype,"features",null),e([m()],V.prototype,"featureStream",null),e([m()],V.prototype,"featuresPerPage",void 0),e([m()],V.prototype,"featureMenuOpen",void 0),e([m({type:j})],V.prototype,"featureItemAbilities",void 0),e([m({readOnly:!0})],V.prototype,"featureItems",void 0),e([m()],V.prototype,"heading",void 0),e([m()],V.prototype,"highlightEnabled",void 0),e([m()],V.prototype,"includeDefaultActions",void 0),e([m({value:"feature"})],V.prototype,"initialDisplayMode",null),e([m({type:y})],V.prototype,"location",null),e([m()],V.prototype,"map",null),e([m()],V.prototype,"open",void 0),e([m({readOnly:!0})],V.prototype,"pendingPromisesCount",null),e([m({readOnly:!0})],V.prototype,"promiseCount",null),e([m()],V.prototype,"promises",null),e([m({value:null,readOnly:!0})],V.prototype,"selectedFeature",null),e([m({value:-1})],V.prototype,"selectedFeatureIndex",null),e([m({readOnly:!0})],V.prototype,"selectedFeatureItem",null),e([m({type:F})],V.prototype,"spatialReference",null),e([m({readOnly:!0})],V.prototype,"state",null),e([m()],V.prototype,"timeZone",null),e([m()],V.prototype,"updateLocationEnabled",void 0),e([m()],V.prototype,"view",void 0),e([m({readOnly:!0})],V.prototype,"waitingForContents",null),e([m({readOnly:!0})],V.prototype,"waitingForResult",null),e([m()],V.prototype,"zoomFactor",void 0),V=e([f("esri.popup.FeatureContentCollection")],V);const D=V;export{D as default};
|
|
@@ -84,7 +84,7 @@ export default abstract class ActionBase extends ActionBaseSuperclass {
|
|
|
84
84
|
/**
|
|
85
85
|
* Sets the `className` property internally without logging a deprecation warning.
|
|
86
86
|
*
|
|
87
|
-
* @deprecated since 5.1. We can remove this for 6.0 - https://devtopia.esri.com/WebGIS/
|
|
87
|
+
* @deprecated since 5.1. We can remove this for 6.0 - https://devtopia.esri.com/WebGIS/webgis-sdk/issues/21185
|
|
88
88
|
* @param className - The CSS class name to set on the action button.
|
|
89
89
|
* @internal
|
|
90
90
|
*/
|
package/support/revision.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const
|
|
2
|
+
const c="20260824",d="813e1c0279fde19c795204989bf852ad4d3461f0";export{c as buildDate,d as revision};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{importLazily as x}from"../../../../../../../geometry/operators/importUtils.js";import{getLabelPoint as P}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as v,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import M from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{tileSize as w}from"../../../definitions.js";import L from"../../../collisions/BoundingBox.js";import{LabelMetric as I}from"../../../collisions/LabelMetric.js";import{smoothPaths as B,pathDivide as S}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as z,processColorInput as G}from"../fill/meshWriterUtils.js";import{TextMeshWriter as j,maxLabelZoom as D}from"../text/TextMeshWriter.js";const A=1,F=0,R=128,$=w*w/16,k=x(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),C=x(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function O(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(D-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function X(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(D-s)}`)}const Y=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class U extends j{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),k.getImportPromise(),C.getImportPromise()])}_write(e,{target:t,effectGeometry:i,level:r,viewExtent:s}){if(this._zoomLevel=r,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new I(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=k.module,s=C.module.constructFromFlatGeometry,o=t.readGeometryForDisplay()?.justXY(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const x=p(new _(d.toFlatGeometry())),v=y.fromOptimized(x,"esriGeometryPolygon",1),b=P(v)??n;this._writePoint(e,b[0],b[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new I(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<A);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:z(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay()?.justXY();if(!n)return;const a=v(n,"esriGeometryPolyline",1)??new M,l=W(a,o),c=W(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=B(m.paths,s.bounds.width),d=B(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,S(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,S(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=B(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,S(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=Y(t),f=this._current.shaping.bounds.width/(1<<A),g=Math.sqrt(n||R)/(1<<A),p=Math.min(i,r-i),_=h.isMultiline?D:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+A-y),P=this._zoomLevel-x,v=h.bounds.width/2*2**P,b=O(a,c,m,t,this._zoomLevel),M=X(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,b,M):s&&P<0?this._placeStraightAlong(e,u,b,M):"parallel"===o?this._placeStraightAlong(e,x,b,M):"curved"===o&&this._placeCurved(e,x,v,b,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(D,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+F;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+F}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+F;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+F}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+F))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],D)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+F)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,d=this._getDefaultGlyphMetrics(this.evaluatedMeshParams.glyphs),f=s.fontSize??h;this._writeQuad(e,t,i,r,{sdfSize:d.sdfSize,sdfRadius:d.sdfRadius,texcoords:l,offsets:c,fontSize:f,haloSize:m,outlineSize:u,color:s.color?G(s.color):G(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)&&t.bounds){const i=t.bounds,r=new L(i.x+s[0],i.y+s[1],i.width,i.height);e.metricBoxWrite(r)}}_isVisible(e){const t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]),r=this._zoomLevel;return t<=r&&r<=i}}function W(e,t){const i=new M,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const v=p[0]*g[0]+p[1]*g[1];0!==v&&m(p,p,v),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{U as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,O as lineLabelIdHash,X as lineLabelMetricHash};
|
|
2
|
+
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as r}from"../../../../../../../core/string.js";import{fromRotation as i,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{importLazily as x}from"../../../../../../../geometry/operators/importUtils.js";import{getLabelPoint as v}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import M from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{tileSize as w}from"../../../definitions.js";import L from"../../../collisions/BoundingBox.js";import{LabelMetric as I}from"../../../collisions/LabelMetric.js";import{smoothPaths as B,pathDivide as z}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as G,processColorInput as S}from"../fill/meshWriterUtils.js";import{TextMeshWriter as j,maxLabelZoom as D}from"../text/TextMeshWriter.js";const F=1,A=0,R=128,$=w*w/16,k=x(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),C=x(()=>import("../../../../../../../chunks/FlatGeometry.js"));function O(e,t,i){return r(`${e}${t}${i}`)}function E(e,t,i,s,o){return r(`${e}${t}${i}${s*2**(D-o)}`)}function T(e,t,i){return r(`${e}${t}${i}`)}function X(e,t,i,s,o){return r(`${e}${o}${t}${i*2**(D-s)}`)}const Y=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class U extends j{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),k.getImportPromise(),C.getImportPromise()])}_write(e,{target:t,effectGeometry:r,level:i,viewExtent:s}){if(this._zoomLevel=i,null!=r)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const r=t.readXForDisplay(),i=t.readYForDisplay();this._writePoint(e,r,i,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let r=0;const i=y.fromFeatureSetReader(t);if(i?.nextPath())for(;i.nextPoint();)this._writePoint(e,i.x,i.y,r++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,r,i,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new I(e,h,t,r,i,s,n,a,l,c,o)}_writePolygon(e,t,r){const i=k.module,s=C.module.constructFromFlatGeometry,o=t.readGeometryForDisplay()?.justXY(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(r)),h=s(f({x:n[0],y:n[1]})),m=!!i.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=i.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const x=p(new _(d.toFlatGeometry())),P=y.fromOptimized(x,"esriGeometryPolygon",1),b=v(P)??n;this._writePoint(e,b[0],b[1],0,t)}_writePoint(e,t,r,i,s){if(t<0||t>w||r<0||r>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=O(this.evaluatedMeshParams.layerId,s.getObjectId(),i),c=T(s.getObjectId(),a,i),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new I(n,a,l,c,t,r,h,m,u,d,f)),this._writeGlyphs(e,n,t,r,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:r,verticalAlignment:i}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,r,i)=>this._placeSubdivGlyphs(e,t,r,i),a=(o.bounds.width+s)/(1<<F);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:G(r,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===i?"above":"top"===i?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,r){const{repeatLabel:i}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay()?.justXY();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new M,l=W(a,o),c=W(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=B(m.paths,s.bounds.width),d=B(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,z(u[f],r,t,!!i);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,z(d[f],r,t,!!i)}_writeCenterAlong(e,t,r){const{repeatLabel:i}=this.evaluatedMeshParams,{shaping:s}=this._current,o=B(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,z(o[n],r,t,!!i)}_placeSubdivGlyphs(e,t,r,i){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=Y(t),f=this._current.shaping.bounds.width/(1<<F),g=Math.sqrt(n||R)/(1<<F),p=Math.min(r,i-r),_=h.isMultiline?D:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+F-y),v=this._zoomLevel-x,P=h.bounds.width/2*2**v,b=E(a,c,m,t,this._zoomLevel),M=X(c,m,t,this._zoomLevel,l);s&&v<0?this._placeStraightAlong(e,u,b,M):"parallel"===o||h.isMultiline?this._placeStraightAlong(e,x,b,M):"curved"===o&&this._placeCurved(e,x,P,b,M)}_placeCurved(e,t,r,i,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,i,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,r,1,l),this._placeForward(e,a,t,r,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,r,0,c),this._placeForward(e,a,t,r,0,c)),o.metricEnd()}_placeStraightAlong(e,r,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(r,m[0],0),a=Math.min(D,m[1]),f=i(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[r,i]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,i,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[r,i]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,i,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,r,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,r,0,y,!0),l.metricEnd()}_placeBack(e,t,r,i,s,o){const n=e.clone();let a=e.backwardLength+A;for(;n.prev()&&!(a>=i);)this._placeOnSegment(n,t,a,r,-1,s,o),a+=n.length+A}_placeForward(e,t,r,i,s,o){const n=e.clone();let a=e.remainingLength+A;for(;n.next()&&!(a>=i);)this._placeOnSegment(n,t,a,r,1,s,o),a+=n.length+A}_placeFirst(e,t,r,i,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?r:1-r,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+A))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-r)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],D)];this._writeLineGlyph(o,n,e.x,e.y,u,_,i,c),this._writeLineGlyphBox(o,u,r,_,m)}}_placeOnSegment(e,t,r,i,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+r*-s*u,y:e.y+r*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/r)-.1),d=Math.max(i,this._zoomLevel+Math.log2(m/(r+e.length+A)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const r=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(r,s),l=i(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,r,i,s,o,n,a){if(r<0||r>w||i<0||i>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,d=this._getDefaultGlyphMetrics(this.evaluatedMeshParams.glyphs),f=s.fontSize??h;this._writeQuad(e,t,r,i,{sdfSize:d.sdfSize,sdfRadius:d.sdfRadius,texcoords:l,offsets:c,fontSize:f,haloSize:m,outlineSize:u,color:s.color?S(s.color):S(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,r,i,s){if((r||this._current.offsetDirection)&&this._isVisible(i)&&t.bounds){const r=t.bounds,i=new L(r.x+s[0],r.y+s[1],r.width,r.height);e.metricBoxWrite(i)}}_isVisible(e){const t=Math.max(this._current.zoomRange[0],e[0]),r=Math.min(this._current.zoomRange[1],e[1]),i=this._zoomLevel;return t<=i&&i<=r}}function W(e,t){const r=new M,{coords:i,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),v=_*(s+y+1);s>0?a(o,i[d],i[d+1]):a(o,0,0),a(n,i[x],i[x+1]),s<e-1?a(u,i[v],i[v+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const P=p[0]*g[0]+p[1]*g[1];0!==P&&m(p,p,P),m(p,p,t),r.coords.push(n[0]+p[0],n[1]+p[1])}r.lengths.push(e),y+=e}return r}export{U as LabelMeshWriter,O as labelIdHash,T as labelMetricHash,E as lineLabelIdHash,X as lineLabelMetricHash};
|