@arcgis/core 4.34.0-next.1 → 4.34.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/Map.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/DimensionAnalysis.js +1 -1
  4. package/analysis/LineOfSightAnalysis.js +1 -1
  5. package/analysis/ViewshedAnalysis.js +1 -1
  6. package/arcade/Voxel.js +1 -1
  7. package/arcade/functions/knowledgegraph.js +1 -1
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/{253bcc3cc7bc4c2dc6ea.js → 03db109e9b695528c35d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fa63b0f7fa799cb2f81d.js → 07e58dff44fcbb3b3539.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{fc61d02286b6ff5447cc.js → 09da6b3085fc84cd69d5.js} +1 -1
  12. package/assets/esri/core/workers/chunks/0fd826e7f64a37aaaa1e.js +1 -0
  13. package/assets/esri/core/workers/chunks/{1c86aa3802d9ae0230ae.js → 28e31ac00dc95a1318e9.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{0d23610475c85385fbff.js → 355e6bcdb401ada71f39.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{bba6d7615d8f3862fe70.js → 36f0046ff6b46adce7b7.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{42d9989b2aad3ac28d4d.js → 397b15d46f22718c9f38.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{b0522dffa5600345c07e.js → 3e85e63148b5e93d3074.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{d2ebb72a43d995ed368a.js → 42bb9bb6fe44a47d9b81.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{6ee41e9c92ed8ba4c763.js → 4dd0a5f327fa5fc7249d.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{36b0d6b4089a96475201.js → 51ba7345c31e6eb79060.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{66e79aa02b3aa12b3778.js → 5200be8bce60fa831026.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{6b23ca6570357f9fb724.js → 52a57106a41b8c9483d7.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{585c7b485c42555ec554.js → 61f9747c960d959b571b.js} +2 -2
  24. package/assets/esri/core/workers/chunks/{9fc35ec8185beba96715.js → 632d1a1287dde980479e.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{1d043965dcdc11b3aeaa.js → 63852887b3f07d50f7c9.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{c16e0da7a19310c71e8b.js → 677af0281e4fc9f3bd98.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{6ecc3a3737ae8622dfa4.js → 7b12607633bbdc318936.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{d839a237d5edc243d645.js → 8aa8f9986b966ccb64e2.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{67338948e470c1251d8a.js → 8d14e957219364a81d5f.js} +3 -3
  30. package/assets/esri/core/workers/chunks/92a5dccb328229a9336b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{631205dc4d73d49ec9ed.js → 95507ff0a243e451b99e.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{1051a5a57b2fb843a555.js → 9cd55043f3d789f41815.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{2b1486a466760d2152f5.js → a0f2df8ca7cd14bfa013.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{06eb4832b6c86744e52e.js → aba19485b6cdcb70dac6.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{9a06476b834584d00d5c.js → b160dcbea6256e0cf689.js} +1 -1
  36. package/assets/esri/core/workers/chunks/b2a6afa0cd537805b4b8.js +1 -0
  37. package/assets/esri/core/workers/chunks/{571252c9822d73cf7b01.js → b845586219f284a215b2.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{97c148adf0347c69a79c.js → c9604f8df909ec4fad46.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{b87fec1753f164c845c5.js → ca76950d81ab4ebb65e1.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{faa40ef04604c7cce706.js → cb63ea6a53d3c2fc3179.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{55f087bca75c3f2a4515.js → d3c0d7799c92c6f0e7d3.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{ca60b34c3e1ed2ff5934.js → dd2b316baae02bbdddac.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{80b596496800e8d60eb8.js → ed75e0962358523f4439.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{0cf979a093e9744d1e80.js → ef7955a2509be0f03ca2.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{b5d68d8460b7c15001dd.js → f1c6df5cf2ccb6ac47a1.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{523046e04679e301797d.js → f3d97a4c4f433adbdab5.js} +1 -1
  47. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  48. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  49. package/chunks/FocusAreaColor.glsl.js +10 -8
  50. package/chunks/persistableUrlUtils.js +1 -1
  51. package/config.js +1 -1
  52. package/core/accessorSupport/decorators/persistable.js +1 -1
  53. package/geometry/projection/projectPointToVector.js +1 -1
  54. package/geometry/projection/projectVectorToPoint.js +1 -1
  55. package/geometry/projection/projectVectorToVector.js +1 -1
  56. package/geometry/projection.js +1 -1
  57. package/geometry/projectionUtils.js +5 -0
  58. package/geometry/support/meshUtils/elevation.js +1 -1
  59. package/geometry/support/meshUtils/extent.js +1 -1
  60. package/interfaces.d.ts +34 -2
  61. package/kernel.js +1 -1
  62. package/layers/MapNotesLayer.js +1 -1
  63. package/layers/RouteLayer.js +1 -1
  64. package/layers/graphics/applyEditsUtils.js +1 -1
  65. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  66. package/layers/graphics/data/QueryEngine.js +1 -1
  67. package/layers/graphics/data/projectionSupport.js +1 -1
  68. package/layers/graphics/data/queryUtils.js +1 -1
  69. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  70. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  71. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  72. package/layers/ogc/wfsUtils.js +1 -1
  73. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  74. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  75. package/layers/orientedImagery/transformations/utils.js +1 -1
  76. package/layers/support/ControlPointsGeoreference.js +1 -1
  77. package/layers/support/CornersGeoreference.js +1 -1
  78. package/layers/support/ElevationQuery.js +1 -1
  79. package/layers/support/ExtentAndRotationGeoreference.js +1 -1
  80. package/layers/support/GeoreferenceBase.js +1 -1
  81. package/layers/support/LocalMediaElementSource.js +1 -1
  82. package/layers/support/MediaElementView.js +1 -1
  83. package/layers/support/PolygonCollection.js +1 -1
  84. package/layers/support/SceneModification.js +1 -1
  85. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  86. package/package.json +1 -1
  87. package/portal/schemas/definitions.js +1 -1
  88. package/portal/schemas/webScene.js +1 -1
  89. package/portal/support/portalItemUtils.js +1 -1
  90. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  91. package/smartMapping/renderers/size.js +1 -1
  92. package/smartMapping/renderers/support/spikeUtils.js +1 -1
  93. package/smartMapping/statistics/histogram.js +1 -1
  94. package/smartMapping/statistics/summaryStatistics.js +1 -1
  95. package/support/persistableUrlUtils.js +1 -1
  96. package/support/revision.js +1 -1
  97. package/views/2d/ViewStateManager.js +1 -1
  98. package/views/2d/constraints/GeometryConstraint.js +1 -1
  99. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  100. package/views/2d/grid/GridView2D.js +1 -1
  101. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  102. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  103. package/views/2d/layers/KMLLayerView2D.js +1 -1
  104. package/views/2d/viewpointUtils.js +1 -1
  105. package/views/3d/FocusAreasView.js +1 -1
  106. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  107. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  108. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  109. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  110. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  111. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  112. package/views/3d/analysis/support/projectionUtils.js +1 -1
  113. package/views/3d/environment/EnvironmentManager.js +1 -1
  114. package/views/3d/interactive/Manipulator3D.js +1 -1
  115. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  116. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  117. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  118. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  119. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  120. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  121. package/views/3d/layers/FlowSubView3D.js +1 -1
  122. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  123. package/views/3d/layers/SceneLayerWorker.js +1 -1
  124. package/views/3d/layers/TileLayerView3D.js +1 -1
  125. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  126. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  127. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  128. package/views/3d/layers/graphics/focusAreaStyle.js +1 -1
  129. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  130. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  131. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  132. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  133. package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
  134. package/views/3d/state/ViewStateManager.js +1 -1
  135. package/views/3d/support/cameraUtils.js +1 -1
  136. package/views/3d/support/viewpointUtils.js +1 -1
  137. package/views/3d/terrain/ExtentHelper.js +1 -1
  138. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  139. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  140. package/views/3d/webgl-engine/effects/focusArea/FocusAreaEffect.js +5 -0
  141. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  142. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  143. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +1 -1
  144. package/views/FocusArea.js +1 -1
  145. package/views/FocusAreaOutline.js +1 -1
  146. package/views/FocusAreas.js +1 -1
  147. package/views/SceneView.js +1 -1
  148. package/views/View2D.js +1 -1
  149. package/views/interactive/GraphicManipulator.js +1 -1
  150. package/views/interactive/dragEventPipeline.js +1 -1
  151. package/views/interactive/snapping/GridSnappingEngine.js +1 -1
  152. package/views/interactive/snapping/SnappingManager.js +1 -1
  153. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  154. package/views/layers/SceneLayerView.js +1 -1
  155. package/views/support/projectionUtils.js +1 -1
  156. package/webscene/Slide.js +1 -1
  157. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  158. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  159. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  160. package/widgets/CoordinateConversion/support/Format.js +1 -1
  161. package/widgets/Editor/Upload.js +1 -1
  162. package/widgets/Editor.js +1 -1
  163. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  164. package/widgets/Features/FeaturesViewModel.js +1 -1
  165. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  166. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  167. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  168. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  169. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  170. package/widgets/Sketch/SketchViewModel.js +1 -1
  171. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  172. package/widgets/support/AnchorElementViewModel.js +1 -1
  173. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  174. package/widgets/support/tests.js +1 -1
  175. package/assets/esri/core/workers/chunks/3a743653b786b010a57f.js +0 -1
  176. package/assets/esri/core/workers/chunks/6d1e1a4fcb90ea8b6848.js +0 -1
  177. package/assets/esri/core/workers/chunks/87fc7b6c3e2d4f7775e2.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as s}from"../../../core/arrayUtils.js";import{createResolver as t}from"../../../core/promiseUtils.js";import{initializeProjection as e,projectMany as n}from"../../../geometry/projection.js";import{jsonAdapter as r}from"../../../geometry/geometryAdapters/json.js";import{isValid as i,equals as o,isWebMercator as a}from"../../../geometry/support/spatialReferenceUtils.js";import{canProject as m,lngLatToXY as u,xyToLngLat as p}from"../../../geometry/support/webMercatorUtils.js";const c=[0,0];function l(s,t){if(!t)return null;if("x"in t){const e={x:0,y:0};return[e.x,e.y]=s(t.x,t.y,c),null!=t.z&&(e.z=t.z),null!=t.m&&(e.m=t.m),e}if("xmin"in t){const e={xmin:0,ymin:0,xmax:0,ymax:0};return[e.xmin,e.ymin]=s(t.xmin,t.ymin,c),[e.xmax,e.ymax]=s(t.xmax,t.ymax,c),t.hasZ&&(e.zmin=t.zmin,e.zmax=t.zmax,e.hasZ=!0),t.hasM&&(e.mmin=t.mmin,e.mmax=t.mmax,e.hasM=!0),e}return"rings"in t?{rings:h(t.rings,s),hasM:t.hasM,hasZ:t.hasZ}:"paths"in t?{paths:h(t.paths,s),hasM:t.hasM,hasZ:t.hasZ}:"points"in t?{points:f(t.points,s),hasM:t.hasM,hasZ:t.hasZ}:null}function h(s,t){const e=[];for(const n of s)e.push(f(n,t));return e}function f(s,t){const e=[];for(const n of s){const s=t(n[0],n[1],[0,0]);e.push(s),n.length>2&&s.push(n[2]),n.length>3&&s.push(n[3])}return e}async function x(t,n){if(!t||!n)return;const r=Array.isArray(t)?t.map((s=>null!=s.geometry?s.geometry.spatialReference:null)).filter(s):[t];await e(r.map((s=>({source:s,dest:n}))))}const y=l.bind(null,u),g=l.bind(null,p);function j(s,t,e,u){if(!s)return null;if(e||(e=t,t=s.spatialReference),!i(t)||!i(e)||o(t,e))return s;if(m(t,e)){const t=a(e)?y(s):g(s);return t.spatialReference=e,t}return n(r,[s],t,e,null,u)[0]}class _{constructor(){this._jobs=[],this._timer=null,this._process=this._process.bind(this)}async push(s,e,n,r){if(!s?.length||!e||!n||o(e,n))return s;const i={geometries:s,inSpatialReference:e,outSpatialReference:n,geographicTransformation:r,resolve:t()};return this._jobs.push(i),this._timer??=setTimeout(this._process,10),i.resolve.promise}_process(){this._timer=null;const s=this._jobs.shift();if(!s)return;const{geometries:t,inSpatialReference:e,outSpatialReference:i,resolve:o,geographicTransformation:u}=s;m(e,i)?a(i)?o(t.map(y)):o(t.map(g)):o(n(r,t,e,i,u,null)),this._jobs.length>0&&(this._timer=setTimeout(this._process,10))}}const M=new _;function b(s,t,e,n){return M.push(s,t,e,n)}export{x as checkProjectionSupport,j as project,b as projectMany};
5
+ import{isSome as s}from"../../../core/arrayUtils.js";import{createResolver as t}from"../../../core/promiseUtils.js";import{initializeProjection as e,projectMany as n}from"../../../geometry/projectionUtils.js";import{jsonAdapter as r}from"../../../geometry/geometryAdapters/json.js";import{isValid as i,equals as o,isWebMercator as a}from"../../../geometry/support/spatialReferenceUtils.js";import{canProject as m,lngLatToXY as u,xyToLngLat as l}from"../../../geometry/support/webMercatorUtils.js";const p=[0,0];function c(s,t){if(!t)return null;if("x"in t){const e={x:0,y:0};return[e.x,e.y]=s(t.x,t.y,p),null!=t.z&&(e.z=t.z),null!=t.m&&(e.m=t.m),e}if("xmin"in t){const e={xmin:0,ymin:0,xmax:0,ymax:0};return[e.xmin,e.ymin]=s(t.xmin,t.ymin,p),[e.xmax,e.ymax]=s(t.xmax,t.ymax,p),t.hasZ&&(e.zmin=t.zmin,e.zmax=t.zmax,e.hasZ=!0),t.hasM&&(e.mmin=t.mmin,e.mmax=t.mmax,e.hasM=!0),e}return"rings"in t?{rings:h(t.rings,s),hasM:t.hasM,hasZ:t.hasZ}:"paths"in t?{paths:h(t.paths,s),hasM:t.hasM,hasZ:t.hasZ}:"points"in t?{points:f(t.points,s),hasM:t.hasM,hasZ:t.hasZ}:null}function h(s,t){const e=[];for(const n of s)e.push(f(n,t));return e}function f(s,t){const e=[];for(const n of s){const s=t(n[0],n[1],[0,0]);e.push(s),n.length>2&&s.push(n[2]),n.length>3&&s.push(n[3])}return e}async function x(t,n){if(!t||!n)return;const r=Array.isArray(t)?t.map((s=>null!=s.geometry?s.geometry.spatialReference:null)).filter(s):[t];await e(r.map((s=>({source:s,dest:n}))))}const y=c.bind(null,u),g=c.bind(null,l);function j(s,t,e,u){if(!s)return null;if(e||(e=t,t=s.spatialReference),!i(t)||!i(e)||o(t,e))return s;if(m(t,e)){const t=a(e)?y(s):g(s);return t.spatialReference=e,t}return n(r,[s],t,e,null,u)[0]}class _{constructor(){this._jobs=[],this._timer=null,this._process=this._process.bind(this)}async push(s,e,n,r){if(!s?.length||!e||!n||o(e,n))return s;const i={geometries:s,inSpatialReference:e,outSpatialReference:n,geographicTransformation:r,resolve:t()};return this._jobs.push(i),this._timer??=setTimeout(this._process,10),i.resolve.promise}_process(){this._timer=null;const s=this._jobs.shift();if(!s)return;const{geometries:t,inSpatialReference:e,outSpatialReference:i,resolve:o,geographicTransformation:u}=s;m(e,i)?a(i)?o(t.map(y)):o(t.map(g)):o(n(r,t,e,i,u,null)),this._jobs.length>0&&(this._timer=setTimeout(this._process,10))}}const M=new _;function b(s,t,e,n){return M.push(s,t,e,n)}export{x as checkProjectionSupport,j as project,b as projectMany};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import{JSONMap as e}from"../../../core/jsonMap.js";import{getUnitString as i}from"../../../core/unitUtils.js";import{canProjectWithoutEngine as r}from"../../../geometry/projection.js";import{getGeometryExtent as n}from"../../../geometry/support/extentUtils.js";import{fromJSON as a,isPolygon as o,isExtent as s,isPolyline as l}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as m}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as u,isWebMercator as c,wgs84 as p,equals as f}from"../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as y,project as d}from"./projectionSupport.js";const g=new e({esriSRUnit_Meter:"meters",esriSRUnit_Kilometer:"kilometers",esriSRUnit_Foot:"feet",esriSRUnit_StatuteMile:"miles",esriSRUnit_NauticalMile:"nautical-miles",esriSRUnit_USNauticalMile:"us-nautical-miles"}),S=Object.freeze({}),R="frequency";async function w(t,e,i){const r=t.bin;return r.onField&&(r.onField=r.onField.trim()),r.onExpression?.value&&(r.onExpression.value=r.onExpression.value.trim()),r.splitBy&&(r.splitBy.value&&(r.splitBy.value=r.splitBy.value.trim()),r.splitBy.outAlias&&(r.splitBy.outAlias=r.splitBy.outAlias.trim())),r.stackBy&&(r.stackBy.value&&(r.stackBy.value=r.stackBy.value.trim()),r.stackBy.outAlias&&(r.stackBy.outAlias=r.stackBy.outAlias.trim())),"normalizationField"in r.parameters&&r.parameters.normalizationField&&(r.parameters.normalizationField=r.parameters.normalizationField.trim()),t.outStatistics?.length||(t.outStatistics=[{statisticType:"count",onStatisticField:"1",outStatisticFieldName:R}]),x(t,e,i)}async function x(t,e,i){const{outFields:r,orderByFields:n,groupByFieldsForStatistics:a,outStatistics:o}=t;if(r)for(let s=0;s<r.length;s++)r[s]=r[s].trim();if(n)for(let s=0;s<n.length;s++)n[s]=n[s].trim();if(a)for(let s=0;s<a.length;s++)a[s]=a[s].trim();if(o)for(let s=0;s<o.length;s++)o[s].onStatisticField&&(o[s].onStatisticField=o[s].onStatisticField.trim());return t.geometry&&!t.outSR&&(t.outSR=t.geometry.spatialReference),B(t,e,i)}async function B(t,e,i){if(!t)return null;let{where:r}=t;if(t.where=r=r?.trim(),(!r||/^1 *= *1$/.test(r)||e&&e===r)&&(t.where=null),!t.geometry)return t;let o=await v(t);if(t.distance=0,t.units=null,"esriSpatialRelEnvelopeIntersects"===t.spatialRel){const{spatialReference:e}=t.geometry;o=n(o),o.spatialReference=e}if(o){await y(o.spatialReference,i),o=j(o,i);const e=(await m(a(o)))[0];if(null==e)throw S;const r="quantizationParameters"in t&&t.quantizationParameters?.tolerance||"maxAllowableOffset"in t&&t.maxAllowableOffset||0,n=r&&F(o,i)?{densificationStep:8*r}:void 0,s=e.toJSON(),l=d(s,s.spatialReference,i,n);if(!l)throw S;l.spatialReference=i,t.geometry=l}return t}function F(t,e){if(!t)return!1;const i=t.spatialReference;return(s(t)||o(t)||l(t))&&!f(i,e)&&!r(i,e)}function j(t,e){const i=t.spatialReference;return F(t,e)&&s(t)?{spatialReference:i,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:t}async function v(e){const{distance:r,units:n}=e,a=e.geometry;if(null==r||"vertexAttributes"in a)return a;const s=a.spatialReference,l=n?g.fromJSON(n):i(s),m=s&&(u(s)||c(s))?a:await y(s,p).then((()=>d(a,p))),f=await import("../../../geometry/operators/json/geodesicBufferOperator.js");await f.load();const S=f.execute(m,r||1,{unit:l})??void 0;if(!S||!o(S)||0===S.rings.length)throw new t("unsupported-query:invalid-parameters","Invalid parameters for query by distance");return S}function h(t,e){return null==t?null:"string"==typeof t?e?new Date(`1970-01-01T${t}Z`).getTime():new Date(t).getTime():t instanceof Date?t.getTime():t}export{h as getDateInNumber,w as normalizeAttributeBinsQuery,x as normalizeQuery,B as normalizeQueryLike,S as queryEngineEmptyResult,g as unitsKebabDict};
5
+ import t from"../../../core/Error.js";import{JSONMap as e}from"../../../core/jsonMap.js";import{getUnitString as i}from"../../../core/unitUtils.js";import{canProjectWithoutEngine as r}from"../../../geometry/projectionUtils.js";import{getGeometryExtent as n}from"../../../geometry/support/extentUtils.js";import{fromJSON as a,isPolygon as o,isExtent as s,isPolyline as l}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as m}from"../../../geometry/support/normalizeUtils.js";import{isGeographic as u,isWebMercator as c,wgs84 as p,equals as f}from"../../../geometry/support/spatialReferenceUtils.js";import{checkProjectionSupport as y,project as d}from"./projectionSupport.js";const g=new e({esriSRUnit_Meter:"meters",esriSRUnit_Kilometer:"kilometers",esriSRUnit_Foot:"feet",esriSRUnit_StatuteMile:"miles",esriSRUnit_NauticalMile:"nautical-miles",esriSRUnit_USNauticalMile:"us-nautical-miles"}),S=Object.freeze({}),R="frequency";async function w(t,e,i){const r=t.bin;return r.onField&&(r.onField=r.onField.trim()),r.onExpression?.value&&(r.onExpression.value=r.onExpression.value.trim()),r.splitBy&&(r.splitBy.value&&(r.splitBy.value=r.splitBy.value.trim()),r.splitBy.outAlias&&(r.splitBy.outAlias=r.splitBy.outAlias.trim())),r.stackBy&&(r.stackBy.value&&(r.stackBy.value=r.stackBy.value.trim()),r.stackBy.outAlias&&(r.stackBy.outAlias=r.stackBy.outAlias.trim())),"normalizationField"in r.parameters&&r.parameters.normalizationField&&(r.parameters.normalizationField=r.parameters.normalizationField.trim()),t.outStatistics?.length||(t.outStatistics=[{statisticType:"count",onStatisticField:"1",outStatisticFieldName:R}]),x(t,e,i)}async function x(t,e,i){const{outFields:r,orderByFields:n,groupByFieldsForStatistics:a,outStatistics:o}=t;if(r)for(let s=0;s<r.length;s++)r[s]=r[s].trim();if(n)for(let s=0;s<n.length;s++)n[s]=n[s].trim();if(a)for(let s=0;s<a.length;s++)a[s]=a[s].trim();if(o)for(let s=0;s<o.length;s++)o[s].onStatisticField&&(o[s].onStatisticField=o[s].onStatisticField.trim());return t.geometry&&!t.outSR&&(t.outSR=t.geometry.spatialReference),B(t,e,i)}async function B(t,e,i){if(!t)return null;let{where:r}=t;if(t.where=r=r?.trim(),(!r||/^1 *= *1$/.test(r)||e&&e===r)&&(t.where=null),!t.geometry)return t;let o=await v(t);if(t.distance=0,t.units=null,"esriSpatialRelEnvelopeIntersects"===t.spatialRel){const{spatialReference:e}=t.geometry;o=n(o),o.spatialReference=e}if(o){await y(o.spatialReference,i),o=j(o,i);const e=(await m(a(o)))[0];if(null==e)throw S;const r="quantizationParameters"in t&&t.quantizationParameters?.tolerance||"maxAllowableOffset"in t&&t.maxAllowableOffset||0,n=r&&F(o,i)?{densificationStep:8*r}:void 0,s=e.toJSON(),l=d(s,s.spatialReference,i,n);if(!l)throw S;l.spatialReference=i,t.geometry=l}return t}function F(t,e){if(!t)return!1;const i=t.spatialReference;return(s(t)||o(t)||l(t))&&!f(i,e)&&!r(i,e)}function j(t,e){const i=t.spatialReference;return F(t,e)&&s(t)?{spatialReference:i,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:t}async function v(e){const{distance:r,units:n}=e,a=e.geometry;if(null==r||"vertexAttributes"in a)return a;const s=a.spatialReference,l=n?g.fromJSON(n):i(s),m=s&&(u(s)||c(s))?a:await y(s,p).then((()=>d(a,p))),f=await import("../../../geometry/operators/json/geodesicBufferOperator.js");await f.load();const S=f.execute(m,r||1,{unit:l})??void 0;if(!S||!o(S)||0===S.rings.length)throw new t("unsupported-query:invalid-parameters","Invalid parameters for query by distance");return S}function h(t,e){return null==t?null:"string"==typeof t?e?new Date(`1970-01-01T${t}Z`).getTime():new Date(t).getTime():t instanceof Date?t.getTime():t}export{h as getDateInNumber,w as normalizeAttributeBinsQuery,x as normalizeQuery,B as normalizeQueryLike,S as queryEngineEmptyResult,g as unitsKebabDict};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import{parseDate as i}from"../../../../core/date.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{urlToObject as o,getFilename as a}from"../../../../core/urlUtils.js";import{projectMany as l}from"../../../../geometry/projection.js";import m from"../../../../geometry/SpatialReference.js";import{jsonAdapter as c}from"../../../../geometry/geometryAdapters/json.js";import{equals as d,isWebMercator as u,wgs84 as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as p}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as y}from"../../OptimizedFeature.js";import h from"../../OptimizedGeometry.js";import{executeQueryForSnapping as g}from"../../data/executeQueryForSnapping.js";import I from"../../data/FeatureStore.js";import{checkProjectionSupport as _}from"../../data/projectionSupport.js";import{QueryEngine as F}from"../../data/QueryEngine.js";import{parseRows as w,parseNumber as E,severSlicedString as j,readRows as T,inferDelimiterAndLocationInfo as x,extractFieldNamesAndAliasesFromRow as N,inferFields as S}from"../csv/csv.js";import{createDefaultAttributesFunction as q,createDrawingInfo as b}from"./clientSideDefaults.js";import C from"../../../support/FieldsIndex.js";import{getFieldDefaultValue as O}from"../../../support/fieldUtils.js";import{isNumber as v}from"../../../../support/guards.js";import{utc as D}from"../../../../time/constants.js";const k=b("esriGeometryPoint"),P=["csv"],R=[0,0];class V{constructor(e,t){this.x=e,this.y=t}}class A{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,t={}){this._loadOptions=e;const[i]=await Promise.all([this._fetch(t.signal),this._checkProjection(e?.parsingOptions?.spatialReference)]),n=G(i,e);this._locationInfo=n.locationInfo,this._delimiter=n.delimiter,this._queryEngine=this._createQueryEngine(n);const r=await this._createFeatures(i);this._queryEngine.featureStore.addMany(r);const{fullExtent:s,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();if(n.layerDefinition.extent=s,o){const{start:e,end:t}=o;n.layerDefinition.timeInfo.timeExtent=[e,t]}return n}async applyEdits(){throw new n("csv-layer:editing-not-supported","applyEdits() is not supported on CSVLayer")}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){await this._waitSnapshotComplete();return(await this._queryEngine.executeQueryForIds(e,t.signal)).filter(v)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),g(this._queryEngine,e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then((e=>{this._queryEngine.featureStore.clear(),e&&this._queryEngine.featureStore.addMany(e)}),(e=>{this._queryEngine.featureStore.clear(),s(e)||r.getLogger("esri.layers.CSVLayer").error(new n("csv-layer:refresh","An error occurred during refresh",{error:e}))})),await this._waitSnapshotComplete();const{fullExtent:i,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:i,timeExtent:o}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:i,customParameters:r}=this._loadOptions;if(!i)throw new n("csv-layer:invalid-source","url not defined");const s=o(i);return(await e(s.path,{query:{...s.query,...r},responseType:"text",signal:t})).data}_createQueryEngine(e){const{objectIdField:t,fields:i,extent:n,timeInfo:r}=e.layerDefinition,s=new I({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1}),o={type:"object-id",fieldName:t};return new F({fieldsIndex:C.fromLayerJSON({fields:i,dateFieldsTimeReference:{timeZoneIANA:D}}),geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1,timeInfo:r,featureIdInfo:o,spatialReference:n.spatialReference||{wkid:4326},featureStore:s})}async _createFeatures(e){const{latitudeFieldName:t,longitudeFieldName:n}=this._locationInfo,{objectIdField:r,fieldsIndex:s,spatialReference:o}=this._queryEngine;let a=[];const f=[],g=s.fields.filter((e=>e.name!==r)).map((e=>e.name));let I=0;const _={};for(const i of s.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=O(i);void 0!==e&&(_[i.name]=e)}const F=w(e,g,this._delimiter,q(_,r));for(const l of F){const e=this._parseCoordinateValue(l[t]),o=this._parseCoordinateValue(l[n]);if(null!=o&&null!=e&&!isNaN(e)&&!isNaN(o)){l[t]=e,l[n]=o;for(const e in l)if(e!==t&&e!==n)if(s.isDateField(e))l[e]=i(l[e]);else if(s.isNumericField(e)){const t=E(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=j(l[e]));l[r]=I,I++,a.push(new V(o,e)),f.push(l)}}if(!d({wkid:4326},o))if(u(o))for(const i of a)[i.x,i.y]=p(i.x,i.y,R);else a=l(c,a,m.WGS84,o,null,null);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=f[i];n[r]=i+1,T.push(new y(new h([],[e,t]),n,null,n[r]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=E(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await _(f,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function G(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name:a(t.url,P)||"csv",dateFieldsTimeReference:{timeZoneIANA:D},drawingInfo:k,geometryType:"esriGeometryPoint",objectIdField:null,fields:[],timeInfo:i.timeInfo,extent:{xmin:Number.POSITIVE_INFINITY,ymin:Number.POSITIVE_INFINITY,xmax:Number.NEGATIVE_INFINITY,ymax:Number.NEGATIVE_INFINITY,spatialReference:i.spatialReference||{wkid:4326}}},o=T(e),l=o.next().value?.trim(),m=o.next().value?.trim();if(!l)throw new n("csv-layer:empty-csv","CSV is empty",{csv:e});const{delimiter:c,locationInfo:d}=x(l,m,i);if(!c)throw new n("csv-layer:invalid-delimiter","Unable to detect the delimiter from CSV",{firstLine:l,secondLine:m,parsingOptions:i});if(!d)throw new n("csv-layer:location-fields-not-found","Unable to identify latitude and longitude fields from the CSV file",{firstLine:l,secondLine:m,parsingOptions:i});r.locationInfo=d,r.delimiter=c;const{names:u,aliases:f}=N(l,c),p=S(e,r.delimiter,u,f,r.locationInfo);if(i.fields?.length){const e=new C(i.fields);for(const t of p){const i=e.get(t.name);i&&Object.assign(t,i)}}if(!p.some((e=>"esriFieldTypeOID"===e.type&&(s.objectIdField=e.name,!0)))){const e={name:"__OBJECTID",alias:"__OBJECTID",type:"esriFieldTypeOID",editable:!1,nullable:!1};s.objectIdField=e.name,p.unshift(e)}s.fields=p;const y=new C(s.fields);if(r.locationInfo&&(r.locationInfo.latitudeFieldName=y.get(r.locationInfo.latitudeFieldName).name,r.locationInfo.longitudeFieldName=y.get(r.locationInfo.longitudeFieldName).name),s.timeInfo){const e=s.timeInfo;if(e.startTimeField){const t=y.get(e.startTimeField);t?(e.startTimeField=t.name,t.type="esriFieldTypeDate"):e.startTimeField=null}if(e.endTimeField){const t=y.get(e.endTimeField);t?(e.endTimeField=t.name,t.type="esriFieldTypeDate"):e.endTimeField=null}if(e.trackIdField){const t=y.get(e.trackIdField);e.trackIdField=t?t.name:null}e.startTimeField||e.endTimeField||(s.timeInfo=null)}return r}export{A as default};
5
+ import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import{parseDate as i}from"../../../../core/date.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{urlToObject as o,getFilename as a}from"../../../../core/urlUtils.js";import{projectMany as l}from"../../../../geometry/projectionUtils.js";import m from"../../../../geometry/SpatialReference.js";import{jsonAdapter as c}from"../../../../geometry/geometryAdapters/json.js";import{equals as d,isWebMercator as u,wgs84 as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as p}from"../../../../geometry/support/webMercatorUtils.js";import{OptimizedFeature as y}from"../../OptimizedFeature.js";import h from"../../OptimizedGeometry.js";import{executeQueryForSnapping as g}from"../../data/executeQueryForSnapping.js";import I from"../../data/FeatureStore.js";import{checkProjectionSupport as _}from"../../data/projectionSupport.js";import{QueryEngine as F}from"../../data/QueryEngine.js";import{parseRows as w,parseNumber as E,severSlicedString as j,readRows as T,inferDelimiterAndLocationInfo as x,extractFieldNamesAndAliasesFromRow as N,inferFields as S}from"../csv/csv.js";import{createDefaultAttributesFunction as q,createDrawingInfo as b}from"./clientSideDefaults.js";import C from"../../../support/FieldsIndex.js";import{getFieldDefaultValue as O}from"../../../support/fieldUtils.js";import{isNumber as v}from"../../../../support/guards.js";import{utc as D}from"../../../../time/constants.js";const k=b("esriGeometryPoint"),P=["csv"],R=[0,0];class V{constructor(e,t){this.x=e,this.y=t}}class A{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=null}async load(e,t={}){this._loadOptions=e;const[i]=await Promise.all([this._fetch(t.signal),this._checkProjection(e?.parsingOptions?.spatialReference)]),n=G(i,e);this._locationInfo=n.locationInfo,this._delimiter=n.delimiter,this._queryEngine=this._createQueryEngine(n);const r=await this._createFeatures(i);this._queryEngine.featureStore.addMany(r);const{fullExtent:s,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();if(n.layerDefinition.extent=s,o){const{start:e,end:t}=o;n.layerDefinition.timeInfo.timeExtent=[e,t]}return n}async applyEdits(){throw new n("csv-layer:editing-not-supported","applyEdits() is not supported on CSVLayer")}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){await this._waitSnapshotComplete();return(await this._queryEngine.executeQueryForIds(e,t.signal)).filter(v)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),g(this._queryEngine,e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then((e=>{this._queryEngine.featureStore.clear(),e&&this._queryEngine.featureStore.addMany(e)}),(e=>{this._queryEngine.featureStore.clear(),s(e)||r.getLogger("esri.layers.CSVLayer").error(new n("csv-layer:refresh","An error occurred during refresh",{error:e}))})),await this._waitSnapshotComplete();const{fullExtent:i,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:i,timeExtent:o}}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:i,customParameters:r}=this._loadOptions;if(!i)throw new n("csv-layer:invalid-source","url not defined");const s=o(i);return(await e(s.path,{query:{...s.query,...r},responseType:"text",signal:t})).data}_createQueryEngine(e){const{objectIdField:t,fields:i,extent:n,timeInfo:r}=e.layerDefinition,s=new I({geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1}),o={type:"object-id",fieldName:t};return new F({fieldsIndex:C.fromLayerJSON({fields:i,dateFieldsTimeReference:{timeZoneIANA:D}}),geometryType:"esriGeometryPoint",hasM:!1,hasZ:!1,timeInfo:r,featureIdInfo:o,spatialReference:n.spatialReference||{wkid:4326},featureStore:s})}async _createFeatures(e){const{latitudeFieldName:t,longitudeFieldName:n}=this._locationInfo,{objectIdField:r,fieldsIndex:s,spatialReference:o}=this._queryEngine;let a=[];const f=[],g=s.fields.filter((e=>e.name!==r)).map((e=>e.name));let I=0;const _={};for(const i of s.fields)if("esriFieldTypeOID"!==i.type&&"esriFieldTypeGlobalID"!==i.type){const e=O(i);void 0!==e&&(_[i.name]=e)}const F=w(e,g,this._delimiter,q(_,r));for(const l of F){const e=this._parseCoordinateValue(l[t]),o=this._parseCoordinateValue(l[n]);if(null!=o&&null!=e&&!isNaN(e)&&!isNaN(o)){l[t]=e,l[n]=o;for(const e in l)if(e!==t&&e!==n)if(s.isDateField(e))l[e]=i(l[e]);else if(s.isNumericField(e)){const t=E(l[e]);isNaN(t)?l[e]=null:l[e]=t}else null!=l[e]&&(l[e]=j(l[e]));l[r]=I,I++,a.push(new V(o,e)),f.push(l)}}if(!d({wkid:4326},o))if(u(o))for(const i of a)[i.x,i.y]=p(i.x,i.y,R);else a=l(c,a,m.WGS84,o,null,null);const T=[];for(let i=0;i<a.length;i++){const{x:e,y:t}=a[i],n=f[i];n[r]=i+1,T.push(new y(new h([],[e,t]),n,null,n[r]))}return T}_parseCoordinateValue(e){if(null==e||""===e)return null;let t=E(e);return(isNaN(t)||Math.abs(t)>181)&&(t=parseFloat(e)),t}async _checkProjection(e){try{await _(f,e)}catch{throw new n("csv-layer:projection-not-supported","Projection not supported")}}}function G(e,t){const i=t.parsingOptions||{},r={delimiter:i.delimiter,layerDefinition:null,locationInfo:{latitudeFieldName:i.latitudeField,longitudeFieldName:i.longitudeField}},s=r.layerDefinition={name:a(t.url,P)||"csv",dateFieldsTimeReference:{timeZoneIANA:D},drawingInfo:k,geometryType:"esriGeometryPoint",objectIdField:null,fields:[],timeInfo:i.timeInfo,extent:{xmin:Number.POSITIVE_INFINITY,ymin:Number.POSITIVE_INFINITY,xmax:Number.NEGATIVE_INFINITY,ymax:Number.NEGATIVE_INFINITY,spatialReference:i.spatialReference||{wkid:4326}}},o=T(e),l=o.next().value?.trim(),m=o.next().value?.trim();if(!l)throw new n("csv-layer:empty-csv","CSV is empty",{csv:e});const{delimiter:c,locationInfo:d}=x(l,m,i);if(!c)throw new n("csv-layer:invalid-delimiter","Unable to detect the delimiter from CSV",{firstLine:l,secondLine:m,parsingOptions:i});if(!d)throw new n("csv-layer:location-fields-not-found","Unable to identify latitude and longitude fields from the CSV file",{firstLine:l,secondLine:m,parsingOptions:i});r.locationInfo=d,r.delimiter=c;const{names:u,aliases:f}=N(l,c),p=S(e,r.delimiter,u,f,r.locationInfo);if(i.fields?.length){const e=new C(i.fields);for(const t of p){const i=e.get(t.name);i&&Object.assign(t,i)}}if(!p.some((e=>"esriFieldTypeOID"===e.type&&(s.objectIdField=e.name,!0)))){const e={name:"__OBJECTID",alias:"__OBJECTID",type:"esriFieldTypeOID",editable:!1,nullable:!1};s.objectIdField=e.name,p.unshift(e)}s.fields=p;const y=new C(s.fields);if(r.locationInfo&&(r.locationInfo.latitudeFieldName=y.get(r.locationInfo.latitudeFieldName).name,r.locationInfo.longitudeFieldName=y.get(r.locationInfo.longitudeFieldName).name),s.timeInfo){const e=s.timeInfo;if(e.startTimeField){const t=y.get(e.startTimeField);t?(e.startTimeField=t.name,t.type="esriFieldTypeDate"):e.startTimeField=null}if(e.endTimeField){const t=y.get(e.endTimeField);t?(e.endTimeField=t.name,t.type="esriFieldTypeDate"):e.endTimeField=null}if(e.trackIdField){const t=y.get(e.trackIdField);e.trackIdField=t?t.name:null}e.startTimeField||e.endTimeField||(s.timeInfo=null)}return r}export{A 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Error.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{createAbortError as s}from"../../core/promiseUtils.js";import{parseWhereClause as a}from"../../core/sql.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Extent.js";import l from"../../geometry/Polygon.js";import{initializeProjection as m,project as h}from"../../geometry/projection.js";import{wgs84 as c}from"../../geometry/support/spatialReferenceUtils.js";import{systemOidFieldName as y,systemOriginIdFieldName as u,systemDestinationIdFieldName as f,systemIsSpatialFieldName as g,systemLayoutGeometryFieldName as b}from"./constants.js";import w from"./SessionMemoryStorage.js";import{utilsExtentToInBoundsRings as T}from"./supportUtils.js";import{executeQueryStreaming as I}from"../../rest/knowledgeGraphService.js";import M from"../../rest/knowledgeGraph/GraphQueryStreaming.js";import D from"../../rest/support/Query.js";let E=class extends t{constructor(e){super(e),this._processingCacheUpdatesLookup=new Map,this.knowledgeGraph=null,this.inclusionModeDefinition={generateAllSublayers:!0,namedTypeDefinitions:new Map},this.entityTypeNames=new Set,this.relationshipTypeNames=new Set,this.geographicLookup=new Map,this.sublayerCaches=new Map,this.nodeConnectionsLookup=new Map,this.relationshipConnectionsLookup=new Map,this.memberIdTypeLookup=new Map;const t=new Map;e.knowledgeGraph.dataModel.entityTypes?.forEach((i=>{i.name&&(t.set(i.name,"entity"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.entityTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((i=>{i.name&&(t.set(i.name,"relationship"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.relationshipTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((i,s)=>{if("entity"===t.get(s))this.entityTypeNames.add(s);else{if("relationship"!==t.get(s))return n.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);this.relationshipTypeNames.add(s)}const a=new Map;i.members?.forEach((e=>{o(this.memberIdTypeLookup,e.id,(()=>new Set)).add(s);const t=this.getById(e.id);t&&a.set(e.id,t)})),this.sublayerCaches.set(s,a)}))}addToLayer(e){e.forEach((({typeName:e,id:t})=>{if(!this.inclusionModeDefinition)throw new i("knowledge-graph:layer-data-manager","You cannot add to a layer's exclusion list if it was not created with an exclusion list originally");if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){const i=this.inclusionModeDefinition.namedTypeDefinitions.get(e);i.members||(i.members=new Map),i.members.set(t,{id:t}),o(this.memberIdTypeLookup,t,(()=>new Set)).add(e)}}else{const i=new Map;i.set(t,{id:t}),this.inclusionModeDefinition.namedTypeDefinitions.set(e,{useAllData:!1,members:i}),o(this.memberIdTypeLookup,t,(()=>new Set)).add(e)}}))}getById(e){return w.getInstance().readFromStoreById(e)}async getData(e,t,i){if(t.objectType.name&&this.inclusionModeDefinition?.namedTypeDefinitions&&this.inclusionModeDefinition.namedTypeDefinitions.size>0&&!this.inclusionModeDefinition.namedTypeDefinitions.has(t.objectType.name))return[];let n;if(n=e||new D({where:"1=1",outFields:["*"]}),"link-chart"===t.parentCompositeLayer.type){const e=t.parentCompositeLayer,i=this._processingCacheUpdatesLookup.get(t.objectType.name??""),o=n.outFields;o&&1===o.length&&o[0]===y&&"1=1"===n.where||await Promise.all(i??[]);const s=this.sublayerCaches.has(t.objectType.name??"")?Array.from(this.sublayerCaches.get(t.objectType.name)?.values()):[],a=[];return s.forEach((i=>{if(this.relationshipTypeNames.has(t.objectType.name)){i.geometry=e.relationshipLinkChartDiagramLookup.get(i.attributes[t.objectIdField]);const n=this.memberIdTypeLookup.get(i.attributes[u]),o=this.memberIdTypeLookup.get(i.attributes[f]),s=this._isEndEntitySpatial(n,i,u),a=this._isEndEntitySpatial(o,i,f);i.attributes[g]=Number(s&&a)}else{i.geometry=e.entityLinkChartDiagramLookup.get(i.attributes[t.objectIdField]);const n=this.geographicLookup.get(t.objectType.name);n&&i.attributes[n.name]?i.attributes[g]=1:i.attributes[g]=0}i.attributes[b]=i.geometry,a.push(i)})),a}return this.retrieveDataFromService(n,t,i)}async getConnectedRecordIds(e,t,i){const n=[];let o="";const s=this._getNamedTypeIdMapFromNodeIds(e);if(t&&0!==t?.length){for(const e of t)o=o+e+"|";o=o.slice(0,-1)}const a={},r=[];for(const[l,m]of s){const e=`${l}_ids`;a[e]=m,t&&0!==t?.length?r.push(`MATCH (n:${l}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r:${o}]-(m) RETURN id(r), type(r), id(m), labels(m)[0]`):r.push(`MATCH (n:${l}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]-(m) RETURN id(r), type(r), id(m), labels(m)[0]`)}if(!r.length)return n;const p=r.join(" UNION "),d=(await I(this.knowledgeGraph,new M({openCypherQuery:p,bindParameters:a}),{signal:i?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await d.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];n.push({id:e[0],typeName:e[1]}),n.push({id:e[2],typeName:e[3]})}}return n}async getRelationshipsBetweenNodes(e,t,i){const n=this._getNamedTypeIdMapFromNodeIds(e);if(0===n.size)return[];const o={relationshipExclusionIds:t,possibleConnectionEntityIds:e},s=[];for(const[d,l]of n.entries()){const e=`${d}_ids`;o[e]=l,s.push(`MATCH (n:${d}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]->(m) WHERE id(m) IN $possibleConnectionEntityIds AND NOT id(r) IN $relationshipExclusionIds RETURN id(r), type(r)`)}const a=s.join(" UNION "),r=[],p=(await I(this.knowledgeGraph,new M({openCypherQuery:a,bindParameters:o}),{signal:i?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await p.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];r.push({id:e[0],typeName:e[1]})}}return r}async getRelationshipsFromNodes(e,t,i,n){const o=this._getNamedTypeIdMapFromNodeIds(e);if(0===o.size||0===t.length)return[];const s={relationshipExclusionIds:i,possibleConnectionEntityIds:t},a=[];for(const[m,h]of o.entries()){const e=`${m}_ids`;s[e]=h,a.push(`MATCH (n:${m}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]-(m) WHERE id(m) IN $possibleConnectionEntityIds AND NOT id(r) IN $relationshipExclusionIds RETURN id(r), type(r)`)}const r=a.join(" UNION "),p=new Map,d=(await I(this.knowledgeGraph,new M({openCypherQuery:r,bindParameters:s}),{signal:n?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await d.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];let n=p.get(e[1]);n||(n=new Set,p.set(e[1],n)),n.add(e[0])}}const l=[];for(const[m,h]of p)for(const e of h)l.push({id:e,typeName:m});return l}async refreshCacheContent(e,t,n,a=!0,r){const p=w.getInstance(),d=[],l=new Map,m=new Map;this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&m.set(e.name,e)})),this.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&m.set(e.name,e)})),e||this.inclusionModeDefinition?e?e.forEach((e=>{if(this.memberIdTypeLookup.has(e))for(const t of this.memberIdTypeLookup.get(e))l.has(t)?l.get(t)?.push(e):l.set(t,[e])})):this.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e.useAllData?l.set(t,null):e.members&&e.members.forEach((e=>{l.has(t)&&null!==l.get(t)?l.get(t)?.push(e.id):l.set(t,[e.id])}))})):(this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&l.set(e.name,null)})),this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&l.set(e.name,null)})));for(const[s,h]of l){const e=new Set(h),l=new Promise(((d,l)=>{const c=async()=>{const d=new Set,l=[];let c,u="",f=!1;if(t||m.get(s)?.properties?.forEach((e=>{e.name&&d.add(e.name)})),n&&this.geographicLookup.has(s)){const e=this.geographicLookup.get(s)?.name;e&&d.add(e)}if(this.entityTypeNames.has(s))u=`MATCH (n:${s}) ${h?"WHERE id(n) IN $ids ":""}return ID(n)`,d.forEach((e=>{u+=`, n.${e}`,l.push(e)}));else{if(!this.relationshipTypeNames.has(s))throw new i("knowledge-graph:layer-data-manager",`The graph type of ${s} could not be determined. Was this type set in the KG data model and inclusion definition?`);f=!0,u=`MATCH ()-[n:${s}]->() ${h?"WHERE id(n) IN $ids ":""}return ID(n), id(startNode(n)), id(endNode(n))`,d.forEach((e=>{u+=`, n.${e}`,l.push(e)}))}c=new M(h?{openCypherQuery:u,bindParameters:{ids:h}}:{openCypherQuery:u});const g=(await I(this.knowledgeGraph,c,{signal:r?.signal})).resultRowsStream.getReader();for(;;){const{done:t,value:i}=await g.read();if(t)break;const n=[];for(let s=0;s<i.length;s++){const t=i[s];let a=0,r=0;const p={properties:{}};for(p.id=t[a],a++,r++,f&&(p.originId=t[a],a++,r++,p.destinationId=t[a],a++,r++,o(this.nodeConnectionsLookup,p.originId,(()=>new Set)).add(p.id),o(this.nodeConnectionsLookup,p.destinationId,(()=>new Set)).add(p.id),o(this.relationshipConnectionsLookup,p.id,(()=>[p.originId,p.destinationId])));a<t.length;a++)p.properties[l[a-r]]=t[a];e.delete(p.id),n.push(p)}const r=p.writeToStore(n,y,this.geographicLookup.get(s)?.name);this.sublayerCaches.has(s)||this.sublayerCaches.set(s,new Map),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.has(s)&&this.inclusionModeDefinition?.namedTypeDefinitions.set(s,{useAllData:!1,members:new Map}),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members&&(this.inclusionModeDefinition.namedTypeDefinitions.get(s).members=new Map);const d=this.sublayerCaches.get(s);r.forEach((e=>{d?.set(e.attributes[y],e),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members.has(e.attributes[y])&&(this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members.set(e.attributes[y],{id:e.attributes[y]}),o(this.memberIdTypeLookup,e.attributes[y],(()=>new Set)).add(s))}))}const b=this.inclusionModeDefinition?.namedTypeDefinitions.get(s);if(b)for(const t of e)b.members?.delete(t)};c().then((()=>{d(null)})).catch((e=>{"AbortError"===e.name?d(null):l(e)}))}));d.push(l),this._processingCacheUpdatesLookup.get(s)?.push(l)}if(await Promise.all(d),r?.signal?.aborted)throw s()}removeFromLayer(e){const t=new Set,i=new Set(e.map((e=>e.id)));for(const n of e)t.add(n.typeName),1===this.memberIdTypeLookup.get(n.id)?.size?this.memberIdTypeLookup.delete(n.id):this.memberIdTypeLookup.get(n.id)?.delete(n.typeName),this.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{t===n.typeName&&e.members?.has(n.id)&&e.members.delete(n.id)}));t.forEach((e=>{this.sublayerCaches.get(e)?.forEach(((t,n)=>{i.has(n)&&this.sublayerCaches.get(e)?.delete(n)}))}))}async retrieveDataFromService(e,t,n){const o=w.getInstance(),s=new Set,r=[];let p,u="",f=[];const g="relationship"===t.graphType,b=this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData,D=t.parentCompositeLayer.sublayerIdsCache.get(t.objectType.name);let E=!b&&D?Array.from(D).sort():null;if(this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData)this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData&&null!=e.objectIds&&(E=e.objectIds);else if(null!=e.objectIds&&E&&E.length>0){const t=e.objectIds;e.objectIds=E.filter((e=>t.includes(e)))}else if(null!=e.objectIds)E=e.objectIds;else{if(this.inclusionModeDefinition?.namedTypeDefinitions.has(t.objectType.name)&&(!this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members||this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members?.size<1))return e.objectIds=[],[];e.objectIds=E}if(null!=e.outFields){const i=e.outFields;i.includes("*")?t.fields.forEach((e=>{s.add(e.name)})):i.forEach((e=>{e!==y&&e!==t.geometryFieldName&&s.add(e)}))}if(null!=e.geometry){const n=e.geometry;let o;const y=t.parentCompositeLayer.dataManager.knowledgeGraph.serviceDefinition,f=y?.spatialReference,b=y?.serviceCapabilities?.geometryCapabilities;let w=b?.geometryMaxBoundingRectangleSizeX,I=b?.geometryMaxBoundingRectangleSizeY;if("point"===n.type){let e=n;e.spatialReference?.isWGS84||(await m(e.spatialReference,c),e=h(e,c)),o=new d({spatialReference:c,xmin:e.x-1e-4,ymin:e.y-1e-4,xmax:e.x+1e-4,ymax:e.y+1e-4})}else n?.extent?.spatialReference&&!n.spatialReference?.isWGS84?(await m(n.extent.spatialReference,c),o=h(n.extent,c)):o=n.extent;if(w&&I&&f){if(4326!==f.wkid){const e=new d({spatialReference:f,xmax:w,ymax:I}),t=h(e,c);w=t.xmax,I=t.ymax}if(o.xmax-o.xmin>w)throw new i("knowledge-graph:layer-data-manager",`Extent x bounds should be within ${w}° latitude, limit exceeded`);if(o.ymax-o.ymin>I)throw new i("knowledge-graph:layer-data-manager",`Extent y bounds should be within ${I}° longitude, limit exceeded`)}if(null!=e.where&&"1=1"!==e.where){const i=await a(e.where.toUpperCase(),t.fieldsIndex);t.fields.forEach((e=>{i.fieldNames.includes(e.name)&&s.add(e.name)}))}u=g?`Match ()-[n:${t.objectType.name}]->() WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n), id(startNode(r)), id(endNode(r))`:`Match (n:${t.objectType.name}) WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n)`,t.geometryFieldName&&s.add(t.geometryFieldName),s.forEach((e=>{u+=`, n.${e}`,r.push(e)})),p=new M({openCypherQuery:u,bindParameters:{param_filter_geom:new l({rings:T(o)})}})}else{let i="";if(null!=e.where&&"1=1"!==e.where){const n=await a(e.where,t.fieldsIndex);t.fields.forEach((e=>{n.fieldNames.includes(e.name)&&s.add(e.name)}));const o=new Set(["column-reference","string","number","binary-expression"]),r=new Set(["=","<","<=","<>",">",">=","AND","OR","LIKE"]);let p=!1;const d=e=>{if("column-reference"===e.type)return`n.${e.column}`;if("string"===e.type)return`'${e.value}'`;if("number"===e.type)return`${e.value}`;if("binary-expression"===e.type&&o.has(e.left.type)&&o.has(e.right.type)&&r.has(e.operator))return`${d(e.left)} ${e.operator} ${d(e.right)}`;if("binary-expression"===e.type&&"LIKE"===e.operator){let t="";if("function"===e.left.type&&"column-reference"===e.left.args.value[0].type)t+=`lower(n.${e.left.args.value[0].column})`;else{if("column-reference"!==e.left.type)return p=!0,"";t+=`lower(n.${e.left.column})`}if(t+=" CONTAINS (","string"!==e.right.type)return p=!0,"";{let i=e.right.value;"%"===i.charAt(0)&&(i=i.slice(1)),"%"===i.charAt(i.length-1)&&(i=i.slice(0,-1)),t+=`'${i.toLowerCase()}')`}return t}return p=!0,""};i=d(n.parseTree),p&&(i="")}let n="";n=g?`Match ()-[n:${t.objectType.name}]->()`:`Match (n:${t.objectType.name})`;let o=!1;E&&(o=!0,n+=" WHERE ID(n) IN $ids"),i&&(n+=o?" AND":" WHERE",n+=` ${i}`),n+=" return ID(n)",g&&(n+=", id(startNode(n)), id(endNode(n))"),e.returnGeometry&&t.geometryFieldName&&s.add(t.geometryFieldName),s.forEach((e=>{n+=`, n.${e}`,r.push(e)})),p=new M(E?{openCypherQuery:n,bindParameters:{ids:E}}:{openCypherQuery:n})}const N=(await I(t.parentCompositeLayer.dataManager.knowledgeGraph,p,n)).resultRowsStream.getReader();for(;;){const{done:e,value:i}=await N.read();if(e)break;const n=[];for(let t=0;t<i.length;t++){const e=i[t];let o=0,s=0;const a={properties:{}};for(a.id=e[o],o++,s++,g&&(a.originId=e[o],o++,s++,a.destinationId=e[o],o++,s++);o<e.length;o++)a.properties[r[o-s]]=e[o];n.push(a)}f=f.concat(o.writeToStore(n,y,t.parentCompositeLayer.dataManager.geographicLookup.get(t.objectType.name)?.name))}return f}_isEndEntitySpatial(e,t,i){for(const n of e??[])if(this.entityTypeNames.has(n)){const e=this.geographicLookup.get(n),o=e&&this.sublayerCaches.get(n)?.get(t.attributes[i]);if(e&&o?.attributes[e.name])return!0}return!1}_getNamedTypeIdMapFromNodeIds(e){const t=new Map;return e.forEach((e=>{if(this.memberIdTypeLookup.has(e))for(const i of this.memberIdTypeLookup.get(e)){if(!this.entityTypeNames.has(i))return;t.has(i)?t.get(i)?.push(e):t.set(i,[e])}})),t}};e([r()],E.prototype,"knowledgeGraph",void 0),e([r()],E.prototype,"inclusionModeDefinition",void 0),e([r()],E.prototype,"entityTypeNames",void 0),e([r()],E.prototype,"relationshipTypeNames",void 0),e([r()],E.prototype,"geographicLookup",void 0),e([r()],E.prototype,"sublayerCaches",void 0),e([r()],E.prototype,"nodeConnectionsLookup",void 0),e([r()],E.prototype,"relationshipConnectionsLookup",void 0),e([r()],E.prototype,"memberIdTypeLookup",void 0),E=e([p("esri.layers.knowledgeGraph.KnowledgeGraphLayerDataManager")],E);export{E as KnowledgeGraphLayerDataManager};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Error.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{createAbortError as s}from"../../core/promiseUtils.js";import{parseWhereClause as a}from"../../core/sql.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../geometry/Extent.js";import l from"../../geometry/Polygon.js";import{initializeProjection as m,project as h}from"../../geometry/projectionUtils.js";import{wgs84 as c}from"../../geometry/support/spatialReferenceUtils.js";import{systemOidFieldName as y,systemOriginIdFieldName as u,systemDestinationIdFieldName as f,systemIsSpatialFieldName as g,systemLayoutGeometryFieldName as b}from"./constants.js";import w from"./SessionMemoryStorage.js";import{utilsExtentToInBoundsRings as T}from"./supportUtils.js";import{executeQueryStreaming as I}from"../../rest/knowledgeGraphService.js";import M from"../../rest/knowledgeGraph/GraphQueryStreaming.js";import D from"../../rest/support/Query.js";let E=class extends t{constructor(e){super(e),this._processingCacheUpdatesLookup=new Map,this.knowledgeGraph=null,this.inclusionModeDefinition={generateAllSublayers:!0,namedTypeDefinitions:new Map},this.entityTypeNames=new Set,this.relationshipTypeNames=new Set,this.geographicLookup=new Map,this.sublayerCaches=new Map,this.nodeConnectionsLookup=new Map,this.relationshipConnectionsLookup=new Map,this.memberIdTypeLookup=new Map;const t=new Map;e.knowledgeGraph.dataModel.entityTypes?.forEach((i=>{i.name&&(t.set(i.name,"entity"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.entityTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.knowledgeGraph.dataModel.relationshipTypes?.forEach((i=>{i.name&&(t.set(i.name,"relationship"),this._processingCacheUpdatesLookup.set(i.name,[]),e.inclusionModeDefinition&&!e.inclusionModeDefinition?.generateAllSublayers||this.relationshipTypeNames.add(i.name),i.properties?.forEach((e=>{e.geometryType&&"esriGeometryNull"!==e.geometryType&&this.geographicLookup.set(i.name,{name:e.name??"",geometryType:e.geometryType})})))})),e.inclusionModeDefinition?.namedTypeDefinitions.forEach(((i,s)=>{if("entity"===t.get(s))this.entityTypeNames.add(s);else{if("relationship"!==t.get(s))return n.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);this.relationshipTypeNames.add(s)}const a=new Map;i.members?.forEach((e=>{o(this.memberIdTypeLookup,e.id,(()=>new Set)).add(s);const t=this.getById(e.id);t&&a.set(e.id,t)})),this.sublayerCaches.set(s,a)}))}addToLayer(e){e.forEach((({typeName:e,id:t})=>{if(!this.inclusionModeDefinition)throw new i("knowledge-graph:layer-data-manager","You cannot add to a layer's exclusion list if it was not created with an exclusion list originally");if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){if(this.inclusionModeDefinition.namedTypeDefinitions.has(e)){const i=this.inclusionModeDefinition.namedTypeDefinitions.get(e);i.members||(i.members=new Map),i.members.set(t,{id:t}),o(this.memberIdTypeLookup,t,(()=>new Set)).add(e)}}else{const i=new Map;i.set(t,{id:t}),this.inclusionModeDefinition.namedTypeDefinitions.set(e,{useAllData:!1,members:i}),o(this.memberIdTypeLookup,t,(()=>new Set)).add(e)}}))}getById(e){return w.getInstance().readFromStoreById(e)}async getData(e,t,i){if(t.objectType.name&&this.inclusionModeDefinition?.namedTypeDefinitions&&this.inclusionModeDefinition.namedTypeDefinitions.size>0&&!this.inclusionModeDefinition.namedTypeDefinitions.has(t.objectType.name))return[];let n;if(n=e||new D({where:"1=1",outFields:["*"]}),"link-chart"===t.parentCompositeLayer.type){const e=t.parentCompositeLayer,i=this._processingCacheUpdatesLookup.get(t.objectType.name??""),o=n.outFields;o&&1===o.length&&o[0]===y&&"1=1"===n.where||await Promise.all(i??[]);const s=this.sublayerCaches.has(t.objectType.name??"")?Array.from(this.sublayerCaches.get(t.objectType.name)?.values()):[],a=[];return s.forEach((i=>{if(this.relationshipTypeNames.has(t.objectType.name)){i.geometry=e.relationshipLinkChartDiagramLookup.get(i.attributes[t.objectIdField]);const n=this.memberIdTypeLookup.get(i.attributes[u]),o=this.memberIdTypeLookup.get(i.attributes[f]),s=this._isEndEntitySpatial(n,i,u),a=this._isEndEntitySpatial(o,i,f);i.attributes[g]=Number(s&&a)}else{i.geometry=e.entityLinkChartDiagramLookup.get(i.attributes[t.objectIdField]);const n=this.geographicLookup.get(t.objectType.name);n&&i.attributes[n.name]?i.attributes[g]=1:i.attributes[g]=0}i.attributes[b]=i.geometry,a.push(i)})),a}return this.retrieveDataFromService(n,t,i)}async getConnectedRecordIds(e,t,i){const n=[];let o="";const s=this._getNamedTypeIdMapFromNodeIds(e);if(t&&0!==t?.length){for(const e of t)o=o+e+"|";o=o.slice(0,-1)}const a={},r=[];for(const[l,m]of s){const e=`${l}_ids`;a[e]=m,t&&0!==t?.length?r.push(`MATCH (n:${l}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r:${o}]-(m) RETURN id(r), type(r), id(m), labels(m)[0]`):r.push(`MATCH (n:${l}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]-(m) RETURN id(r), type(r), id(m), labels(m)[0]`)}if(!r.length)return n;const p=r.join(" UNION "),d=(await I(this.knowledgeGraph,new M({openCypherQuery:p,bindParameters:a}),{signal:i?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await d.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];n.push({id:e[0],typeName:e[1]}),n.push({id:e[2],typeName:e[3]})}}return n}async getRelationshipsBetweenNodes(e,t,i){const n=this._getNamedTypeIdMapFromNodeIds(e);if(0===n.size)return[];const o={relationshipExclusionIds:t,possibleConnectionEntityIds:e},s=[];for(const[d,l]of n.entries()){const e=`${d}_ids`;o[e]=l,s.push(`MATCH (n:${d}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]->(m) WHERE id(m) IN $possibleConnectionEntityIds AND NOT id(r) IN $relationshipExclusionIds RETURN id(r), type(r)`)}const a=s.join(" UNION "),r=[],p=(await I(this.knowledgeGraph,new M({openCypherQuery:a,bindParameters:o}),{signal:i?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await p.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];r.push({id:e[0],typeName:e[1]})}}return r}async getRelationshipsFromNodes(e,t,i,n){const o=this._getNamedTypeIdMapFromNodeIds(e);if(0===o.size||0===t.length)return[];const s={relationshipExclusionIds:i,possibleConnectionEntityIds:t},a=[];for(const[m,h]of o.entries()){const e=`${m}_ids`;s[e]=h,a.push(`MATCH (n:${m}) WHERE id(n) IN $${e} WITH n MATCH (n)-[r]-(m) WHERE id(m) IN $possibleConnectionEntityIds AND NOT id(r) IN $relationshipExclusionIds RETURN id(r), type(r)`)}const r=a.join(" UNION "),p=new Map,d=(await I(this.knowledgeGraph,new M({openCypherQuery:r,bindParameters:s}),{signal:n?.signal})).resultRowsStream.getReader();for(;;){const{done:e,value:t}=await d.read();if(e)break;for(let i=0;i<t.length;i++){const e=t[i];let n=p.get(e[1]);n||(n=new Set,p.set(e[1],n)),n.add(e[0])}}const l=[];for(const[m,h]of p)for(const e of h)l.push({id:e,typeName:m});return l}async refreshCacheContent(e,t,n,a=!0,r){const p=w.getInstance(),d=[],l=new Map,m=new Map;this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&m.set(e.name,e)})),this.knowledgeGraph.dataModel.relationshipTypes?.forEach((e=>{e.name&&m.set(e.name,e)})),e||this.inclusionModeDefinition?e?e.forEach((e=>{if(this.memberIdTypeLookup.has(e))for(const t of this.memberIdTypeLookup.get(e))l.has(t)?l.get(t)?.push(e):l.set(t,[e])})):this.inclusionModeDefinition?.namedTypeDefinitions?.forEach(((e,t)=>{e.useAllData?l.set(t,null):e.members&&e.members.forEach((e=>{l.has(t)&&null!==l.get(t)?l.get(t)?.push(e.id):l.set(t,[e.id])}))})):(this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&l.set(e.name,null)})),this.knowledgeGraph.dataModel.entityTypes?.forEach((e=>{e.name&&l.set(e.name,null)})));for(const[s,h]of l){const e=new Set(h),l=new Promise(((d,l)=>{const c=async()=>{const d=new Set,l=[];let c,u="",f=!1;if(t||m.get(s)?.properties?.forEach((e=>{e.name&&d.add(e.name)})),n&&this.geographicLookup.has(s)){const e=this.geographicLookup.get(s)?.name;e&&d.add(e)}if(this.entityTypeNames.has(s))u=`MATCH (n:${s}) ${h?"WHERE id(n) IN $ids ":""}return ID(n)`,d.forEach((e=>{u+=`, n.${e}`,l.push(e)}));else{if(!this.relationshipTypeNames.has(s))throw new i("knowledge-graph:layer-data-manager",`The graph type of ${s} could not be determined. Was this type set in the KG data model and inclusion definition?`);f=!0,u=`MATCH ()-[n:${s}]->() ${h?"WHERE id(n) IN $ids ":""}return ID(n), id(startNode(n)), id(endNode(n))`,d.forEach((e=>{u+=`, n.${e}`,l.push(e)}))}c=new M(h?{openCypherQuery:u,bindParameters:{ids:h}}:{openCypherQuery:u});const g=(await I(this.knowledgeGraph,c,{signal:r?.signal})).resultRowsStream.getReader();for(;;){const{done:t,value:i}=await g.read();if(t)break;const n=[];for(let s=0;s<i.length;s++){const t=i[s];let a=0,r=0;const p={properties:{}};for(p.id=t[a],a++,r++,f&&(p.originId=t[a],a++,r++,p.destinationId=t[a],a++,r++,o(this.nodeConnectionsLookup,p.originId,(()=>new Set)).add(p.id),o(this.nodeConnectionsLookup,p.destinationId,(()=>new Set)).add(p.id),o(this.relationshipConnectionsLookup,p.id,(()=>[p.originId,p.destinationId])));a<t.length;a++)p.properties[l[a-r]]=t[a];e.delete(p.id),n.push(p)}const r=p.writeToStore(n,y,this.geographicLookup.get(s)?.name);this.sublayerCaches.has(s)||this.sublayerCaches.set(s,new Map),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.has(s)&&this.inclusionModeDefinition?.namedTypeDefinitions.set(s,{useAllData:!1,members:new Map}),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members&&(this.inclusionModeDefinition.namedTypeDefinitions.get(s).members=new Map);const d=this.sublayerCaches.get(s);r.forEach((e=>{d?.set(e.attributes[y],e),a&&!this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members.has(e.attributes[y])&&(this.inclusionModeDefinition?.namedTypeDefinitions.get(s).members.set(e.attributes[y],{id:e.attributes[y]}),o(this.memberIdTypeLookup,e.attributes[y],(()=>new Set)).add(s))}))}const b=this.inclusionModeDefinition?.namedTypeDefinitions.get(s);if(b)for(const t of e)b.members?.delete(t)};c().then((()=>{d(null)})).catch((e=>{"AbortError"===e.name?d(null):l(e)}))}));d.push(l),this._processingCacheUpdatesLookup.get(s)?.push(l)}if(await Promise.all(d),r?.signal?.aborted)throw s()}removeFromLayer(e){const t=new Set,i=new Set(e.map((e=>e.id)));for(const n of e)t.add(n.typeName),1===this.memberIdTypeLookup.get(n.id)?.size?this.memberIdTypeLookup.delete(n.id):this.memberIdTypeLookup.get(n.id)?.delete(n.typeName),this.inclusionModeDefinition?.namedTypeDefinitions.forEach(((e,t)=>{t===n.typeName&&e.members?.has(n.id)&&e.members.delete(n.id)}));t.forEach((e=>{this.sublayerCaches.get(e)?.forEach(((t,n)=>{i.has(n)&&this.sublayerCaches.get(e)?.delete(n)}))}))}async retrieveDataFromService(e,t,n){const o=w.getInstance(),s=new Set,r=[];let p,u="",f=[];const g="relationship"===t.graphType,b=this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData,D=t.parentCompositeLayer.sublayerIdsCache.get(t.objectType.name);let E=!b&&D?Array.from(D).sort():null;if(this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData)this.inclusionModeDefinition?.namedTypeDefinitions?.get(t.objectType.name)?.useAllData&&null!=e.objectIds&&(E=e.objectIds);else if(null!=e.objectIds&&E&&E.length>0){const t=e.objectIds;e.objectIds=E.filter((e=>t.includes(e)))}else if(null!=e.objectIds)E=e.objectIds;else{if(this.inclusionModeDefinition?.namedTypeDefinitions.has(t.objectType.name)&&(!this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members||this.inclusionModeDefinition.namedTypeDefinitions.get(t.objectType.name)?.members?.size<1))return e.objectIds=[],[];e.objectIds=E}if(null!=e.outFields){const i=e.outFields;i.includes("*")?t.fields.forEach((e=>{s.add(e.name)})):i.forEach((e=>{e!==y&&e!==t.geometryFieldName&&s.add(e)}))}if(null!=e.geometry){const n=e.geometry;let o;const y=t.parentCompositeLayer.dataManager.knowledgeGraph.serviceDefinition,f=y?.spatialReference,b=y?.serviceCapabilities?.geometryCapabilities;let w=b?.geometryMaxBoundingRectangleSizeX,I=b?.geometryMaxBoundingRectangleSizeY;if("point"===n.type){let e=n;e.spatialReference?.isWGS84||(await m(e.spatialReference,c),e=h(e,c)),o=new d({spatialReference:c,xmin:e.x-1e-4,ymin:e.y-1e-4,xmax:e.x+1e-4,ymax:e.y+1e-4})}else n?.extent?.spatialReference&&!n.spatialReference?.isWGS84?(await m(n.extent.spatialReference,c),o=h(n.extent,c)):o=n.extent;if(w&&I&&f){if(4326!==f.wkid){const e=new d({spatialReference:f,xmax:w,ymax:I}),t=h(e,c);w=t.xmax,I=t.ymax}if(o.xmax-o.xmin>w)throw new i("knowledge-graph:layer-data-manager",`Extent x bounds should be within ${w}° latitude, limit exceeded`);if(o.ymax-o.ymin>I)throw new i("knowledge-graph:layer-data-manager",`Extent y bounds should be within ${I}° longitude, limit exceeded`)}if(null!=e.where&&"1=1"!==e.where){const i=await a(e.where.toUpperCase(),t.fieldsIndex);t.fields.forEach((e=>{i.fieldNames.includes(e.name)&&s.add(e.name)}))}u=g?`Match ()-[n:${t.objectType.name}]->() WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n), id(startNode(r)), id(endNode(r))`:`Match (n:${t.objectType.name}) WHERE esri.graph.ST_Intersects($param_filter_geom, n.${t.geometryFieldName}) return ID(n)`,t.geometryFieldName&&s.add(t.geometryFieldName),s.forEach((e=>{u+=`, n.${e}`,r.push(e)})),p=new M({openCypherQuery:u,bindParameters:{param_filter_geom:new l({rings:T(o)})}})}else{let i="";if(null!=e.where&&"1=1"!==e.where){const n=await a(e.where,t.fieldsIndex);t.fields.forEach((e=>{n.fieldNames.includes(e.name)&&s.add(e.name)}));const o=new Set(["column-reference","string","number","binary-expression"]),r=new Set(["=","<","<=","<>",">",">=","AND","OR","LIKE"]);let p=!1;const d=e=>{if("column-reference"===e.type)return`n.${e.column}`;if("string"===e.type)return`'${e.value}'`;if("number"===e.type)return`${e.value}`;if("binary-expression"===e.type&&o.has(e.left.type)&&o.has(e.right.type)&&r.has(e.operator))return`${d(e.left)} ${e.operator} ${d(e.right)}`;if("binary-expression"===e.type&&"LIKE"===e.operator){let t="";if("function"===e.left.type&&"column-reference"===e.left.args.value[0].type)t+=`lower(n.${e.left.args.value[0].column})`;else{if("column-reference"!==e.left.type)return p=!0,"";t+=`lower(n.${e.left.column})`}if(t+=" CONTAINS (","string"!==e.right.type)return p=!0,"";{let i=e.right.value;"%"===i.charAt(0)&&(i=i.slice(1)),"%"===i.charAt(i.length-1)&&(i=i.slice(0,-1)),t+=`'${i.toLowerCase()}')`}return t}return p=!0,""};i=d(n.parseTree),p&&(i="")}let n="";n=g?`Match ()-[n:${t.objectType.name}]->()`:`Match (n:${t.objectType.name})`;let o=!1;E&&(o=!0,n+=" WHERE ID(n) IN $ids"),i&&(n+=o?" AND":" WHERE",n+=` ${i}`),n+=" return ID(n)",g&&(n+=", id(startNode(n)), id(endNode(n))"),e.returnGeometry&&t.geometryFieldName&&s.add(t.geometryFieldName),s.forEach((e=>{n+=`, n.${e}`,r.push(e)})),p=new M(E?{openCypherQuery:n,bindParameters:{ids:E}}:{openCypherQuery:n})}const N=(await I(t.parentCompositeLayer.dataManager.knowledgeGraph,p,n)).resultRowsStream.getReader();for(;;){const{done:e,value:i}=await N.read();if(e)break;const n=[];for(let t=0;t<i.length;t++){const e=i[t];let o=0,s=0;const a={properties:{}};for(a.id=e[o],o++,s++,g&&(a.originId=e[o],o++,s++,a.destinationId=e[o],o++,s++);o<e.length;o++)a.properties[r[o-s]]=e[o];n.push(a)}f=f.concat(o.writeToStore(n,y,t.parentCompositeLayer.dataManager.geographicLookup.get(t.objectType.name)?.name))}return f}_isEndEntitySpatial(e,t,i){for(const n of e??[])if(this.entityTypeNames.has(n)){const e=this.geographicLookup.get(n),o=e&&this.sublayerCaches.get(n)?.get(t.attributes[i]);if(e&&o?.attributes[e.name])return!0}return!1}_getNamedTypeIdMapFromNodeIds(e){const t=new Map;return e.forEach((e=>{if(this.memberIdTypeLookup.has(e))for(const i of this.memberIdTypeLookup.get(e)){if(!this.entityTypeNames.has(i))return;t.has(i)?t.get(i)?.push(e):t.set(i,[e])}})),t}};e([r()],E.prototype,"knowledgeGraph",void 0),e([r()],E.prototype,"inclusionModeDefinition",void 0),e([r()],E.prototype,"entityTypeNames",void 0),e([r()],E.prototype,"relationshipTypeNames",void 0),e([r()],E.prototype,"geographicLookup",void 0),e([r()],E.prototype,"sublayerCaches",void 0),e([r()],E.prototype,"nodeConnectionsLookup",void 0),e([r()],E.prototype,"relationshipConnectionsLookup",void 0),e([r()],E.prototype,"memberIdTypeLookup",void 0),E=e([p("esri.layers.knowledgeGraph.KnowledgeGraphLayerDataManager")],E);export{E as KnowledgeGraphLayerDataManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import{clone as r}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as i}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../../core/accessorSupport/decorators/writer.js";import{OriginId as p}from"../../core/accessorSupport/PropertyOrigin.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import u from"../../geometry/Polygon.js";import m from"../../geometry/Polyline.js";import{initializeProjection as d,project as h}from"../../geometry/projection.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as f}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as g}from"../../geometry/support/typeUtils.js";import j from"../Layer.js";import b from"../graphics/data/FeatureStore.js";import{QueryEngine as w}from"../graphics/data/QueryEngine.js";import{createCapabilities as T,createDrawingInfo as I}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as S,systemAggregationCountFieldName as v,systemIsSpatialFieldName as O,systemLayoutGeometryFieldName as E,systemOriginIdFieldName as x,systemDestinationIdFieldName as N}from"./constants.js";import{KnowledgeGraphSublayerBase as L}from"./KnowledgeGraphSublayerBase.js";import{getDisplayLabelProperty as F,getLinkChartDefaultLabelingInfo as _,getMapDefaultLabelingInfo as R,getKGSublayerSymbolColor as Q,getDefaultLCRelationshipSublayerSymbol as C}from"./layerUtils.js";import{BlendLayer as M,blendModeProperty as k,effectProperty as J}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as D,displayFilterEnabledProperty as P,displayFilterInfoProperty as q}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as G,featureEffectProperty as U}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as A}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as Z,orderByProperty as B}from"../mixins/OrderedLayer.js";import{RefreshableLayer as V}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as K}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as W,useViewTimeProperty as Y}from"../mixins/TemporalLayer.js";import{legendEnabled as z,maxScale as H,minScale as X,opacity as $,popupEnabled as ee}from"../support/commonProperties.js";import{featureReductionProperty as te}from"../support/featureReductionUtils.js";import re from"../support/Field.js";import{fixRendererFields as oe,fixTimeInfoFields as ie}from"../support/fieldUtils.js";import ne from"../support/LabelClass.js";import{reader as se}from"../support/labelingInfo.js";import ae from"../support/TimeInfo.js";import pe from"../../renderers/SimpleRenderer.js";import{fromJSON as le}from"../../renderers/support/jsonUtils.js";import{rendererTypes as ye}from"../../renderers/support/typeUtils.js";import ue from"../../rest/support/FeatureSet.js";import me from"../../rest/support/Query.js";import{createPopupTemplate as de}from"../../support/popupUtils.js";import{applyColorToSymbol as he}from"../../symbols/support/utils.js";import ce from"../../core/workers/RemoteClient.js";function fe(e){if(!e.json)return e;e.json.write=ge(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=ge(e.write))}return e}function ge(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=je(e)),e):!0===e?be():e}function je(e){const{target:t,writer:r,overridePolicy:o,...i}=e;return function(e,t){const r=we.call(this,e,t);return r.enabled?{...i,...r}:r}}function be(){return{overridePolicy:we}}function we(e,t){const r=!!this.geometryType;let o={enabled:r};return r&&(o={...o,...Te.call(this,e,t)}),o}function Te(e,t){return{ignoreOrigin:this.originIdOf(t)>p.DEFAULTS}}let Ie=class extends(L(D(A(G(M(Z(W(K(V(i(j))))))))))){constructor(e){super(e),this.blendMode="normal",this.capabilities=T(!1,!1),this.charts=null,this.definitionExpression=null,this.displayField="",this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=S,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then((()=>{const e=new MessageChannel;return new ce(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=me.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]}))},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach((t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(re.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))})),e.push(re.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),re.fromJSON({name:v,type:"esriFieldTypeInteger",alias:v,editable:!1}),re.fromJSON({name:O,type:"esriFieldTypeInteger",alias:O,editable:!1})),e}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?g.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return E;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphTypeName(){return this.objectType?.name}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");const e=this.objectType.properties?F(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?_(this.graphType,this.graphTypeName,e):R(this.graphTypeName,this.geometryType,e)}set renderer(e){oe(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map((e=>e.name)).indexOf(this.graphTypeName),r=Q(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new pe({type:"simple",symbol:C(r)});const e=le(I(g.toJSON("point")).renderer);return he(e.symbol,r),e}const o=le(I(g.toJSON(this.geometryType)).renderer);return he(o.symbol,r),o}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return de(this,e)}createQuery(){return new me({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e),i=ue.fromJSON(await o.executeQuery(r.toJSON(),t?.signal));return i.features.forEach((e=>{e.sourceLayer=this})),i}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e);return await o.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e);return o.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:o,queryEngine:i}=await this._setupQueryObjects(r),n=await i.executeQueryForExtent(o.toJSON(),t?.signal);let s;return s=null!=n.extent?.xmin&&null!=n.extent?.xmax&&null!=n.extent?.ymin&&null!=n.extent?.ymax?new l(n.extent):new l,{count:n.count,extent:s}}async queryObjectIds(e,t){await this.load();const r=me.from(e);let o;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)o=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);o=this.loadQueryEngine(e)}return await o.executeQueryForIds(r.toJSON(),t?.signal)}loadQueryEngine(e){const t=new b({geometryType:g.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new w({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:g.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new me({where:"1=1",outFields:[S]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then((()=>ie(this.timeInfo,this.fieldsIndex)))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=me.from(e),o=r.geometry;if(o&&!o.spatialReference?.isWGS84&&(await d(o.spatialReference,f),r.geometry=h(o instanceof u||o instanceof m||o instanceof y?o:o.extent,f)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const i=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(i)}}};function Se(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",v],["ESRI__ORIGIN_ID",x],["ESRI__DESTINATION_ID",N],["ESRI__LAYOUT_GEOMETRY",E]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(n){o.getLogger(this).warn("Error updating labelingInfo",n)}return se(e,t,r)}e([n(fe(r(k)))],Ie.prototype,"blendMode",void 0),e([n()],Ie.prototype,"capabilities",void 0),e([n({json:{origins:{"web-scene":{write:!1}},write:be()}})],Ie.prototype,"charts",void 0),e([n({readOnly:!0})],Ie.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],Ie.prototype,"definitionExpression",void 0),e([n()],Ie.prototype,"displayField",void 0),e([n(fe(r(P)))],Ie.prototype,"displayFilterEnabled",void 0),e([n(fe(r(q)))],Ie.prototype,"displayFilterInfo",void 0),e([n(fe(r(J)))],Ie.prototype,"effect",void 0),e([n()],Ie.prototype,"elevationInfo",void 0),e([n(fe(r(U)))],Ie.prototype,"featureEffect",void 0),e([n(fe(r(te)))],Ie.prototype,"featureReduction",null),e([n()],Ie.prototype,"fields",null),e([n()],Ie.prototype,"geometryType",null),e([n()],Ie.prototype,"geometryFieldName",null),e([n({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ie.prototype,"graphType",void 0),e([n({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ie.prototype,"graphTypeName",null),e([n()],Ie.prototype,"hasM",null),e([n()],Ie.prototype,"hasZ",null),e([n({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Ie.prototype,"id",void 0),e([n({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],Ie.prototype,"labelsVisible",void 0),e([n({type:[ne],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:Se,write:be()}})],Ie.prototype,"labelingInfo",null),e([n({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ie.prototype,"layerType",void 0),e([n(fe(r(z)))],Ie.prototype,"legendEnabled",void 0),e([n(fe(r(H)))],Ie.prototype,"maxScale",void 0),e([n(fe(r(X)))],Ie.prototype,"minScale",void 0),e([n()],Ie.prototype,"objectIdField",void 0),e([n()],Ie.prototype,"objectType",void 0),e([n(fe(r($)))],Ie.prototype,"opacity",void 0),e([n(fe(r(B)))],Ie.prototype,"orderBy",void 0),e([n({clonable:!1})],Ie.prototype,"parent",void 0),e([n()],Ie.prototype,"parentCompositeLayer",void 0),e([n(fe(r(ee)))],Ie.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],Ie.prototype,"popupTemplate",void 0),e([n({type:Number,json:{write:{overridePolicy:Te}}})],Ie.prototype,"refreshInterval",void 0),e([n({types:ye,json:{name:"layerDefinition.drawingInfo.renderer",write:be()}})],Ie.prototype,"renderer",null),e([n()],Ie.prototype,"source",void 0),e([n()],Ie.prototype,"spatialReference",null),e([n({type:ae,json:{name:"layerDefinition.timeInfo",write:!0,origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:!0},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:!0}}}})],Ie.prototype,"timeInfo",null),e([n({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ie.prototype,"title",null),e([a("title")],Ie.prototype,"writeTitle",null),e([n({json:{read:!1}})],Ie.prototype,"type",void 0),e([n(fe(r(Y)))],Ie.prototype,"useViewTime",void 0),e([n({type:Boolean,json:{name:"visibility",write:be()}})],Ie.prototype,"visible",void 0),Ie=e([s("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],Ie);export{Ie as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import{clone as r}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as i}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../../core/accessorSupport/decorators/writer.js";import{OriginId as p}from"../../core/accessorSupport/PropertyOrigin.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import u from"../../geometry/Polygon.js";import m from"../../geometry/Polyline.js";import{initializeProjection as d,project as h}from"../../geometry/projectionUtils.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as f}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as g}from"../../geometry/support/typeUtils.js";import j from"../Layer.js";import b from"../graphics/data/FeatureStore.js";import{QueryEngine as w}from"../graphics/data/QueryEngine.js";import{createCapabilities as T,createDrawingInfo as I}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as S,systemAggregationCountFieldName as v,systemIsSpatialFieldName as O,systemLayoutGeometryFieldName as E,systemOriginIdFieldName as x,systemDestinationIdFieldName as N}from"./constants.js";import{KnowledgeGraphSublayerBase as L}from"./KnowledgeGraphSublayerBase.js";import{getDisplayLabelProperty as F,getLinkChartDefaultLabelingInfo as _,getMapDefaultLabelingInfo as R,getKGSublayerSymbolColor as Q,getDefaultLCRelationshipSublayerSymbol as C}from"./layerUtils.js";import{BlendLayer as M,blendModeProperty as k,effectProperty as J}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as D,displayFilterEnabledProperty as P,displayFilterInfoProperty as q}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as G,featureEffectProperty as U}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as A}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as Z,orderByProperty as B}from"../mixins/OrderedLayer.js";import{RefreshableLayer as V}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as K}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as W,useViewTimeProperty as Y}from"../mixins/TemporalLayer.js";import{legendEnabled as z,maxScale as H,minScale as X,opacity as $,popupEnabled as ee}from"../support/commonProperties.js";import{featureReductionProperty as te}from"../support/featureReductionUtils.js";import re from"../support/Field.js";import{fixRendererFields as oe,fixTimeInfoFields as ie}from"../support/fieldUtils.js";import ne from"../support/LabelClass.js";import{reader as se}from"../support/labelingInfo.js";import ae from"../support/TimeInfo.js";import pe from"../../renderers/SimpleRenderer.js";import{fromJSON as le}from"../../renderers/support/jsonUtils.js";import{rendererTypes as ye}from"../../renderers/support/typeUtils.js";import ue from"../../rest/support/FeatureSet.js";import me from"../../rest/support/Query.js";import{createPopupTemplate as de}from"../../support/popupUtils.js";import{applyColorToSymbol as he}from"../../symbols/support/utils.js";import ce from"../../core/workers/RemoteClient.js";function fe(e){if(!e.json)return e;e.json.write=ge(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=ge(e.write))}return e}function ge(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=je(e)),e):!0===e?be():e}function je(e){const{target:t,writer:r,overridePolicy:o,...i}=e;return function(e,t){const r=we.call(this,e,t);return r.enabled?{...i,...r}:r}}function be(){return{overridePolicy:we}}function we(e,t){const r=!!this.geometryType;let o={enabled:r};return r&&(o={...o,...Te.call(this,e,t)}),o}function Te(e,t){return{ignoreOrigin:this.originIdOf(t)>p.DEFAULTS}}let Ie=class extends(L(D(A(G(M(Z(W(K(V(i(j))))))))))){constructor(e){super(e),this.blendMode="normal",this.capabilities=T(!1,!1),this.charts=null,this.definitionExpression=null,this.displayField="",this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=S,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then((()=>{const e=new MessageChannel;return new ce(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=me.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]}))},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach((t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(re.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))})),e.push(re.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),re.fromJSON({name:v,type:"esriFieldTypeInteger",alias:v,editable:!1}),re.fromJSON({name:O,type:"esriFieldTypeInteger",alias:O,editable:!1})),e}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?g.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return E;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphTypeName(){return this.objectType?.name}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");const e=this.objectType.properties?F(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?_(this.graphType,this.graphTypeName,e):R(this.graphTypeName,this.geometryType,e)}set renderer(e){oe(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map((e=>e.name)).indexOf(this.graphTypeName),r=Q(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new pe({type:"simple",symbol:C(r)});const e=le(I(g.toJSON("point")).renderer);return he(e.symbol,r),e}const o=le(I(g.toJSON(this.geometryType)).renderer);return he(o.symbol,r),o}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return de(this,e)}createQuery(){return new me({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e),i=ue.fromJSON(await o.executeQuery(r.toJSON(),t?.signal));return i.features.forEach((e=>{e.sourceLayer=this})),i}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e);return await o.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:o}=await this._setupQueryObjects(e);return o.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:o,queryEngine:i}=await this._setupQueryObjects(r),n=await i.executeQueryForExtent(o.toJSON(),t?.signal);let s;return s=null!=n.extent?.xmin&&null!=n.extent?.xmax&&null!=n.extent?.ymin&&null!=n.extent?.ymax?new l(n.extent):new l,{count:n.count,extent:s}}async queryObjectIds(e,t){await this.load();const r=me.from(e);let o;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)o=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);o=this.loadQueryEngine(e)}return await o.executeQueryForIds(r.toJSON(),t?.signal)}loadQueryEngine(e){const t=new b({geometryType:g.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new w({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:g.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new me({where:"1=1",outFields:[S]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then((()=>ie(this.timeInfo,this.fieldsIndex)))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=me.from(e),o=r.geometry;if(o&&!o.spatialReference?.isWGS84&&(await d(o.spatialReference,f),r.geometry=h(o instanceof u||o instanceof m||o instanceof y?o:o.extent,f)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const i=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(i)}}};function Se(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",v],["ESRI__ORIGIN_ID",x],["ESRI__DESTINATION_ID",N],["ESRI__LAYOUT_GEOMETRY",E]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(n){o.getLogger(this).warn("Error updating labelingInfo",n)}return se(e,t,r)}e([n(fe(r(k)))],Ie.prototype,"blendMode",void 0),e([n()],Ie.prototype,"capabilities",void 0),e([n({json:{origins:{"web-scene":{write:!1}},write:be()}})],Ie.prototype,"charts",void 0),e([n({readOnly:!0})],Ie.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],Ie.prototype,"definitionExpression",void 0),e([n()],Ie.prototype,"displayField",void 0),e([n(fe(r(P)))],Ie.prototype,"displayFilterEnabled",void 0),e([n(fe(r(q)))],Ie.prototype,"displayFilterInfo",void 0),e([n(fe(r(J)))],Ie.prototype,"effect",void 0),e([n()],Ie.prototype,"elevationInfo",void 0),e([n(fe(r(U)))],Ie.prototype,"featureEffect",void 0),e([n(fe(r(te)))],Ie.prototype,"featureReduction",null),e([n()],Ie.prototype,"fields",null),e([n()],Ie.prototype,"geometryType",null),e([n()],Ie.prototype,"geometryFieldName",null),e([n({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ie.prototype,"graphType",void 0),e([n({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ie.prototype,"graphTypeName",null),e([n()],Ie.prototype,"hasM",null),e([n()],Ie.prototype,"hasZ",null),e([n({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Ie.prototype,"id",void 0),e([n({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],Ie.prototype,"labelsVisible",void 0),e([n({type:[ne],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:Se,write:be()}})],Ie.prototype,"labelingInfo",null),e([n({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ie.prototype,"layerType",void 0),e([n(fe(r(z)))],Ie.prototype,"legendEnabled",void 0),e([n(fe(r(H)))],Ie.prototype,"maxScale",void 0),e([n(fe(r(X)))],Ie.prototype,"minScale",void 0),e([n()],Ie.prototype,"objectIdField",void 0),e([n()],Ie.prototype,"objectType",void 0),e([n(fe(r($)))],Ie.prototype,"opacity",void 0),e([n(fe(r(B)))],Ie.prototype,"orderBy",void 0),e([n({clonable:!1})],Ie.prototype,"parent",void 0),e([n()],Ie.prototype,"parentCompositeLayer",void 0),e([n(fe(r(ee)))],Ie.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],Ie.prototype,"popupTemplate",void 0),e([n({type:Number,json:{write:{overridePolicy:Te}}})],Ie.prototype,"refreshInterval",void 0),e([n({types:ye,json:{name:"layerDefinition.drawingInfo.renderer",write:be()}})],Ie.prototype,"renderer",null),e([n()],Ie.prototype,"source",void 0),e([n()],Ie.prototype,"spatialReference",null),e([n({type:ae,json:{name:"layerDefinition.timeInfo",write:!0,origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:!0},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:!0}}}})],Ie.prototype,"timeInfo",null),e([n({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ie.prototype,"title",null),e([a("title")],Ie.prototype,"writeTitle",null),e([n({json:{read:!1}})],Ie.prototype,"type",void 0),e([n(fe(r(Y)))],Ie.prototype,"useViewTime",void 0),e([n({type:Boolean,json:{name:"visibility",write:be()}})],Ie.prototype,"visible",void 0),Ie=e([s("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],Ie);export{Ie 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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import t from"../../core/Error.js";import{find as r,cache as n}from"../../core/iteratorUtils.js";import{isHTTPSProtocol as a,hasSameOrigin as o,toHTTPS as s}from"../../core/urlUtils.js";import i from"../../geometry/Extent.js";import{initializeProjection as p,project as u}from"../../geometry/projection.js";import l from"../../geometry/SpatialReference.js";import{equals as c,wgs84 as m}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import{getGeometryType as y}from"../graphics/sources/geojson/geojson.js";import{visitXML as d,iterateXML as g}from"./xmlUtils.js";import{isArcGISUrl as w}from"../support/arcgisLayerUrl.js";import b from"../support/Field.js";import{getFieldDefaultLength as h}from"../support/fieldUtils.js";const T="xlink:href",S="2.0.0",F="__esri_wfs_id__",x="wfs-layer:getWFSLayerTypeInfo-error",C="wfs-layer:empty-service",E="wfs-layer:feature-type-not-found",R="wfs-layer:geojson-not-supported",k="wfs-layer:kvp-encoding-not-supported",P="wfs-layer:malformed-json",j="wfs-layer:unknown-geometry-type",A="wfs-layer:unknown-field-type",N="wfs-layer:unsupported-spatial-reference",G="wfs-layer:unsupported-wfs-version";async function v(t,r){const n=U((await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"GetCapabilities",VERSION:S,...r?.customParameters},signal:r?.signal})).data);return D(t,n),n}function U(e){const t=te(e);ne(t),ae(t);const r=t.firstElementChild,a=n(O(r));return{operations:M(r),get featureTypes(){return Array.from(a())},readFeatureTypes:a}}const I=["json","application/json; subtype=geojson; charset=utf-8","application/json; subtype=geojson","application/json","geojson","application/geo+json"];function L(e){for(const t of I){const r=e.findIndex((e=>e.toLowerCase()===t));if(r>=0)return e[r]}return null}function M(e){let r=!1;const n={GetCapabilities:{url:""},DescribeFeatureType:{url:""},GetFeature:{url:"",outputFormat:null,supportsPagination:!1}},a=[],o=[];if(d(e,{OperationsMetadata:{Parameter:e=>{if("outputformat"===e.getAttribute("name")?.toLowerCase())return{AllowedValues:{Value:({textContent:e})=>{e&&a.push(e)}}}},Operation:e=>{switch(e.getAttribute("name")){case"GetCapabilities":return{DCP:{HTTP:{Get:e=>{n.GetCapabilities.url=e.getAttribute(T)}}}};case"DescribeFeatureType":return{DCP:{HTTP:{Get:e=>{n.DescribeFeatureType.url=e.getAttribute(T)}}}};case"GetFeature":return{DCP:{HTTP:{Get:e=>{n.GetFeature.url=e.getAttribute(T)}}},Parameter:e=>{if("outputformat"===e.getAttribute("name")?.toLowerCase())return{AllowedValues:{Value:({textContent:e})=>{e&&o.push(e)}}}}}}},Constraint:e=>{switch(e.getAttribute("name")){case"KVPEncoding":return{DefaultValue:e=>{r="true"===e.textContent.toLowerCase()}};case"ImplementsResultPaging":return{DefaultValue:e=>{n.GetFeature.supportsPagination="true"===e.textContent.toLowerCase()}}}}}}),n.GetFeature.outputFormat=L(o)??L(a),!r)throw new t(k,"WFS service doesn't support key/value pair (KVP) encoding");if(null==n.GetFeature.outputFormat)throw new t(R,"WFS service doesn't support GeoJSON output format");return n}function D(e,t){a(e)&&(o(e,t.operations.DescribeFeatureType.url,!0)&&(t.operations.DescribeFeatureType.url=s(t.operations.DescribeFeatureType.url)),o(e,t.operations.GetFeature.url,!0)&&(t.operations.GetFeature.url=s(t.operations.GetFeature.url)))}function V(e){const t=parseInt(e.textContent?.match(/(?<wkid>\d+$)/i)?.groups?.wkid??"",10);if(!Number.isNaN(t))return t}function O(e){return g(e,{FeatureTypeList:{FeatureType:e=>{const t={typeName:"undefined:undefined",name:"",title:"",description:"",extent:null,namespacePrefix:"",namespaceUri:"",defaultSpatialReference:4326,supportedSpatialReferences:[]},r=new Set;return d(e,{Name:e=>{const{name:r,prefix:n}=re(e.textContent);t.typeName=`${n}:${r}`,t.name=r,t.namespacePrefix=n,t.namespaceUri=e.lookupNamespaceURI(n)},Abstract:e=>{t.description=e.textContent},Title:e=>{t.title=e.textContent},WGS84BoundingBox:e=>{t.extent=i.fromJSON($(e))},DefaultCRS:e=>{const n=V(e);n&&(t.defaultSpatialReference=n,r.add(n))},OtherCRS:e=>{const t=V(e);t&&r.add(t)}}),t.title||(t.title=t.name),r.add(4326),t.supportedSpatialReferences.push(...r),t}}})}function $(e){let t,r,n,a;for(const o of e.children)switch(o.localName){case"LowerCorner":[t,r]=o.textContent.split(" ").map((e=>Number.parseFloat(e)));break;case"UpperCorner":[n,a]=o.textContent.split(" ").map((e=>Number.parseFloat(e)))}return{xmin:t,ymin:r,xmax:n,ymax:a,spatialReference:m}}function Y(e,t,n){return r(e,(e=>n?e.name===t&&e.namespaceUri===n:e.typeName===t||e.name===t))}async function W(e,t,r,n={}){const{featureType:a,extent:o}=await X(e,t,r,n),{spatialReference:s}=oe(e.operations.GetFeature.url,a,n.spatialReference),{fields:i,geometryType:p,swapXY:u,objectIdField:c,geometryField:m}=await q(e,a,s,n);return{url:e.operations.GetCapabilities.url,name:a.name,namespaceUri:a.namespaceUri,fields:i,geometryField:m,geometryType:p,objectIdField:c,spatialReference:n.spatialReference??new l({wkid:a.defaultSpatialReference}),extent:o,swapXY:u,wfsCapabilities:e,customParameters:n.customParameters}}async function X(e,r,n,a={}){const o=e.readFeatureTypes(),s=r?Y(o,r,n):o.next().value,{spatialReference:i=new l({wkid:s?.defaultSpatialReference})}=a;if(null==s)throw r?new t(E,`The type '${r}' could not be found in the service`):new t(C,"The service is empty");let m=s.extent;if(m&&!c(m.spatialReference,i))try{await p(m.spatialReference,i,void 0,a),m=u(m,i)}catch{throw new t(N,"Projection not supported")}return{extent:m,spatialReference:i,featureType:s}}async function q(e,r,n,a={}){const{typeName:o}=r,[s,i]=await Promise.allSettled([J(e.operations.DescribeFeatureType.url,o,a),_(e,o,n,a)]),p=e=>new t(x,`An error occurred while getting info about the feature type '${o}'`,{error:e});if("rejected"===s.status)throw p(s.reason);if("rejected"===i.status)throw p(i.reason);const{fields:u,errors:l}=s.value??{},c=s.value?.geometryType||i.value?.geometryType,m=i.value?.swapXY??!1;if(null==c)throw new t(j,`The geometry type could not be determined for type '${o}`,{typeName:o,geometryType:c,fields:u,errors:l});return{...z(u??[]),geometryType:c,swapXY:m}}function z(e){const t=e.find((e=>"geometry"===e.type));let r=e.find((e=>"oid"===e.type));return e=e.filter((e=>"geometry"!==e.type)),r||(r=new b({name:F,type:"oid",alias:F}),e.unshift(r)),{geometryField:t?.name??null,objectIdField:r.name,fields:e}}async function _(t,r,n,a={}){let o,s=!1;const[i,p]=await Promise.all([K(t.operations.GetFeature.url,r,n,t.operations.GetFeature.outputFormat,{...a,count:1}),e(t.operations.GetFeature.url,{responseType:"text",query:Z(r,n,void 0,{...a,count:1}),signal:a?.signal})]),u="FeatureCollection"===i.type&&i.features[0]?.geometry;if(u){let e;switch(o=f.fromJSON(y(u.type)),u.type){case"Point":e=u.coordinates;break;case"LineString":case"MultiPoint":e=u.coordinates[0];break;case"MultiLineString":case"Polygon":e=u.coordinates[0][0];break;case"MultiPolygon":e=u.coordinates[0][0][0]}const t=/<[^>]*pos[^>]*> *(-?\d+(?:\.\d+)?) (-?\d+(?:\.\d+)?)/.exec(p.data);if(t){const r=e[0].toFixed(3),n=e[1].toFixed(3),a=parseFloat(t[1]).toFixed(3);r===parseFloat(t[2]).toFixed(3)&&n===a&&(s=!0)}}return{geometryType:o,swapXY:s}}async function J(t,r,n){return Q(r,(await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"DescribeFeatureType",VERSION:S,TYPENAME:r,TYPENAMES:r,...n?.customParameters},signal:n?.signal})).data)}function Q(e,n){const{name:a}=re(e),o=te(n);ae(o);const s=r(g(o.firstElementChild,{element:e=>e}),(e=>e.getAttribute("name")===a));if(null!=s){const e=s.getAttribute("type"),t=e?r(g(o.firstElementChild,{complexType:e=>e}),(t=>t.getAttribute("name")===re(e).name)):r(g(s,{complexType:e=>e}),(()=>!0));if(t)return B(t)}throw new t(E,`Type '${e}' not found in document`,{document:(new XMLSerializer).serializeToString(o)})}const H=new Set(["objectid","fid"]);function B(e){const r=[],n=[];let a;const o=g(e,{complexContent:{extension:{sequence:{element:e=>e}}}});for(const s of o){const o=s.getAttribute("name");if(!o)continue;let i,p;if(s.hasAttribute("type")?i=re(s.getAttribute("type")).name:d(s,{simpleType:{restriction:e=>(i=re(e.getAttribute("base")).name,{maxLength:e=>{p=+e.getAttribute("value")}})}}),!i)continue;const u="true"===s.getAttribute("nillable");let l=!1;switch(i.toLowerCase()){case"integer":case"nonpositiveinteger":case"negativeinteger":case"long":case"int":case"short":case"byte":case"nonnegativeinteger":case"unsignedlong":case"unsignedint":case"unsignedshort":case"unsignedbyte":case"positiveinteger":n.push(new b({name:o,alias:o,type:"integer",nullable:u,length:h("integer")}));break;case"float":case"double":case"decimal":n.push(new b({name:o,alias:o,type:"double",nullable:u,length:h("double")}));break;case"boolean":case"string":case"gyearmonth":case"gyear":case"gmonthday":case"gday":case"gmonth":case"anyuri":case"qname":case"notation":case"normalizedstring":case"token":case"language":case"idrefs":case"entities":case"nmtoken":case"nmtokens":case"name":case"ncname":case"id":case"idref":case"entity":case"duration":case"time":n.push(new b({name:o,alias:o,type:"string",nullable:u,length:p??h("string")}));break;case"datetime":case"date":n.push(new b({name:o,alias:o,type:"date",nullable:u,length:p??h("date")}));break;case"pointpropertytype":a="point",l=!0;break;case"multipointpropertytype":a="multipoint",l=!0;break;case"curvepropertytype":case"multicurvepropertytype":case"multilinestringpropertytype":a="polyline",l=!0;break;case"surfacepropertytype":case"multisurfacepropertytype":case"multipolygonpropertytype":a="polygon",l=!0;break;case"geometrypropertytype":case"multigeometrypropertytype":l=!0,r.push(new t(j,`geometry type '${i}' is not supported`,{type:(new XMLSerializer).serializeToString(e)}));break;default:r.push(new t(A,`Unknown field type '${i}'`,{type:(new XMLSerializer).serializeToString(e)}))}l&&n.push(new b({name:o,alias:o,type:"geometry",nullable:u}))}for(const t of n)if("integer"===t.type&&!t.nullable&&H.has(t.name.toLowerCase())){t.type="oid";break}return{geometryType:a,fields:n,errors:r}}async function K(r,n,a,o,s){let{data:i}=await e(r,{responseType:"text",query:Z(n,a,o,s),signal:s?.signal});i=i.replaceAll(/": +(-?\d+),(\d+)(,)?/g,'": $1.$2$3');try{return JSON.parse(i)}catch(p){throw new t(P,"Error while parsing the response",{response:i,error:p})}}function Z(e,t,r,n){const a="number"==typeof t?t:t.wkid;return{SERVICE:"WFS",REQUEST:"GetFeature",VERSION:S,TYPENAMES:e,OUTPUTFORMAT:r,SRSNAME:"EPSG:"+a,STARTINDEX:n?.startIndex,COUNT:n?.count,...n?.customParameters}}async function ee(t,r,n){const a=await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"GetFeature",VERSION:S,TYPENAMES:r,RESULTTYPE:"hits",...n?.customParameters},signal:n?.signal}),o=/numberMatched=["'](?<numberMatched>\d+)["']/gi.exec(a.data);if(o?.groups)return+o.groups.numberMatched}function te(e){return(new DOMParser).parseFromString(e.trim(),"text/xml")}function re(e){const[t,r]=e.split(":");return{prefix:r?t:"",name:r??t}}function ne(e){const r=e.firstElementChild?.getAttribute("version");if(r&&r!==S)throw new t(G,`Unsupported WFS version ${r}. Supported version: ${S}`)}function ae(e){let r="",n="";if(d(e.firstElementChild,{Exception:e=>(r=e.getAttribute("exceptionCode"),{ExceptionText:e=>{n=e.textContent}})}),r)throw new t(`wfs-layer:${r}`,n)}function oe(e,t,r){const n={wkid:t.defaultSpatialReference},a=null!=r?.wkid?{wkid:r.wkid}:n;return{spatialReference:a,getFeatureSpatialReference:w(e)||a.wkid&&t.supportedSpatialReferences.includes(a.wkid)?{wkid:a.wkid}:{wkid:t.defaultSpatialReference}}}export{J as describeFeatureType,Y as findFeatureType,v as getCapabilities,K as getFeature,ee as getFeatureCount,X as getFeatureTypeInfo,oe as getGetFeatureSpatialReference,W as getWFSLayerInfo,Q as parseDescribeFeatureTypeResponse,U as parseGetCapabilitiesResponse,z as prepareWFSLayerFields,F as wfsOidFieldName};
5
+ import e from"../../request.js";import t from"../../core/Error.js";import{find as r,cache as n}from"../../core/iteratorUtils.js";import{isHTTPSProtocol as a,hasSameOrigin as o,toHTTPS as s}from"../../core/urlUtils.js";import i from"../../geometry/Extent.js";import{initializeProjection as p,project as u}from"../../geometry/projectionUtils.js";import l from"../../geometry/SpatialReference.js";import{equals as c,wgs84 as m}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import{getGeometryType as y}from"../graphics/sources/geojson/geojson.js";import{visitXML as d,iterateXML as g}from"./xmlUtils.js";import{isArcGISUrl as w}from"../support/arcgisLayerUrl.js";import b from"../support/Field.js";import{getFieldDefaultLength as h}from"../support/fieldUtils.js";const T="xlink:href",S="2.0.0",F="__esri_wfs_id__",x="wfs-layer:getWFSLayerTypeInfo-error",C="wfs-layer:empty-service",E="wfs-layer:feature-type-not-found",R="wfs-layer:geojson-not-supported",k="wfs-layer:kvp-encoding-not-supported",P="wfs-layer:malformed-json",j="wfs-layer:unknown-geometry-type",A="wfs-layer:unknown-field-type",N="wfs-layer:unsupported-spatial-reference",G="wfs-layer:unsupported-wfs-version";async function v(t,r){const n=U((await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"GetCapabilities",VERSION:S,...r?.customParameters},signal:r?.signal})).data);return D(t,n),n}function U(e){const t=te(e);ne(t),ae(t);const r=t.firstElementChild,a=n(O(r));return{operations:M(r),get featureTypes(){return Array.from(a())},readFeatureTypes:a}}const I=["json","application/json; subtype=geojson; charset=utf-8","application/json; subtype=geojson","application/json","geojson","application/geo+json"];function L(e){for(const t of I){const r=e.findIndex((e=>e.toLowerCase()===t));if(r>=0)return e[r]}return null}function M(e){let r=!1;const n={GetCapabilities:{url:""},DescribeFeatureType:{url:""},GetFeature:{url:"",outputFormat:null,supportsPagination:!1}},a=[],o=[];if(d(e,{OperationsMetadata:{Parameter:e=>{if("outputformat"===e.getAttribute("name")?.toLowerCase())return{AllowedValues:{Value:({textContent:e})=>{e&&a.push(e)}}}},Operation:e=>{switch(e.getAttribute("name")){case"GetCapabilities":return{DCP:{HTTP:{Get:e=>{n.GetCapabilities.url=e.getAttribute(T)}}}};case"DescribeFeatureType":return{DCP:{HTTP:{Get:e=>{n.DescribeFeatureType.url=e.getAttribute(T)}}}};case"GetFeature":return{DCP:{HTTP:{Get:e=>{n.GetFeature.url=e.getAttribute(T)}}},Parameter:e=>{if("outputformat"===e.getAttribute("name")?.toLowerCase())return{AllowedValues:{Value:({textContent:e})=>{e&&o.push(e)}}}}}}},Constraint:e=>{switch(e.getAttribute("name")){case"KVPEncoding":return{DefaultValue:e=>{r="true"===e.textContent.toLowerCase()}};case"ImplementsResultPaging":return{DefaultValue:e=>{n.GetFeature.supportsPagination="true"===e.textContent.toLowerCase()}}}}}}),n.GetFeature.outputFormat=L(o)??L(a),!r)throw new t(k,"WFS service doesn't support key/value pair (KVP) encoding");if(null==n.GetFeature.outputFormat)throw new t(R,"WFS service doesn't support GeoJSON output format");return n}function D(e,t){a(e)&&(o(e,t.operations.DescribeFeatureType.url,!0)&&(t.operations.DescribeFeatureType.url=s(t.operations.DescribeFeatureType.url)),o(e,t.operations.GetFeature.url,!0)&&(t.operations.GetFeature.url=s(t.operations.GetFeature.url)))}function V(e){const t=parseInt(e.textContent?.match(/(?<wkid>\d+$)/i)?.groups?.wkid??"",10);if(!Number.isNaN(t))return t}function O(e){return g(e,{FeatureTypeList:{FeatureType:e=>{const t={typeName:"undefined:undefined",name:"",title:"",description:"",extent:null,namespacePrefix:"",namespaceUri:"",defaultSpatialReference:4326,supportedSpatialReferences:[]},r=new Set;return d(e,{Name:e=>{const{name:r,prefix:n}=re(e.textContent);t.typeName=`${n}:${r}`,t.name=r,t.namespacePrefix=n,t.namespaceUri=e.lookupNamespaceURI(n)},Abstract:e=>{t.description=e.textContent},Title:e=>{t.title=e.textContent},WGS84BoundingBox:e=>{t.extent=i.fromJSON($(e))},DefaultCRS:e=>{const n=V(e);n&&(t.defaultSpatialReference=n,r.add(n))},OtherCRS:e=>{const t=V(e);t&&r.add(t)}}),t.title||(t.title=t.name),r.add(4326),t.supportedSpatialReferences.push(...r),t}}})}function $(e){let t,r,n,a;for(const o of e.children)switch(o.localName){case"LowerCorner":[t,r]=o.textContent.split(" ").map((e=>Number.parseFloat(e)));break;case"UpperCorner":[n,a]=o.textContent.split(" ").map((e=>Number.parseFloat(e)))}return{xmin:t,ymin:r,xmax:n,ymax:a,spatialReference:m}}function Y(e,t,n){return r(e,(e=>n?e.name===t&&e.namespaceUri===n:e.typeName===t||e.name===t))}async function W(e,t,r,n={}){const{featureType:a,extent:o}=await X(e,t,r,n),{spatialReference:s}=oe(e.operations.GetFeature.url,a,n.spatialReference),{fields:i,geometryType:p,swapXY:u,objectIdField:c,geometryField:m}=await q(e,a,s,n);return{url:e.operations.GetCapabilities.url,name:a.name,namespaceUri:a.namespaceUri,fields:i,geometryField:m,geometryType:p,objectIdField:c,spatialReference:n.spatialReference??new l({wkid:a.defaultSpatialReference}),extent:o,swapXY:u,wfsCapabilities:e,customParameters:n.customParameters}}async function X(e,r,n,a={}){const o=e.readFeatureTypes(),s=r?Y(o,r,n):o.next().value,{spatialReference:i=new l({wkid:s?.defaultSpatialReference})}=a;if(null==s)throw r?new t(E,`The type '${r}' could not be found in the service`):new t(C,"The service is empty");let m=s.extent;if(m&&!c(m.spatialReference,i))try{await p(m.spatialReference,i,void 0,a),m=u(m,i)}catch{throw new t(N,"Projection not supported")}return{extent:m,spatialReference:i,featureType:s}}async function q(e,r,n,a={}){const{typeName:o}=r,[s,i]=await Promise.allSettled([J(e.operations.DescribeFeatureType.url,o,a),_(e,o,n,a)]),p=e=>new t(x,`An error occurred while getting info about the feature type '${o}'`,{error:e});if("rejected"===s.status)throw p(s.reason);if("rejected"===i.status)throw p(i.reason);const{fields:u,errors:l}=s.value??{},c=s.value?.geometryType||i.value?.geometryType,m=i.value?.swapXY??!1;if(null==c)throw new t(j,`The geometry type could not be determined for type '${o}`,{typeName:o,geometryType:c,fields:u,errors:l});return{...z(u??[]),geometryType:c,swapXY:m}}function z(e){const t=e.find((e=>"geometry"===e.type));let r=e.find((e=>"oid"===e.type));return e=e.filter((e=>"geometry"!==e.type)),r||(r=new b({name:F,type:"oid",alias:F}),e.unshift(r)),{geometryField:t?.name??null,objectIdField:r.name,fields:e}}async function _(t,r,n,a={}){let o,s=!1;const[i,p]=await Promise.all([K(t.operations.GetFeature.url,r,n,t.operations.GetFeature.outputFormat,{...a,count:1}),e(t.operations.GetFeature.url,{responseType:"text",query:Z(r,n,void 0,{...a,count:1}),signal:a?.signal})]),u="FeatureCollection"===i.type&&i.features[0]?.geometry;if(u){let e;switch(o=f.fromJSON(y(u.type)),u.type){case"Point":e=u.coordinates;break;case"LineString":case"MultiPoint":e=u.coordinates[0];break;case"MultiLineString":case"Polygon":e=u.coordinates[0][0];break;case"MultiPolygon":e=u.coordinates[0][0][0]}const t=/<[^>]*pos[^>]*> *(-?\d+(?:\.\d+)?) (-?\d+(?:\.\d+)?)/.exec(p.data);if(t){const r=e[0].toFixed(3),n=e[1].toFixed(3),a=parseFloat(t[1]).toFixed(3);r===parseFloat(t[2]).toFixed(3)&&n===a&&(s=!0)}}return{geometryType:o,swapXY:s}}async function J(t,r,n){return Q(r,(await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"DescribeFeatureType",VERSION:S,TYPENAME:r,TYPENAMES:r,...n?.customParameters},signal:n?.signal})).data)}function Q(e,n){const{name:a}=re(e),o=te(n);ae(o);const s=r(g(o.firstElementChild,{element:e=>e}),(e=>e.getAttribute("name")===a));if(null!=s){const e=s.getAttribute("type"),t=e?r(g(o.firstElementChild,{complexType:e=>e}),(t=>t.getAttribute("name")===re(e).name)):r(g(s,{complexType:e=>e}),(()=>!0));if(t)return B(t)}throw new t(E,`Type '${e}' not found in document`,{document:(new XMLSerializer).serializeToString(o)})}const H=new Set(["objectid","fid"]);function B(e){const r=[],n=[];let a;const o=g(e,{complexContent:{extension:{sequence:{element:e=>e}}}});for(const s of o){const o=s.getAttribute("name");if(!o)continue;let i,p;if(s.hasAttribute("type")?i=re(s.getAttribute("type")).name:d(s,{simpleType:{restriction:e=>(i=re(e.getAttribute("base")).name,{maxLength:e=>{p=+e.getAttribute("value")}})}}),!i)continue;const u="true"===s.getAttribute("nillable");let l=!1;switch(i.toLowerCase()){case"integer":case"nonpositiveinteger":case"negativeinteger":case"long":case"int":case"short":case"byte":case"nonnegativeinteger":case"unsignedlong":case"unsignedint":case"unsignedshort":case"unsignedbyte":case"positiveinteger":n.push(new b({name:o,alias:o,type:"integer",nullable:u,length:h("integer")}));break;case"float":case"double":case"decimal":n.push(new b({name:o,alias:o,type:"double",nullable:u,length:h("double")}));break;case"boolean":case"string":case"gyearmonth":case"gyear":case"gmonthday":case"gday":case"gmonth":case"anyuri":case"qname":case"notation":case"normalizedstring":case"token":case"language":case"idrefs":case"entities":case"nmtoken":case"nmtokens":case"name":case"ncname":case"id":case"idref":case"entity":case"duration":case"time":n.push(new b({name:o,alias:o,type:"string",nullable:u,length:p??h("string")}));break;case"datetime":case"date":n.push(new b({name:o,alias:o,type:"date",nullable:u,length:p??h("date")}));break;case"pointpropertytype":a="point",l=!0;break;case"multipointpropertytype":a="multipoint",l=!0;break;case"curvepropertytype":case"multicurvepropertytype":case"multilinestringpropertytype":a="polyline",l=!0;break;case"surfacepropertytype":case"multisurfacepropertytype":case"multipolygonpropertytype":a="polygon",l=!0;break;case"geometrypropertytype":case"multigeometrypropertytype":l=!0,r.push(new t(j,`geometry type '${i}' is not supported`,{type:(new XMLSerializer).serializeToString(e)}));break;default:r.push(new t(A,`Unknown field type '${i}'`,{type:(new XMLSerializer).serializeToString(e)}))}l&&n.push(new b({name:o,alias:o,type:"geometry",nullable:u}))}for(const t of n)if("integer"===t.type&&!t.nullable&&H.has(t.name.toLowerCase())){t.type="oid";break}return{geometryType:a,fields:n,errors:r}}async function K(r,n,a,o,s){let{data:i}=await e(r,{responseType:"text",query:Z(n,a,o,s),signal:s?.signal});i=i.replaceAll(/": +(-?\d+),(\d+)(,)?/g,'": $1.$2$3');try{return JSON.parse(i)}catch(p){throw new t(P,"Error while parsing the response",{response:i,error:p})}}function Z(e,t,r,n){const a="number"==typeof t?t:t.wkid;return{SERVICE:"WFS",REQUEST:"GetFeature",VERSION:S,TYPENAMES:e,OUTPUTFORMAT:r,SRSNAME:"EPSG:"+a,STARTINDEX:n?.startIndex,COUNT:n?.count,...n?.customParameters}}async function ee(t,r,n){const a=await e(t,{responseType:"text",query:{SERVICE:"WFS",REQUEST:"GetFeature",VERSION:S,TYPENAMES:r,RESULTTYPE:"hits",...n?.customParameters},signal:n?.signal}),o=/numberMatched=["'](?<numberMatched>\d+)["']/gi.exec(a.data);if(o?.groups)return+o.groups.numberMatched}function te(e){return(new DOMParser).parseFromString(e.trim(),"text/xml")}function re(e){const[t,r]=e.split(":");return{prefix:r?t:"",name:r??t}}function ne(e){const r=e.firstElementChild?.getAttribute("version");if(r&&r!==S)throw new t(G,`Unsupported WFS version ${r}. Supported version: ${S}`)}function ae(e){let r="",n="";if(d(e.firstElementChild,{Exception:e=>(r=e.getAttribute("exceptionCode"),{ExceptionText:e=>{n=e.textContent}})}),r)throw new t(`wfs-layer:${r}`,n)}function oe(e,t,r){const n={wkid:t.defaultSpatialReference},a=null!=r?.wkid?{wkid:r.wkid}:n;return{spatialReference:a,getFeatureSpatialReference:w(e)||a.wkid&&t.supportedSpatialReferences.includes(a.wkid)?{wkid:a.wkid}:{wkid:t.defaultSpatialReference}}}export{J as describeFeatureType,Y as findFeatureType,v as getCapabilities,K as getFeature,ee as getFeatureCount,X as getFeatureTypeInfo,oe as getGetFeatureSpatialReference,W as getWFSLayerInfo,Q as parseDescribeFeatureTypeResponse,U as parseGetCapabilitiesResponse,z as prepareWFSLayerFields,F as wfsOidFieldName};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as n}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{a,f as o}from"../../../chunks/vec32.js";import i from"../../../geometry/Circle.js";import c from"../../../geometry/Mesh.js";import s from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectWithZConversion as l}from"../../../geometry/projection.js";import m from"../../../geometry/SpatialReference.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import h from"../../../geometry/support/MeshComponent.js";import{MeshVertexAttributes as p}from"../../../geometry/support/MeshVertexAttributes.js";import{create as y,fromArray as g,intersectRay as x}from"../../../geometry/support/plane.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{getWebMercatorScalingFactor as w,createRotationMatrixFromHPR as M,transformMat3 as R,scaleAndAddWithFactor as j,scaleWithFactor as v,computeHFOVAndVFOV as P,projectiveTransform as D}from"../transformations/utils.js";const b=Math.PI/180;function A(e){return e.isSpherical?H(e):I(e)}function I(e){const{horizontalFieldOfView:t,verticalFieldOfView:r,geometry:n,cameraHeading:a}=e,o=w(n.y,n.spatialReference);let i=e.cameraPitch,c=e.cameraRoll??0,s=150;t>150&&(i=90,c=0,s=5);const l=Math.ceil(t/s),m=z(l,a,t);let u=e.farDistance?e.farDistance*o:e.cameraHeight*o/Math.cos(i*b);e.cameraPitch+r/2>=90&&(u=(e.farDistance||20)*o);const h=new f({spatialReference:n?.spatialReference});h.imageID=e.objectId;let p=null;for(const f of m)p=V(f,i,e.cameraHeight,n,u,o,r,t,l,h,c,e.nearDistance);return p.imageID=e.objectId,{polygon:h,frustum:p}}function z(e,t,r){const n=[];if(e%2==0)for(let a=0;a<e/2;a++)n.push(t-r/e*(a+.5),t+r/e*(a+.5));else{n.push(t);for(let a=1;a<e/2;a++)n.push(t-r/e*a,t+r/e*a)}return n.sort(),n}function V(e,i,c,s,f,l,m,u,h,p,y=0,g=0){const x=n(t(),M([e,i,y??0])),d=q({cameraHeight:c,cameraPitch:i,farDistance:f,location:s,horizontalFieldOfView:u,nearDistance:g,verticalFieldOfView:m},x),w=R([0,0,-1],x),{x:P,y:D}=s,A=j([P,D,c],w,f,l),I=2*Math.tan(m*b/2)*f,z=2*Math.tan(u/h*b/2)*f,V=R([0,1,0],x),H=R([1,0,0],x),O=v(V,I/2,l),S=v(H,z/2,l),C=a(r(),O,S),U=o(r(),O,S),E=F([o(r(),A,C),o(r(),A,U),a(r(),A,C),a(r(),A,U)],c,s,l);return E.push(E[0]),p.addRing(E),d}function F(e,t,r,n){return e.map((e=>C(e,t,r,n)))}function H(e){const{geometry:t,farDistance:r,objectId:n,nearDistance:a,cameraHeight:o}=e,s=w(t.y,t.spatialReference),f=new i({center:t.clone(),radius:r*s});if(f.imageID=n,a){const e=new i({center:t.clone(),radius:a*s});f.addRing(e.rings[0])}const l=t.clone();l.z=o-r*s;const m=c.createSphere(l,{size:2*r*s});return m.imageID=n,{polygon:f,frustum:m}}function O(e,t){return e.contains(t)}function S(e,t){return Math.sign(e)!==Math.sign(t)}function q(e,t,n){const{cameraHeight:i,cameraPitch:s,farDistance:f,location:l,horizontalFieldOfView:m,nearDistance:u,verticalFieldOfView:h}=e,y=E(l),g=s+h/2>=90==!1,x=2*Math.tan(h*b/2)*u,d=2*Math.tan(m*b/2)*u,w=2*Math.tan(h*b/2)*f,M=2*Math.tan(m*b/2)*f;let P,D;D=[0,0,-1],D=R(D,t),P=j([l.x,l.y,i],D,f,y),g&&(P[2]=0);const A=j([l.x,l.y,i],D,u,y);let I=[0,1,0];I=R(I,t);let z=[1,0,0];z=R(z,t);let V=[],F=[];u?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],V=V.concat(o(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(o(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y))))):(V=[l.x,l.y,i],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),V=V.concat(o(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(o(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y))));const H=new p({position:Float64Array.from(V)});return new c({vertexAttributes:H,components:F,spatialReference:l.spatialReference})}function C(e,t,n,o){{const i=Math.sqrt((e[2]-t)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/o)**2)*o,c=v(a(r(),[e[0],e[1],e[2]],[n.x,n.y,t]),1/i,1/o),s=t/(t-e[2]),f={x:(1-s)*n.x+s*e[0],y:(1-s)*n.y+s*e[1],z:(1-s)*t+s*e[2]},l=Math.sqrt((f.z-t)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/o)**2)*o,m=v(a(r(),[f.x,f.y,f.z],[n.x,n.y,t]),1/l,1/o);return S(c[0],m[0])&&S(c[1],m[1])&&S(c[2],m[2])||e[2]>=0?[e[0],e[1],0]:[f.x,f.y,f.z]}}function U(e){const{spatialReference:t,x:r,y:n}=e.geometry,{cameraHeading:a,cameraPitch:o,farDistance:i,nearDistance:c}=e,s=E(e.geometry),l=new f({spatialReference:t}),m=Math.abs(1.44*i*s);let u=Math.abs(1.44*c*s);(o<20||null==a)&&(u=m);const h=[];return h[0]={x:r+m*Math.sin((a-45)*b),y:n+m*Math.cos((a-45)*b)},h[1]={x:r+m*Math.sin((a+45)*b),y:n+m*Math.cos((a+45)*b)},h[2]={x:r+u*Math.sin((a+135)*b),y:n+u*Math.cos((a+135)*b)},h[3]={x:r+u*Math.sin((a+225)*b),y:n+u*Math.cos((a+225)*b)},l.addRing([[h[0].x,h[0].y,0],[h[1].x,h[1].y,0],[h[2].x,h[2].y,0],[h[3].x,h[3].y,0],[h[0].x,h[0].y,0]]),l}function E(e){return e&&d(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/u.radius))):1}function k(e,t){const n=1+t/100;if("esri.geometry.Circle"===e.declaredClass){const{radius:t,center:r}=e,a=new i({radius:t*n,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if("esri.geometry.Polygon"===e.declaredClass){const t=new f({spatialReference:e.spatialReference}),o=e.centroid;if(o){const i=[];for(let t=0;t<e.rings[0].length;t++){const c=Math.sqrt((o.x-e.rings[0][t][0])**2+(o.y-e.rings[0][t][1])**2),s=v(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[o.x,o.y,0]),1/c,1),f=j([o.x,o.y,0],s,c*n,1);i.push({x:f[0],y:f[1]})}t.addRing([[i[0].x,i[0].y,0],[i[1].x,i[1].y,0],[i[2].x,i[2].y,0],[i[3].x,i[3].y,0],[i[0].x,i[0].y,0]])}return t}return e}async function L(e,t,r){const{cameraHeight:n,cameraLocation:a,cameraPitch:o,frustumVertices:i,horizontalFieldOfView:c,imageHeight:s,imageWidth:f,inSRS:l,outSRS:u,verticalFieldOfView:h,cameraRoll:p,options:y}=r,g=new m(l),x=new m(u),d=P(c,h,p??0),w=i.length>15;return o+d.vfov/2>=90?await K(i,e,f,s,g,x,w,y):await W(i,e,t,a,n,w,g,x,y)}async function W(e,t,r,n,a,o,i,s,f){const l=B(e,t,r,n,a);if(!l)return;const{farPlane:m,nearPlane:u}=l,h=await N([...u?.vertexPositions??e.slice(0,3),...m.vertexPositions],i,s,f),y=Z(h);return new c({vertexAttributes:new p({position:h}),components:Y(o?T(y,!0):X(y,!0)),spatialReference:s})}function B(e,t,r,n,a){const o=Q(e),i=Q(e,"near");if(!o)return;const c=t.length;for(let s=0;s<c;s++){const e=Array.from(r[s]),t=[e[0]-n[0],e[1]-n[1],e[2]-(n[2]??a)];J(n,t,s,i),G(n,t,s,o)}return{farPlane:o,nearPlane:i}}function G(e,t,n,a){const{coefficients:o,vertexPositions:i}=a,c=r();x(o,{origin:e,direction:t},c)&&i.splice(3*n,3,...c)}function J(e,t,n,a){if(!a)return;const o=r();x(a.coefficients,{origin:e,direction:t},o)&&a.vertexPositions.splice(3*n,3,...o)}async function K(e,t,r,n,a,o,i,s){let f,l=i?new Array:[e[0],e[1],e[2]],m=new Array;for(const c of t)i?(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),l=l.concat(...f),f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),m=m.concat(...f)):(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),l=l.concat(...f));l=l.concat(m);const u=await N(l,a,o,s),h=Z(u);return new c({vertexAttributes:new p({position:u}),components:Y(i?T(h,!0):X(h,!0)),spatialReference:o})}async function N(t,r,n,a){if(r.equals(n))return t;const o=t.reduce(((e,t,r)=>{const n=Math.floor(r/3);return e[n]||(e[n]=new Array),e[n].push(t),e}),new Array),{points:i}=await l(new s(o,r),n,a);return e(a),i.flat()}function Q(e,t="far"){const r=y();let n;switch(t){case"far":if(n=Array.from(15===e.length?e.slice(3):e.slice(12)),g(r,n,!1))return{coefficients:r,vertexPositions:n};break;case"near":if(n=Array.from(e.slice(0,12)),15===e.length||!g(r,n,!1))return;return{coefficients:r,vertexPositions:n}}}const T=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw new Error("Invalid number of vertices");const r=[],n=e/2,a=Math.round((t?e-2:e)/2);for(let o=0;o<a;o++){const a=o+n,i=t?a+1:a,c=i%e,s=(t?a:i+1)%e;r.push({faces:new Uint32Array([o,s,c,o,o+1,c])})}return r};function X(e,t=!1){if(e<3||t&&e-1<3)throw new Error("Invalid number of vertices");const r=[],n=t?e-2:e-1;for(let a=0;a<n;a++)r.push({faces:new Uint32Array([0,a+1,a+2])});return r}const Y=e=>e.map((e=>new h(e))),Z=e=>e.length/3;export{O as checkIfPolygonContainsSelectedPoint,U as computePolygonForInspection,A as createCoveragePolygon,F as limitZToGround,N as projectVertices,k as resizePolygon,L as updateFrustum};
5
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as n}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{a,f as o}from"../../../chunks/vec32.js";import i from"../../../geometry/Circle.js";import c from"../../../geometry/Mesh.js";import s from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectWithZConversion as l}from"../../../geometry/projectionUtils.js";import m from"../../../geometry/SpatialReference.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import h from"../../../geometry/support/MeshComponent.js";import{MeshVertexAttributes as p}from"../../../geometry/support/MeshVertexAttributes.js";import{create as y,fromArray as g,intersectRay as x}from"../../../geometry/support/plane.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{getWebMercatorScalingFactor as w,createRotationMatrixFromHPR as M,transformMat3 as R,scaleAndAddWithFactor as j,scaleWithFactor as v,computeHFOVAndVFOV as P,projectiveTransform as D}from"../transformations/utils.js";const b=Math.PI/180;function A(e){return e.isSpherical?H(e):I(e)}function I(e){const{horizontalFieldOfView:t,verticalFieldOfView:r,geometry:n,cameraHeading:a}=e,o=w(n.y,n.spatialReference);let i=e.cameraPitch,c=e.cameraRoll??0,s=150;t>150&&(i=90,c=0,s=5);const l=Math.ceil(t/s),m=z(l,a,t);let u=e.farDistance?e.farDistance*o:e.cameraHeight*o/Math.cos(i*b);e.cameraPitch+r/2>=90&&(u=(e.farDistance||20)*o);const h=new f({spatialReference:n?.spatialReference});h.imageID=e.objectId;let p=null;for(const f of m)p=V(f,i,e.cameraHeight,n,u,o,r,t,l,h,c,e.nearDistance);return p.imageID=e.objectId,{polygon:h,frustum:p}}function z(e,t,r){const n=[];if(e%2==0)for(let a=0;a<e/2;a++)n.push(t-r/e*(a+.5),t+r/e*(a+.5));else{n.push(t);for(let a=1;a<e/2;a++)n.push(t-r/e*a,t+r/e*a)}return n.sort(),n}function V(e,i,c,s,f,l,m,u,h,p,y=0,g=0){const x=n(t(),M([e,i,y??0])),d=q({cameraHeight:c,cameraPitch:i,farDistance:f,location:s,horizontalFieldOfView:u,nearDistance:g,verticalFieldOfView:m},x),w=R([0,0,-1],x),{x:P,y:D}=s,A=j([P,D,c],w,f,l),I=2*Math.tan(m*b/2)*f,z=2*Math.tan(u/h*b/2)*f,V=R([0,1,0],x),H=R([1,0,0],x),O=v(V,I/2,l),S=v(H,z/2,l),C=a(r(),O,S),U=o(r(),O,S),E=F([o(r(),A,C),o(r(),A,U),a(r(),A,C),a(r(),A,U)],c,s,l);return E.push(E[0]),p.addRing(E),d}function F(e,t,r,n){return e.map((e=>C(e,t,r,n)))}function H(e){const{geometry:t,farDistance:r,objectId:n,nearDistance:a,cameraHeight:o}=e,s=w(t.y,t.spatialReference),f=new i({center:t.clone(),radius:r*s});if(f.imageID=n,a){const e=new i({center:t.clone(),radius:a*s});f.addRing(e.rings[0])}const l=t.clone();l.z=o-r*s;const m=c.createSphere(l,{size:2*r*s});return m.imageID=n,{polygon:f,frustum:m}}function O(e,t){return e.contains(t)}function S(e,t){return Math.sign(e)!==Math.sign(t)}function q(e,t,n){const{cameraHeight:i,cameraPitch:s,farDistance:f,location:l,horizontalFieldOfView:m,nearDistance:u,verticalFieldOfView:h}=e,y=E(l),g=s+h/2>=90==!1,x=2*Math.tan(h*b/2)*u,d=2*Math.tan(m*b/2)*u,w=2*Math.tan(h*b/2)*f,M=2*Math.tan(m*b/2)*f;let P,D;D=[0,0,-1],D=R(D,t),P=j([l.x,l.y,i],D,f,y),g&&(P[2]=0);const A=j([l.x,l.y,i],D,u,y);let I=[0,1,0];I=R(I,t);let z=[1,0,0];z=R(z,t);let V=[],F=[];u?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],V=V.concat(o(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(o(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y))))):(V=[l.x,l.y,i],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),V=V.concat(o(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(o(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y))));const H=new p({position:Float64Array.from(V)});return new c({vertexAttributes:H,components:F,spatialReference:l.spatialReference})}function C(e,t,n,o){{const i=Math.sqrt((e[2]-t)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/o)**2)*o,c=v(a(r(),[e[0],e[1],e[2]],[n.x,n.y,t]),1/i,1/o),s=t/(t-e[2]),f={x:(1-s)*n.x+s*e[0],y:(1-s)*n.y+s*e[1],z:(1-s)*t+s*e[2]},l=Math.sqrt((f.z-t)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/o)**2)*o,m=v(a(r(),[f.x,f.y,f.z],[n.x,n.y,t]),1/l,1/o);return S(c[0],m[0])&&S(c[1],m[1])&&S(c[2],m[2])||e[2]>=0?[e[0],e[1],0]:[f.x,f.y,f.z]}}function U(e){const{spatialReference:t,x:r,y:n}=e.geometry,{cameraHeading:a,cameraPitch:o,farDistance:i,nearDistance:c}=e,s=E(e.geometry),l=new f({spatialReference:t}),m=Math.abs(1.44*i*s);let u=Math.abs(1.44*c*s);(o<20||null==a)&&(u=m);const h=[];return h[0]={x:r+m*Math.sin((a-45)*b),y:n+m*Math.cos((a-45)*b)},h[1]={x:r+m*Math.sin((a+45)*b),y:n+m*Math.cos((a+45)*b)},h[2]={x:r+u*Math.sin((a+135)*b),y:n+u*Math.cos((a+135)*b)},h[3]={x:r+u*Math.sin((a+225)*b),y:n+u*Math.cos((a+225)*b)},l.addRing([[h[0].x,h[0].y,0],[h[1].x,h[1].y,0],[h[2].x,h[2].y,0],[h[3].x,h[3].y,0],[h[0].x,h[0].y,0]]),l}function E(e){return e&&d(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/u.radius))):1}function k(e,t){const n=1+t/100;if("esri.geometry.Circle"===e.declaredClass){const{radius:t,center:r}=e,a=new i({radius:t*n,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if("esri.geometry.Polygon"===e.declaredClass){const t=new f({spatialReference:e.spatialReference}),o=e.centroid;if(o){const i=[];for(let t=0;t<e.rings[0].length;t++){const c=Math.sqrt((o.x-e.rings[0][t][0])**2+(o.y-e.rings[0][t][1])**2),s=v(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[o.x,o.y,0]),1/c,1),f=j([o.x,o.y,0],s,c*n,1);i.push({x:f[0],y:f[1]})}t.addRing([[i[0].x,i[0].y,0],[i[1].x,i[1].y,0],[i[2].x,i[2].y,0],[i[3].x,i[3].y,0],[i[0].x,i[0].y,0]])}return t}return e}async function L(e,t,r){const{cameraHeight:n,cameraLocation:a,cameraPitch:o,frustumVertices:i,horizontalFieldOfView:c,imageHeight:s,imageWidth:f,inSRS:l,outSRS:u,verticalFieldOfView:h,cameraRoll:p,options:y}=r,g=new m(l),x=new m(u),d=P(c,h,p??0),w=i.length>15;return o+d.vfov/2>=90?await K(i,e,f,s,g,x,w,y):await W(i,e,t,a,n,w,g,x,y)}async function W(e,t,r,n,a,o,i,s,f){const l=B(e,t,r,n,a);if(!l)return;const{farPlane:m,nearPlane:u}=l,h=await N([...u?.vertexPositions??e.slice(0,3),...m.vertexPositions],i,s,f),y=Z(h);return new c({vertexAttributes:new p({position:h}),components:Y(o?T(y,!0):X(y,!0)),spatialReference:s})}function B(e,t,r,n,a){const o=Q(e),i=Q(e,"near");if(!o)return;const c=t.length;for(let s=0;s<c;s++){const e=Array.from(r[s]),t=[e[0]-n[0],e[1]-n[1],e[2]-(n[2]??a)];J(n,t,s,i),G(n,t,s,o)}return{farPlane:o,nearPlane:i}}function G(e,t,n,a){const{coefficients:o,vertexPositions:i}=a,c=r();x(o,{origin:e,direction:t},c)&&i.splice(3*n,3,...c)}function J(e,t,n,a){if(!a)return;const o=r();x(a.coefficients,{origin:e,direction:t},o)&&a.vertexPositions.splice(3*n,3,...o)}async function K(e,t,r,n,a,o,i,s){let f,l=i?new Array:[e[0],e[1],e[2]],m=new Array;for(const c of t)i?(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),l=l.concat(...f),f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),m=m.concat(...f)):(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),l=l.concat(...f));l=l.concat(m);const u=await N(l,a,o,s),h=Z(u);return new c({vertexAttributes:new p({position:u}),components:Y(i?T(h,!0):X(h,!0)),spatialReference:o})}async function N(t,r,n,a){if(r.equals(n))return t;const o=t.reduce(((e,t,r)=>{const n=Math.floor(r/3);return e[n]||(e[n]=new Array),e[n].push(t),e}),new Array),{points:i}=await l(new s(o,r),n,a);return e(a),i.flat()}function Q(e,t="far"){const r=y();let n;switch(t){case"far":if(n=Array.from(15===e.length?e.slice(3):e.slice(12)),g(r,n,!1))return{coefficients:r,vertexPositions:n};break;case"near":if(n=Array.from(e.slice(0,12)),15===e.length||!g(r,n,!1))return;return{coefficients:r,vertexPositions:n}}}const T=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw new Error("Invalid number of vertices");const r=[],n=e/2,a=Math.round((t?e-2:e)/2);for(let o=0;o<a;o++){const a=o+n,i=t?a+1:a,c=i%e,s=(t?a:i+1)%e;r.push({faces:new Uint32Array([o,s,c,o,o+1,c])})}return r};function X(e,t=!1){if(e<3||t&&e-1<3)throw new Error("Invalid number of vertices");const r=[],n=t?e-2:e-1;for(let a=0;a<n;a++)r.push({faces:new Uint32Array([0,a+1,a+2])});return r}const Y=e=>e.map((e=>new h(e))),Z=e=>e.length/3;export{O as checkIfPolygonContainsSelectedPoint,U as computePolygonForInspection,A as createCoveragePolygon,F as limitZToGround,N as projectVertices,k as resizePolygon,L as updateFrustum};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import t from"../../../core/Logger.js";import{isAbortError as r,waitTick as a}from"../../../core/promiseUtils.js";import{projectWithZConversion as o}from"../../../geometry/projection.js";import{fromExtent as n}from"../../../geometry/support/aaBoundingRect.js";import i from"../../ElevationLayer.js";import s from"../../ImageryLayer.js";import c from"../../ImageryTileLayer.js";import{TileElevationSampler as l}from"../../support/ElevationSampler.js";import{ElevationTile as u}from"../../support/ElevationTile.js";import{ElevationTileData as m}from"../../support/ElevationTileData.js";import p from"../../support/RasterFunction.js";import f from"../../support/TileInfo.js";import{TileKey as w}from"../../support/TileKey.js";import{identify as y}from"../../../rest/imageService.js";import g from"../../../rest/support/ImageIdentifyParameters.js";import{fetchArcGISServiceJSON as d}from"../../../support/requestPresets.js";import{logAndThrow as v}from"../../../widgets/OrientedImageryViewer/utils.js";async function I(t,r,a){if(!r.extent||!r.url)throw v("esri.layer.orientedImagery.transformations",new e("update-elevation:missing-property","both extent and url are required to create a sampler",r));const o=await j(r);if(!o)throw v("esri.layers.orientedImagery.transformations",new e("update-elevation:elevation-source","could not create a sampler using provided elevation source",r));return E(t,o,a)}async function E(e,t,r){await a(r);const o=N(t,r),n=Array.isArray(e)?e:[e];return await Promise.all(n.map(o))}var h;!function(e){e[e.DYNAMIC=0]="DYNAMIC",e[e.ELEVATION=1]="ELEVATION",e[e.IMAGE=2]="IMAGE"}(h||(h={}));const j=async(e,a)=>{let o;const{extent:n,rasterFunction:i,url:s,lod:c}=e;try{o=await R(s)}catch(l){if(r(l))return;t.getLogger("esri.layers.orientedImagery.transformations").error("updateElevationUsingElevationSource",l)}switch(o){case h.DYNAMIC:return await L(s,n,i,a);case h.ELEVATION:return await A(s,n,c,a);default:return}};async function A(e,a,o,n){const s=new i(e);let c;try{const{tileInfo:e}=await s.load(),t=(o&&e.lodAt(Math.min(e.lods.length-1,o))?.resolution)??"finest-contiguous";c=await s.createElevationSampler(a,{...n,demResolution:t})}catch(l){if(r(l))return;t.getLogger(s).error(l)}finally{s.destroy()}return c}async function L(e,t,r,a){const o=r?new p({functionName:r}):void 0,i=new s({url:e,rasterFunction:o,format:"lerc"});await i.load(a);let c,y=512,g=512;const d=t.width/t.height;d>1?(g/=d,c=t.height/g):(y*=d,c=t.width/y);const v=await i.internalFetchImage(t,y,g,a),I=f.create({scales:[c],size:512,spatialReference:t.spatialReference}),E=new w(null,0,0,0,n(t)),h=new m(v.pixelData.pixelBlock.pixels[0],y,g,0),j=new u(E,h);return new l(j,I,void 0)}async function R(t,r){await a(r);const o=await d(t),{tileInfo:n,cacheType:i}=o;if(!o.hasOwnProperty("bandCount")||!o.hasOwnProperty("pixelSizeX"))throw new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${t}`);return n?"LERC"!==n?.format?.toUpperCase()||i&&"elevation"!==i.toLowerCase()?h.IMAGE:h.ELEVATION:h.DYNAMIC}function N(e,t){return async r=>{let a=r.clone();const n=r.spatialReference.equals(e.spatialReference)?a:await o(r,e.spatialReference,t),i=e.queryElevation(n);if(i){a=r.spatialReference.equals(e.spatialReference)?i.clone():await o(i,r.spatialReference,t)}return a.z=a.z??1,a}}async function T(e,t,r){return await a(r),e.map((e=>(e.z=t,e)))}async function M(e,a,o){const{url:n,rasterFunction:i}=a;let s;try{s=await R(n,o)}catch(l){r(l)||t.getLogger("esri.layers.orientedImagery.transformations").error(l)}switch(s){case h.ELEVATION:case h.DYNAMIC:{const t=await y(n,new g({geometry:e,rasterFunction:i?new p({functionName:i}):void 0}));if(t.value?.[0]){const r=e.clone();return r.z=+t.value[0],r}break}case h.IMAGE:{const t=new c(n,o);await t.load();const r=await t.identify(e,o);if(r.value?.[0]){const t=e.clone();return t.z=+r.value[0],t}break}}return e}export{j as getElevationSampler,L as getElevationSamplerFromDynamicImageService,A as getElevationSamplerFromElevationLayer,T as updateUsingConstant,E as updateUsingElevationSampler,I as updateUsingElevationSource,M as updateZfromService,R as validateElevationSourceURL};
5
+ import e from"../../../core/Error.js";import t from"../../../core/Logger.js";import{isAbortError as r,waitTick as a}from"../../../core/promiseUtils.js";import{projectWithZConversion as o}from"../../../geometry/projectionUtils.js";import{fromExtent as n}from"../../../geometry/support/aaBoundingRect.js";import i from"../../ElevationLayer.js";import s from"../../ImageryLayer.js";import c from"../../ImageryTileLayer.js";import{TileElevationSampler as l}from"../../support/ElevationSampler.js";import{ElevationTile as u}from"../../support/ElevationTile.js";import{ElevationTileData as m}from"../../support/ElevationTileData.js";import p from"../../support/RasterFunction.js";import f from"../../support/TileInfo.js";import{TileKey as w}from"../../support/TileKey.js";import{identify as y}from"../../../rest/imageService.js";import g from"../../../rest/support/ImageIdentifyParameters.js";import{fetchArcGISServiceJSON as d}from"../../../support/requestPresets.js";import{logAndThrow as v}from"../../../widgets/OrientedImageryViewer/utils.js";async function I(t,r,a){if(!r.extent||!r.url)throw v("esri.layer.orientedImagery.transformations",new e("update-elevation:missing-property","both extent and url are required to create a sampler",r));const o=await j(r);if(!o)throw v("esri.layers.orientedImagery.transformations",new e("update-elevation:elevation-source","could not create a sampler using provided elevation source",r));return E(t,o,a)}async function E(e,t,r){await a(r);const o=N(t,r),n=Array.isArray(e)?e:[e];return await Promise.all(n.map(o))}var h;!function(e){e[e.DYNAMIC=0]="DYNAMIC",e[e.ELEVATION=1]="ELEVATION",e[e.IMAGE=2]="IMAGE"}(h||(h={}));const j=async(e,a)=>{let o;const{extent:n,rasterFunction:i,url:s,lod:c}=e;try{o=await R(s)}catch(l){if(r(l))return;t.getLogger("esri.layers.orientedImagery.transformations").error("updateElevationUsingElevationSource",l)}switch(o){case h.DYNAMIC:return await L(s,n,i,a);case h.ELEVATION:return await A(s,n,c,a);default:return}};async function A(e,a,o,n){const s=new i(e);let c;try{const{tileInfo:e}=await s.load(),t=(o&&e.lodAt(Math.min(e.lods.length-1,o))?.resolution)??"finest-contiguous";c=await s.createElevationSampler(a,{...n,demResolution:t})}catch(l){if(r(l))return;t.getLogger(s).error(l)}finally{s.destroy()}return c}async function L(e,t,r,a){const o=r?new p({functionName:r}):void 0,i=new s({url:e,rasterFunction:o,format:"lerc"});await i.load(a);let c,y=512,g=512;const d=t.width/t.height;d>1?(g/=d,c=t.height/g):(y*=d,c=t.width/y);const v=await i.internalFetchImage(t,y,g,a),I=f.create({scales:[c],size:512,spatialReference:t.spatialReference}),E=new w(null,0,0,0,n(t)),h=new m(v.pixelData.pixelBlock.pixels[0],y,g,0),j=new u(E,h);return new l(j,I,void 0)}async function R(t,r){await a(r);const o=await d(t),{tileInfo:n,cacheType:i}=o;if(!o.hasOwnProperty("bandCount")||!o.hasOwnProperty("pixelSizeX"))throw new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${t}`);return n?"LERC"!==n?.format?.toUpperCase()||i&&"elevation"!==i.toLowerCase()?h.IMAGE:h.ELEVATION:h.DYNAMIC}function N(e,t){return async r=>{let a=r.clone();const n=r.spatialReference.equals(e.spatialReference)?a:await o(r,e.spatialReference,t),i=e.queryElevation(n);if(i){a=r.spatialReference.equals(e.spatialReference)?i.clone():await o(i,r.spatialReference,t)}return a.z=a.z??1,a}}async function T(e,t,r){return await a(r),e.map((e=>(e.z=t,e)))}async function M(e,a,o){const{url:n,rasterFunction:i}=a;let s;try{s=await R(n,o)}catch(l){r(l)||t.getLogger("esri.layers.orientedImagery.transformations").error(l)}switch(s){case h.ELEVATION:case h.DYNAMIC:{const t=await y(n,new g({geometry:e,rasterFunction:i?new p({functionName:i}):void 0}));if(t.value?.[0]){const r=e.clone();return r.z=+t.value[0],r}break}case h.IMAGE:{const t=new c(n,o);await t.load();const r=await t.identify(e,o);if(r.value?.[0]){const t=e.clone();return t.z=+r.value[0],t}break}}return e}export{j as getElevationSampler,L as getElevationSamplerFromDynamicImageService,A as getElevationSamplerFromElevationLayer,T as updateUsingConstant,E as updateUsingElevationSampler,I as updateUsingElevationSource,M as updateZfromService,R as validateElevationSourceURL};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as e,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as r}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as s,transpose as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as f,mul as h}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as u,f as m}from"../../../chunks/vec32.js";import{isSerializable as p}from"../../../core/support/jsonUtils.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as g}from"../../../geometry/projection.js";import{earth as v}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isConstantElevation as w,isElevationSource as y,ConstantElevation as O}from"../core/ElevationSourceDefinitions.js";import{getElevationSampler as b}from"./updateElevationUtils.js";import{isNumber as j}from"../../../support/guards.js";import{defaultImageSphereSize as E}from"../../../widgets/PanoramicViewer/constants.js";function z(t,n,a){const[i,o,r,c]=n,[s,l,u,m]=a;F(i,o,r,c);const p=F(s,l,u,m),M=V(i,o,r,c),g=V(s,l,u,m),v=f(e(),M),d=h(e(),v,g),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function F(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function S(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=S(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const c=D(r([...i,1]),f(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=c[0],l=c[1],h=c[2],u=e();return u[0]=s*t[0],u[1]=l*n[0],u[2]=h*a[0],u[3]=0,u[4]=s*t[1],u[5]=l*n[1],u[6]=h*a[1],u[7]=0,u[8]=s*t[2],u[9]=l*n[2],u[10]=h*a[2],u[11]=0,u[12]=s,u[13]=l,u[14]=h,u[15]=1,u}function C(t,n,a,i,e=c()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function R(t,n,a){const i=c();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=c();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function D(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,e,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=i();switch(e){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const H={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function N(n,a,e=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=i();for(let t=0;t<3;t++){const[i,r]=a[t],c=I(n[t],i,r,e);s(o,c,o)}return o}function q(t,n=!0){return N(t,H.OPK,n)}function k(t,n=!0){return N(t,H.HPR,n)}function A(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),h=a(c),u=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-h,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(u*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-u+M*Math.sin(f)]}function U(t,i){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=i,h=a(c),u=a(s),m=l/Math.sqrt(1-f*Math.sin(h)**2),p=e/m,M=o/m,g=r/m,v=Math.cos(h)-Math.sin(h)*M+Math.cos(h)*g,d=Math.sin(h)+Math.cos(h)*M+Math.sin(h)*g,x=Math.sqrt(v**2+p**2),w=f*m*Math.sin(h),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(h),b=Math.atan(e/(m*v))+u,j=n(O);return[n(b),j,e/(Math.cos(O)*Math.sin(b-u))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function W(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function T(t,n,a,i=E/2){const{heading:e,pitch:o}=Y(t,i);return X(e,o,n,a)}function X(t,n,a,i){return{x:a/2+t/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function Y(t,a){const i=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:i}}function Z(t,n,i=E/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}function J(t,n,a,i=E/2){const{heading:e,pitch:o}=W(t,n,a);return Z(e,o,i)}async function $(t,a,i){const e=await g(a,t.spatialReference,i);let o=n(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function B(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const G=t=>t.toArray(),Q=(...t)=>t.some((t=>t));function _(t,n){if(Q(0===t.length,t.some((({x:t,y:n})=>Q(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function tt(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function nt(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function at(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/v.radius))):1}const it=t=>n=>new M(n,t),et=t=>null!=t&&"queryExtent"in t;function ot(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>z(x(c(),a,[n,e,0]),i,t)))}function rt({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(ct);return null!=s&&st(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function ct(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function st(t){return null!=t[1]&&null!=t[5]}function lt(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=t,h=r??(l.z??0)-i;return{...ut(t,n,a),averageElevation:h,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function ft(t,n,a,i){return wt(i)?q([i.omega,i.phi,i.kappa]):yt(i)?k([i.heading,i.pitch,i.roll]):k([t,n,a??0])}function ht(t,n,a){const{cameraHeading:i,cameraHeight:e,elevation:o,farDistance:r,horizontalFieldOfView:c,location:s,verticalFieldOfView:l}=t;return{averageElevation:o??(s.z??0)-e,cameraLocation:s,cameraHeading:i,farDistance:r,horizontalFieldOfView:c,imageHeight:a,imageWidth:n,verticalFieldOfView:l}}function ut(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:h,cameraRoll:u,focalLength:m,horizontalFieldOfView:p,location:M,matrix:g,principalX:v,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=rt({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=g??ft(l,h,u,f),E=null!=v&&null!=d?[v,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const mt=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,pt=t=>y(t?.elevationSource)&&null!=t?.extent,Mt=t=>w(t?.elevationSource),gt=async(t,n,a)=>null!=n&&(mt(n)||Mt(n))?n:pt(n)?{elevationSample:await b({...p(n.elevationSource)?n.elevationSource.toJSON():n.elevationSource,extent:n.extent},a),elevationSource:new O({constantElevation:t})}:{elevationSource:new O({constantElevation:t})},vt=t=>j(t?.heading)&&j(t?.pitch),dt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function xt(t){const{cameraLocation:n,farDistance:e,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:s,verticalFieldOfView:f}=t,h=i();l(h,r);const p=2*Math.tan(a(f)/2)*e*s,M=2*Math.tan(a(o)/2)*e*s,g=L([0,0,-1],h),v=C([n.x,n.y,n.z],g,t.farDistance*s,s),d=L([0,1,0],h),x=L([1,0,0],h),w=R(d,p/2,s),y=R(x,M/2,s),O=u(c(),w,y),b=m(c(),w,y);return[m(c(),v,O),m(c(),v,b),u(c(),v,O),u(c(),v,b)]}const wt=t=>2===t?.type,yt=t=>1===t?.type;function Ot(t){const n=t%360;return n<-180?n+360:n}function bt(t,n,a){if("panoramic"===t){const[t,i]=a;return T({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var jt;!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(jt||(jt={}));export{xt as computeFarplaneVertices,A as computeHFOVAndVFOV,ot as computeNewReferenceCoordinates,Z as convertHeadingPitchToSphereVertex,X as convertOrientationToPixelLocation,J as convertPixelLocationToSphereVertex,W as convertPixelToHeadingPitch,Y as convertSphereVertexToOrientation,T as convertSphereVertexToPixelLocation,N as createRotationMatrix,k as createRotationMatrixFromHPR,q as createRotationMatrixFromOPK,K as geographicToLTP,rt as getAffinesAndFocalLength,ht as getImageToWorldPanoramicProperties,lt as getImageToWorldProperties,$ as getInitialAngle,gt as getUpdateElevationProps,at as getWebMercatorScalingFactor,ut as getWorldToImageProperties,vt as hasAngles,yt as hasHeadingPitchRoll,wt as hasOmegaPhiKappa,et as isElevationSampler,mt as isUpdateElevationWithElevationSampler,pt as isUpdateElevationWithElevationSource,Mt as isUpdateUsingConstantElevation,st as isValidAffines,V as linearEquationSolve,U as ltpToGeographic,Ot as normalizeHeading,Q as or,G as pointToArray,z as projectiveTransform,dt as reducerFn,B as rotatePixel,C as scaleAndAddWithFactor,R as scaleWithFactor,bt as transformGraphicCoordinatesToPixel,L as transformMat3,D as transformMat4,_ as validatePixelsToTransform,tt as validatePointsToTransform,nt as validateRotationMatrix,it as vecToPoint};
5
+ import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as e,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as r}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as s,transpose as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as f,mul as h}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as u,f as m}from"../../../chunks/vec32.js";import{isSerializable as p}from"../../../core/support/jsonUtils.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as g}from"../../../geometry/projectionUtils.js";import{earth as v}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isConstantElevation as w,isElevationSource as y,ConstantElevation as O}from"../core/ElevationSourceDefinitions.js";import{getElevationSampler as b}from"./updateElevationUtils.js";import{isNumber as j}from"../../../support/guards.js";import{defaultImageSphereSize as E}from"../../../widgets/PanoramicViewer/constants.js";function z(t,n,a){const[i,o,r,c]=n,[s,l,u,m]=a;F(i,o,r,c);const p=F(s,l,u,m),M=V(i,o,r,c),g=V(s,l,u,m),v=f(e(),M),d=h(e(),v,g),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function F(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function S(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=S(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const c=D(r([...i,1]),f(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=c[0],l=c[1],h=c[2],u=e();return u[0]=s*t[0],u[1]=l*n[0],u[2]=h*a[0],u[3]=0,u[4]=s*t[1],u[5]=l*n[1],u[6]=h*a[1],u[7]=0,u[8]=s*t[2],u[9]=l*n[2],u[10]=h*a[2],u[11]=0,u[12]=s,u[13]=l,u[14]=h,u[15]=1,u}function C(t,n,a,i,e=c()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function R(t,n,a){const i=c();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=c();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function D(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,e,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=i();switch(e){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const H={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function N(n,a,e=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=i();for(let t=0;t<3;t++){const[i,r]=a[t],c=I(n[t],i,r,e);s(o,c,o)}return o}function q(t,n=!0){return N(t,H.OPK,n)}function U(t,n=!0){return N(t,H.HPR,n)}function k(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function A(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),h=a(c),u=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-h,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(u*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-u+M*Math.sin(f)]}function K(t,i){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=i,h=a(c),u=a(s),m=l/Math.sqrt(1-f*Math.sin(h)**2),p=e/m,M=o/m,g=r/m,v=Math.cos(h)-Math.sin(h)*M+Math.cos(h)*g,d=Math.sin(h)+Math.cos(h)*M+Math.sin(h)*g,x=Math.sqrt(v**2+p**2),w=f*m*Math.sin(h),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(h),b=Math.atan(e/(m*v))+u,j=n(O);return[n(b),j,e/(Math.cos(O)*Math.sin(b-u))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function W(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function T(t,n,a,i=E/2){const{heading:e,pitch:o}=Y(t,i);return X(e,o,n,a)}function X(t,n,a,i){return{x:a/2+t/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function Y(t,a){const i=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:i}}function Z(t,n,i=E/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}function J(t,n,a,i=E/2){const{heading:e,pitch:o}=W(t,n,a);return Z(e,o,i)}async function $(t,a,i){const e=await g(a,t.spatialReference,i);let o=n(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function B(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const G=t=>t.toArray(),Q=(...t)=>t.some((t=>t));function _(t,n){if(Q(0===t.length,t.some((({x:t,y:n})=>Q(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function tt(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function nt(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function at(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/v.radius))):1}const it=t=>n=>new M(n,t),et=t=>null!=t&&"queryExtent"in t;function ot(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>z(x(c(),a,[n,e,0]),i,t)))}function rt({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(ct);return null!=s&&st(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function ct(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function st(t){return null!=t[1]&&null!=t[5]}function lt(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=t,h=r??(l.z??0)-i;return{...ut(t,n,a),averageElevation:h,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function ft(t,n,a,i){return wt(i)?q([i.omega,i.phi,i.kappa]):yt(i)?U([i.heading,i.pitch,i.roll]):U([t,n,a??0])}function ht(t,n,a){const{cameraHeading:i,cameraHeight:e,elevation:o,farDistance:r,horizontalFieldOfView:c,location:s,verticalFieldOfView:l}=t;return{averageElevation:o??(s.z??0)-e,cameraLocation:s,cameraHeading:i,farDistance:r,horizontalFieldOfView:c,imageHeight:a,imageWidth:n,verticalFieldOfView:l}}function ut(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:h,cameraRoll:u,focalLength:m,horizontalFieldOfView:p,location:M,matrix:g,principalX:v,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=rt({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=g??ft(l,h,u,f),E=null!=v&&null!=d?[v,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const mt=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,pt=t=>y(t?.elevationSource)&&null!=t?.extent,Mt=t=>w(t?.elevationSource),gt=async(t,n,a)=>null!=n&&(mt(n)||Mt(n))?n:pt(n)?{elevationSample:await b({...p(n.elevationSource)?n.elevationSource.toJSON():n.elevationSource,extent:n.extent},a),elevationSource:new O({constantElevation:t})}:{elevationSource:new O({constantElevation:t})},vt=t=>j(t?.heading)&&j(t?.pitch),dt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function xt(t){const{cameraLocation:n,farDistance:e,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:s,verticalFieldOfView:f}=t,h=i();l(h,r);const p=2*Math.tan(a(f)/2)*e*s,M=2*Math.tan(a(o)/2)*e*s,g=L([0,0,-1],h),v=C([n.x,n.y,n.z],g,t.farDistance*s,s),d=L([0,1,0],h),x=L([1,0,0],h),w=R(d,p/2,s),y=R(x,M/2,s),O=u(c(),w,y),b=m(c(),w,y);return[m(c(),v,O),m(c(),v,b),u(c(),v,O),u(c(),v,b)]}const wt=t=>2===t?.type,yt=t=>1===t?.type;function Ot(t){const n=t%360;return n<-180?n+360:n}function bt(t,n,a){if("panoramic"===t){const[t,i]=a;return T({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var jt;!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(jt||(jt={}));export{xt as computeFarplaneVertices,k as computeHFOVAndVFOV,ot as computeNewReferenceCoordinates,Z as convertHeadingPitchToSphereVertex,X as convertOrientationToPixelLocation,J as convertPixelLocationToSphereVertex,W as convertPixelToHeadingPitch,Y as convertSphereVertexToOrientation,T as convertSphereVertexToPixelLocation,N as createRotationMatrix,U as createRotationMatrixFromHPR,q as createRotationMatrixFromOPK,A as geographicToLTP,rt as getAffinesAndFocalLength,ht as getImageToWorldPanoramicProperties,lt as getImageToWorldProperties,$ as getInitialAngle,gt as getUpdateElevationProps,at as getWebMercatorScalingFactor,ut as getWorldToImageProperties,vt as hasAngles,yt as hasHeadingPitchRoll,wt as hasOmegaPhiKappa,et as isElevationSampler,mt as isUpdateElevationWithElevationSampler,pt as isUpdateElevationWithElevationSource,Mt as isUpdateUsingConstantElevation,st as isValidAffines,V as linearEquationSolve,K as ltpToGeographic,Ot as normalizeHeading,Q as or,G as pointToArray,z as projectiveTransform,dt as reducerFn,B as rotatePixel,C as scaleAndAddWithFactor,R as scaleWithFactor,bt as transformGraphicCoordinatesToPixel,L as transformMat3,D as transformMat4,_ as validatePixelsToTransform,tt as validatePointsToTransform,nt as validateRotationMatrix,it as vecToPoint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Clonable.js";import e from"../../core/Error.js";import r from"../../core/JSONSupport.js";import n from"../../core/Logger.js";import{transformProjective as i,getProjectiveTransform as s}from"../../core/perspectiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as u}from"../../core/accessorSupport/decorators/writer.js";import{invert as m}from"../../core/libs/gl-matrix-2/math/mat3.js";import{fromValues as f,create as P}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,lerp as d,rotate as y}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as g,fromValues as j}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import w from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import{projectOrLoad as x}from"../../geometry/projection.js";import v from"../../geometry/SpatialReference.js";import b from"./GeoreferenceBase.js";const S=P(),C=g();let N=class extends r{};t([c({type:Number,json:{write:{isRequired:!0}}})],N.prototype,"x",void 0),t([c({type:Number,json:{write:{isRequired:!0}}})],N.prototype,"y",void 0),N=t([p("esri.layers.support.ControlPointsGeoreference.ControlPointJSONType")],N);let q=class extends o{constructor(){super(...arguments),this.sourcePoint=null,this.mapPoint=null}};t([c()],q.prototype,"sourcePoint",void 0),t([c({type:w})],q.prototype,"mapPoint",void 0),q=t([p("esri.layers.support.ControlPointsGeoreference.ControlPoint")],q);let O=class extends(r.JSONSupportMixin(b)){constructor(t){super(t),this.controlPoints=null,this.height=0,this.type="control-points",this.width=0}readControlPoints(t,o){const e=v.fromJSON(o.spatialReference),r=f(...o.coefficients,1);return t.map((t=>(h(C,t.x,t.y),i(C,C,r),{sourcePoint:t,mapPoint:new w({x:C[0],y:C[1],spatialReference:e})})))}writeControlPoints(t,o,r,i){if(null!=this.transform)null!=t&&T(t[0])&&(o.controlPoints=t.map((t=>{const o=t.sourcePoint;return{x:o.x,y:o.y}})),o.spatialReference=t[0].mapPoint.spatialReference.toJSON(),o.coefficients=this.transform.slice(0,8));else{const t=new e("web-document-write:invalid-georeference","Invalid 'controlPoints', 'width', 'height' configuration. Make sure the parent media element is loaded i.e. the ImageElement or VideoElement set as 'MediaLayer.source'.",{layer:i?.layer,georeference:this});i?.messages?i.messages.push(t):n.getLogger(this).error(t.name,t.message)}}get coords(){if(null==this.controlPoints)return null;const t=this._updateTransform(S);if(null==t||!T(this.controlPoints[0]))return null;const o=this.controlPoints[0].mapPoint.spatialReference;return K(t,this.width,this.height,o)}set coords(t){if(null==this.controlPoints||!T(this.controlPoints[0]))return;const o=this.controlPoints[0].mapPoint.spatialReference;if(null==(t=this.projectOrWarn(t,o)))return;const{width:e,height:r}=this,{rings:[[n,s,c,a]]}=t,p={sourcePoint:l(0,r),mapPoint:new w({x:n[0],y:n[1],spatialReference:o})},u={sourcePoint:l(0,0),mapPoint:new w({x:s[0],y:s[1],spatialReference:o})},m={sourcePoint:l(e,0),mapPoint:new w({x:c[0],y:c[1],spatialReference:o})},f={sourcePoint:l(e,r),mapPoint:new w({x:a[0],y:a[1],spatialReference:o})};T(p)&&T(u)&&T(m)&&T(f)&&(B(S,p,u,m,f),this.controlPoints=this.controlPoints.map((({sourcePoint:t})=>(h(C,t.x,t.y),i(C,C,S),{sourcePoint:t,mapPoint:new w({x:C[0],y:C[1],spatialReference:o})}))))}get inverseTransform(){return null==this.transform?null:m(P(),this.transform)}get transform(){return this._updateTransform()}toMap(t){if(null==t||null==this.transform||null==this.controlPoints||!T(this.controlPoints[0]))return null;h(C,t.x,t.y);const o=this.controlPoints[0].mapPoint.spatialReference;return i(C,C,this.transform),new w({x:C[0],y:C[1],spatialReference:o})}toSource(t){if(null==t||null==this.inverseTransform||null==this.controlPoints||!T(this.controlPoints[0]))return null;const o=this.controlPoints[0].mapPoint.spatialReference;return t=t.normalize(),null==(t=x(t,o).geometry)?null:(h(C,t.x,t.y),i(C,C,this.inverseTransform),l(C[0],C[1]))}toSourceNormalized(t){const o=this.toSource(t);return null!=o&&(o.x/=this.width,o.y/=this.height),o}_updateTransform(t){const{controlPoints:o,width:e,height:r}=this;if(!(null!=o&&e>0&&r>0))return null;const[n,i,s,l]=o;if(!T(n))return null;const c=n.mapPoint.spatialReference,a=this._projectControlPoint(i,c),p=this._projectControlPoint(s,c),u=this._projectControlPoint(l,c);if(!a.valid||!p.valid||!u.valid)return null;if(!T(a.controlPoint))return null;null==t&&(t=P());let m=null;return m=T(p.controlPoint)&&T(u.controlPoint)?B(t,n,a.controlPoint,p.controlPoint,u.controlPoint):T(p.controlPoint)?V(t,n,a.controlPoint,p.controlPoint):U(t,n,a.controlPoint),m.every((t=>0===t))?null:m}_projectControlPoint(t,o){if(!T(t))return{valid:!0,controlPoint:t};const{sourcePoint:e,mapPoint:r}=t,{geometry:i,pending:s}=x(r,o);return s?{valid:!1,controlPoint:null}:s||i?{valid:!0,controlPoint:{sourcePoint:e,mapPoint:i}}:(n.getLogger(this).warn("map point could not be projected to the spatial reference",{georeference:this,controlPoint:t,sourceSpatialReference:r.spatialReference,targetSpatialReference:o}),{valid:!1,controlPoint:null})}};function T(t){return null!=t?.sourcePoint&&null!=t.mapPoint}t([c({type:[q],json:{write:{allowNull:!1,isRequired:!0,target:{controlPoints:{type:[N],isRequired:!0},coefficients:{type:[Number],isRequired:!0},spatialReference:{type:v,isRequired:!0}}}}})],O.prototype,"controlPoints",void 0),t([a("controlPoints")],O.prototype,"readControlPoints",null),t([u("controlPoints")],O.prototype,"writeControlPoints",null),t([c({clonable:!1})],O.prototype,"coords",null),t([c({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],O.prototype,"height",void 0),t([c({readOnly:!0})],O.prototype,"inverseTransform",null),t([c({readOnly:!0})],O.prototype,"transform",null),t([c({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],O.prototype,"width",void 0),O=t([p("esri.layers.support.ControlPointsGeoreference")],O);const _=g(),M=g(),G=g(),I=g(),J=g(),L=g(),E=g(),k=g(),z=Math.PI/2;function A(t,o,e){h(t,e.sourcePoint.x,e.sourcePoint.y),h(o,e.mapPoint.x,e.mapPoint.y)}function U(t,o,e){return A(_,J,o),A(M,L,e),y(G,M,_,z),y(I,_,M,z),y(E,L,J,-z),y(k,J,L,-z),H(t,_,M,G,I,J,L,E,k)}function V(t,o,e,r){return A(_,J,o),A(M,L,e),A(G,E,r),d(I,_,M,.5),y(I,G,I,Math.PI),d(k,J,L,.5),y(k,E,k,Math.PI),H(t,_,M,G,I,J,L,E,k)}function B(t,o,e,r,n){return A(_,J,o),A(M,L,e),A(G,E,r),A(I,k,n),H(t,_,M,G,I,J,L,E,k)}const W=new Array(8).fill(0),D=new Array(8).fill(0);function F(t,o,e,r,n){return t[0]=o[0],t[1]=o[1],t[2]=e[0],t[3]=e[1],t[4]=r[0],t[5]=r[1],t[6]=n[0],t[7]=n[1],t}function H(t,o,e,r,n,i,l,c,a){return s(t,F(W,o,e,r,n),F(D,i,l,c,a))}function K(t,o,e,r){const n=j(0,e),s=j(0,0),l=j(o,0),c=j(o,e);return i(n,n,t),i(s,s,t),i(l,l,t),i(c,c,t),new R({rings:[[n,s,l,c,n]],spatialReference:r})}export{O as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Clonable.js";import e from"../../core/Error.js";import r from"../../core/JSONSupport.js";import n from"../../core/Logger.js";import{transformProjective as i,getProjectiveTransform as s}from"../../core/perspectiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as u}from"../../core/accessorSupport/decorators/writer.js";import{invert as m}from"../../core/libs/gl-matrix-2/math/mat3.js";import{fromValues as f,create as P}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,lerp as d,rotate as y}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as g,fromValues as j}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import w from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import{projectOrLoad as x}from"../../geometry/projectionUtils.js";import v from"../../geometry/SpatialReference.js";import b from"./GeoreferenceBase.js";const S=P(),C=g();let N=class extends r{};t([c({type:Number,json:{write:{isRequired:!0}}})],N.prototype,"x",void 0),t([c({type:Number,json:{write:{isRequired:!0}}})],N.prototype,"y",void 0),N=t([p("esri.layers.support.ControlPointsGeoreference.ControlPointJSONType")],N);let q=class extends o{constructor(){super(...arguments),this.sourcePoint=null,this.mapPoint=null}};t([c()],q.prototype,"sourcePoint",void 0),t([c({type:w})],q.prototype,"mapPoint",void 0),q=t([p("esri.layers.support.ControlPointsGeoreference.ControlPoint")],q);let O=class extends(r.JSONSupportMixin(b)){constructor(t){super(t),this.controlPoints=null,this.height=0,this.type="control-points",this.width=0}readControlPoints(t,o){const e=v.fromJSON(o.spatialReference),r=f(...o.coefficients,1);return t.map((t=>(h(C,t.x,t.y),i(C,C,r),{sourcePoint:t,mapPoint:new w({x:C[0],y:C[1],spatialReference:e})})))}writeControlPoints(t,o,r,i){if(null!=this.transform)null!=t&&T(t[0])&&(o.controlPoints=t.map((t=>{const o=t.sourcePoint;return{x:o.x,y:o.y}})),o.spatialReference=t[0].mapPoint.spatialReference.toJSON(),o.coefficients=this.transform.slice(0,8));else{const t=new e("web-document-write:invalid-georeference","Invalid 'controlPoints', 'width', 'height' configuration. Make sure the parent media element is loaded i.e. the ImageElement or VideoElement set as 'MediaLayer.source'.",{layer:i?.layer,georeference:this});i?.messages?i.messages.push(t):n.getLogger(this).error(t.name,t.message)}}get coords(){if(null==this.controlPoints)return null;const t=this._updateTransform(S);if(null==t||!T(this.controlPoints[0]))return null;const o=this.controlPoints[0].mapPoint.spatialReference;return K(t,this.width,this.height,o)}set coords(t){if(null==this.controlPoints||!T(this.controlPoints[0]))return;const o=this.controlPoints[0].mapPoint.spatialReference;if(null==(t=this.projectOrWarn(t,o)))return;const{width:e,height:r}=this,{rings:[[n,s,c,a]]}=t,p={sourcePoint:l(0,r),mapPoint:new w({x:n[0],y:n[1],spatialReference:o})},u={sourcePoint:l(0,0),mapPoint:new w({x:s[0],y:s[1],spatialReference:o})},m={sourcePoint:l(e,0),mapPoint:new w({x:c[0],y:c[1],spatialReference:o})},f={sourcePoint:l(e,r),mapPoint:new w({x:a[0],y:a[1],spatialReference:o})};T(p)&&T(u)&&T(m)&&T(f)&&(B(S,p,u,m,f),this.controlPoints=this.controlPoints.map((({sourcePoint:t})=>(h(C,t.x,t.y),i(C,C,S),{sourcePoint:t,mapPoint:new w({x:C[0],y:C[1],spatialReference:o})}))))}get inverseTransform(){return null==this.transform?null:m(P(),this.transform)}get transform(){return this._updateTransform()}toMap(t){if(null==t||null==this.transform||null==this.controlPoints||!T(this.controlPoints[0]))return null;h(C,t.x,t.y);const o=this.controlPoints[0].mapPoint.spatialReference;return i(C,C,this.transform),new w({x:C[0],y:C[1],spatialReference:o})}toSource(t){if(null==t||null==this.inverseTransform||null==this.controlPoints||!T(this.controlPoints[0]))return null;const o=this.controlPoints[0].mapPoint.spatialReference;return t=t.normalize(),null==(t=x(t,o).geometry)?null:(h(C,t.x,t.y),i(C,C,this.inverseTransform),l(C[0],C[1]))}toSourceNormalized(t){const o=this.toSource(t);return null!=o&&(o.x/=this.width,o.y/=this.height),o}_updateTransform(t){const{controlPoints:o,width:e,height:r}=this;if(!(null!=o&&e>0&&r>0))return null;const[n,i,s,l]=o;if(!T(n))return null;const c=n.mapPoint.spatialReference,a=this._projectControlPoint(i,c),p=this._projectControlPoint(s,c),u=this._projectControlPoint(l,c);if(!a.valid||!p.valid||!u.valid)return null;if(!T(a.controlPoint))return null;null==t&&(t=P());let m=null;return m=T(p.controlPoint)&&T(u.controlPoint)?B(t,n,a.controlPoint,p.controlPoint,u.controlPoint):T(p.controlPoint)?V(t,n,a.controlPoint,p.controlPoint):A(t,n,a.controlPoint),m.every((t=>0===t))?null:m}_projectControlPoint(t,o){if(!T(t))return{valid:!0,controlPoint:t};const{sourcePoint:e,mapPoint:r}=t,{geometry:i,pending:s}=x(r,o);return s?{valid:!1,controlPoint:null}:s||i?{valid:!0,controlPoint:{sourcePoint:e,mapPoint:i}}:(n.getLogger(this).warn("map point could not be projected to the spatial reference",{georeference:this,controlPoint:t,sourceSpatialReference:r.spatialReference,targetSpatialReference:o}),{valid:!1,controlPoint:null})}};function T(t){return null!=t?.sourcePoint&&null!=t.mapPoint}t([c({type:[q],json:{write:{allowNull:!1,isRequired:!0,target:{controlPoints:{type:[N],isRequired:!0},coefficients:{type:[Number],isRequired:!0},spatialReference:{type:v,isRequired:!0}}}}})],O.prototype,"controlPoints",void 0),t([a("controlPoints")],O.prototype,"readControlPoints",null),t([u("controlPoints")],O.prototype,"writeControlPoints",null),t([c({clonable:!1})],O.prototype,"coords",null),t([c({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],O.prototype,"height",void 0),t([c({readOnly:!0})],O.prototype,"inverseTransform",null),t([c({readOnly:!0})],O.prototype,"transform",null),t([c({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],O.prototype,"width",void 0),O=t([p("esri.layers.support.ControlPointsGeoreference")],O);const _=g(),M=g(),G=g(),I=g(),J=g(),L=g(),E=g(),U=g(),k=Math.PI/2;function z(t,o,e){h(t,e.sourcePoint.x,e.sourcePoint.y),h(o,e.mapPoint.x,e.mapPoint.y)}function A(t,o,e){return z(_,J,o),z(M,L,e),y(G,M,_,k),y(I,_,M,k),y(E,L,J,-k),y(U,J,L,-k),H(t,_,M,G,I,J,L,E,U)}function V(t,o,e,r){return z(_,J,o),z(M,L,e),z(G,E,r),d(I,_,M,.5),y(I,G,I,Math.PI),d(U,J,L,.5),y(U,E,U,Math.PI),H(t,_,M,G,I,J,L,E,U)}function B(t,o,e,r,n){return z(_,J,o),z(M,L,e),z(G,E,r),z(I,U,n),H(t,_,M,G,I,J,L,E,U)}const W=new Array(8).fill(0),D=new Array(8).fill(0);function F(t,o,e,r,n){return t[0]=o[0],t[1]=o[1],t[2]=e[0],t[3]=e[1],t[4]=r[0],t[5]=r[1],t[6]=n[0],t[7]=n[1],t}function H(t,o,e,r,n,i,l,c,a){return s(t,F(W,o,e,r,n),F(D,i,l,c,a))}function K(t,o,e,r){const n=j(0,e),s=j(0,0),l=j(o,0),c=j(o,e);return i(n,n,t),i(s,s,t),i(l,l,t),i(c,c,t),new R({rings:[[n,s,l,c,n]],spatialReference:r})}export{O 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{getProjectiveTransform as o,transformProjective as e}from"../../core/perspectiveUtils.js";import{createScreenPoint as r}from"../../core/screenUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{create as l}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import c from"../../geometry/Point.js";import m from"../../geometry/Polygon.js";import{projectOrLoad as a}from"../../geometry/projection.js";import f from"./GeoreferenceBase.js";const u=p();let y=class extends f{constructor(t){super(t),this.bottomLeft=null,this.bottomRight=null,this.topLeft=null,this.topRight=null,this.type="corners"}get coords(){let{topLeft:t,topRight:o,bottomLeft:e,bottomRight:r}=this;if(null==t||null==o||null==e||null==r)return null;const s=t.spatialReference;return o=this.projectOrWarn(o,s),e=this.projectOrWarn(e,s),r=this.projectOrWarn(r,s),null==o||null==e||null==r?null:new m({rings:[[[e.x,e.y],[t.x,t.y],[o.x,o.y],[r.x,r.y],[e.x,e.y]]],spatialReference:s})}set coords(t){const{topLeft:o}=this;if(null==o)return;const e=o.spatialReference;if(null==(t=this.projectOrWarn(t,e)))return;const{rings:[[r,s,i,l]]}=t;this.bottomLeft=new c({x:r[0],y:r[1],spatialReference:e}),this.topLeft=new c({x:s[0],y:s[1],spatialReference:e}),this.topRight=new c({x:i[0],y:i[1],spatialReference:e}),this.bottomRight=new c({x:l[0],y:l[1],spatialReference:e})}toSourceNormalized(t){const{topLeft:s,topRight:i,bottomRight:p,bottomLeft:c}=this;if(null==t||null==s||null==i||null==p||null==c)return null;const m=s.spatialReference;t=t.normalize();const f=a(t,m).geometry;if(null==f)return null;n(u,f.x,f.y);const y=o(l(),[s.x,s.y,c.x,c.y,i.x,i.y,p.x,p.y],[0,0,0,1,1,0,1,1]);return e(u,u,y),r(u[0],u[1])}};t([s({clonable:!1})],y.prototype,"coords",null),t([s({type:c})],y.prototype,"bottomLeft",void 0),t([s({type:c})],y.prototype,"bottomRight",void 0),t([s({type:c})],y.prototype,"topLeft",void 0),t([s({type:c})],y.prototype,"topRight",void 0),y=t([i("esri.layers.support.CornersGeoreference")],y);const h=y;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{getProjectiveTransform as o,transformProjective as e}from"../../core/perspectiveUtils.js";import{createScreenPoint as r}from"../../core/screenUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{create as l}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as n}from"../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import c from"../../geometry/Point.js";import m from"../../geometry/Polygon.js";import{projectOrLoad as a}from"../../geometry/projectionUtils.js";import f from"./GeoreferenceBase.js";const u=p();let y=class extends f{constructor(t){super(t),this.bottomLeft=null,this.bottomRight=null,this.topLeft=null,this.topRight=null,this.type="corners"}get coords(){let{topLeft:t,topRight:o,bottomLeft:e,bottomRight:r}=this;if(null==t||null==o||null==e||null==r)return null;const s=t.spatialReference;return o=this.projectOrWarn(o,s),e=this.projectOrWarn(e,s),r=this.projectOrWarn(r,s),null==o||null==e||null==r?null:new m({rings:[[[e.x,e.y],[t.x,t.y],[o.x,o.y],[r.x,r.y],[e.x,e.y]]],spatialReference:s})}set coords(t){const{topLeft:o}=this;if(null==o)return;const e=o.spatialReference;if(null==(t=this.projectOrWarn(t,e)))return;const{rings:[[r,s,i,l]]}=t;this.bottomLeft=new c({x:r[0],y:r[1],spatialReference:e}),this.topLeft=new c({x:s[0],y:s[1],spatialReference:e}),this.topRight=new c({x:i[0],y:i[1],spatialReference:e}),this.bottomRight=new c({x:l[0],y:l[1],spatialReference:e})}toSourceNormalized(t){const{topLeft:s,topRight:i,bottomRight:p,bottomLeft:c}=this;if(null==t||null==s||null==i||null==p||null==c)return null;const m=s.spatialReference;t=t.normalize();const f=a(t,m).geometry;if(null==f)return null;n(u,f.x,f.y);const y=o(l(),[s.x,s.y,c.x,c.y,i.x,i.y,p.x,p.y],[0,0,0,1,1,0,1,1]);return e(u,u,y),r(u[0],u[1])}};t([s({clonable:!1})],y.prototype,"coords",null),t([s({type:c})],y.prototype,"bottomLeft",void 0),t([s({type:c})],y.prototype,"bottomRight",void 0),t([s({type:c})],y.prototype,"topLeft",void 0),t([s({type:c})],y.prototype,"topRight",void 0),y=t([i("esri.layers.support.CornersGeoreference")],y);const h=y;export{h as default};