@arcgis/core 4.31.0-next.20240705 → 4.31.0-next.20240708
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/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{734844c5bef28f609a8c.js → 17c37078ab65f8d4046b.js} +1 -1
- package/assets/esri/core/workers/chunks/{3edc527a24cb9a4868e5.js → 20d0390504e4cc9f93f4.js} +1 -1
- package/assets/esri/core/workers/chunks/291bdab5737152bc1825.js +1 -0
- package/assets/esri/core/workers/chunks/{ef8ba10380053ea4c4dd.js → 34ea46659c8cebec3ffa.js} +1 -1
- package/assets/esri/core/workers/chunks/3de4fe7458b7844e2aae.js +1 -0
- package/assets/esri/core/workers/chunks/413609b0aa85f2052154.js +1 -0
- package/assets/esri/core/workers/chunks/5089a12084a8a8fb93d8.js +1 -0
- package/assets/esri/core/workers/chunks/527932bf4c31cec46922.js +1 -0
- package/assets/esri/core/workers/chunks/65d34a9d408c678de2ca.js +1 -0
- package/assets/esri/core/workers/chunks/{5d0761c14d6ee53dd653.js → 7447883bb4a981e6d759.js} +1 -1
- package/assets/esri/core/workers/chunks/{86f3ef84cc27de6d8540.js → 87f33a60768801ca1ce8.js} +1 -1
- package/assets/esri/core/workers/chunks/{a734359619e3eb955399.js → b4d850e82a8ae902d684.js} +1 -1
- package/assets/esri/core/workers/chunks/d85c51abde781660b1f5.js +1 -0
- package/assets/esri/core/workers/chunks/{5afc1562bb5c20127ef1.js → e840e54455eb500b501d.js} +18 -18
- package/assets/esri/themes/base/widgets/_Tooltip.scss +4 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ChapmanAtmosphere.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +3 -3
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/EdgeShader.glsl.js +5 -6
- package/chunks/Heatmap.glsl.js +4 -4
- package/chunks/HighlightApply.glsl.js +172 -135
- package/chunks/LineCallout.glsl.js +4 -4
- package/chunks/MeasurementArrow.glsl.js +5 -5
- package/chunks/RealisticTree.glsl.js +2 -2
- package/chunks/Terrain.glsl.js +39 -39
- package/geometry/Polyline.js +1 -1
- package/geometry/SpatialReference.js +1 -1
- package/geometry/geometryEngine.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/video/videoUtils.js +1 -1
- package/package.json +1 -1
- package/rest/knowledgeGraph/wasmInterface/wasmToGeometryFactories.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/interactive/SnappingVisualizer2D.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TransparencyMode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +9 -0
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +5 -0
- package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeShader.glsl.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/assets/esri/core/workers/chunks/164debfd5eac01ce3121.js +0 -1
- package/assets/esri/core/workers/chunks/1972e6be738a3b9289e8.js +0 -1
- package/assets/esri/core/workers/chunks/2e62e34c85d8505c98f4.js +0 -1
- package/assets/esri/core/workers/chunks/4ef2ce12499fae8b85c4.js +0 -1
- package/assets/esri/core/workers/chunks/5bf51ad34e2d729f9048.js +0 -1
- package/assets/esri/core/workers/chunks/9a9abefa8099aa1ebc3d.js +0 -1
- package/assets/esri/core/workers/chunks/da3af488df83bd8e153b.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js +0 -7
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +0 -7
- package/views/3d/webgl-engine/lib/MainColor.js +0 -5
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/DiscardByCoverage.glsl.js +0 -5
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{ShaderOutput as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{InstancedDoublePrecision as l}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as t}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as s}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{SymbolColor as n}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js";import{TextureCoordinateAttribute as d}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VerticalOffset as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{DefaultMaterialAuxiliaryPasses as m}from"../views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import{EvaluateAmbientOcclusion as v}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as b,addAmbientBoostFactor as w,addLightingGlobalFactor as p}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as u,addMainLightIntensity as h}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PhysicallyBasedRendering as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import{PhysicallyBasedRenderingParameters as y,PBRMode as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapPass as L,ReadShadowMapDraw as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{VisualVariables as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js";import{alphaCutoff as O}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaPass as P}from"../views/3d/webgl-engine/core/shaderLibrary/util/
|
|
5
|
+
import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{Offset as o}from"../views/3d/webgl-engine/core/shaderLibrary/Offset.glsl.js";import{ShaderOutput as r}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as i}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as a}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{InstancedDoublePrecision as l}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as t}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as s}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{SymbolColor as n}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js";import{TextureCoordinateAttribute as d}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as c}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VerticalOffset as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{DefaultMaterialAuxiliaryPasses as m}from"../views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import{EvaluateAmbientOcclusion as v}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as b,addAmbientBoostFactor as w,addLightingGlobalFactor as p}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as u,addMainLightIntensity as h}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PhysicallyBasedRendering as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import{PhysicallyBasedRenderingParameters as y,PBRMode as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapPass as L,ReadShadowMapDraw as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{VisualVariables as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js";import{alphaCutoff as O}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaPass as P}from"../views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import{MixExternalColor as A}from"../views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js";import{addProjViewLocalOrigin as E,addCameraPosition as S}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as N}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{Float4PassUniform as F}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as $}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as D}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as T}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as V}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{VertexAttribute as I}from"../views/3d/webgl-engine/lib/VertexAttribute.js";import{outputColorHighlightOID as B}from"../views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js";function _(_){const R=new T,{vertex:z,fragment:k,varyings:G}=R;return E(z,_),R.include(s),G.add("vpos","vec3"),R.include(M,_),R.include(l,_),R.include(g,_),_.output===r.Color&&(S(R.vertex,_),R.include(t,_),R.include(a,_),_.offsetBackfaces&&R.include(o),_.instancedColor&&R.attributes.add(I.INSTANCECOLOR,"vec4"),G.add("vNormalWorld","vec3"),G.add("localvpos","vec3"),_.multipassEnabled&&G.add("depth","float"),R.include(d,_),R.include(e,_),R.include(n,_),R.include(c,_),z.uniforms.add(new F("externalColor",(e=>e.externalColor))),G.add("vcolorExt","vec4"),z.code.add(D`
|
|
6
6
|
void main(void) {
|
|
7
7
|
forwardNormalizedVertexColor();
|
|
8
8
|
vcolorExt = externalColor;
|
|
@@ -26,7 +26,7 @@ import{ForwardLinearDepth as e}from"../views/3d/webgl-engine/core/shaderLibrary/
|
|
|
26
26
|
forwardLinearDepth();
|
|
27
27
|
forwardTextureCoordinates();
|
|
28
28
|
}
|
|
29
|
-
`)),_.output===r.Color&&(R.include(b,_),R.include(v,_),R.include(P,_),R.include(_.instancedDoublePrecision?L:j,_),R.include(f,_),R.include(i,_),R.include(B,_),
|
|
29
|
+
`)),_.output===r.Color&&(R.include(b,_),R.include(v,_),R.include(P,_),R.include(_.instancedDoublePrecision?L:j,_),R.include(f,_),R.include(i,_),R.include(B,_),S(R.fragment,_),u(k),w(k),p(k),k.uniforms.add(z.uniforms.get("localOrigin"),z.uniforms.get("view"),new N("ambient",(e=>e.ambient)),new N("diffuse",(e=>e.diffuse)),new $("opacity",(e=>e.opacity)),new $("layerOpacity",(e=>e.layerOpacity))),_.hasColorTexture&&k.uniforms.add(new V("tex",(e=>e.texture))),R.include(y,_),R.include(x,_),k.include(A),h(k),k.code.add(D`
|
|
30
30
|
void main() {
|
|
31
31
|
discardBySlice(vpos);
|
|
32
32
|
${_.multipassEnabled?D`terrainDepthTest(depth);`:""}
|
package/chunks/Terrain.glsl.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{translate as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{n as o,s as i}from"./vec32.js";import{create as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{OverlayContent as l}from"../views/3d/terrain/OverlayContent.js";import{TransparencyMode as t}from"../views/3d/terrain/TransparencyMode.js";import{addLinearDepth as n,addNearFar as s,ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as v}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as m}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{NormalAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{TextureCoordinateAttribute as f}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexTangent as w}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js";import{OutputDepth as h}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as
|
|
5
|
+
import{translate as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{n as o,s as i}from"./vec32.js";import{create as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{OverlayContent as l}from"../views/3d/terrain/OverlayContent.js";import{TransparencyMode as t}from"../views/3d/terrain/TransparencyMode.js";import{addLinearDepth as n,addNearFar as s,ForwardLinearDepth as d}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as v}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as m}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{NormalAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{TextureCoordinateAttribute as f}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexTangent as w}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js";import{OutputDepth as h}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as b}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{EvaluateAmbientOcclusion as u}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as y,addAmbientBoostFactor as C,addLightingGlobalFactor as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as O,addMainLightIntensity as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{NormalUtils as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js";import{PBRMode as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapDraw as z}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{OverlayMode as P,OverlayTerrain as T}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{OverlayTerrainPassParameters as M,TerrainTexture as $}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js";import{alphaCutoff as N}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{addProjViewLocalOrigin as D,addViewNormal as W,addCameraPosition as V}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as U}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{glsl as F}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{Matrix4DrawUniform as A}from"../views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js";import{ShaderBuilder as _}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as B}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";class k extends M{}function I(r){const a=new _,{vertex:M,fragment:k,varyings:I}=a;a.include(p),a.include(g,r),a.include(f,r);const E=()=>{a.include(j,r),M.code.add(F`vec3 getNormal() {
|
|
6
6
|
float z = 1.0 - abs(normalCompressed.x) - abs(normalCompressed.y);
|
|
7
7
|
vec3 n = vec3(normalCompressed + vec2(normalCompressed.x >= 0.0 ? 1.0 : -1.0,
|
|
8
8
|
normalCompressed.y >= 0.0 ? 1.0 : -1.0) * min(z, 0.0), z);
|
|
9
9
|
return normalize(n);
|
|
10
|
-
}`)}
|
|
10
|
+
}`)};D(M,r),a.include(m,r);const G=r.transparencyMode===t.InvisibleWithDraped||r.transparencyMode===t.Invisible,R=r.overlayMode!==P.Disabled,J=R&&G;switch(r.output){case c.Color:{a.include($,r),a.include(y,r),R&&a.include(T,{...r,pbrMode:r.pbrMode===L.Simplified?L.TerrainWithWater:L.Water});const t=r.overlayMode===P.EnabledWithWater;t&&a.include(w,r),I.add("vnormal","vec3"),I.add("vpos","vec3"),I.add("vup","vec3"),E(),r.screenSizePerspective&&W(M);const n=r.receiveShadows&&!r.renderOccluded;n&&a.include(d,r),r.screenSizePerspective&&(I.add("screenSizeDistanceToCamera","float"),I.add("screenSizeCosAngle","float")),M.code.add(F`
|
|
11
11
|
void main(void) {
|
|
12
12
|
//Position
|
|
13
13
|
vpos = position;
|
|
@@ -20,27 +20,27 @@ return normalize(n);
|
|
|
20
20
|
//Up
|
|
21
21
|
vup = getLocalUp(position, localOrigin);
|
|
22
22
|
|
|
23
|
-
${t?
|
|
23
|
+
${t?F`forwardVertexTangent(vnormal);`:F``}
|
|
24
24
|
|
|
25
25
|
//Texture UV
|
|
26
26
|
vec2 uv = getUV0();
|
|
27
27
|
forwardTextureCoordinatesWithTransform(uv);
|
|
28
|
-
${
|
|
29
|
-
${r.tileBorders?
|
|
28
|
+
${R?F`setOverlayVTC(uv);`:""}
|
|
29
|
+
${r.tileBorders?F`forwardTextureCoordinates();`:""}
|
|
30
30
|
|
|
31
|
-
${r.screenSizePerspective?
|
|
31
|
+
${r.screenSizePerspective?F`
|
|
32
32
|
vec3 viewPos = (view * vec4(vpos, 1.0)).xyz;
|
|
33
33
|
screenSizeDistanceToCamera = length(viewPos);
|
|
34
34
|
vec3 viewSpaceNormal = (viewNormal * vec4(normalize(positionWorld), 1.0)).xyz;
|
|
35
35
|
screenSizeCosAngle = abs(viewSpaceNormal.z);`:""}
|
|
36
36
|
|
|
37
|
-
${n?
|
|
37
|
+
${n?F`forwardLinearDepth();`:""}
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`),a.include(v,r),a.include(y,r),a.include(
|
|
40
|
+
`),a.include(v,r),a.include(y,r),a.include(u,r),a.include(z,r),V(k,r),C(k),x(k),k.uniforms.add(M.uniforms.get("localOrigin"),new U("viewDirection",((e,r)=>o(q,i(q,r.camera.viewMatrix[12],r.camera.viewMatrix[13],r.camera.viewMatrix[14]))))),t&&k.uniforms.add(new B("ovWaterTex",((e,r)=>r.overlay?.getTexture(l.WaterNormal))),new A("view",((r,o)=>e(H,o.camera.viewMatrix,r.origin)))),k.code.add(F`const float sliceOpacity = 0.2;
|
|
41
41
|
float lum(vec3 c) {
|
|
42
42
|
return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
43
|
-
}`),O(
|
|
43
|
+
}`),O(k),S(k),k.code.add(F`
|
|
44
44
|
void main() {
|
|
45
45
|
vec3 normal = normalize(vnormal);
|
|
46
46
|
float vndl = dot(normal, mainLightDirection);
|
|
@@ -51,16 +51,16 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
51
51
|
float ssao = evaluateAmbientOcclusionInverse();
|
|
52
52
|
vec4 tileColor = getTileColor();
|
|
53
53
|
|
|
54
|
-
${
|
|
54
|
+
${R?F`
|
|
55
55
|
vec4 overlayColorOpaque = getOverlayColor(ovColorTex, vtcOverlay);
|
|
56
56
|
vec4 overlayColor = overlayOpacity * overlayColorOpaque;
|
|
57
|
-
${
|
|
57
|
+
${G?F`if (overlayColor.a < ${F.float(N)}) { discard; }`:""}
|
|
58
58
|
vec4 groundColor = tileColor;
|
|
59
59
|
tileColor = tileColor * (1.0 - overlayColor.a) + overlayColor;`:""}
|
|
60
60
|
|
|
61
61
|
// If combined alpha is 0 we can discard pixel. The performance impact by having a discard here
|
|
62
62
|
// is neglectable because terrain typically renders first into the framebuffer.
|
|
63
|
-
if(tileColor.a
|
|
63
|
+
if(tileColor.a < ${F.float(N)}) {
|
|
64
64
|
discard;
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -75,8 +75,8 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
75
75
|
|
|
76
76
|
vec3 additionalLight = ssao * mainLightIntensity * additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor;
|
|
77
77
|
|
|
78
|
-
${r.pbrMode===L.Simplified||r.pbrMode===L.TerrainWithWater?
|
|
79
|
-
${t?
|
|
78
|
+
${r.pbrMode===L.Simplified||r.pbrMode===L.TerrainWithWater?F`fragColor = vec4(evaluatePBRSimplifiedLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight, normalize(vpos - cameraPosition), vup), tileColor.a);`:F`fragColor = vec4(evaluateSceneLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight), tileColor.a);`}
|
|
79
|
+
${t?F`
|
|
80
80
|
vec4 overlayWaterMask = getOverlayColor(ovWaterTex, vtcOverlay);
|
|
81
81
|
float waterNormalLength = length(overlayWaterMask);
|
|
82
82
|
if (waterNormalLength > 0.95) {
|
|
@@ -89,7 +89,7 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
89
89
|
// un-gamma the ground color to mix in linear space
|
|
90
90
|
fragColor = mix(groundColor, waterColorNonLinear, waterColorLinear.w) * opacity;
|
|
91
91
|
}`:""}
|
|
92
|
-
${r.screenSizePerspective?
|
|
92
|
+
${r.screenSizePerspective?F`
|
|
93
93
|
float perspectiveScale = screenSizePerspectiveScaleFloat(1.0, screenSizeCosAngle, screenSizeDistanceToCamera, vec4(0.0, 0.0, 0.0, 0.0));
|
|
94
94
|
if (perspectiveScale <= 0.25) {
|
|
95
95
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 0.0, 1.0), perspectiveScale * 4.0);
|
|
@@ -103,72 +103,72 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
103
103
|
else {
|
|
104
104
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 1.0, 1.0), (perspectiveScale - 0.5) * 2.0);
|
|
105
105
|
}`:""}
|
|
106
|
-
${r.visualizeNormals?r.spherical?
|
|
106
|
+
${r.visualizeNormals?r.spherical?F`
|
|
107
107
|
vec3 localUp = normalize(vpos + localOrigin);
|
|
108
108
|
vec3 right = normalize(cross(vec3(0.0, 0.0, 1.0), localUp));
|
|
109
109
|
vec3 forward = normalize(cross(localUp, right));
|
|
110
110
|
mat3 tbn = mat3(right, forward, localUp);
|
|
111
111
|
vec3 tNormal = normalize(normal * tbn);
|
|
112
112
|
fragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
113
|
-
`:
|
|
113
|
+
`:F`
|
|
114
114
|
vec3 tNormal = normalize(normal);
|
|
115
115
|
fragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
116
116
|
`:""}
|
|
117
|
-
${r.tileBorders?
|
|
117
|
+
${r.tileBorders?F`
|
|
118
118
|
vec2 dVuv = fwidth(vuv0);
|
|
119
119
|
vec2 edgeFactors = smoothstep(vec2(0.0), 1.5 * dVuv, min(vuv0, 1.0 - vuv0));
|
|
120
120
|
float edgeFactor = 1.0 - min(edgeFactors.x, edgeFactors.y);
|
|
121
121
|
fragColor = mix(fragColor, vec4(1.0, 0.0, 0.0, 1.0), edgeFactor);`:""}
|
|
122
122
|
fragColor = highlightSlice(fragColor, vpos);
|
|
123
123
|
}
|
|
124
|
-
`)}break;case c.Depth:
|
|
124
|
+
`)}break;case c.Depth:J&&a.include(T,r),M.code.add(F`
|
|
125
125
|
void main(void) {
|
|
126
|
-
${
|
|
126
|
+
${J?F`setOverlayVTC(getUV0());`:""}
|
|
127
127
|
gl_Position = transformPosition(proj, view, position);
|
|
128
128
|
}
|
|
129
|
-
`),
|
|
129
|
+
`),k.code.add(F`
|
|
130
130
|
void main() {
|
|
131
|
-
${
|
|
131
|
+
${J?F`if (getCombinedOverlayColor().a < ${F.float(N)}) discard;`:""}
|
|
132
132
|
}
|
|
133
|
-
`);break;case c.Shadow:case c.ShadowHighlight:case c.ShadowExcludeHighlight:case c.ViewshedShadow:a.include(h,r),n(a),s(a),M.code.add(
|
|
133
|
+
`);break;case c.Shadow:case c.ShadowHighlight:case c.ShadowExcludeHighlight:case c.ViewshedShadow:a.include(h,r),n(a),s(a),M.code.add(F`void main(void) {
|
|
134
134
|
gl_Position = transformPositionWithDepth(proj, view, position, nearFar, linearDepth);
|
|
135
|
-
}`),
|
|
135
|
+
}`),k.code.add(F`void main() {
|
|
136
136
|
outputDepth(linearDepth);
|
|
137
|
-
}`);break;case c.Normal:
|
|
137
|
+
}`);break;case c.Normal:J&&a.include(T,r),I.add("vnormal","vec3"),W(M),E(),M.code.add(F`
|
|
138
138
|
void main(void) {
|
|
139
|
-
${
|
|
139
|
+
${J?F`setOverlayVTC(getUV0());`:""}
|
|
140
140
|
gl_Position = transformPosition(proj, view, position);
|
|
141
141
|
vnormal = normalize((viewNormal * vec4(getNormal(), 1.0)).xyz);
|
|
142
142
|
}
|
|
143
|
-
`),
|
|
143
|
+
`),k.code.add(F`
|
|
144
144
|
void main() {
|
|
145
|
-
${
|
|
145
|
+
${J?F`if (getCombinedOverlayColor().a < ${F.float(N)}) discard;`:""}
|
|
146
146
|
vec3 normal = normalize(vnormal);
|
|
147
147
|
if (gl_FrontFacing == false) {
|
|
148
148
|
normal = -normal;
|
|
149
149
|
}
|
|
150
150
|
fragColor = vec4(vec3(0.5) + 0.5 * normal, 1.0);
|
|
151
151
|
}
|
|
152
|
-
`);break;case c.Highlight:
|
|
152
|
+
`);break;case c.Highlight:R&&a.include(T,r),M.code.add(F`
|
|
153
153
|
void main() {
|
|
154
|
-
${
|
|
154
|
+
${R?F`setOverlayVTC(getUV0());`:""}
|
|
155
155
|
gl_Position = transformPosition(proj, view, position);
|
|
156
156
|
}
|
|
157
|
-
`),a.include(
|
|
157
|
+
`),a.include(b,r),k.code.add(F`
|
|
158
158
|
void main() {
|
|
159
|
-
${
|
|
159
|
+
${R?F`
|
|
160
160
|
vec4 combinedOverlayColor = getCombinedOverlayColor();
|
|
161
161
|
if (combinedOverlayColor == vec4(0.0)) { discard; }
|
|
162
|
-
`:
|
|
162
|
+
`:F``}
|
|
163
163
|
outputHighlight();
|
|
164
164
|
}
|
|
165
|
-
`)}if(r.output===c.ObjectAndLayerIdColor)if(
|
|
165
|
+
`)}if(r.output===c.ObjectAndLayerIdColor)if(R)a.include(T,{...r,pbrMode:L.Disabled}),M.code.add(F`void main(void) {
|
|
166
166
|
gl_Position = transformPosition(proj, view, position);
|
|
167
167
|
setOverlayVTC(getUV0());
|
|
168
|
-
}`),
|
|
168
|
+
}`),k.code.add(F`void main() {
|
|
169
169
|
fragColor = getOverlayColorTexel(vtcOverlay);
|
|
170
|
-
}`);else{const e=r.transparencyMode===t.Opaque;M.code.add(
|
|
171
|
-
${e?
|
|
172
|
-
}`),
|
|
170
|
+
}`);else{const e=r.transparencyMode===t.Opaque;M.code.add(F`void main(void) {
|
|
171
|
+
${e?F` gl_Position = transformPosition(proj, view, position);`:""}
|
|
172
|
+
}`),k.code.add(F`void main() {
|
|
173
173
|
fragColor = vec4(0.0);
|
|
174
|
-
}`)}return a}const
|
|
174
|
+
}`)}return a}const H=r(),q=a(),E=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:k,build:I},Symbol.toStringTag,{value:"Module"}));export{k as T,E as a,I as b};
|
package/geometry/Polyline.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import{clone as e}from"../core/lang.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{writer as i}from"../core/accessorSupport/decorators/writer.js";import a from"./Extent.js";import n from"./Geometry.js";import o from"./Point.js";import h from"./SpatialReference.js";import{getPolylineExtent as p}from"./support/extentUtils.js";import{updateSupportFromPoint as l}from"./support/zmUtils.js";var c;function u(t){return!Array.isArray(t[0])}
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{clone as e}from"../core/lang.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{writer as i}from"../core/accessorSupport/decorators/writer.js";import a from"./Extent.js";import n from"./Geometry.js";import o from"./Point.js";import h from"./SpatialReference.js";import{getPolylineExtent as p}from"./support/extentUtils.js";import{updateSupportFromPoint as l}from"./support/zmUtils.js";var c;function u(t){return!Array.isArray(t[0])}function f(t){return"number"==typeof t[0]?.[0]}function m(t){if(!t)return;let{paths:e,hasM:s,hasZ:r,spatialReference:i}=t;switch(e??=[],f(e)&&(e=[e]),e[0]?.[0]?.length){case 4:r??=!0,s??=!0;break;case 3:r??=!0!==s,s??=!r;break;default:r??=!1,s??=!1}return i??=h.WGS84,{hasM:s,hasZ:r,paths:e,spatialReference:i}}let y=c=class extends n{constructor(t){super(m(t)),this.paths=[],this.type="polyline"}get cache(){return this.commitProperty("paths"),this.commitProperty("hasZ"),this.commitProperty("hasM"),this.commitProperty("spatialReference"),{}}get extent(){const{spatialReference:t}=this,e=p(this);if(!e)return null;const s=new a(e);return s.spatialReference=t,s}writePaths(t,s){s.paths=e(this.paths)}addPath(t){if(!t)return;const e=this.paths,s=e.length;if(u(t)){const r=[];for(let e=0,s=t.length;e<s;e++)r[e]=t[e].toArray();e[s]=r}else e[s]=t.concat();return this.notifyChange("paths"),this}clone(){const t=new c;return t.spatialReference=this.spatialReference,t.paths=e(this.paths),t.hasZ=this.hasZ,t.hasM=this.hasM,t}getPoint(t,e){if(!this._validateInputs(t,e))return null;const s=this.paths[t][e],r=this.hasZ,i=this.hasM;return r&&!i?new o(s[0],s[1],s[2],void 0,this.spatialReference):i&&!r?new o(s[0],s[1],void 0,s[2],this.spatialReference):r&&i?new o(s[0],s[1],s[2],s[3],this.spatialReference):new o(s[0],s[1],this.spatialReference)}insertPoint(t,e,s){return this._validateInputs(t,e,!0)?(l(this,s),Array.isArray(s)||(s=s.toArray()),this.paths[t].splice(e,0,s),this.notifyChange("paths"),this):this}removePath(t){if(!this._validateInputs(t,null))return null;const e=this.paths.splice(t,1)[0],s=this.spatialReference,r=e.map((t=>new o(t,s)));return this.notifyChange("paths"),r}removePoint(t,e){if(!this._validateInputs(t,e))return null;const s=new o(this.paths[t].splice(e,1)[0],this.spatialReference);return this.notifyChange("paths"),s}setPoint(t,e,s){return this._validateInputs(t,e)?(l(this,s),Array.isArray(s)||(s=s.toArray()),this.paths[t][e]=s,this.notifyChange("paths"),this):this}_validateInputs(t,e,s=!1){if(null==t||t<0||t>=this.paths.length)return!1;if(null!=e){const r=this.paths[t];if(s&&(e<0||e>r.length))return!1;if(!s&&(e<0||e>=r.length))return!1}return!0}toJSON(t){return this.write({},t)}};t([s({readOnly:!0})],y.prototype,"cache",null),t([s({readOnly:!0})],y.prototype,"extent",null),t([s({type:[[[Number]]],json:{write:{isRequired:!0}}})],y.prototype,"paths",void 0),t([i("paths")],y.prototype,"writePaths",null),y=c=t([r("esri.geometry.Polyline")],y);const d=y;y.prototype.toJSON.isDefaultToJSON=!0;export{d as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{JSONSupport as t}from"../core/JSONSupport.js";import{clone as r}from"../core/lang.js";import{getMetersPerUnitForSR as i,getUnitString as o}from"../core/unitUtils.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";import{wgs84 as p,webMercator as u,plateCarree as c,isWGS84 as d,isWebMercator as m,isGeographic as w,isWrappable as y,equals as k}from"./support/spatialReferenceUtils.js";var h;let S=h=class extends t{static fromJSON(e){if(!e)return null;if(
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{JSONSupport as t}from"../core/JSONSupport.js";import{clone as r}from"../core/lang.js";import{getMetersPerUnitForSR as i,getUnitString as o}from"../core/unitUtils.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";import{wgs84 as p,webMercator as u,plateCarree as c,isWGS84 as d,isWebMercator as m,isGeographic as w,isWrappable as y,equals as k}from"./support/spatialReferenceUtils.js";var h;let S=h=class extends t{static fromJSON(e){if(!e)return null;if(102100===e?.wkid)return h.WebMercator;if(4326===e?.wkid)return h.WGS84;const t=new h;return t.read(e),t}constructor(e){super(e),this.latestWkid=null,this.wkid=null,this.wkt=null,this.wkt2=null,this.vcsWkid=null,this.latestVcsWkid=null,this.imageCoordinateSystem=null}normalizeCtorArgs(e){if(e&&"object"==typeof e)return e;const t="string"==typeof e?"wkt":"wkid";return{[t]:e}}get isWGS84(){return d(this)}get isWebMercator(){return m(this)}get isGeographic(){return w(this)}get isWrappable(){return y(this)}get metersPerUnit(){return i(this)}get unit(){return o(this)||(this.isGeographic?"degrees":null)}writeWkt(e,t){this.wkid||(t.wkt=e)}clone(){if(this===h.WGS84)return new h(p);if(this===h.WebMercator)return new h(u);const e=new h;return null!=this.wkid?(e.wkid=this.wkid,null!=this.latestWkid&&(e.latestWkid=this.latestWkid),null!=this.vcsWkid&&(e.vcsWkid=this.vcsWkid),null!=this.latestVcsWkid&&(e.latestVcsWkid=this.latestVcsWkid)):(null!=this.wkt&&(e.wkt=this.wkt),null!=this.wkt2&&(e.wkt2=this.wkt2)),this.imageCoordinateSystem&&(e.imageCoordinateSystem=r(this.imageCoordinateSystem)),e}equals(e){if(null==e)return!1;if(this.imageCoordinateSystem||e.imageCoordinateSystem){if(null==this.imageCoordinateSystem||null==e.imageCoordinateSystem)return!1;const{id:t,referenceServiceName:r}=e.imageCoordinateSystem,{geodataXform:i}=e.imageCoordinateSystem,o=this.imageCoordinateSystem;return null==t||i?JSON.stringify(o)===JSON.stringify(e.imageCoordinateSystem):r?o.id===t&&o.referenceServiceName===r:o.id===t}return k(this,e)}toJSON(e){return this.write(void 0,e)}};S.GCS_NAD_1927=null,S.WGS84=null,S.WebMercator=null,S.PlateCarree=null,e([n({readOnly:!0})],S.prototype,"isWGS84",null),e([n({readOnly:!0})],S.prototype,"isWebMercator",null),e([n({readOnly:!0})],S.prototype,"isGeographic",null),e([n({readOnly:!0})],S.prototype,"isWrappable",null),e([n({type:s,json:{write:!0}})],S.prototype,"latestWkid",void 0),e([n({readOnly:!0})],S.prototype,"metersPerUnit",null),e([n({readOnly:!0})],S.prototype,"unit",null),e([n({type:s,json:{write:!0,origins:{"web-scene":{write:{overridePolicy(){return{isRequired:null==this.wkt}}}}}}})],S.prototype,"wkid",void 0),e([n({type:String,json:{origins:{"web-scene":{write:{overridePolicy(){return{isRequired:null==this.wkid}}}}}}})],S.prototype,"wkt",void 0),e([a("wkt"),a("web-scene","wkt")],S.prototype,"writeWkt",null),e([n({type:String,json:{write:!1}})],S.prototype,"wkt2",void 0),e([n({type:s,json:{write:!0}})],S.prototype,"vcsWkid",void 0),e([n({type:s,json:{write:!0}})],S.prototype,"latestVcsWkid",void 0),e([n()],S.prototype,"imageCoordinateSystem",void 0),S=h=e([l("esri.geometry.SpatialReference")],S),S.prototype.toJSON.isDefaultToJSON=!0,S.GCS_NAD_1927=new S({wkid:4267,wkt:'GEOGCS["GCS_North_American_1927",DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'}),S.WGS84=new S(p),S.WebMercator=new S(u),S.PlateCarree=new S(c),Object.freeze&&(Object.freeze(S.GCS_NAD_1927),Object.freeze(S.WGS84),Object.freeze(S.WebMercator),Object.freeze(S.PlateCarree));const f=S;export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import"../geometry.js";import{ensureClass as n}from"../core/accessorSupport/ensureType.js";import{G as e}from"../chunks/geometryEngineBase.js";import{hydratedAdapter as r}from"./geometryAdapters/hydrated.js";import t from"./SpatialReference.js";function u(e){const r=Array.isArray(e)?e[0].spatialReference:e.spatialReference;return r?n(t,r):t.WGS84}function i(n){return e.extendedSpatialReferenceInfo(n)}function o(n,t){return e.clip(r,u(n),n,t)}function c(n,t){return e.cut(r,u(n),n,t)}function f(n,t){return e.contains(r,u(n),n,t)}function s(n,t){return e.crosses(r,u(n),n,t)}function a(n,t,i){return e.distance(r,u(n),n,t,i)}function l(n,t){return e.equals(r,u(n),n,t)}function p(n,t){return e.intersects(r,u(n),n,t)}function m(n,t){return e.touches(r,u(n),n,t)}function d(n,t){return e.within(r,u(n),n,t)}function g(n,t){return e.disjoint(r,u(n),n,t)}function h(n,t){return e.overlaps(r,u(n),n,t)}function w(n,t,i){return e.relate(r,u(n),n,t,i)}function R(n){return e.isSimple(r,u(n),n)}function y(n){return e.simplify(r,u(n),n)}function x(n,t=!1){return e.convexHull(r,u(n),n,t)}function S(n,t){return e.difference(r,u(n),n,t)}function j(n,t){return e.symmetricDifference(r,u(n),n,t)}function A(n,t){return e.intersect(r,u(n),n,t)}function D(n,t=null){return e.union(r,u(n),n,t)}function T(n,t,i,o,c,f){return e.offset(r,u(n),n,t,i,o,c,f)}function E(n,t,i,o=!1){return e.buffer(r,u(n),n,t,i,o)}function J(n,t,i,o,c,f){return e.geodesicBuffer(r,u(n),n,t,i,o,c,f)}function L(n,t,i=!0){return e.nearestCoordinate(r,u(n),n,t,i)}function N(n,t){return e.nearestVertex(r,u(n),n,t)}function O(n,t,i,o){return e.nearestVertices(r,u(n),n,t,i,o)}function V(n){return"xmin"in n?"center"in n?n.center:null:"x"in n?n:"extent"in n?n.extent?.center??null:null}function v(n,r,t){if(null==n)throw new K;const u=n.spatialReference;if(null==(t=t??V(n)))throw new K;const i=n.constructor.fromJSON(e.rotate(n,r,t));return i.spatialReference=u,i}function z(n,r){if(null==n)throw new K;const t=n.spatialReference;if(null==(r=r??V(n)))throw new K;const u=n.constructor.fromJSON(e.flipHorizontal(n,r));return u.spatialReference=t,u}function B(n,r){if(null==n)throw new K;const t=n.spatialReference;if(null==(r=r??V(n)))throw new K;const u=n.constructor.fromJSON(e.flipVertical(n,r));return u.spatialReference=t,u}function G(n,t,i,o){return e.generalize(r,u(n),n,t,i,o)}function H(n,t,i){return e.densify(r,u(n),n,t,i)}function I(n,t,i,o=0){return e.geodesicDensify(r,u(n),n,t,i,o)}function b(n,t){return e.planarArea(r,u(n),n,t)}function k(n,t){return e.planarLength(r,u(n),n,t)}function q(n,t,i){return e.geodesicArea(r,u(n),n,t,i)}function C(n,t,i){return e.geodesicLength(r,u(n),n,t,i)}function P(n,t){return e.intersectLinesToPoints(r,u(n),n,t)}function W(n,r){e.changeDefaultSpatialReferenceTolerance(n,r)}function F(n){e.clearDefaultSpatialReferenceTolerance(n)}class K extends Error{constructor(){super("Illegal Argument Exception")}}export{E as buffer,W as changeDefaultSpatialReferenceTolerance,F as clearDefaultSpatialReferenceTolerance,o as clip,f as contains,x as convexHull,s as crosses,c as cut,H as densify,S as difference,g as disjoint,a as distance,l as equals,i as extendedSpatialReferenceInfo,z as flipHorizontal,B as flipVertical,G as generalize,q as geodesicArea,J as geodesicBuffer,I as geodesicDensify,C as geodesicLength,A as intersect,P as intersectLinesToPoints,p as intersects,R as isSimple,L as nearestCoordinate,N as nearestVertex,O as nearestVertices,T as offset,h as overlaps,b as planarArea,k as planarLength,w as relate,v as rotate,y as simplify,j as symmetricDifference,m as touches,D as union,d as within};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../geometry.js";import e from"../../core/Error.js";import{convertUnit as t}from"../../core/unitUtils.js";import{toRadians as
|
|
5
|
+
import"../../geometry.js";import e from"../../core/Error.js";import{convertUnit as t}from"../../core/unitUtils.js";import{ensureClass as n}from"../../core/accessorSupport/ensureType.js";import{toRadians as i,spheroids as s,wktSpheroidRegex as r}from"./geodesicConstants.js";import{equals as a,isWebMercator as o,isGeographic as c}from"./spatialReferenceUtils.js";import l from"../Polyline.js";import h from"../SpatialReference.js";import p from"../Polygon.js";import f from"../Point.js";function u(e){if(!e)return null;if(c(e)&&e.wkid){const t=s[e.wkid];if(t)return t}const t=e.wkt2||e.wkt;if(t){const e=m(t);if(e)return e}return null}function m(e){const t=r.exec(e);if(!t||2!==t.length)return null;const n=t[1].split(",");if(!n||n.length<3)return null;const i=parseFloat(n[1]),s=parseFloat(n[2]);if(isNaN(i)||isNaN(s))return null;return{a:i,f:0===s?0:1/s}}function d(e){const t=u(e);if(g(t))return t;const n=t.a*(1-t.f);return Object.assign(t,{b:n,eSq:1-(n/t.a)**2,radius:(2*t.a+n)/3,densificationRatio:1e4/((2*t.a+n)/3)})}function g(e){return null!=e&&"b"in e&&"eSq"in e&&"radius"in e}function M(e){return null!=e&&e<0?e+360:e}function w(e,t,n){const{a:s,eSq:r}=d(n),a=Math.sqrt(r),o=Math.sin(t[1]*i),c=s*t[0]*i;let l;if(r>0){l=s*((1-r)*(o/(1-r*(o*o))-1/(2*a)*Math.log((1-a*o)/(1+a*o))))*.5}else l=s*o;return e[0]=c,e[1]=l,e}function y(e){return null!==u(e)}function v(n,i="square-meters"){if(n.some((e=>!y(e.spatialReference))))throw new e("geodesic-areas:invalid-spatial-reference","the input geometries spatial reference is not supported");const s=[];for(let e=0;e<n.length;e++){const t=n[e],i=t.spatialReference,{radius:r,densificationRatio:a}=d(i),o=r*a;s.push(z(t,o))}const r=[],a=[0,0],o=[0,0];for(let e=0;e<s.length;e++){const{rings:n,spatialReference:c}=s[e];let l=0;for(let e=0;e<n.length;e++){const t=n[e];w(a,t[0],c),w(o,t[t.length-1],c);let i=o[0]*a[1]-a[0]*o[1];for(let e=0;e<t.length-1;e++)w(a,t[e+1],c),w(o,t[e],c),i+=o[0]*a[1]-a[0]*o[1];l+=i}l=t(l,"square-meters",i),r.push(l/-2)}return r}function R(n,i="meters"){if(!n)throw new e("geodesic-lengths:invalid-geometries","the input geometries type is not supported");if(n.some((e=>!y(e.spatialReference))))throw new e("geodesic-lengths:invalid-spatial-reference","the input geometries spatial reference is not supported");const s=[];for(let e=0;e<n.length;e++){const r=n[e],{spatialReference:a}=r,o="polyline"===r.type?r.paths:r.rings;let c=0;for(let e=0;e<o.length;e++){const t=o[e];let n=0;for(let e=1;e<t.length;e++){const i=t[e-1][0],s=t[e][0],r=t[e-1][1],o=t[e][1];if(r!==o||i!==s){const e=new b;q(e,[i,r],[s,o],a),n+=e.distance}}c+=n}c=t(c,"meters",i),s.push(c)}return s}function z(t,i){if("polyline"!==t.type&&"polygon"!==t.type)throw new e("geodesic-densify:invalid-geometry","the input geometry is neither polyline nor polygon");const{spatialReference:s}=t;if(!y(s))throw new e("geodesic-densify:invalid-spatial-reference","the input geometry spatial reference is not supported");const r="polyline"===t.type?t.paths:t.rings,a=[],o=[0,0],c=new b;for(const e of r){const t=[];a.push(t),t.push([e[0][0],e[0][1]]);let n,r,l=e[0][0],h=e[0][1];for(let a=0;a<e.length-1;a++){if(n=e[a+1][0],r=e[a+1][1],l===n&&h===r)continue;const p=[l,h];q(c,[l,h],[n,r],s);const{azimuth:f,distance:u}=c,m=u/i;if(m>1){for(let e=1;e<=m-1;e++){j(o,p,f,e*i,s),t.push(o.slice(0))}j(o,p,f,(u+Math.floor(m-1)*i)/2,s),t.push(o.slice(0))}j(o,p,f,u,s),t.push(o.slice(0)),l=o[0],h=o[1]}}return"polyline"===t.type?new l({paths:a,spatialReference:n(h,s)}):new p({rings:a,spatialReference:s})}class b{constructor(e=0,t=void 0,n=void 0){this.distance=e,this.azimuth=t,this.reverseAzimuth=n}}function j(e,t,n,s,r){const a=t[0],o=t[1],c=a*i,l=o*i,h=(n??0)*i,{a:p,b:f,f:u}=d(r),m=Math.sin(h),g=Math.cos(h),M=(1-u)*Math.tan(l),w=1/Math.sqrt(1+M*M),y=M*w,v=Math.atan2(M,g),R=w*m,z=R*R,b=1-z,j=b*(p*p-f*f)/(f*f),q=1+j/16384*(4096+j*(j*(320-175*j)-768)),x=j/1024*(256+j*(j*(74-47*j)-128));let A,N,S,k,P=s/(f*q),F=2*Math.PI;for(;Math.abs(P-F)>1e-12;)S=Math.cos(2*v+P),A=Math.sin(P),N=Math.cos(P),k=x*A*(S+x/4*(N*(2*S*S-1)-x/6*S*(4*A*A-3)*(4*S*S-3))),F=P,P=s/(f*q)+k;const U=y*A-w*N*g,C=Math.atan2(y*N+w*A*g,(1-u)*Math.sqrt(z+U*U)),E=Math.atan2(A*m,w*N-y*A*g),G=u/16*b*(4+u*(4-3*b)),I=C/i,O=(c+(E-(1-G)*u*R*(P+G*A*(S+G*N*(2*S*S-1)))))/i;return e[0]=O,e[1]=I,e}function q(e,t,n,s){const r=t[0]*i,a=t[1]*i,o=n[0]*i,c=n[1]*i,{a:l,b:h,f:p,radius:f}=d(s),u=o-r,m=Math.atan((1-p)*Math.tan(a)),g=Math.atan((1-p)*Math.tan(c)),M=Math.sin(m),w=Math.cos(m),y=Math.sin(g),v=Math.cos(g);let R,z,b,j,q,x,A,N,S,k,P=1e3,F=u;do{if(A=Math.sin(F),N=Math.cos(F),b=Math.sqrt(v*A*(v*A)+(w*y-M*v*N)*(w*y-M*v*N)),0===b)return e.distance=0,e.azimuth=void 0,e.reverseAzimuth=void 0,e;q=M*y+w*v*N,x=Math.atan2(b,q),S=w*v*A/b,z=1-S*S,j=q-2*M*y/z,isNaN(j)&&(j=0),k=p/16*z*(4+p*(4-3*z)),R=F,F=u+(1-k)*p*S*(x+k*b*(j+k*q*(2*j*j-1)))}while(Math.abs(F-R)>1e-12&&--P>0);if(0===P){const t=f,n=Math.acos(Math.sin(a)*Math.sin(c)+Math.cos(a)*Math.cos(c)*Math.cos(o-r))*t,s=o-r,l=Math.sin(s)*Math.cos(c),h=Math.cos(a)*Math.sin(c)-Math.sin(a)*Math.cos(c)*Math.cos(s),p=Math.atan2(l,h);return e.azimuth=p/i,e.distance=n,e.reverseAzimuth=void 0,e}const U=z*(l*l-h*h)/(h*h),C=U/1024*(256+U*(U*(74-47*U)-128)),E=h*(1+U/16384*(4096+U*(U*(320-175*U)-768)))*(x-C*b*(j+C/4*(q*(2*j*j-1)-C/6*j*(4*b*b-3)*(4*j*j-3)))),G=Math.atan2(v*Math.sin(F),w*y-M*v*Math.cos(F)),I=Math.atan2(w*Math.sin(F),w*y*Math.cos(F)-M*v);return e.azimuth=G/i,e.distance=E,e.reverseAzimuth=I/i,e}function x(n,i,s="meters"){if(!n||!i)throw new e("geodesic-distance:missing-parameters","one or both input parameters are missing");if(!n.spatialReference||!i.spatialReference)throw new e("geodesic-distance:invalid-parameters","one or both input points do not have a spatial reference");if(!a(n.spatialReference,i.spatialReference))throw new e("geodesic-distance:invalid-parameters","spatial references of input parameters do not match");const{spatialReference:r}=n;if(!y(r))throw new e("geodesic-distance:not-supported","input geometry spatial reference is not supported");if(n.x===i.x&&n.y===i.y)return new b(0,0,0);const o=new b;return q(o,[n.x,n.y],[i.x,i.y],r),o.distance=t(o.distance,"meters",s),o.azimuth=M(o.azimuth),o.reverseAzimuth=M(o.reverseAzimuth),o}function A(t,n,i){if(!t||null==n||null==i)throw new e("point-from-distance:missing-parameters","one or more input parameters are missing or undefined");if(i<0||i>360)throw new e("point-from-distance:-of-bounds","azimuth is restricted to angles between, and including, 0° to 360° degrees");if(!t.spatialReference)throw new e("point-from-distance:missing-spatial-reference","the input point must have a spatial reference");const{spatialReference:s}=t;if(!y(s))throw new e("geodesic-distance:not-supported","input geometry spatial reference is not supported");const r=[0,0];return j(r,[t.x,t.y],i,n,s),new f({x:r[0],y:r[1],spatialReference:s})}function N(e){return y(e)?e:o(e)?h.WGS84:null}export{b as InverseGeodeticSolverResult,j as directGeodeticSolver,v as geodesicAreas,N as geodesicCompatibleSpatialReference,z as geodesicDensify,x as geodesicDistance,R as geodesicLengths,q as inverseGeodeticSolver,y as isSupported,A as pointFromDistance};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{deg2rad as s}from"../../../../../core/mathUtils.js";import{exactEquals as r}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as i,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{e as o}from"../../../../../chunks/vec32.js";import{ZEROS as n,clone as l,ONES as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as h}from"../../vertexSpaceConversion.js";import{Buffer as f}from"./buffer.js";import{smoothNormals as m}from"./geometry.js";import{BufferOutputType as p,ImageOutputType as d,AttributeType as g,TargetBuffer as x,AlphaMode as _}from"./types.js";import{imageToArrayBuffer as T,imageToDataURI as R}from"./imageutils.js";import{isEncodedMeshTexture as A}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as b,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const M=()=>e.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class O{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===p.GLB||t.output.image===d.GLB;s&&(t.binChunkBuffer=new f(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;o(s,n)||(t.translation=l(s));const u=e.rotation;r(u,i)||(t.rotation=a(u));const h=e.scale;o(h,c)||(t.scale=l(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===p.GLB;let r;r=s?t.binChunkBuffer:new f(this.gltf);const i=this.options.origin,a=e.vertexSpace.clone();a.origin=[i.x,i.y,i.z??0];const o=h({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},a,{targetUnit:"meters"});if(!o)return[];m(e,o),w(o);const{position:n,normal:l,tangent:c}=o,{uv:u,color:d}=e.vertexAttributes,_=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER);let T,R,A,E;l&&(T=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER)),u&&(R=r.addBufferView(b.FLOAT,g.VEC2,x.ARRAY_BUFFER)),c&&(A=r.addBufferView(b.FLOAT,g.VEC4,x.ARRAY_BUFFER)),d&&(E=r.addBufferView(b.UNSIGNED_BYTE,g.VEC4,x.ARRAY_BUFFER)),_.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),E&&E.startAccessor("COLOR_0");const M=o.position.length/3;for(let h=0;h<M;++h)_.push(n[3*h]),_.push(n[3*h+1]),_.push(n[3*h+2]),T&&null!=l&&(T.push(l[3*h]),T.push(l[3*h+1]),T.push(l[3*h+2])),R&&null!=u&&(R.push(u[2*h]),R.push(u[2*h+1])),A&&null!=c&&(A.push(c[4*h]),A.push(c[4*h+1]),A.push(c[4*h+2]),A.push(c[4*h+3])),E&&null!=d&&(E.push(d[4*h]),E.push(d[4*h+1]),E.push(d[4*h+2]),E.push(d[4*h+3]));const O=_.endAccessor(),
|
|
5
|
+
import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{deg2rad as s}from"../../../../../core/mathUtils.js";import{exactEquals as r}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as i,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{e as o}from"../../../../../chunks/vec32.js";import{ZEROS as n,clone as l,ONES as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as h}from"../../vertexSpaceConversion.js";import{Buffer as f}from"./buffer.js";import{smoothNormals as m}from"./geometry.js";import{BufferOutputType as p,ImageOutputType as d,AttributeType as g,TargetBuffer as x,AlphaMode as _}from"./types.js";import{imageToArrayBuffer as T,imageToDataURI as R}from"./imageutils.js";import{isEncodedMeshTexture as A}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as b,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const M=()=>e.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class O{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===p.GLB||t.output.image===d.GLB;s&&(t.binChunkBuffer=new f(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;o(s,n)||(t.translation=l(s));const u=e.rotation;r(u,i)||(t.rotation=a(u));const h=e.scale;o(h,c)||(t.scale=l(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===p.GLB;let r;r=s?t.binChunkBuffer:new f(this.gltf);const i=this.options.origin,a=e.vertexSpace.clone();a.origin=[i.x,i.y,i.z??0];const o=h({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},a,{targetUnit:"meters"});if(!o)return[];m(e,o),w(o);const{position:n,normal:l,tangent:c}=o,{uv:u,color:d}=e.vertexAttributes,_=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER);let T,R,A,E;l&&(T=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER)),u&&(R=r.addBufferView(b.FLOAT,g.VEC2,x.ARRAY_BUFFER)),c&&(A=r.addBufferView(b.FLOAT,g.VEC4,x.ARRAY_BUFFER)),d&&(E=r.addBufferView(b.UNSIGNED_BYTE,g.VEC4,x.ARRAY_BUFFER)),_.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),E&&E.startAccessor("COLOR_0");const M=o.position.length/3;for(let h=0;h<M;++h)_.push(n[3*h]),_.push(n[3*h+1]),_.push(n[3*h+2]),T&&null!=l&&(T.push(l[3*h]),T.push(l[3*h+1]),T.push(l[3*h+2])),R&&null!=u&&(R.push(u[2*h]),R.push(u[2*h+1])),A&&null!=c&&(A.push(c[4*h]),A.push(c[4*h+1]),A.push(c[4*h+2]),A.push(c[4*h+3])),E&&null!=d&&(E.push(d[4*h]),E.push(d[4*h+1]),E.push(d[4*h+2]),E.push(d[4*h+3]));const O=_.endAccessor(),I=this._addAccessor(_.index,O);let N,C,v,S,B;if(T){const e=T.endAccessor();N=this._addAccessor(T.index,e)}if(R){const e=R.endAccessor();C=this._addAccessor(R.index,e)}if(A){const e=A.endAccessor();v=this._addAccessor(A.index,e)}if(E){const e=E.endAccessor();S=this._addAccessor(E.index,e)}const L=[];return e.components&&e.components.length>0&&e.components[0].faces?(B=r.addBufferView(b.UNSIGNED_INT,g.SCALAR,x.ELEMENT_ARRAY_BUFFER),this._addMeshVertexIndexed(B,e.components,L,I,N,C,v,S)):this._addMeshVertexNonIndexed(e.components,L,I,N,C,v,S),_.finalize(),T&&T.finalize(),R&&R.finalize(),A&&A.finalize(),B&&B.finalize(),E&&E.finalize(),s||r.finalize(),L}_addMaterial(e){if(null===e)return;const t=this._materialMap.indexOf(e);if(-1!==t)return t;this.gltf.materials||(this.gltf.materials=[]);const s={};switch(e.alphaMode){case"mask":s.alphaMode=_.MASK;break;case"auto":case"blend":s.alphaMode=_.BLEND}s.alphaCutoff=e.alphaCutoff,e.doubleSided&&(s.doubleSided=e.doubleSided),s.pbrMetallicRoughness={};const r=e=>e**2.1,i=e=>{const t=e.toRgba();return t[0]=r(t[0]/255),t[1]=r(t[1]/255),t[2]=r(t[2]/255),t};if(null!=e.color&&(s.pbrMetallicRoughness.baseColorFactor=i(e.color)),null!=e.colorTexture&&(s.pbrMetallicRoughness.baseColorTexture=this._createTextureInfo(e.colorTexture,e.colorTextureTransform)),null!=e.normalTexture&&(s.normalTexture=this._createTextureInfo(e.normalTexture,e.normalTextureTransform)),e instanceof u){if(null!=e.emissiveTexture&&(s.emissiveTexture=this._createTextureInfo(e.emissiveTexture,e.emissiveTextureTransform)),null!=e.emissiveColor){const t=i(e.emissiveColor);s.emissiveFactor=[t[0],t[1],t[2]]}null!=e.occlusionTexture&&(s.occlusionTexture=this._createTextureInfo(e.occlusionTexture,e.occlusionTextureTransform)),null!=e.metallicRoughnessTexture&&(s.pbrMetallicRoughness.metallicRoughnessTexture=this._createTextureInfo(e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),s.pbrMetallicRoughness.metallicFactor=e.metallic,s.pbrMetallicRoughness.roughnessFactor=e.roughness}else s.pbrMetallicRoughness.metallicFactor=1,s.pbrMetallicRoughness.roughnessFactor=1,M().warnOnce("Meshes exported to GLTF without MeshMaterialMetallicRoughness material will appear different when imported back.");const a=this.gltf.materials.length;return this.gltf.materials.push(s),this._materialMap.push(e),a}_createTextureInfo(e,t){const r={index:this._addTexture(e)};return t?(r.extensions||(r.extensions={}),r.extensions.KHR_texture_transform={scale:t.scale,offset:t.offset,rotation:s(t.rotation)},r):r}_addTexture(e){const s=this.gltf.textures??[];return this.gltf.textures=s,t(this._textureMap,e,(()=>{const t={sampler:this._addSampler(e),source:this._addImage(e)},r=s.length;return s.push(t),r}))}_addImage(e){const t=this._imageMap.get(e);if(null!=t)return t;this.gltf.images||(this.gltf.images=[]);const s={};if(e.url)s.uri=e.url;else{const t=e.data;s.extras=t;for(let e=0;e<this.gltf.images.length;++e)if(t===this.gltf.images[e].extras)return e;const r=this.gltf.extras;switch(r.output.image){case d.GLB:{const e=r.binChunkBuffer.addBufferView(b.UNSIGNED_BYTE,g.SCALAR);if(A(t))null!=t.data&&e.writeOutToBuffer(t.data,0);else{const i=T(t,this.options.signal).then((({data:e,type:t})=>(s.mimeType=t,e)));r.promises.push(e.writeAsync(i).then((()=>{e.finalize()})))}s.bufferView=e.index;break}case d.DataURI:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}s.uri=R(t);break;default:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}r.promises.push(T(t,this.options.signal).then((({data:e,type:t})=>{s.uri=e,s.mimeType=t})))}}const r=this.gltf.images.length;return this.gltf.images.push(s),this._imageMap.set(e,r),r}_addSampler(e){this.gltf.samplers||(this.gltf.samplers=[]);let t=E.REPEAT,s=E.REPEAT;if("string"==typeof e.wrap)switch(e.wrap){case"clamp":t=E.CLAMP_TO_EDGE,s=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT,s=E.MIRRORED_REPEAT}else{switch(e.wrap.vertical){case"clamp":s=E.CLAMP_TO_EDGE;break;case"mirror":s=E.MIRRORED_REPEAT}switch(e.wrap.horizontal){case"clamp":t=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT}}const r={wrapS:t,wrapT:s};for(let a=0;a<this.gltf.samplers.length;++a)if(JSON.stringify(r)===JSON.stringify(this.gltf.samplers[a]))return a;const i=this.gltf.samplers.length;return this.gltf.samplers.push(r),i}_addAccessor(e,t){this.gltf.accessors||(this.gltf.accessors=[]);const s={bufferView:e,byteOffset:t.byteOffset,componentType:t.componentType,count:t.count,type:t.type,min:t.min,max:t.max,name:t.name};t.normalized&&(s.normalized=!0);const r=this.gltf.accessors.length;return this.gltf.accessors.push(s),r}_addMeshVertexIndexed(e,t,s,r,i,a,o,n){const l=new Map;for(const c of t){e.startAccessor("INDICES");for(let s=0;s<c.faces.length;++s)e.push(c.faces[s]);const t=e.endAccessor(),u={attributes:{POSITION:r},indices:this._addAccessor(e.index,t),material:this._addMaterial(c.material)};i&&"flat"!==c.shading&&(u.attributes.NORMAL=i),a&&(u.attributes.TEXCOORD_0=a),o&&"flat"!==c.shading&&(u.attributes.TANGENT=o),n&&(u.attributes.COLOR_0=n);const h=l.get(c.name);if(h)h.primitives.push(u);else{const e={name:c.name,primitives:[u]};l.set(c.name,e),s.push(e)}}}_addMeshVertexNonIndexed(e,t,s,r,i,a,o){const n={primitives:[]};t.push(n);const l={attributes:{POSITION:s}};r&&(l.attributes.NORMAL=r),i&&(l.attributes.TEXCOORD_0=i),a&&(l.attributes.TANGENT=a),o&&(l.attributes.COLOR_0=o),e&&(l.material=this._addMaterial(e[0].material)),n.primitives.push(l)}}function w({position:e,normal:t,tangent:s}){I(e,3),I(t,3),I(s,4)}function I(e,t){if(null!=e)for(let s=1,r=2;s<e.length;s+=t,r+=t){const t=e[s],i=e[r];e[s]=i,e[r]=-t}}export{O as GLTF};
|
package/layers/LinkChartLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../core/Collection.js";import a from"../core/Error.js";import i from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{throwIfAborted as o}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import l from"./Layer.js";import{convertFromGeometry as h}from"./graphics/featureConversionUtils.js";import d from"./graphics/OptimizedGeometry.js";import{IdealEdgeLengthTypeOptions as p}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as u,mockOidFieldName as c,mockOriginIdFieldName as y,mockDestinationIdFieldName as g,mockLayoutGeometryFieldName as m,mockAggregationCountFieldName as f}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import L from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{getRelationshipEndNodeIds as C}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as k}from"./mixins/BlendLayer.js";import{ScaleRangeLayer as w}from"./mixins/ScaleRangeLayer.js";import{LCChronologicalLayout as M,LCSimpleLayout as b,LCSmartTreeLayout as T,LCRadialTreeLayout as E,LCHierarchicalLayout as D,LCCommunityLayout as N,LCForceDirectedLayout as x,NodeFlag as I,load as R,LinkType as v}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as A}from"../rest/knowledgeGraphService.js";import G from"../geometry/Extent.js";import _ from"../geometry/Point.js";import O from"../geometry/Polyline.js";let j=class extends(k(w(l))){constructor(e){if(super(e),this.dataPreloadedInLocalCache=!1,this.defaultLinkChartConfig=null,this._currentLinkChartConfig={layoutMode:"RADIAL_TREE"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new t,this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new G({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.sublayerIdsCache=new Map,this.tables=new t,this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e.inclusionModeDefinition,e.dataPreloadedInLocalCache&&!e.inclusionModeDefinition)throw new a("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")}normalizeCtorArgs(e){return{url:e.url,title:e.title,dataPreloadedInLocalCache:e.dataPreloadedInLocalCache,defaultLinkChartConfig:e.defaultLinkChartConfig}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let n=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new a("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.inclusionModeDefinition?.generateAllSublayers?(n=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((a,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return i.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),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),n.push(r)):(i.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))})):(n=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new u({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=n,this.memberRelationshipTypes=o,this.dataManager=s}load(e){return this.addResolvingPromise(new Promise((t=>{A(this.url).then((a=>{if(this._initializeLayerProperties({knowledgeGraph:a,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})}))),this.dataPreloadedInLocalCache)this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.useAllData=!1,e.members?.forEach((e=>{let t;t=e.linkChartLocation instanceof d?e.linkChartLocation:e.linkChartLocation?h(e.linkChartLocation):null,t&&2===t.coords.length&&0===t.lengths.length?this.entityLinkChartDiagramLookup.set(e.id,t):this.relationshipLinkChartDiagramLookup.set(e.id,t)})),this.addResolvingPromise(this._initializeDiagram().then((async()=>{this.layers.forEach((async e=>{await e.refreshCachedQueryEngine()})),this.tables.forEach((async e=>{await e.refreshCachedQueryEngine()}))})))}));else{const t="GEOGRAPHIC"===this.defaultLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then((async()=>{o(e);const t=[],a=[];this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1,this.dataManager.inclusionModeDefinition.namedTypeDefinitions.forEach((e=>{e.useAllData=!1}))),await this._initializeDiagram(),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine()),t.push(new Promise((t=>{e.on("layerview-create",(()=>{t(null)}))})))})),this.tables.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a)})))}t(null)}))}))),Promise.resolve(this)}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await C(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));await this._handleNewRecords(i)}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1}){let i=[];for(const o of e)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(o.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(o.typeName)?.members?.has(o.id)&&i.push(o);if(t){const e=new Set,t=[];for(const a of i)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});i=i.concat(t)}this.dataManager.removeFromLayer(i);for(const o of i)this.sublayerIdsCache.get(o.typeName)?.delete(o.id),this.dataManager.relationshipTypeNames.has(o.typeName)?this.relationshipLinkChartDiagramLookup.delete(o.id):this.entityLinkChartDiagramLookup.delete(o.id);a&&await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,this._currentLinkChartConfig.layoutOptions);const n=[];return this.layers.forEach((e=>{n.push(e.refreshCachedQueryEngine())})),await Promise.all(n),this._refreshNamedTypes(),i}async expand(e,t){const a=await this.dataManager.getConnectedRecordIds(e,t),i=a.filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));return await this._handleNewRecords(a),{records:i}}loadLayerAssumingLocalCache(){this.memberRelationshipTypes.forEach((e=>{const t=new L({objectType:e,parentCompositeLayer:this,graphType:"relationship",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.memberEntityTypes.forEach((e=>{const t=new L({objectType:e,parentCompositeLayer:this,graphType:"entity",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{const a=n(this.sublayerIdsCache,t,(()=>new Set));e.members?.forEach((e=>{if(a.add(e.id),e.linkChartLocation)if(e.linkChartLocation instanceof d)this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e.id,e.linkChartLocation):this.entityLinkChartDiagramLookup.set(e.id,e.linkChartLocation);else{const a=h(e.linkChartLocation);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e.id,e.linkChartLocation?a:null):this.entityLinkChartDiagramLookup.set(e.id,e.linkChartLocation?a:null)}}))}))}async calculateLinkChartLayout(e="RADIAL_TREE",t){const n=[],o=[],s=[];this.dataManager.sublayerCaches.forEach(((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach((e=>{n.push({typeName:t,feature:e})})):this.dataManager.relationshipTypeNames.has(t)&&e.forEach((e=>{o.push({typeName:t,feature:e})}))})),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const r=new Map,l=new Map,d=new Map,p=new Map,u=new Uint8Array(n.length),L=new Float64Array(n.length),C=new Float64Array(n.length),k=new Float64Array(n.length),w=new Float64Array(n.length),A=new Uint32Array(o.length),j=new Uint32Array(o.length),P=new Float64Array(o.length),S=new Float64Array(o.length),F=[],B="FORCE_DIRECTED",H=new G({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let z,U="FORCE_DIRECTED",Q=0,W=0;const K=M.apply;switch(U="GEOGRAPHIC"===e?B:e,U){case"FORCE_DIRECTED":z=x.apply;break;case"COMMUNITY":z=N.apply;break;case"HIERARCHICAL":z=D.apply;break;case"RADIAL_TREE":z=E.apply;break;case"SMART_TREE":z=T.apply;break;default:z=b.apply}let Y=!1;n.forEach((({typeName:a,feature:i})=>{if("CHRONOLOGICAL"!==e&&t?.lockedNodeLocations?.has(i.attributes[c])){"GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)?u[Q]=I.IsGeographic:u[Q]=I.None;const n=t.lockedNodeLocations.get(i.attributes[c]);L[Q]=n.x,C[Q]=n.y}else if("GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)){u[Q]=I.IsGeographic;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[Q]=t?.x,C[Q]=t?.y;break;case"esriGeometryPolygon":e=t?.centroid,null!=e?.x&&null!=e?.y?(L[Q]=e.x,C[Q]=e.y):u[Q]=I.IsMovable;break;case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[Q]=e.x,C[Q]=e.y):u[Q]=I.IsMovable;break;default:u[Q]=I.IsMovable}(null==L[Q]||null==C[Q]||Number.isNaN(L[Q])||Number.isNaN(C[Q]))&&(u[Q]=I.IsMovable,L[Q]=0,C[Q]=0)}else if("CHRONOLOGICAL"===e){!Y&&t?.lockedNodeLocations?.has(i.attributes[c])&&(Y=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;k[Q]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;w[Q]=r?new Date(r).getTime():NaN,L[Q]=0,C[Q]=0,u[Q]=I.IsMovable}else u[Q]=I.IsMovable,L[Q]=0,C[Q]=0;p.set(i.attributes[c],Q),F[Q]={feature:i,typeName:a},Q++})),Y&&i.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let $=!1;const q=new Map;o.forEach((a=>{const i=a.feature.attributes[y],n=a.feature.attributes[g],o=p.get(i),r=p.get(n),l=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?l?.startField:null,d=h?a.feature.attributes[h]:null,u=l?.endField,c=u?a.feature.attributes[u]:null;if(void 0!==o&&void 0!==r){let t=i+"-"+n;"CHRONOLOGICAL"===e&&(t=t+"-"+d+"-"+c);const l=q.get(t),h=l?.has(a.typeName);h||(A[W]=o,j[W]=r,"CHRONOLOGICAL"===e&&(P[W]=d?new Date(d).getTime():NaN,S[W]=c?new Date(c).getTime():NaN),void 0===l?q.set(t,new Map([[a.typeName,W]])):l.set(a.typeName,W),W++),s.push(a)}else $=!0,this.relationshipLinkChartDiagramLookup.set(i,null)})),$&&i.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 J=this._validateLayoutSettings(e,t),V=this._convertLayoutSettingsToCalculationSettings(J);await R();let X=!1,Z=null;if("CHRONOLOGICAL"===e){const e=!0;let t;({success:X,links:Z,graphics:t}=K(u,L,C,k,w,A.subarray(0,W),j.subarray(0,W),P.subarray(0,W),S.subarray(0,W),e,{})),X&&(this.chronologicalAuxiliaryGraphics=t)}else({success:X,links:Z}=z(u,L,C,A.subarray(0,W),j.subarray(0,W),V.computationBudgetTime,V.idealEdgeLengthMultiplier,V.repulsionRadiusMultiplier));if(!X)throw new a("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");for(let a=0;a<F.length;a++){if(C[a]>84.9999?C[a]=84.9999:C[a]<-84.9999&&(C[a]=-84.9999),L[a]>179.9999?L[a]=179.9999:L[a]<-179.9999&&(L[a]=-179.9999),F[a].feature.attributes[m]=new _(L[a],C[a]),r.has(F[a].typeName)){const e=r.get(F[a].typeName);e?.set(F[a].feature.attributes[c],F[a].feature)}else{const e=new Map;e.set(F[a].feature.attributes[c],F[a].feature),r.set(F[a].typeName,e)}d.set(F[a].feature.attributes[c],F[a].feature);const e=h(F[a].feature.attributes[m]);this.entityLinkChartDiagramLookup.set(F[a].feature.attributes[c],F[a].feature.attributes[m]?e:null),F[a].feature.attributes[m].x<H.xmin&&(H.xmin=F[a].feature.attributes[m].x),F[a].feature.attributes[m].x>H.xmax&&(H.xmax=F[a].feature.attributes[m].x),F[a].feature.attributes[m].y<H.ymin&&(H.ymin=F[a].feature.attributes[m].y),F[a].feature.attributes[m].y>H.ymax&&(H.ymax=F[a].feature.attributes[m].y)}if(this.linkChartExtent.xmin=H.xmin,this.linkChartExtent.xmax=H.xmax,this.linkChartExtent.ymin=H.ymin,this.linkChartExtent.ymax=H.ymax,!Z)throw new a("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ee=new Map,te=new Map,ae=new Map,ie=new Set;for(let a=0;a<s.length;a++){const n=[],o=s[a],r=o.feature.attributes[y],u=o.feature.attributes[g];let f=r+"-"+u;if("CHRONOLOGICAL"===e){const e=t?.timeInfoByTypeName?.get(o.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?o.feature.attributes[a]:null,n=e?.endField;f+="-"+i+"-"+(n?o.feature.attributes[n]:null)}const L=q.get(f).get(o.typeName),C=0===L?0:Z?.vertexEndIndex[L-1];if(!ie.has(L)){if(ie.add(L),Z.types[L]===v.Recursive){const e=[Z.vertices[2*C],Z.vertices[2*C+1]],t=[Z.vertices[2*(C+1)],Z.vertices[2*(C+1)+1]],a=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],i=[a[0]-e[0],a[1]-e[1]],o=[a[0]+i[1],a[1]-i[0]],s=[a[0]-i[1],a[1]+i[0]];n.push(e),n.push(o),n.push(t),n.push(s),n.push(e)}else{if(Z.types[L]!==v.Regular){i.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=C;e<Z.vertexEndIndex[L];e++)n.push([Z.vertices[2*e],Z.vertices[2*e+1]])}if("CHRONOLOGICAL"!==e){const e=F[p.get(r)]?.feature.attributes[m],t=F[p.get(u)]?.feature.attributes[m];n[0][0]===e.x&&n[0][1]===e.y||(n[0]=[e.x,e.y]),n[n.length-1][0]===t.x&&n[n.length-1][1]===t.y||(n[n.length-1]=[t.x,t.y])}for(let e=1;e<n.length-1;e++)n[e][1]>85.5?n[e][1]=85.5:n[e][1]<-85.5&&(n[e][1]=-85.5),n[e][0]>179.9999?n[e][0]=179.9999:n[e][0]<-179.9999&&(n[e][0]=-179.9999);ee.has(f)?ee.get(f).push(n):ee.set(f,[n])}const k=ee.get(f);te.has(f)||(te.set(f,new Map),ae.set(f,new Map));const w=te.get(f),M=ae.get(f);w.has(o.typeName)||(w.set(o.typeName,k.shift()),M.set(o.typeName,0));const b=w.get(o.typeName);M.set(o.typeName,M.get(o.typeName)+1);const T=new O({paths:b});if(o.feature.attributes[m]=T,l.has(o.typeName)){const e=l.get(o.typeName);e?.set(o.feature.attributes[c],o.feature)}else{const e=new Map;e.set(o.feature.attributes[c],o.feature),l.set(o.typeName,e)}d.set(o.feature.attributes[c],o.feature);const E=h(o.feature.attributes[m]);this.relationshipLinkChartDiagramLookup.set(o.feature.attributes[c],o.feature.attributes[m]?E:null)}for(const a of s)a.feature.attributes[f]=ae.get(a.feature.attributes[y]+"-"+a.feature.attributes[g])?.get(a.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutOptions:J},{nodes:r,links:l,idMap:d}}async applyNewLinkChartLayout(e="RADIAL_TREE",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;return this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((t=>{t?.members?.forEach((t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new _({x:i.x,y:i.y})))}))})),e}async synchronizeInclusionListWithCache(){return new Promise((e=>{this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{if(e.useAllData=!1,e.members&&e.members.size>0){if(!this.dataManager.sublayerCaches.get(t))return;const a=new Set(Array.from(this.dataManager.sublayerCaches.get(t).keys()));Array.from(e.members.keys()).filter((e=>!a.has(e))).forEach((t=>{e.members?.delete(t)}))}})),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){let t=[];for(const i of this.dataManager.relationshipTypeNames){const e=this.sublayerIdsCache.get(i);e&&(t=t.concat(Array.from(e.keys())))}const a=await this.dataManager.getRelationshipsBetweenNodes(e,t);return await this._handleNewRecords(a),{records:a}}async connectFromEntities(e){let t=[];for(const n of this.dataManager.relationshipTypeNames){const e=this.sublayerIdsCache.get(n);e&&(t=t.concat(Array.from(e.keys())))}let a=[];for(const n of this.dataManager.entityTypeNames){const e=this.sublayerIdsCache.get(n);e&&(a=a.concat(Array.from(e)))}const i=await this.dataManager.getRelationshipsFromNodes(e,a,t);return await this._handleNewRecords(i),{records:i}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="RADIAL_TREE",t){const a=new Map;this.layers.forEach((e=>{a.set(e.objectType.name,e.timeInfo)})),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t})}async _handleNewRecords(e){const t=[];this.dataManager.addToLayer(e);for(const i of e)this.sublayerIdsCache.has(i.typeName)||(this.sublayerIdsCache.set(i.typeName,new Set),t.push(i.typeName)),this.sublayerIdsCache.get(i.typeName).add(i.id);for(const i of t){const e=this._graphTypeLookup.get(i);if(e){const t=new L({objectType:e,parentCompositeLayer:this,graphType:e.type,title:i});"entity"===e.type?this.dataManager.entityTypeNames.add(i):this.dataManager.relationshipTypeNames.add(i),t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.set(i,new Map)}}await this.dataManager.refreshCacheContent(e.map((e=>e.id)));const a=Object.assign({},this._currentLinkChartConfig.layoutOptions);a.lockedNodeLocations=new Map;for(const[i,n]of this.entityLinkChartDiagramLookup.entries())n&&a.lockedNodeLocations.set(i,new _(n.coords[0],n.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,a)}async _initializeDiagram(){this.defaultLinkChartConfig?this.defaultLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e?.members?.forEach((e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=h(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)}))})),this.memberRelationshipTypes.forEach((e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach((e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[y]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[g]);if(t&&a){const i=h(new O({paths:[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[c],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[c],null)}))}))):await this._calculateLayoutWithSublayerTimeInfo(this.defaultLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.defaultLinkChartConfig.layoutOptions||{}}):await this._calculateLayoutWithSublayerTimeInfo("RADIAL_TREE",{lockedNodeLocations: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})}_validateLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),n=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(p).includes(e),r=e=>a(e)&&e>=0,l=new Set(["FORCE_DIRECTED","COMMUNITY","GEOGRAPHIC"]),h={};if(!l.has(e)||!t)return!l.has(e)&&t&&i.getLogger(this).warn("Layout mode options were given for a layout mode that does not utilize them, settings will be ignored"),h;const{computationBudgetTime:d,repulsionRadiusMultiplier:u,idealEdgeLength:c,idealEdgeLengthType:y}=t;o(d)?h.computationBudgetTime=d:void 0!==d&&i.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),n(u)?h.repulsionRadiusMultiplier=u:void 0!==u&&i.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting");const g=void 0!==c||void 0!==y;return"GEOGRAPHIC"!==e&&g?i.getLogger(this).warn("Ideal edge length settings were specified for an incompatible layout mode, and will be ignored"):"GEOGRAPHIC"===e&&g&&(s(y)?h.idealEdgeLengthType=y:void 0!==y&&i.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),r(c)?h.idealEdgeLength=c:void 0!==c&&i.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),h}_convertLayoutSettingsToCalculationSettings(e){let t=e.idealEdgeLength;return e.idealEdgeLengthType===p.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier,idealEdgeLengthMultiplier:t}}};e([s()],j.prototype,"dataPreloadedInLocalCache",void 0),e([s()],j.prototype,"defaultLinkChartConfig",void 0),e([s()],j.prototype,"dataManager",void 0),e([s()],j.prototype,"knowledgeGraph",void 0),e([s()],j.prototype,"layers",void 0),e([s()],j.prototype,"entityLinkChartDiagramLookup",void 0),e([s()],j.prototype,"relationshipLinkChartDiagramLookup",void 0),e([s()],j.prototype,"linkChartExtent",void 0),e([s()],j.prototype,"memberEntityTypes",void 0),e([s()],j.prototype,"memberRelationshipTypes",void 0),e([s()],j.prototype,"sublayerIdsCache",void 0),e([s()],j.prototype,"tables",void 0),e([s({json:{read:!1}})],j.prototype,"type",void 0),e([s({json:{read:!1}})],j.prototype,"chronologicalAuxiliaryGraphics",void 0),j=e([r("esri.layers.LinkChartLayer")],j);const P=j;export{P as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../core/Collection.js";import a from"../core/Error.js";import i from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{throwIfAborted as o}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import l from"./Layer.js";import{convertFromGeometry as h}from"./graphics/featureConversionUtils.js";import d from"./graphics/OptimizedGeometry.js";import{IdealEdgeLengthTypeOptions as p}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as u,mockOidFieldName as c,mockOriginIdFieldName as y,mockDestinationIdFieldName as g,mockLayoutGeometryFieldName as m,mockAggregationCountFieldName as f}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import L from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{getRelationshipEndNodeIds as C}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as k}from"./mixins/BlendLayer.js";import{ScaleRangeLayer as w}from"./mixins/ScaleRangeLayer.js";import{LCChronologicalLayout as M,LCSimpleLayout as b,LCSmartTreeLayout as T,LCRadialTreeLayout as E,LCHierarchicalLayout as D,LCCommunityLayout as N,LCForceDirectedLayout as x,NodeFlag as I,load as R,LinkType as v}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as A}from"../rest/knowledgeGraphService.js";import G from"../geometry/Extent.js";import _ from"../geometry/Point.js";import O from"../geometry/Polyline.js";let j=class extends(k(w(l))){constructor(e){if(super(e),this.dataPreloadedInLocalCache=!1,this.defaultLinkChartConfig=null,this._currentLinkChartConfig={layoutMode:"RADIAL_TREE"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new t,this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new G({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.sublayerIdsCache=new Map,this.tables=new t,this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e.inclusionModeDefinition,e.dataPreloadedInLocalCache&&!e.inclusionModeDefinition)throw new a("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")}normalizeCtorArgs(e){return{url:e.url,title:e.title,dataPreloadedInLocalCache:e.dataPreloadedInLocalCache,defaultLinkChartConfig:e.defaultLinkChartConfig}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let n=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new a("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&this._graphTypeLookup.set(e.name,e)})),e.inclusionModeDefinition?.generateAllSublayers?(n=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((a,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return i.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),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),n.push(r)):(i.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))})):(n=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new u({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=n,this.memberRelationshipTypes=o,this.dataManager=s}load(e){return this.addResolvingPromise(new Promise((t=>{A(this.url).then((a=>{if(this._initializeLayerProperties({knowledgeGraph:a,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})}))),this.dataPreloadedInLocalCache)this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach((e=>{e.useAllData=!1,e.members?.forEach((e=>{let t;t=e.linkChartLocation instanceof d?e.linkChartLocation:e.linkChartLocation?h(e.linkChartLocation):null,t&&2===t.coords.length&&0===t.lengths.length?this.entityLinkChartDiagramLookup.set(e.id,t):this.relationshipLinkChartDiagramLookup.set(e.id,t)})),this.addResolvingPromise(this._initializeDiagram().then((async()=>{this.layers.forEach((async e=>{await e.refreshCachedQueryEngine()})),this.tables.forEach((async e=>{await e.refreshCachedQueryEngine()}))})))}));else{const t="GEOGRAPHIC"===this.defaultLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then((async()=>{o(e);const t=[],a=[];this.loadLayerAssumingLocalCache(),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1,this.dataManager.inclusionModeDefinition.namedTypeDefinitions.forEach((e=>{e.useAllData=!1}))),await this._initializeDiagram(),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine()),t.push(new Promise((t=>{e.on("layerview-create",(()=>{t(null)}))})))})),this.tables.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a)})))}t(null)}))}))),Promise.resolve(this)}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await C(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));await this._handleNewRecords(i)}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1}){let i=[];for(const o of e)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(o.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(o.typeName)?.members?.has(o.id)&&i.push(o);if(t){const e=new Set,t=[];for(const a of i)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});i=i.concat(t)}this.dataManager.removeFromLayer(i);for(const o of i)this.sublayerIdsCache.get(o.typeName)?.delete(o.id),this.dataManager.relationshipTypeNames.has(o.typeName)?this.relationshipLinkChartDiagramLookup.delete(o.id):this.entityLinkChartDiagramLookup.delete(o.id);a&&await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,this._currentLinkChartConfig.layoutOptions);const n=[];return this.layers.forEach((e=>{n.push(e.refreshCachedQueryEngine())})),await Promise.all(n),this._refreshNamedTypes(),i}async expand(e,t){const a=await this.dataManager.getConnectedRecordIds(e,t),i=a.filter((e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)));return await this._handleNewRecords(a),{records:i}}loadLayerAssumingLocalCache(){this.memberRelationshipTypes.forEach((e=>{const t=new L({objectType:e,parentCompositeLayer:this,graphType:"relationship",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.memberEntityTypes.forEach((e=>{const t=new L({objectType:e,parentCompositeLayer:this,graphType:"entity",title:e.name});t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.has(e.name)||this.dataManager.sublayerCaches.set(e.name,new Map)})),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{const a=n(this.sublayerIdsCache,t,(()=>new Set));e.members?.forEach((e=>{if(a.add(e.id),e.linkChartLocation)if(e.linkChartLocation instanceof d)this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e.id,e.linkChartLocation):this.entityLinkChartDiagramLookup.set(e.id,e.linkChartLocation);else{const a=h(e.linkChartLocation);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e.id,e.linkChartLocation?a:null):this.entityLinkChartDiagramLookup.set(e.id,e.linkChartLocation?a:null)}}))}))}async calculateLinkChartLayout(e="RADIAL_TREE",t){const n=[],o=[],s=[];this.dataManager.sublayerCaches.forEach(((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach((e=>{n.push({typeName:t,feature:e})})):this.dataManager.relationshipTypeNames.has(t)&&e.forEach((e=>{o.push({typeName:t,feature:e})}))})),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const r=new Map,l=new Map,d=new Map,p=new Map,u=new Uint8Array(n.length),L=new Float64Array(n.length),C=new Float64Array(n.length),k=new Float64Array(n.length),w=new Float64Array(n.length),A=new Uint32Array(o.length),j=new Uint32Array(o.length),P=new Float64Array(o.length),S=new Float64Array(o.length),F=[],B="FORCE_DIRECTED",H=new G({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let z,U="FORCE_DIRECTED",Q=0,W=0;const K=M.apply;switch(U="GEOGRAPHIC"===e?B:e,U){case"FORCE_DIRECTED":z=x.apply;break;case"COMMUNITY":z=N.apply;break;case"HIERARCHICAL":z=D.apply;break;case"RADIAL_TREE":z=E.apply;break;case"SMART_TREE":z=T.apply;break;default:z=b.apply}let Y=!1;n.forEach((({typeName:a,feature:i})=>{if("CHRONOLOGICAL"!==e&&t?.lockedNodeLocations?.has(i.attributes[c])){"GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)?u[Q]=I.IsGeographic:u[Q]=I.None;const n=t.lockedNodeLocations.get(i.attributes[c]);L[Q]=n.x,C[Q]=n.y}else if("GEOGRAPHIC"===e&&this.dataManager.geographicLookup.has(a)){u[Q]=I.IsGeographic;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[Q]=t?.x,C[Q]=t?.y;break;case"esriGeometryPolygon":e=t?.centroid,null!=e?.x&&null!=e?.y?(L[Q]=e.x,C[Q]=e.y):u[Q]=I.IsMovable;break;case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[Q]=e.x,C[Q]=e.y):u[Q]=I.IsMovable;break;default:u[Q]=I.IsMovable}(null==L[Q]||null==C[Q]||Number.isNaN(L[Q])||Number.isNaN(C[Q]))&&(u[Q]=I.IsMovable,L[Q]=0,C[Q]=0)}else if("CHRONOLOGICAL"===e){!Y&&t?.lockedNodeLocations?.has(i.attributes[c])&&(Y=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;k[Q]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;w[Q]=r?new Date(r).getTime():NaN,L[Q]=0,C[Q]=0,u[Q]=I.IsMovable}else u[Q]=I.IsMovable,L[Q]=0,C[Q]=0;p.set(i.attributes[c],Q),F[Q]={feature:i,typeName:a},Q++})),Y&&i.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let $=!1;const q=new Map;o.forEach((a=>{const i=a.feature.attributes[y],n=a.feature.attributes[g],o=p.get(i),r=p.get(n),l=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?l?.startField:null,d=h?a.feature.attributes[h]:null,u=l?.endField,c=u?a.feature.attributes[u]:null;if(void 0!==o&&void 0!==r){let t=i+"-"+n;"CHRONOLOGICAL"===e&&(t=t+"-"+d+"-"+c);const l=q.get(t),h=l?.has(a.typeName);h||(A[W]=o,j[W]=r,"CHRONOLOGICAL"===e&&(P[W]=d?new Date(d).getTime():NaN,S[W]=c?new Date(c).getTime():NaN),void 0===l?q.set(t,new Map([[a.typeName,W]])):l.set(a.typeName,W),W++),s.push(a)}else $=!0,this.relationshipLinkChartDiagramLookup.set(i,null)})),$&&i.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 J=this._validateLayoutSettings(e,t),V=this._convertLayoutSettingsToCalculationSettings(J);await R();let X=!1,Z=null;if("CHRONOLOGICAL"===e){const e=!0;let t;({success:X,links:Z,graphics:t}=K(u,L,C,k,w,A.subarray(0,W),j.subarray(0,W),P.subarray(0,W),S.subarray(0,W),e,{})),X&&(this.chronologicalAuxiliaryGraphics=t)}else({success:X,links:Z}=z(u,L,C,A.subarray(0,W),j.subarray(0,W),V.computationBudgetTime,V.idealEdgeLengthMultiplier,V.repulsionRadiusMultiplier));if(!X)throw new a("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");for(let a=0;a<F.length;a++){if(C[a]>84.9999?C[a]=84.9999:C[a]<-84.9999&&(C[a]=-84.9999),L[a]>179.9999?L[a]=179.9999:L[a]<-179.9999&&(L[a]=-179.9999),F[a].feature.attributes[m]=new _(L[a],C[a]),r.has(F[a].typeName)){const e=r.get(F[a].typeName);e?.set(F[a].feature.attributes[c],F[a].feature)}else{const e=new Map;e.set(F[a].feature.attributes[c],F[a].feature),r.set(F[a].typeName,e)}d.set(F[a].feature.attributes[c],F[a].feature);const e=h(F[a].feature.attributes[m]);this.entityLinkChartDiagramLookup.set(F[a].feature.attributes[c],F[a].feature.attributes[m]?e:null),F[a].feature.attributes[m].x<H.xmin&&(H.xmin=F[a].feature.attributes[m].x),F[a].feature.attributes[m].x>H.xmax&&(H.xmax=F[a].feature.attributes[m].x),F[a].feature.attributes[m].y<H.ymin&&(H.ymin=F[a].feature.attributes[m].y),F[a].feature.attributes[m].y>H.ymax&&(H.ymax=F[a].feature.attributes[m].y)}if(this.linkChartExtent.xmin=H.xmin,this.linkChartExtent.xmax=H.xmax,this.linkChartExtent.ymin=H.ymin,this.linkChartExtent.ymax=H.ymax,!Z)throw new a("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ee=new Map,te=new Map,ae=new Map,ie=new Set;for(let a=0;a<s.length;a++){const n=[],o=s[a],r=o.feature.attributes[y],u=o.feature.attributes[g];let f=r+"-"+u;if("CHRONOLOGICAL"===e){const e=t?.timeInfoByTypeName?.get(o.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?o.feature.attributes[a]:null,n=e?.endField;f+="-"+i+"-"+(n?o.feature.attributes[n]:null)}const L=q.get(f).get(o.typeName),C=0===L?0:Z?.vertexEndIndex[L-1];if(!ie.has(L)){if(ie.add(L),Z.types[L]===v.Recursive){const e=[Z.vertices[2*C],Z.vertices[2*C+1]],t=[Z.vertices[2*(C+1)],Z.vertices[2*(C+1)+1]],a=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],i=[a[0]-e[0],a[1]-e[1]],o=[a[0]+i[1],a[1]-i[0]],s=[a[0]-i[1],a[1]+i[0]];n.push(e),n.push(o),n.push(t),n.push(s),n.push(e)}else{if(Z.types[L]!==v.Regular){i.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=C;e<Z.vertexEndIndex[L];e++)n.push([Z.vertices[2*e],Z.vertices[2*e+1]])}if("CHRONOLOGICAL"!==e){const e=F[p.get(r)]?.feature.attributes[m],t=F[p.get(u)]?.feature.attributes[m];n[0][0]===e.x&&n[0][1]===e.y||(n[0]=[e.x,e.y]),n[n.length-1][0]===t.x&&n[n.length-1][1]===t.y||(n[n.length-1]=[t.x,t.y])}for(let e=1;e<n.length-1;e++)n[e][1]>85.5?n[e][1]=85.5:n[e][1]<-85.5&&(n[e][1]=-85.5),n[e][0]>179.9999?n[e][0]=179.9999:n[e][0]<-179.9999&&(n[e][0]=-179.9999);ee.has(f)?ee.get(f).push(n):ee.set(f,[n])}const k=ee.get(f);te.has(f)||(te.set(f,new Map),ae.set(f,new Map));const w=te.get(f),M=ae.get(f);w.has(o.typeName)||(w.set(o.typeName,k.shift()),M.set(o.typeName,0));const b=w.get(o.typeName);M.set(o.typeName,M.get(o.typeName)+1);const T=new O({paths:[b]});if(o.feature.attributes[m]=T,l.has(o.typeName)){const e=l.get(o.typeName);e?.set(o.feature.attributes[c],o.feature)}else{const e=new Map;e.set(o.feature.attributes[c],o.feature),l.set(o.typeName,e)}d.set(o.feature.attributes[c],o.feature);const E=h(o.feature.attributes[m]);this.relationshipLinkChartDiagramLookup.set(o.feature.attributes[c],o.feature.attributes[m]?E:null)}for(const a of s)a.feature.attributes[f]=ae.get(a.feature.attributes[y]+"-"+a.feature.attributes[g])?.get(a.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutOptions:J},{nodes:r,links:l,idMap:d}}async applyNewLinkChartLayout(e="RADIAL_TREE",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach((e=>{a.push(e.refreshCachedQueryEngine())})),await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;return this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((t=>{t?.members?.forEach((t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new _({x:i.x,y:i.y})))}))})),e}async synchronizeInclusionListWithCache(){return new Promise((e=>{this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{if(e.useAllData=!1,e.members&&e.members.size>0){if(!this.dataManager.sublayerCaches.get(t))return;const a=new Set(Array.from(this.dataManager.sublayerCaches.get(t).keys()));Array.from(e.members.keys()).filter((e=>!a.has(e))).forEach((t=>{e.members?.delete(t)}))}})),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){let t=[];for(const i of this.dataManager.relationshipTypeNames){const e=this.sublayerIdsCache.get(i);e&&(t=t.concat(Array.from(e.keys())))}const a=await this.dataManager.getRelationshipsBetweenNodes(e,t);return await this._handleNewRecords(a),{records:a}}async connectFromEntities(e){let t=[];for(const n of this.dataManager.relationshipTypeNames){const e=this.sublayerIdsCache.get(n);e&&(t=t.concat(Array.from(e.keys())))}let a=[];for(const n of this.dataManager.entityTypeNames){const e=this.sublayerIdsCache.get(n);e&&(a=a.concat(Array.from(e)))}const i=await this.dataManager.getRelationshipsFromNodes(e,a,t);return await this._handleNewRecords(i),{records:i}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="RADIAL_TREE",t){const a=new Map;this.layers.forEach((e=>{a.set(e.objectType.name,e.timeInfo)})),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t})}async _handleNewRecords(e){const t=[];this.dataManager.addToLayer(e);for(const i of e)this.sublayerIdsCache.has(i.typeName)||(this.sublayerIdsCache.set(i.typeName,new Set),t.push(i.typeName)),this.sublayerIdsCache.get(i.typeName).add(i.id);for(const i of t){const e=this._graphTypeLookup.get(i);if(e){const t=new L({objectType:e,parentCompositeLayer:this,graphType:e.type,title:i});"entity"===e.type?this.dataManager.entityTypeNames.add(i):this.dataManager.relationshipTypeNames.add(i),t.geometryType?this.layers.push(t):this.tables.push(t),this.dataManager.sublayerCaches.set(i,new Map)}}await this.dataManager.refreshCacheContent(e.map((e=>e.id)));const a=Object.assign({},this._currentLinkChartConfig.layoutOptions);a.lockedNodeLocations=new Map;for(const[i,n]of this.entityLinkChartDiagramLookup.entries())n&&a.lockedNodeLocations.set(i,new _(n.coords[0],n.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,a)}async _initializeDiagram(){this.defaultLinkChartConfig?this.defaultLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e?.members?.forEach((e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=h(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)}))})),this.memberRelationshipTypes.forEach((e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach((e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[y]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[g]);if(t&&a){const i=h(new O({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[c],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[c],null)}))}))):await this._calculateLayoutWithSublayerTimeInfo(this.defaultLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.defaultLinkChartConfig.layoutOptions||{}}):await this._calculateLayoutWithSublayerTimeInfo("RADIAL_TREE",{lockedNodeLocations: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})}_validateLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),n=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(p).includes(e),r=e=>a(e)&&e>=0,l=new Set(["FORCE_DIRECTED","COMMUNITY","GEOGRAPHIC"]),h={};if(!l.has(e)||!t)return!l.has(e)&&t&&i.getLogger(this).warn("Layout mode options were given for a layout mode that does not utilize them, settings will be ignored"),h;const{computationBudgetTime:d,repulsionRadiusMultiplier:u,idealEdgeLength:c,idealEdgeLengthType:y}=t;o(d)?h.computationBudgetTime=d:void 0!==d&&i.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),n(u)?h.repulsionRadiusMultiplier=u:void 0!==u&&i.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting");const g=void 0!==c||void 0!==y;return"GEOGRAPHIC"!==e&&g?i.getLogger(this).warn("Ideal edge length settings were specified for an incompatible layout mode, and will be ignored"):"GEOGRAPHIC"===e&&g&&(s(y)?h.idealEdgeLengthType=y:void 0!==y&&i.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),r(c)?h.idealEdgeLength=c:void 0!==c&&i.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),h}_convertLayoutSettingsToCalculationSettings(e){let t=e.idealEdgeLength;return e.idealEdgeLengthType===p.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier,idealEdgeLengthMultiplier:t}}};e([s()],j.prototype,"dataPreloadedInLocalCache",void 0),e([s()],j.prototype,"defaultLinkChartConfig",void 0),e([s()],j.prototype,"dataManager",void 0),e([s()],j.prototype,"knowledgeGraph",void 0),e([s()],j.prototype,"layers",void 0),e([s()],j.prototype,"entityLinkChartDiagramLookup",void 0),e([s()],j.prototype,"relationshipLinkChartDiagramLookup",void 0),e([s()],j.prototype,"linkChartExtent",void 0),e([s()],j.prototype,"memberEntityTypes",void 0),e([s()],j.prototype,"memberRelationshipTypes",void 0),e([s()],j.prototype,"sublayerIdsCache",void 0),e([s()],j.prototype,"tables",void 0),e([s({json:{read:!1}})],j.prototype,"type",void 0),e([s({json:{read:!1}})],j.prototype,"chronologicalAuxiliaryGraphics",void 0),j=e([r("esri.layers.LinkChartLayer")],j);const P=j;export{P as default};
|