@arcgis/core 5.0.0-next.34 → 5.0.0-next.35

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 (81) hide show
  1. package/applications/Components/SketchTooltipControls.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f8a5b26e0231244972d8.js → 032444974011118127d7.js} +1 -1
  4. package/assets/esri/core/workers/chunks/15c1a48e8cd2a8882d85.js +1 -0
  5. package/assets/esri/core/workers/chunks/{1dd867fa7c58c06b79ea.js → 1bacdd17e199e22b5cd1.js} +1 -1
  6. package/assets/esri/core/workers/chunks/234ffd08c2be03a0b9fe.js +1 -0
  7. package/assets/esri/core/workers/chunks/32d32d3c3b38a215d20d.js +1 -0
  8. package/assets/esri/core/workers/chunks/36130910ba141f34531b.js +1 -0
  9. package/assets/esri/core/workers/chunks/48d1a443b324753921de.js +1 -0
  10. package/assets/esri/core/workers/chunks/4f4d51181ae7db9fbe6d.js +1 -0
  11. package/assets/esri/core/workers/chunks/{fee942ef802a162e0248.js → 5dc0d853c21ccb6054c7.js} +1 -1
  12. package/assets/esri/core/workers/chunks/768d9b6eaba7bfa18dde.js +1 -0
  13. package/assets/esri/core/workers/chunks/{a4b7ba8aec109beb5b4d.js → 7d3e665613927904ba4f.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{486e69261aa2caf9ec3c.js → a372d9af43ade7c6314c.js} +1 -1
  15. package/assets/esri/core/workers/chunks/ad138b989c2c7a1168ac.js +1 -0
  16. package/assets/esri/core/workers/chunks/ef5b13ee3362763c1096.js +1 -0
  17. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  18. package/config.js +1 -1
  19. package/core/workers/registry.js +1 -1
  20. package/geometry/geometryEngineJSON.js +1 -1
  21. package/geometry/support/buffer/BufferView.js +1 -1
  22. package/geometry/support/coordsUtils.js +1 -1
  23. package/geometry/support/curves/curveUtils.js +1 -1
  24. package/geometry/support/curves/interpolateCurve.js +5 -0
  25. package/geometry/support/meshUtils/Metadata.js +1 -1
  26. package/geometry/support/vector.js +1 -1
  27. package/interfaces.d.ts +26 -420
  28. package/kernel.js +1 -1
  29. package/layers/SceneLayer.js +1 -1
  30. package/layers/graphics/data/QueryEngine.js +1 -1
  31. package/layers/graphics/data/QueryEngineResult.js +1 -1
  32. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  33. package/package.json +1 -1
  34. package/smartMapping/statistics/support/statsWorker.js +1 -1
  35. package/support/revision.js +1 -1
  36. package/views/2d/interactive/SegmentLabels2D.js +5 -0
  37. package/views/3d/interactive/SegmentLabels3D.js +1 -1
  38. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  39. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +18 -12
  40. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +8 -8
  41. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +7 -12
  42. package/views/3d/webgl-engine/core/shaderModules/Texture2DUintDrawUniform.js +5 -0
  43. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  44. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +1 -1
  45. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  46. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  47. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  48. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  49. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  50. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +18 -18
  51. package/views/Attribution.js +1 -1
  52. package/views/draw/support/Reshape.js +1 -1
  53. package/views/interactive/SegmentLabels.js +1 -1
  54. package/views/interactive/coordinateHelper.js +1 -1
  55. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  56. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  57. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  58. package/views/interactive/sketch/normalizedPoint.js +1 -1
  59. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  60. package/widgets/Editor/Upload.js +1 -1
  61. package/widgets/Editor/components/Settings.js +1 -1
  62. package/widgets/Editor/support/SketchController.js +1 -1
  63. package/widgets/Sketch/SketchViewModel.js +1 -1
  64. package/widgets/Sketch.js +1 -1
  65. package/widgets/support/SketchTooltipControls.js +1 -1
  66. package/assets/esri/core/workers/chunks/08957e462d06c4dc8ab5.js +0 -1
  67. package/assets/esri/core/workers/chunks/22d66d1c8dfccdbbcf30.js +0 -1
  68. package/assets/esri/core/workers/chunks/484cd728dd17b8dc1f72.js +0 -1
  69. package/assets/esri/core/workers/chunks/61cb30e2e8edd18ebbf0.js +0 -1
  70. package/assets/esri/core/workers/chunks/6c8f5a56e94fdbe6a4a5.js +0 -1
  71. package/assets/esri/core/workers/chunks/745fc2b89fd7d816f2e0.js +0 -1
  72. package/assets/esri/core/workers/chunks/79c7391f00a55e7bcf6b.js +0 -1
  73. package/assets/esri/core/workers/chunks/7f8b85de079614b9c336.js +0 -1
  74. package/assets/esri/core/workers/chunks/c6cc3db057da49755d15.js +0 -1
  75. package/assets/esri/core/workers/chunks/d6d03f22c91f528b97e5.js +0 -1
  76. package/assets/esri/core/workers/chunks/ea5bf896acfcc3106bf5.js +0 -1
  77. package/chunks/geometryEngineJSON.js +0 -5
  78. package/geometry/geometryEngineAsync.d.ts +0 -39
  79. package/geometry/geometryEngineAsync.js +0 -5
  80. package/geometry/geometryEngineWorker.js +0 -5
  81. package/views/3d/webgl-engine/collections/Component/Material/ComponentDataConstants.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import r from"../PopupTemplate.js";import{ClonableMixin as i}from"../core/Clonable.js";import s from"../core/Collection.js";import{deprecated as o}from"../core/deprecate.js";import a from"../core/Error.js";import{abortHandle as n}from"../core/handleUtils.js";import l from"../core/Logger.js";import{destroyMaybe as p}from"../core/maybe.js";import{MultiOriginJSONMixin as d}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as y,throwIfAborted as u,isAbortError as c,throwIfNotAbortError as h}from"../core/promiseUtils.js";import{whenOnce as f}from"../core/reactiveUtils.js";import{property as m,subclass as g}from"../core/accessorSupport/decorators.js";import{getProperties as v}from"../core/accessorSupport/utils.js";import b from"../geometry/Point.js";import{projectWithZConversion as w}from"../geometry/projectionUtils.js";import I from"../graphic/SceneGraphicOrigin.js";import L from"./Layer.js";import{NoModelError as j,MultipleModelsError as F}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as S}from"./mixins/APIKeyMixin.js";import{ArcGISService as O}from"./mixins/ArcGISService.js";import{CustomParametersMixin as _}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as P}from"./mixins/EditBusLayer.js";import{OperationalLayer as T}from"./mixins/OperationalLayer.js";import{PortalLayer as A}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{SceneService as E}from"./mixins/SceneService.js";import{useViewTimeProperty as D}from"./mixins/TemporalLayer.js";import{TemporalSceneLayer as U}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as R}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as q}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as C}from"./support/capabilities.js";import{elevationInfo as N,labelsVisible as G,legendEnabled as Q,popupEnabled as V,attributeTableTemplate as M,screenSizePerspectiveEnabled as k}from"./support/commonProperties.js";import{getFieldDomain as K,computeEffectiveEditingEnabled as $,getGlobalIdToObjectIdMap as H}from"./support/featureLayerUtils.js";import{FeatureReduction as z}from"./support/FeatureReduction.js";import W from"./support/FeatureReductionSelection.js";import{defineFieldProperties as Z}from"./support/fieldProperties.js";import B from"./support/FieldsIndex.js";import{fixRendererFields as J,unpackFieldNames as X}from"./support/fieldUtils.js";import{I3SNodePageDefinition as Y,I3SMaterialDefinition as ee,I3STextureSetDefinition as te,I3SGeometryDefinition as re}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as ie,isFileSupported as se}from"./support/infoFor3D.js";import oe from"./support/LabelClass.js";import{reader as ae}from"./support/labelingInfo.js";import ne from"./support/LayerFloorInfo.js";import{layerLookupMap as le}from"./support/lazyLayerLoader.js";import{getMeshTransformForMetersToSpatialReference as pe}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as de}from"./support/RangeInfo.js";import ye from"./support/SceneFilter.js";import{cacheIsOutOfSync as ue}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ce}from"./support/sceneLayerStatistics.js";import{loadStyleRenderer as he}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as fe}from"../renderers/support/typeUtils.js";import me from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as ge,elevationModeUnsupportedMessage as ve,featureExpressionUnsupportedMessage as be}from"../support/elevationInfoUtils.js";import{createPopupTemplate as we}from"../support/popupUtils.js";import{extractZipFiles as Ie}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as Le}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as je,getFetchPopupTemplate as Fe}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as Se}from"../webdoc/support/opacityUtils.js";import{reader as Oe}from"../core/accessorSupport/decorators/reader.js";const _e=new Set(["3DObject","Point"]),Pe=Z();let Te=class extends(U(P(E(O(T(A(x(d(_(S(i(L)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.graphicOrigin=new I(this),this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new s,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.attributeTableTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null),this.associatedLayer=p(this.associatedLayer)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getField(e)?.domain??null;return this.associatedLayer?K(this.associatedLayer,e,t,r):r}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new B(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:Y.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&$(this.associatedLayer)}get geometryType(){return xe[this.profile]||"mesh"}set renderer(e){J(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:C;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,w=!!this.associatedLayer?.infoFor3D;return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:w&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:w&&c&&b,supportsDelete:w&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some(t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e)),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some(t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e)),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&Ae[r]?Ae[r]:(l.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}get useViewTime(){return this.associatedLayer?.useViewTime??!0}set useViewTime(e){this._override("useViewTime",e)}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=e?.signal;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(y),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await this.loadTimeInfoFromService(e),await he(this,{origin:"service"},t),J(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){l.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new me;return"mesh"===this.geometryType?this.capabilities.query.supportsReturnMesh&&(e.returnGeometry=!0):(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryExtent(e||this.createQuery(),t))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatureCount(e||this.createQuery(),t))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatures(e||this.createQuery(),t)).then(e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new a("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new a("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=X(this.fieldsIndex,await je(this,Fe(this)));return Le(this.parsedUrl?.path??"",this.attributeStorageInfo??[],e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new a("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s.origin=this.graphicOrigin,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryObjectIds(e||this.createQuery(),t))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryAttachments(e,t))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(l.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return we(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new a("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new a("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some(t=>t.name===e)}async queryCachedStatistics(e,t){return await this.load(t),await this.fetchStatistics(e,t)}async saveAs(e,t){return this._debouncedSaveOperations(1,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(0,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new a(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:o}=s,n=!!s.infoFor3D,l=i?.globalIdUsed??!0;if(n&&null==o)throw new a(`${this.type}-layer:not-editable`,"Valid globalIdField expected on editable SceneLayer");if(n&&!l)throw new a(`${this.type}-layer:globalid-required`,"globalIdUsed must not be false for SceneLayer editing as globalIds are required.");return R(s.url)&&n&&null!=e.deleteFeatures&&null!=o&&(i={...i,globalIdToObjectId:await H(s,e.deleteFeatures,o)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new a(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}async convertMesh(e,t){t??={},null!=t.location&&o(l.getLogger(this),"The 'location' option of convertMesh() has been deprecated in favour of 'origin'.",{version:"4.34",replacement:"origin",warnOnce:!0});const r=e=>{throw l.getLogger(this).error(".convertMesh()",e.message),e};await this.load(t),this.infoFor3D||r(new a("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e);u(t);const s=i.reduce((e,t)=>ie(this.infoFor3D,t)?e+1:e,0);0===s&&r(new j),s>1&&r(new F);const n=this.spatialReference,p=t.origin??t.location,d=await w(p??t.defaultOrigin??new b({x:0,y:0,z:0,spatialReference:n}),n,t),y=d.spatialReference.isGeographic?"local":"georeferenced",{default:c}=await import("../geometry/Mesh.js");u(t);const h=c.createWithExternalSource(d,{type:"client",files:i},{vertexSpace:y,transform:pe(d.spatialReference),unitConversionDisabled:!0}),[f]=await this.uploadAssets([h],{...t,useAssetOrigin:!p});return f}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await Ie(e)).filter(e=>se(t,e))}validateLayer(e){if(e.layerType&&!_e.has(e.layerType))throw new a("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new a("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new a("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new a("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new a("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new a("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!!this.attributeStorageInfo?.some(t=>t.name===e.name),r=!!this.associatedLayer?.fields?.some(t=>t&&e.name===t.name),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPropertyOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPropertyOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled","attributeTableTemplate"],t=v(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(2===o||3===o)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.getAtOrigin("fullExtent","service");if(null==this.associatedLayer?.infoFor3D||!e||!R(this.associatedLayer?.url)||!ue(this))return;v(this).setAtOrigin("fullExtent",e.clone(),2)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await q(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await le.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){c(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){const e=new AbortController;this.addHandles(n(e));try{await f(()=>this.popupEnabled&&null!=this.popupTemplate,e.signal)}catch(r){return void h(r)}const t=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?l.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${t}`):l.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${t}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&ge(l.getLogger(this),ve("Mesh scene layers","relative-to-scene",e)),ge(l.getLogger(this),be("Scene layers",e))}async fetchStatistics(e,t){return await ce({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:"scenelayer",fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??"",customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}};e([m({types:{key:"type",base:z,typeMap:{selection:W}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:{allowNull:!0}},"portal-item":{name:"layerDefinition.featureReduction",write:{allowNull:!0}}}}})],Te.prototype,"featureReduction",void 0),e([m({type:[de],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}},clonable:!1})],Te.prototype,"rangeInfos",void 0),e([m({json:{read:!1}})],Te.prototype,"associatedLayer",void 0),e([m({type:["show","hide"]})],Te.prototype,"listMode",void 0),e([m({type:["ArcGISSceneServiceLayer"]})],Te.prototype,"operationalLayerType",void 0),e([m({json:{read:!1},readOnly:!0})],Te.prototype,"type",void 0),e([m({...Pe.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Te.prototype,"fields",void 0),e([m()],Te.prototype,"types",null),e([m()],Te.prototype,"typeIdField",null),e([m()],Te.prototype,"templates",null),e([m()],Te.prototype,"formTemplate",null),e([m({readOnly:!0})],Te.prototype,"graphicOrigin",void 0),e([m({readOnly:!0,clonable:!1})],Te.prototype,"fieldsIndex",null),e([m({type:ne,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Te.prototype,"floorInfo",void 0),e([m(Pe.outFields)],Te.prototype,"outFields",void 0),e([m({type:Y,readOnly:!0,json:{read:!1},clonable:!1})],Te.prototype,"nodePages",void 0),e([Oe("service","nodePages",["nodePages","pointNodePages"])],Te.prototype,"readNodePages",null),e([m({type:[ee],readOnly:!0,clonable:!1})],Te.prototype,"materialDefinitions",void 0),e([m({type:[te],readOnly:!0,clonable:!1})],Te.prototype,"textureSetDefinitions",void 0),e([m({type:[re],readOnly:!0,clonable:!1})],Te.prototype,"geometryDefinitions",void 0),e([m({readOnly:!0})],Te.prototype,"serviceUpdateTimeStamp",void 0),e([m({readOnly:!0})],Te.prototype,"attributeStorageInfo",void 0),e([m({readOnly:!0})],Te.prototype,"statisticsInfo",void 0),e([m({type:s.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Te.prototype,"excludeObjectIds",void 0),e([m({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Te.prototype,"definitionExpression",void 0),e([m({type:ye,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Te.prototype,"filter",void 0),e([m({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Te.prototype,"path",void 0),e([m(N)],Te.prototype,"elevationInfo",null),e([m({readOnly:!0,json:{read:!1}})],Te.prototype,"effectiveCapabilities",null),e([m({readOnly:!0})],Te.prototype,"effectiveEditingEnabled",null),e([m({type:String})],Te.prototype,"geometryType",null),e([m(G)],Te.prototype,"labelsVisible",void 0),e([m({type:[oe],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:ae},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:ae},write:!0}})],Te.prototype,"labelingInfo",void 0),e([m(Q)],Te.prototype,"legendEnabled",void 0),e([m({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?Se(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Te.prototype,"opacity",void 0),e([m({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Te.prototype,"priority",void 0),e([m({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Te.prototype,"semantic",void 0),e([m({types:fe,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Te.prototype,"renderer",null),e([m({json:{read:!1}})],Te.prototype,"cachedDrawingInfo",void 0),e([Oe("service","cachedDrawingInfo")],Te.prototype,"readCachedDrawingInfo",null),e([m({readOnly:!0,json:{read:!1}})],Te.prototype,"capabilities",null),e([m({type:Boolean,json:{read:!1}})],Te.prototype,"editingEnabled",null),e([m({readOnly:!0,json:{write:!1,read:!1}})],Te.prototype,"infoFor3D",null),e([m({readOnly:!0,json:{write:!1,read:!1}})],Te.prototype,"relationships",null),e([m(V)],Te.prototype,"popupEnabled",void 0),e([m({type:r,json:{name:"popupInfo",write:!0}})],Te.prototype,"popupTemplate",void 0),e([m({readOnly:!0,json:{read:!1}})],Te.prototype,"defaultPopupTemplate",null),e([m(M)],Te.prototype,"attributeTableTemplate",void 0),e([m({type:String,json:{read:!1}})],Te.prototype,"objectIdField",void 0),e([Oe("service","objectIdField",["objectIdField","fields"])],Te.prototype,"readObjectIdField",null),e([m({type:String,json:{read:!1}})],Te.prototype,"globalIdField",void 0),e([Oe("service","globalIdField",["globalIdField","fields"])],Te.prototype,"readGlobalIdField",null),e([m({readOnly:!0,type:String,json:{read:!1}})],Te.prototype,"displayField",null),e([m({type:String,json:{read:!1}})],Te.prototype,"profile",void 0),e([Oe("service","profile",["store.profile"])],Te.prototype,"readProfile",null),e([m({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Te.prototype,"normalReferenceFrame",void 0),e([m(k)],Te.prototype,"screenSizePerspectiveEnabled",void 0),e([m({json:{read:!1,origins:{service:{read:!0}}}})],Te.prototype,"serviceItemId",void 0),e([m(D)],Te.prototype,"useViewTime",null),Te=e([g("esri.layers.SceneLayer")],Te);const Ae={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},xe={"mesh-pyramids":"mesh",points:"point"},Ee=Te;export{Ee as default};
5
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import r from"../PopupTemplate.js";import{ClonableMixin as i}from"../core/Clonable.js";import s from"../core/Collection.js";import o from"../core/Error.js";import{abortHandle as a}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{MultiOriginJSONMixin as p}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as d,throwIfAborted as y,isAbortError as u,throwIfNotAbortError as c}from"../core/promiseUtils.js";import{whenOnce as h}from"../core/reactiveUtils.js";import{property as f,subclass as m}from"../core/accessorSupport/decorators.js";import{getProperties as g}from"../core/accessorSupport/utils.js";import v from"../geometry/Point.js";import{projectWithZConversion as b}from"../geometry/projectionUtils.js";import w from"../graphic/SceneGraphicOrigin.js";import I from"./Layer.js";import{NoModelError as L,MultipleModelsError as j}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as F}from"./mixins/APIKeyMixin.js";import{ArcGISService as S}from"./mixins/ArcGISService.js";import{CustomParametersMixin as O}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as _}from"./mixins/EditBusLayer.js";import{OperationalLayer as P}from"./mixins/OperationalLayer.js";import{PortalLayer as A}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as T}from"./mixins/ScaleRangeLayer.js";import{SceneService as x}from"./mixins/SceneService.js";import{useViewTimeProperty as E}from"./mixins/TemporalLayer.js";import{TemporalSceneLayer as D}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as U}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as q}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as R}from"./support/capabilities.js";import{elevationInfo as C,labelsVisible as N,legendEnabled as G,popupEnabled as Q,attributeTableTemplate as V,screenSizePerspectiveEnabled as M}from"./support/commonProperties.js";import{getFieldDomain as k,computeEffectiveEditingEnabled as K,getGlobalIdToObjectIdMap as $}from"./support/featureLayerUtils.js";import{FeatureReduction as H}from"./support/FeatureReduction.js";import z from"./support/FeatureReductionSelection.js";import{defineFieldProperties as W}from"./support/fieldProperties.js";import Z from"./support/FieldsIndex.js";import{fixRendererFields as B,unpackFieldNames as J}from"./support/fieldUtils.js";import{I3SNodePageDefinition as X,I3SMaterialDefinition as Y,I3STextureSetDefinition as ee,I3SGeometryDefinition as te}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as re,isFileSupported as ie}from"./support/infoFor3D.js";import se from"./support/LabelClass.js";import{reader as oe}from"./support/labelingInfo.js";import ae from"./support/LayerFloorInfo.js";import{layerLookupMap as ne}from"./support/lazyLayerLoader.js";import{getMeshTransformForMetersToSpatialReference as le}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as pe}from"./support/RangeInfo.js";import de from"./support/SceneFilter.js";import{cacheIsOutOfSync as ye}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ue}from"./support/sceneLayerStatistics.js";import{loadStyleRenderer as ce}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as he}from"../renderers/support/typeUtils.js";import fe from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as me,elevationModeUnsupportedMessage as ge,featureExpressionUnsupportedMessage as ve}from"../support/elevationInfoUtils.js";import{createPopupTemplate as be}from"../support/popupUtils.js";import{extractZipFiles as we}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as Ie}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as Le,getFetchPopupTemplate as je}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as Fe}from"../webdoc/support/opacityUtils.js";import{reader as Se}from"../core/accessorSupport/decorators/reader.js";const Oe=new Set(["3DObject","Point"]),_e=W();let Pe=class extends(D(_(x(S(P(A(T(p(O(F(i(I)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.graphicOrigin=new w(this),this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new s,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.attributeTableTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null),this.associatedLayer=l(this.associatedLayer)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getField(e)?.domain??null;return this.associatedLayer?k(this.associatedLayer,e,t,r):r}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new Z(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:X.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return null!=this.associatedLayer&&K(this.associatedLayer)}get geometryType(){return Te[this.profile]||"mesh"}set renderer(e){B(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e=null!=e?e:R;const{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsRollbackOnFailure:s,supportsUploadWithItemId:o,supportsGeometryUpdate:a,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:l,supportsM:p,isVersioned:d,supportsAttachment:y},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:h,supportsDelete:f,supportsQuery:m,supportsQueryAttachments:g,supportsAsyncConvert3D:v}}=e,b=e.operations.supportsChangeTracking,w=!!this.associatedLayer?.infoFor3D;return{query:t,queryRelated:r,editing:{supportsGlobalId:i,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:s,supportsGeometryUpdate:w&&a,supportsUploadWithItemId:o},data:{supportsAttachment:y,supportsZ:l,supportsM:p,isVersioned:d},operations:{supportsQuery:m,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:w&&c&&b,supportsDelete:w&&f&&b,supportsUpdate:h&&b,supportsAsyncConvert3D:v}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some(t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e)),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some(t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e)),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&Ae[r]?Ae[r]:(n.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}get useViewTime(){return this.associatedLayer?.useViewTime??!0}set useViewTime(e){this._override("useViewTime",e)}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){const t=e?.signal;await this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(d),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await this.loadTimeInfoFromService(e),await ce(this,{origin:"service"},t),B(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){n.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new fe;return"mesh"===this.geometryType?this.capabilities.query.supportsReturnMesh&&(e.returnGeometry=!0):(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryExtent(e||this.createQuery(),t))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatureCount(e||this.createQuery(),t))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryFeatures(e||this.createQuery(),t)).then(e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new o("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new o("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){const r=J(this.fieldsIndex,await Le(this,je(this)));return Ie(this.parsedUrl?.path??"",this.attributeStorageInfo??[],e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const i=await this.queryCachedAttributes(e,[r]);if(!i||0===i.length)throw new o("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const s=new t;return s.attributes=i[0],s.layer=this,s.sourceLayer=this,s.origin=this.graphicOrigin,s}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryObjectIds(e||this.createQuery(),t))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then(r=>r.queryAttachments(e,t))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(n.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return be(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new o("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new o("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some(t=>t.name===e)}async queryCachedStatistics(e,t){return await this.load(t),await this.fetchStatistics(e,t)}async saveAs(e,t){return this._debouncedSaveOperations(1,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(0,e)}async applyEdits(e,t){const{applyEdits:r}=await import("./graphics/editingSupport.js");let i=t;await this.load();const s=this.associatedLayer;if(!s)throw new o(`${this.type}-layer:not-editable`,"Service is not editable");await s.load();const{globalIdField:a}=s,n=!!s.infoFor3D,l=i?.globalIdUsed??!0;if(n&&null==a)throw new o(`${this.type}-layer:not-editable`,"Valid globalIdField expected on editable SceneLayer");if(n&&!l)throw new o(`${this.type}-layer:globalid-required`,"globalIdUsed must not be false for SceneLayer editing as globalIds are required.");return U(s.url)&&n&&null!=e.deleteFeatures&&null!=a&&(i={...i,globalIdToObjectId:await $(s,e.deleteFeatures,a)}),r(this,s.source,e,i)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new o(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}async convertMesh(e,t){t??={};const r=e=>{throw n.getLogger(this).error(".convertMesh()",e.message),e};await this.load(t),this.infoFor3D||r(new o("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e);y(t);const s=i.reduce((e,t)=>re(this.infoFor3D,t)?e+1:e,0);0===s&&r(new L),s>1&&r(new j);const a=this.spatialReference,l=t.origin,p=await b(l??t.defaultOrigin??new v({x:0,y:0,z:0,spatialReference:a}),a,t),d=a.isGeographic?"local":"georeferenced",{default:u}=await import("../geometry/Mesh.js");y(t);const c=u.createWithExternalSource(p,{type:"client",files:i},{vertexSpace:d,transform:le(a),unitConversionDisabled:!0}),[h]=await this.uploadAssets([c],{...t,useAssetOrigin:!l});return h}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await we(e)).filter(e=>ie(t,e))}validateLayer(e){if(e.layerType&&!Oe.has(e.layerType))throw new o("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new o("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new o("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});function t(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new o("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new o("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}t(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new o("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!!this.attributeStorageInfo?.some(t=>t.name===e.name),r=!!this.associatedLayer?.fields?.some(t=>t&&e.name===t.name),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPropertyOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPropertyOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled","attributeTableTemplate"],t=g(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(2===o||3===o)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}_applyAssociatedLayerExtentOverride(){const e=this.associatedLayer?.getAtOrigin("fullExtent","service");if(null==this.associatedLayer?.infoFor3D||!e||!U(this.associatedLayer?.url)||!ye(this))return;g(this).setAtOrigin("fullExtent",e.clone(),2)}_applyAssociatedLayerPrivileges(){const e=this.associatedLayer;e&&(this._set("userHasEditingPrivileges",e.userHasEditingPrivileges),this._set("userHasFullEditingPrivileges",e.userHasFullEditingPrivileges),this._set("userHasUpdateItemPrivileges",e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if(["mesh-pyramids","points"].includes(this.profile))try{const{serverUrl:t,layerId:r,portalItem:i}=await q(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await ne.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){u(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){const e=new AbortController;this.addHandles(a(e));try{await h(()=>this.popupEnabled&&null!=this.popupTemplate,e.signal)}catch(r){return void c(r)}const t=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?n.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${t}`):n.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${t}`)}_validateElevationInfo(){const e=this.elevationInfo;"mesh-pyramids"===this.profile&&me(n.getLogger(this),ge("Mesh scene layers","relative-to-scene",e)),me(n.getLogger(this),ve("Scene layers",e))}async fetchStatistics(e,t){return await ue({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:"scenelayer",fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??"",customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}};e([f({types:{key:"type",base:H,typeMap:{selection:z}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:{allowNull:!0}},"portal-item":{name:"layerDefinition.featureReduction",write:{allowNull:!0}}}}})],Pe.prototype,"featureReduction",void 0),e([f({type:[pe],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}},clonable:!1})],Pe.prototype,"rangeInfos",void 0),e([f({json:{read:!1}})],Pe.prototype,"associatedLayer",void 0),e([f({type:["show","hide"]})],Pe.prototype,"listMode",void 0),e([f({type:["ArcGISSceneServiceLayer"]})],Pe.prototype,"operationalLayerType",void 0),e([f({json:{read:!1},readOnly:!0})],Pe.prototype,"type",void 0),e([f({..._e.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Pe.prototype,"fields",void 0),e([f()],Pe.prototype,"types",null),e([f()],Pe.prototype,"typeIdField",null),e([f()],Pe.prototype,"templates",null),e([f()],Pe.prototype,"formTemplate",null),e([f({readOnly:!0})],Pe.prototype,"graphicOrigin",void 0),e([f({readOnly:!0,clonable:!1})],Pe.prototype,"fieldsIndex",null),e([f({type:ae,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Pe.prototype,"floorInfo",void 0),e([f(_e.outFields)],Pe.prototype,"outFields",void 0),e([f({type:X,readOnly:!0,json:{read:!1},clonable:!1})],Pe.prototype,"nodePages",void 0),e([Se("service","nodePages",["nodePages","pointNodePages"])],Pe.prototype,"readNodePages",null),e([f({type:[Y],readOnly:!0,clonable:!1})],Pe.prototype,"materialDefinitions",void 0),e([f({type:[ee],readOnly:!0,clonable:!1})],Pe.prototype,"textureSetDefinitions",void 0),e([f({type:[te],readOnly:!0,clonable:!1})],Pe.prototype,"geometryDefinitions",void 0),e([f({readOnly:!0})],Pe.prototype,"serviceUpdateTimeStamp",void 0),e([f({readOnly:!0})],Pe.prototype,"attributeStorageInfo",void 0),e([f({readOnly:!0})],Pe.prototype,"statisticsInfo",void 0),e([f({type:s.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Pe.prototype,"excludeObjectIds",void 0),e([f({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Pe.prototype,"definitionExpression",void 0),e([f({type:de,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Pe.prototype,"filter",void 0),e([f({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Pe.prototype,"path",void 0),e([f(C)],Pe.prototype,"elevationInfo",null),e([f({readOnly:!0,json:{read:!1}})],Pe.prototype,"effectiveCapabilities",null),e([f({readOnly:!0})],Pe.prototype,"effectiveEditingEnabled",null),e([f({type:String})],Pe.prototype,"geometryType",null),e([f(N)],Pe.prototype,"labelsVisible",void 0),e([f({type:[se],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:oe},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:oe},write:!0}})],Pe.prototype,"labelingInfo",void 0),e([f(G)],Pe.prototype,"legendEnabled",void 0),e([f({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?Fe(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Pe.prototype,"opacity",void 0),e([f({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Pe.prototype,"priority",void 0),e([f({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Pe.prototype,"semantic",void 0),e([f({types:he,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Pe.prototype,"renderer",null),e([f({json:{read:!1}})],Pe.prototype,"cachedDrawingInfo",void 0),e([Se("service","cachedDrawingInfo")],Pe.prototype,"readCachedDrawingInfo",null),e([f({readOnly:!0,json:{read:!1}})],Pe.prototype,"capabilities",null),e([f({type:Boolean,json:{read:!1}})],Pe.prototype,"editingEnabled",null),e([f({readOnly:!0,json:{write:!1,read:!1}})],Pe.prototype,"infoFor3D",null),e([f({readOnly:!0,json:{write:!1,read:!1}})],Pe.prototype,"relationships",null),e([f(Q)],Pe.prototype,"popupEnabled",void 0),e([f({type:r,json:{name:"popupInfo",write:!0}})],Pe.prototype,"popupTemplate",void 0),e([f({readOnly:!0,json:{read:!1}})],Pe.prototype,"defaultPopupTemplate",null),e([f(V)],Pe.prototype,"attributeTableTemplate",void 0),e([f({type:String,json:{read:!1}})],Pe.prototype,"objectIdField",void 0),e([Se("service","objectIdField",["objectIdField","fields"])],Pe.prototype,"readObjectIdField",null),e([f({type:String,json:{read:!1}})],Pe.prototype,"globalIdField",void 0),e([Se("service","globalIdField",["globalIdField","fields"])],Pe.prototype,"readGlobalIdField",null),e([f({readOnly:!0,type:String,json:{read:!1}})],Pe.prototype,"displayField",null),e([f({type:String,json:{read:!1}})],Pe.prototype,"profile",void 0),e([Se("service","profile",["store.profile"])],Pe.prototype,"readProfile",null),e([f({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Pe.prototype,"normalReferenceFrame",void 0),e([f(M)],Pe.prototype,"screenSizePerspectiveEnabled",void 0),e([f({json:{read:!1,origins:{service:{read:!0}}}})],Pe.prototype,"serviceItemId",void 0),e([f(E)],Pe.prototype,"useViewTime",null),Pe=e([m("esri.layers.SceneLayer")],Pe);const Ae={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},Te={"mesh-pyramids":"mesh",points:"point"},xe=Pe;export{xe 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as i}from"../../../core/compilerUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{clone as s}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as l,throwIfAborted as u}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as o}from"../../../core/units.js";import{isSerializable as c}from"../../../core/support/jsonUtils.js";import{isLoaded as y}from"../../../geometry/projectionUtils.js";import{set as h,negativeInfinity as d,create as m,expandWithAABB as f}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as x}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as F,isPolygon as w}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as Q}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as R}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as j}from"./attributeSupport.js";import{cleanFromGeometryEngine as b,getGeometry as E}from"./geometryUtils.js";import{project as T,checkProjectionSupport as A,projectMany as v}from"./projectionSupport.js";import{QueryEngineCache as G}from"./QueryEngineCache.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as C}from"./QueryEngineResult.js";import{queryEngineEmptyResult as O,normalizeAttributeBinsQuery as P,normalizeQueryLike as q,normalizeQuery as z}from"./queryUtils.js";import{validateAttributeBinsQuery as U,validateQuery as B,validateStatisticsQuery as M}from"./queryValidationUtils.js";import{getSpatialQueryOperator as H,canQueryWithRBush as N}from"./spatialQuerySupport.js";import{getTimeExtent as Z,getTimeOperator as J}from"./timeSupport.js";import L from"../../support/FieldsIndex.js";import{ImmediateTask as V}from"../../../views/support/Scheduler.js";const D="unsupported-query";class K{constructor(e,t=null,i,r,s){this.attributes=e,this.geometry=i,this.centroid=r,this.filterFlags=s,this.groupId=-1,this.displayId=t}}class W{constructor(e){this._changeHandle=null,this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new G,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=c(e.fieldsIndex)?e.fieldsIndex:L.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority?this._frameTask=e.scheduler.registerTask(e.priority):this._frameTask=V}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}async executeQuery(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryFeatureSet(e),i)}async executeQueryForCount(e={},t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForCount(e),i)}async executeQueryForExtent(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForExtent(e),i)}async executeQueryForIds(e,t){return Array.from(await this.executeQueryForIdSet(e,t))}async executeQueryForIdSet(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForIdSet(e),i)}async executeQueryForLatestObservations(e,t){const i=l(t);if(!this.timeInfo?.trackIdField)throw new r(D,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});return await this._frameTask.scheduleGenerator(()=>this._executeQueryForLatestObservations(e),i)}async executeQueryForOpaqueFeatures(e,t){const i=l(t);return(await this._frameTask.scheduleGenerator(()=>this._executeQuery(e,{}),i)).items}async executeAttributeBinsQuery(e,t){const i=l(t);return e=s(e),await this._frameTask.scheduleGenerator(()=>this._executeAttributeBinsQuery(e),i)}async executeQueryForSummaryStatistics(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSummaryStatistics(e,t),r)}async executeQueryForUniqueValues(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForUniqueValues(e,t),r)}async executeQueryForClassBreaks(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForClassBreaks(e,t),r)}async executeQueryForHistogram(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForHistogram(e,t),r)}async executeQueryForSnapping(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSnapping(e,i),i)}async fetchRecomputedExtents(e){const t=l(e);this._timeExtentPromise||=Z(this.timeInfo,this.featureStore);const[i,r]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return u(t),{fullExtent:i,timeExtent:r}}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async*_executeQueryFeatureSet(e){try{const t=yield*this._executeQuery(e,{});return yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeQueryForCount(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null});return yield,t.createQueryResponseForCount()}catch(t){if(t!==O)throw t;return 0}}async*_executeQueryForExtent(e){const t=e.outSR;try{const i=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const r=i.size;if(!r)return{count:0,extent:null};const s=await this._getBounds(i.items,i.spatialReference,t??this.spatialReference);return yield,{count:r,extent:s}}catch(i){if(i===O)return{count:0,extent:null};throw i}}async*_executeQueryForIdSet(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const i=t.items,r=new Set;for(const e of i)r.add(t.featureAdapter.getObjectId(e));return r}catch(t){if(t===O)return new Set;throw t}}async*_executeQueryForLatestObservations(e){try{const t=yield*this._executeQuery(e,{});return yield,this._filterLatest(t),yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeAttributeBinsQuery(e){let t;try{e=await P(e,this.definitionExpression,this.spatialReference),yield,e=await U(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield,t=yield*this._executeGeometryQuery(e,i),yield,this._executeAggregateIdsQuery(t),yield,this._executeObjectIdsQuery(t),yield,this._executeTimeQuery(t),yield,this._executeAttributesQuery(t),yield}catch(i){if(i!==O)throw i;t=new C([],e,this)}return await t.createQueryBinsResponse(e)}async*_executeQueryForSummaryStatistics(e={},t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createSummaryStatisticsResponse(t)}async*_executeQueryForUniqueValues(e={},t){const{field:i,field2:r,field3:s,valueExpression:a}=t,n=yield*this._executeQueryForStatistics(e,{field:i,field2:r,field3:s,valueExpression:a});return yield,await n.createUniqueValuesResponse(t)}async*_executeQueryForClassBreaks(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createClassBreaksResponse(t)}async*_executeQueryForHistogram(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createHistogramResponse(t)}async*_executeQueryForSnapping(e,t){const{point:i,distance:r,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let l=s(e.query);l=await q(l,this.definitionExpression,this.spatialReference),yield,l=await B(l,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const u=!S(i.spatialReference,this.spatialReference);u&&(await A(i.spatialReference,this.spatialReference),yield);const o="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,y={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},h=u?T(y,this.spatialReference):y;if(!h)return{candidates:[]};const d=(await Q(_(i),null,{signal:t}))[0];yield;const m=(await Q(_(h),null,{signal:t}))[0];if(yield,null==d||null==m)return{candidates:[]};const f=await this._searchFeatures(X(m.toJSON()));yield;const p=new C(f,l,this);this._executeObjectIdsQuery(p),yield,this._executeTimeQuery(p),yield,this._executeAttributesQuery(p),yield,yield*this._executeGeometryQueryForSnapping(p),yield;const x=d.toJSON(),g=u?T(x,this.spatialReference):x,F=u?Math.max(h.xmax-h.xmin,h.ymax-h.ymin)/2:r;return p.createSnappingResponse({...e,point:g,distance:F},l.returnZ,i.spatialReference)}async _getBounds(e,t,i){const r=h(m(),d);return await this.featureStore.forEachBounds(e,e=>f(r,e)),Y(r,t,i,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async _getAllFeaturesQueryEngineResult(e){return new C(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>i(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async*_executeQuery(e,t){e=s(e),e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await B(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield,e={...e,...t};const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),r}async*_executeSceneFilterQuery(e){if(null==e.sceneFilter)return null;const{outSR:t,returnGeometry:i,returnCentroid:r}=e,s=this.featureStore.featureSpatialReference,a=e.sceneFilter.geometry,n=null==s||S(s,a.spatialReference)?a:T(a,s);if(!n)return null;const l=i||r,u=R(t)&&!S(this.spatialReference,t)&&l?async e=>this._project(e,t):e=>e;yield;const o=this.featureAdapter,c=await this._searchFeatures(X(n));yield;if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const t=new Set;for(const e of c)t.add(o.getObjectId(e));const i=await this._getAllFeatures();yield;const r=await H("esriSpatialRelDisjoint",n,this.geometryType);yield;const s=e=>!t.has(o.getObjectId(e))||r(o.getGeometry(e)),a=yield*this._runSpatialFilter(i,s);yield;const l=new C(a,e,this);return await u(l)}if(!c.length)return new C([],e,this);if(this._canExecuteSinglePass(n,e))return await u(new C(c,e,this));const y=await H("esriSpatialRelContains",n,this.geometryType);yield;const h=yield*this._runSpatialFilter(c,e=>y(o.getGeometry(e)));return yield,await u(new C(h,e,this))}async*_executeGeometryQuery(i,r){if(null!=r&&0===r.items.length)return r;const{geometry:s,outSR:a,returnGeometry:n,returnCentroid:l}=i,u=r?null:this._getCacheKey(i),o=u?this._cache.get(u):null;if(o)return new C(o,i,this);const c=R(a)&&!S(this.spatialReference,a),y=n||l,h=async e=>(c&&y&&await this._project(e,a),u&&this._cache.put(u,e.items),e),d=this.featureStore.featureSpatialReference,m=!s||null==d||S(d,s.spatialReference)?s:T(s,d);if(!m)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));yield;const f=this.featureAdapter;let p=await this._searchFeatures(X(s));yield;const x=i.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!p.length)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of p)e.add(f.getObjectId(i));let t;null!=r?t=r.items:(yield,t=await this._getAllFeatures(),yield);const s=await H(x,m,this.geometryType);yield;const a=t=>!e.has(f.getObjectId(t))||s(f.getGeometry(t)),n=yield*this._runSpatialFilter(t,a);yield;const l=new C(n,i,this);return await h(l)}if(null!=r){const i=new t;p=p.filter(t=>e(r.items,t,r.items.length,i)>=0)}if(!p.length){const e=new C([],i,this);return u&&this._cache.put(u,e.items),e}if(this._canExecuteSinglePass(m,i))return await h(new C(p,i,this));const g=await H(x,m,this.geometryType);yield;const _=yield*this._runSpatialFilter(p,e=>g(f.getGeometry(e)));return yield,await h(new C(_,i,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const r of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(r).forEach(e=>t.add(e))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeTimeQuery(e){if(0===e.items.length)return;const t=J(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=j(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async*_executeGeometryQueryForSnapping(e){const{query:t}=e,{spatialRel:i}=t;if(!e?.items?.length||!t.geometry||!i)return;const r=await H(i,t.geometry,this.geometryType);yield;const s=this.featureAdapter,a=e=>r(s.getGeometry(e)),n=yield*this._runSpatialFilter(e.items,a);e.items=n}*_runSpatialFilter(e,t){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=yield;const r=new Array;for(const s of e)t(s)&&r.push(s),i.madeProgress(),i.done&&(i=yield);return r}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:r}=this.timeInfo,s=r||i,a=new Map,n=this.featureAdapter.getAttribute;for(const l of e.items){const e=n(l,t),i=n(l,s),r=a.get(e);(!r||i>n(r,s))&&a.set(e,l)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:i,returnGeometry:r,returnCentroid:s,outSR:a,resultType:n,cacheHint:l}=e;if("tile"!==n&&!l)return null;const u=r||s;return R(a)&&!S(this.spatialReference,a)&&u?JSON.stringify([t,i,a]):JSON.stringify([t,i])}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return N(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||S(this.spatialReference,t))return e;const r=this.featureAdapter,s=y()?await this._getFullExtent():void 0,a=await v(e.items.map(e=>E(this.geometryType,r.getGeometry(e))),this.spatialReference,t,{areaOfInterestExtent:s});return e.items=i(a.map((t,i)=>r.cloneWithGeometry(e.items[i],I(t,this.hasZ,this.hasM)))),e}async _searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const i=Array.from(t.values());return t.clear(),i}async*_executeQueryForStatistics(e,t){e=s(e);try{e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await M(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),yield,r}catch(i){if(i!==O)throw i;return new C([],e,this)}}get test(){}}function X(e){if(N(e)){if(F(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(w(e))return e.rings.map(e=>p(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1])))}return[g(x(),e)]}function Y(e,t,i,r,s){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:b(r)};s&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=T(a,t,i);if(n.spatialReference=b(i),n.xmax-n.xmin===0){const e=o(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=o(n.spatialReference);n.ymin-=e,n.ymax+=e}if(s&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=o(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{K as Feature,W as QueryEngine,Y as getQueryResultExtent};
5
+ import{indexOf as e,PositionHint as t}from"../../../core/arrayUtils.js";import{toConst as i}from"../../../core/compilerUtils.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{clone as s}from"../../../core/lang.js";import{removeMaybe as a,destroyMaybe as n}from"../../../core/maybe.js";import{signalFromSignalOrOptions as l,throwIfAborted as u}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as o}from"../../../core/units.js";import{isSerializable as c}from"../../../core/support/jsonUtils.js";import{isLoaded as y}from"../../../geometry/projectionUtils.js";import{set as h,create as d,expandWithAABB as m,negativeInfinity as f}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as p,create as x}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../../geometry/support/boundsUtils.js";import{fromJSON as _,isExtent as F,isPolygon as w}from"../../../geometry/support/jsonUtils.js";import{normalizeCentralMeridian as Q}from"../../../geometry/support/normalizeUtils.js";import{equals as S,isValid as R}from"../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as I}from"../featureConversionUtils.js";import{getWhereClause as j}from"./attributeSupport.js";import{getGeometry as b,cleanFromGeometryEngine as E}from"./geometryUtils.js";import{checkProjectionSupport as T,project as A,projectMany as v}from"./projectionSupport.js";import{QueryEngineCache as G}from"./QueryEngineCache.js";import{queryCapabilities as k}from"./QueryEngineCapabilities.js";import{QueryEngineResult as C}from"./QueryEngineResult.js";import{queryEngineEmptyResult as O,normalizeAttributeBinsQuery as P,normalizeQueryLike as q,normalizeQuery as z}from"./queryUtils.js";import{validateAttributeBinsQuery as U,validateQuery as B,validateStatisticsQuery as M}from"./queryValidationUtils.js";import{getSpatialQueryOperator as H,canQueryWithRBush as N}from"./spatialQuerySupport.js";import{getTimeExtent as Z,getTimeOperator as J}from"./timeSupport.js";import L from"../../support/FieldsIndex.js";import{ImmediateTask as V}from"../../../views/support/Scheduler.js";const D="unsupported-query";class K{constructor(e,t=null,i,r,s){this.attributes=e,this.geometry=i,this.centroid=r,this.filterFlags=s,this.groupId=-1,this.displayId=t}}class W{constructor(e){this._changeHandle=null,this.capabilities={query:k},this.geometryType=e.geometryType,this.hasM=!!e.hasM,this.hasZ=!!e.hasZ,this.spatialReference=e.spatialReference,this.definitionExpression=e.definitionExpression,this.featureStore=e.featureStore,this.aggregateAdapter=e.aggregateAdapter,this._cache=e.cache??new G,this.timeInfo=e.timeInfo,this.featureIdInfo=e.featureIdInfo,"object-id"===e.featureIdInfo.type&&(this.objectIdField=e.featureIdInfo.fieldName),this._changeHandle=this.featureStore.events.on("changed",()=>this._clearCache()),this.fieldsIndex=c(e.fieldsIndex)?e.fieldsIndex:L.fromJSON(e.fieldsIndex),!e.availableFields||1===e.availableFields.length&&"*"===e.availableFields[0]?this.availableFields=new Set(this.fieldsIndex.fields.map(e=>e.name)):this.availableFields=new Set(e.availableFields.map(e=>this.fieldsIndex.get(e)?.name).filter(e=>null!=e)),e.scheduler&&e.priority?this._frameTask=e.scheduler.registerTask(e.priority):this._frameTask=V}destroy(){this._changeHandle=a(this._changeHandle),this._frameTask=a(this._frameTask),this._clearCache(),n(this._cache)}get featureAdapter(){return this.featureStore.featureAdapter}async executeQuery(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryFeatureSet(e),i)}async executeQueryForCount(e={},t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForCount(e),i)}async executeQueryForExtent(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForExtent(e),i)}async executeQueryForIds(e,t){return Array.from(await this.executeQueryForIdSet(e,t))}async executeQueryForIdSet(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForIdSet(e),i)}async executeQueryForLatestObservations(e,t){const i=l(t);if(!this.timeInfo?.trackIdField)throw new r(D,"Missing timeInfo or timeInfo.trackIdField",{query:e,timeInfo:this.timeInfo});return await this._frameTask.scheduleGenerator(()=>this._executeQueryForLatestObservations(e),i)}async executeQueryForOpaqueFeatures(e,t){const i=l(t);return(await this._frameTask.scheduleGenerator(()=>this._executeQuery(e,{}),i)).items}async executeAttributeBinsQuery(e,t){const i=l(t);return e=s(e),await this._frameTask.scheduleGenerator(()=>this._executeAttributeBinsQuery(e),i)}async executeQueryForSummaryStatistics(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSummaryStatistics(e,t),r)}async executeQueryForUniqueValues(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForUniqueValues(e,t),r)}async executeQueryForClassBreaks(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForClassBreaks(e,t),r)}async executeQueryForHistogram(e={},t,i){const r=l(i);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForHistogram(e,t),r)}async executeQueryForSnapping(e,t){const i=l(t);return await this._frameTask.scheduleGenerator(()=>this._executeQueryForSnapping(e,i),i)}async fetchRecomputedExtents(e){const t=l(e);this._timeExtentPromise||=Z(this.timeInfo,this.featureStore);const[i,r]=await Promise.all([this._getFullExtent(),this._timeExtentPromise]);return u(t),{fullExtent:i,timeExtent:r}}_clearCache(){this._cache.clear(),this._allFeaturesPromise=null,this._timeExtentPromise=null,this._fullExtentPromise=null}async*_executeQueryFeatureSet(e){try{const t=yield*this._executeQuery(e,{});return yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeQueryForCount(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!1,returnCentroid:!1,outSR:null});return yield,t.createQueryResponseForCount()}catch(t){if(t!==O)throw t;return 0}}async*_executeQueryForExtent(e){const t=e.outSR;try{const i=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const r=i.size;if(!r)return{count:0,extent:null};const s=await this._getBounds(i.items,i.spatialReference,t??this.spatialReference);return yield,{count:r,extent:s}}catch(i){if(i===O)return{count:0,extent:null};throw i}}async*_executeQueryForIdSet(e){try{const t=yield*this._executeQuery(e,{returnGeometry:!0,returnCentroid:!1,outSR:null});yield;const i=t.items,r=new Set;for(const e of i)r.add(t.featureAdapter.getObjectId(e));return r}catch(t){if(t===O)return new Set;throw t}}async*_executeQueryForLatestObservations(e){try{const t=yield*this._executeQuery(e,{});return yield,this._filterLatest(t),yield,await t.createQueryResponse()}catch(t){if(t!==O)throw t;return await new C([],e,this).createQueryResponse()}}async*_executeAttributeBinsQuery(e){let t;try{e=await P(e,this.definitionExpression,this.spatialReference),yield,e=await U(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield,t=yield*this._executeGeometryQuery(e,i),yield,this._executeAggregateIdsQuery(t),yield,this._executeObjectIdsQuery(t),yield,this._executeTimeQuery(t),yield,this._executeAttributesQuery(t),yield}catch(i){if(i!==O)throw i;t=new C([],e,this)}return await t.createQueryBinsResponse(e)}async*_executeQueryForSummaryStatistics(e={},t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createSummaryStatisticsResponse(t)}async*_executeQueryForUniqueValues(e={},t){const{field:i,field2:r,field3:s,valueExpression:a}=t,n=yield*this._executeQueryForStatistics(e,{field:i,field2:r,field3:s,valueExpression:a});return yield,await n.createUniqueValuesResponse(t)}async*_executeQueryForClassBreaks(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createClassBreaksResponse(t)}async*_executeQueryForHistogram(e,t){const{field:i,normalizationField:r,valueExpression:s}=t,a=yield*this._executeQueryForStatistics(e,{field:i,normalizationField:r,valueExpression:s});return yield,await a.createHistogramResponse(t)}async*_executeQueryForSnapping(e,t){const{point:i,distance:r,returnEdge:a,vertexMode:n}=e;if(!a&&"none"===n)return{candidates:[]};let l=s(e.query);l=await q(l,this.definitionExpression,this.spatialReference),yield,l=await B(l,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const u=!S(i.spatialReference,this.spatialReference);u&&(await T(i.spatialReference,this.spatialReference),yield);const o="number"==typeof r?r:r.x,c="number"==typeof r?r:r.y,y={xmin:i.x-o,xmax:i.x+o,ymin:i.y-c,ymax:i.y+c,spatialReference:i.spatialReference},h=u?A(y,this.spatialReference):y;if(!h)return{candidates:[]};const d=(await Q(_(i),null,{signal:t}))[0];yield;const m=(await Q(_(h),null,{signal:t}))[0];if(yield,null==d||null==m)return{candidates:[]};const f=await this._searchFeatures(X(m.toJSON()));yield;const p=new C(f,l,this);this._executeObjectIdsQuery(p),yield,this._executeTimeQuery(p),yield,this._executeAttributesQuery(p),yield,yield*this._executeGeometryQueryForSnapping(p),yield;const x=d.toJSON(),g=u?A(x,this.spatialReference):x,F=u?Math.max(h.xmax-h.xmin,h.ymax-h.ymin)/2:r;return p.createSnappingResponse({...e,point:g,distance:F},l.returnZ,i.spatialReference)}async _getBounds(e,t,i){const r=h(d(),f);return await this.featureStore.forEachBounds(e,e=>m(r,e)),Y(r,t,i,this.spatialReference,this.hasZ)}_getFullExtent(){return this._fullExtentPromise||="getFullExtent"in this.featureStore&&this.featureStore.getFullExtent?Promise.resolve(this.featureStore.getFullExtent(this.spatialReference)):this._getAllFeatures().then(e=>this._getBounds(e,this.spatialReference,this.spatialReference)),this._fullExtentPromise}async _getAllFeaturesQueryEngineResult(e){return new C(await this._getAllFeatures(),e,this)}async _getAllFeatures(){if(null==this._allFeaturesPromise){const e=[];this._allFeaturesPromise=(async()=>await this.featureStore.forEach(t=>e.push(t)))().then(()=>i(e))}const e=this._allFeaturesPromise,t=await e;return e===this._allFeaturesPromise?t.slice():this._getAllFeatures()}async*_executeQuery(e,t){e=s(e),e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await B(e,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield,e={...e,...t};const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),r}async*_executeSceneFilterQuery(e){if(null==e.sceneFilter)return null;const{outSR:t,returnGeometry:i,returnCentroid:r}=e,s=this.featureStore.featureSpatialReference,a=e.sceneFilter.geometry,n=null==s||S(s,a.spatialReference)?a:A(a,s);if(!n)return null;const l=i||r,u=R(t)&&!S(this.spatialReference,t)&&l?async e=>this._project(e,t):e=>e;yield;const o=this.featureAdapter,c=await this._searchFeatures(X(n));yield;if("disjoint"===e.sceneFilter.spatialRelationship){if(!c.length)return null;const t=new Set;for(const e of c)t.add(o.getObjectId(e));const i=await this._getAllFeatures();yield;const r=await H("esriSpatialRelDisjoint",n,this.geometryType);yield;const s=e=>!t.has(o.getObjectId(e))||r(o.getGeometry(e)),a=yield*this._runSpatialFilter(i,s);yield;const l=new C(a,e,this);return await u(l)}if(!c.length)return new C([],e,this);if(this._canExecuteSinglePass(n,e))return await u(new C(c,e,this));const y=await H("esriSpatialRelContains",n,this.geometryType);yield;const h=yield*this._runSpatialFilter(c,e=>y(o.getGeometry(e)));return yield,await u(new C(h,e,this))}async*_executeGeometryQuery(i,r){if(null!=r&&0===r.items.length)return r;const{geometry:s,outSR:a,returnGeometry:n,returnCentroid:l}=i,u=r?null:this._getCacheKey(i),o=u?this._cache.get(u):null;if(o)return new C(o,i,this);const c=R(a)&&!S(this.spatialReference,a),y=n||l,h=async e=>(c&&y&&await this._project(e,a),u&&this._cache.put(u,e.items),e),d=this.featureStore.featureSpatialReference,m=!s||null==d||S(d,s.spatialReference)?s:A(s,d);if(!m)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));yield;const f=this.featureAdapter;let p=await this._searchFeatures(X(s));yield;const x=i.spatialRel??"esriSpatialRelIntersects";if("esriSpatialRelDisjoint"===x){if(!p.length)return await h(null!=r?r:await this._getAllFeaturesQueryEngineResult(i));const e=new Set;for(const i of p)e.add(f.getObjectId(i));let t;null!=r?t=r.items:(yield,t=await this._getAllFeatures(),yield);const s=await H(x,m,this.geometryType);yield;const a=t=>!e.has(f.getObjectId(t))||s(f.getGeometry(t)),n=yield*this._runSpatialFilter(t,a);yield;const l=new C(n,i,this);return await h(l)}if(null!=r){const i=new t;p=p.filter(t=>e(r.items,t,r.items.length,i)>=0)}if(!p.length){const e=new C([],i,this);return u&&this._cache.put(u,e.items),e}if(this._canExecuteSinglePass(m,i))return await h(new C(p,i,this));const g=await H(x,m,this.geometryType);yield;const _=yield*this._runSpatialFilter(p,e=>g(f.getGeometry(e)));return yield,await h(new C(_,i,this))}_executeAggregateIdsQuery(e){if(0===e.items.length||!e.query.aggregateIds?.length||null==this.aggregateAdapter)return;const t=new Set;for(const r of e.query.aggregateIds){this.aggregateAdapter.getFeatureObjectIds(r).forEach(e=>t.add(e))}const i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeObjectIdsQuery(e){if(0===e.items.length||!e.query.objectIds?.length)return;const t=new Set(e.query.objectIds),i=this.featureAdapter.getObjectId;e.items=e.items.filter(e=>t.has(i(e)))}_executeTimeQuery(e){if(0===e.items.length)return;const t=J(this.timeInfo,e.query.timeExtent,this.featureAdapter);null!=t&&(e.items=e.items.filter(t))}_executeAttributesQuery(e){if(0===e.items.length)return;const t=j(e.query.where,this.fieldsIndex);if(t){if(!t.isStandardized)throw new TypeError("Where clause is not standardized");e.items=e.items.filter(e=>t.testFeature(e,this.featureAdapter))}}async*_executeGeometryQueryForSnapping(e){const{query:t}=e,{spatialRel:i}=t;if(!e?.items?.length||!t.geometry||!i)return;const r=await H(i,t.geometry,this.geometryType);yield;const s=this.featureAdapter,a=e=>r(s.getGeometry(e)),n=yield*this._runSpatialFilter(e.items,a);e.items=n}*_runSpatialFilter(e,t){if(!t)return e;if(null==this._frameTask)return e.filter(e=>t(e));let i=yield;const r=new Array;for(const s of e)t(s)&&r.push(s),i.madeProgress(),i.done&&(i=yield);return r}_filterLatest(e){const{trackIdField:t,startTimeField:i,endTimeField:r}=this.timeInfo,s=r||i,a=new Map,n=this.featureAdapter.getAttribute;for(const l of e.items){const e=n(l,t),i=n(l,s),r=a.get(e);(!r||i>n(r,s))&&a.set(e,l)}e.items=Array.from(a.values())}_getCacheKey(e){const{geometry:t,spatialRel:i,returnGeometry:r,returnCentroid:s,outSR:a,resultType:n,cacheHint:l}=e;if("tile"!==n&&!l)return null;const u=r||s;return R(a)&&!S(this.spatialReference,a)&&u?JSON.stringify([t,i,a]):JSON.stringify([t,i])}_canExecuteSinglePass(e,t){const{spatialRel:i}=t;return N(e)&&("esriSpatialRelEnvelopeIntersects"===i||"esriGeometryPoint"===this.geometryType&&("esriSpatialRelIntersects"===i||"esriSpatialRelContains"===i))}async _project(e,t){if(!t||S(this.spatialReference,t))return e;const r=this.featureAdapter,s=y()?await this._getFullExtent():void 0,a=await v(e.items.map(e=>b(this.geometryType,r.getGeometry(e))),this.spatialReference,t,{areaOfInterestExtent:s});return e.items=i(a.map((t,i)=>r.cloneWithGeometry(e.items[i],I(t,this.hasZ,this.hasM)))),e}async _searchFeatures(e){const t=new Set;await Promise.all(e.map(e=>this.featureStore.forEachInBounds(e,e=>t.add(e))));const i=Array.from(t.values());return t.clear(),i}async*_executeQueryForStatistics(e,t){e=s(e);try{e=await z(e,this.definitionExpression,this.spatialReference),yield,e=await M(e,t,{availableFields:this.availableFields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,spatialReference:this.spatialReference}),yield;const i=yield*this._executeSceneFilterQuery(e);yield;const r=yield*this._executeGeometryQuery(e,i);return yield,this._executeAggregateIdsQuery(r),yield,this._executeObjectIdsQuery(r),yield,this._executeTimeQuery(r),yield,this._executeAttributesQuery(r),yield,r}catch(i){if(i!==O)throw i;return new C([],e,this)}}get test(){}}function X(e){if(N(e)){if(F(e))return[p(Math.min(e.xmin,e.xmax),Math.min(e.ymin,e.ymax),Math.max(e.xmin,e.xmax),Math.max(e.ymin,e.ymax))];if(w(e))return e.rings.map(e=>p(Math.min(e[0][0],e[2][0]),Math.min(e[0][1],e[2][1]),Math.max(e[0][0],e[2][0]),Math.max(e[0][1],e[2][1])))}return[g(x(),e)]}function Y(e,t,i,r,s){const a={xmin:e[0],ymin:e[1],xmax:e[3],ymax:e[4],spatialReference:E(r)};s&&isFinite(e[2])&&isFinite(e[5])&&(a.zmin=e[2],a.zmax=e[5],a.hasZ=!0);const n=A(a,t,i);if(n.spatialReference=E(i),n.xmax-n.xmin===0){const e=o(n.spatialReference);n.xmin-=e,n.xmax+=e}if(n.ymax-n.ymin===0){const e=o(n.spatialReference);n.ymin-=e,n.ymax+=e}if(s&&null!=n.zmin&&null!=n.zmax&&n.zmax-n.zmin===0){const e=o(n.spatialReference);n.zmin-=e,n.zmax+=e}return n}export{K as Feature,W as QueryEngine,Y as getQueryResultExtent};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as i}from"../../../geometry/support/centroid.js";import{getPolygonExtent as s,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as m}from"./geometryUtils.js";import{project as d}from"./projectionSupport.js";import{getDateInNumber as f}from"./queryUtils.js";import{SnappingCandidateEdge as p,SnappingCandidateVertex as h}from"./SnappingCandidate.js";import{isDateField as y,isDateOnlyField as g,isTimestampOffsetField as x,isStringField as T,isTimeOnlyField as F}from"../../support/fieldUtils.js";import I from"../../../rest/support/AutoIntervalBinParameters.js";import _ from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import V from"../../../rest/support/FixedBoundariesBinParameters.js";import v from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as b,calculateStatistics as R,processSummaryStatisticsResult as B,calculateUniqueValuesCount as z,createUVResult as M,calculateClassBreaks as A,resolveCBResult as N,calculateHistogram as w,getAttributeComparator as D,calculatePercentile as P,binIndex as q,getBinParams as j,isNullCountSupported as Z}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as C}from"luxon";const O="bin";class E{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasM=i.hasM,this.hasZ=i.hasZ,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const n=new Map,r=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!r.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,n);i.push(t)}r.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:s,items:a}=u[t],n=s.join(",");i&&!e.validateItems(a,i)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...d(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,a=Q(this.hasZ,this.hasM),{point:n,mode:r}=e,o="number"==typeof e.distance?e.distance:e.distance.x,l="number"==typeof e.distance?e.distance:e.distance.y,u={candidates:[]},c="esriGeometryPolygon"===this.geometryType,m="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,d=this._getPointCreator(r,t,this.spatialReference,i),f=new U(null,0),y=new U(null,0),g={x:0,y:0,z:0};for(const x of this.items){const t=s.getGeometry(x);if(null==t)continue;const{coords:i}=t,r=t.isPoint?J:t.lengths;if(f.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const r=f;r.coordsIndex=e;const h=y;h.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,n,r,h))continue;const F=(n.x-T.x)/o,I=(n.y-T.y)/l,_=F*F+I*I;_<=1&&u.candidates.push(new p(s.getObjectId(x),d(T),Math.sqrt(_),d(r),d(h)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],m=e,p=y;p.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=f;if(a.coordsIndex=e,c&&t===i-1&&a.x===p.x&&a.y===p.y)continue;const r=(n.x-a.x)/o,m=(n.y-a.y)/l,y=r*r+m*m;y<=1&&u.candidates.push(new h(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<r.length;i++){t.push(e);const s=r[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=f;e.coordsIndex=i;const t=(n.x-e.x)/o,a=(n.y-e.y)/l,r=t*t+a*a;r<=1&&u.candidates.push(new h(s.getObjectId(x),d(e),Math.sqrt(r)))}}}return u.candidates.sort((e,t)=>e.distance-t.distance),u}_getPointCreator(e,t,i,s){const a=null==s||o(i,s)?e=>e:e=>d(e,i,s),{hasZ:n}=this,r=0;return"3d"===e?n&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:r}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=y(m)||g(m)||x(m),f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),p=Z({normalizationType:a,normalizationField:s,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},F=T(m)?b({values:f,supportsNullCount:p,percentileParams:h,outStatisticTypes:c}):R({values:f,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:p,percentileParams:h,outStatisticTypes:c});return B(F,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:n,timeZone:r},this.items,!1),l=z(o);return M(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),p=A(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return N(p,r)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return w(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const t=s.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=D(n?.type,r,"case-sensitive");e.sort((e,t)=>{const s=i(e,a,n),r=i(t,a,n);return o(s,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:f,returnZ:p,returnM:h}=e,y=null!=d&&t.length>(f||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&h,hasZ:a&&p,objectIdFieldName:r,spatialReference:u(c||o),transform:m&&n(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:f,resultOffset:p,resultRecordCount:h,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),n=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:c(this.geometryType,a,f,e,x,T)});t&&a&&!n.geometry&&(n.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),F[I++]=n}else if(!u&&d)for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e),geometry:c(this.geometryType,this.featureAdapter.getGeometry(s),f,e,x,T)})}else for(const n of _){const e=i.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const S=p||0;if(null!=h){const e=S+h;F=F.slice(S,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{const t=Q(this.hasZ,this.hasM),i=this.featureAdapter;e=this.items.reduce((e,t)=>{const s=i.getGeometry(t);return e+(null!=s&&s.coords.length||0)},0)/t>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,n=new Map,r=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:f,resultRecordCount:p}=e,h=m?.length,y=!!h,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,f=l,p="exceedslimit"!==c?l.onStatisticField:void 0,F="percentile_disc"===c||"percentile_cont"===c,I="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===h&&(p===g||x)&&"count"===c;if(y){if(!r.has(p)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}r.set(p,this._calculateUniqueValues(e,t,!I&&u.returnDistinctValues))}const i=r.get(p);if(!i)continue;const s=Object.keys(i);for(const n of s){const{count:s,data:r,items:l,itemPositions:c}=i[n],h=r.join(",");if(!d||u.validateItems(l,d)){const i=o.get(h)||{attributes:{}};if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(f,l);i.aggregateGeometries[t]=e}else{let n=null;if(_)n=s;else{const e=this._getAttributeValues(u,p,t,a),i=c.map(t=>e[t]);n=F&&"statisticParameters"in f?this._getPercentileValue(f,i):this._getStatisticValue(f,i,null,u.returnDistinctValues)}i.attributes[e]=n}let n=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,i)}}}else if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(f,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,p,t,a);i.attributes[e]=F&&"statisticParameters"in f?this._getPercentileValue(f,s):this._getStatisticValue(f,s,n,u.returnDistinctValues)}const S="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(p))&&!this._isAnyDateField(p)?null:this.fieldsIndex.get(p)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,f,(e,t)=>e.attributes[t]),p&&(F.length=Math.min(p,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return y(t)||g(t)||x(t)||F(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:f}=this,p=n.map(e=>c(f,m.getGeometry(e))),h=r(d,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?s(h):a(o(d,p));y.aggregateGeometries={...e,spatialReference:d},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):i(a(o(d,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:n}=e;let r=null;r=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?b({values:t,returnDistinct:s}):R({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:n,orderBy:r}=s,o=this.fieldsIndex.get(i);return P(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),n=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,n),n}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==s[o]?s[o]={count:1,data:r,items:[a],itemPositions:[n]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(n))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(i,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(i,e(t),s)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,n=t.max??0,r=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=n){const e=q(s,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,n=[],r=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:O,alias:O,type:"esriFieldTypeInteger"}],o=new l(e,this.featureAdapter,this.fieldsIndex),u=new Map,c=[...this.items];this._sortFeatures(c,[i],(e,t,i)=>o.getFieldValue(e,t,i));const m=this._getAttributeValues(o,i,c,u),d=this._calculateUniqueValues([m],c,o.returnDistinctValues);for(const l in d){const{items:t}=d[l],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(I.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(_.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(V.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(v.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=j(c,{field:s,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:f(l,!1),maxValue:f(u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l}=e,u=a.unit,c=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},i),m=F(this.fieldsIndex.get(s)),d=S.toJSON(u),p=c.filter(Boolean).sort((e,t)=>e-t),h=null!=n?f(n,m):p[0],y=null!=r?f(r,m):p[p.length-1],g=[];if(null!=h&&null!=y){const e={zone:t.outTimeReference?.ianaTimeZone??G},i=C.fromMillis(h,e),s=C.fromMillis(y,e);if("last"===o){let e=s;for(;e>i;){const t=e.minus({[d]:a.value});if(t<i){g.unshift([l?t.toMillis():i.toMillis(),e.toMillis()]);break}g.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?i:i.startOf(d);for(;e<=s;){const t=e.plus({[d]:a.value});if(t>s){g.push([e.toMillis(),l?t.toMillis():s.toMillis()]);break}g.push([e.toMillis(),t.toMillis()]),e=t}}}const x=this._calculateHistogramBins(c,{intervals:g,min:h,max:y},i);return this._createFeaturesFromHistogramBins(x,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),n=F(this.fieldsIndex.get(s)),r=e.boundaries.map(e=>f(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:n,end:r}=e,o=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),l=F(this.fieldsIndex.get(s)),u=j(o,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:f(n,l),maxValue:f(r,l)},!0),c=this._calculateHistogramBins(o,u,i);return this._createFeaturesFromHistogramBins(c,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",n=i||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:O,alias:O,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const f of e){const{minValue:e,maxValue:i,items:s}=f,p={attributes:{}};let h;if(p.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,p.attributes[n]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),p.attributes[O]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...p.attributes}:{...t,...p.attributes}}))):(p.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(p))):(t.bin?.splitBy&&(p.attributes[O]=++c),h=await this._createStatisticsQueryResponse(t,s,p),r.push(p)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function H(e,t,i,s){const a=s.x-i.x,n=s.y-i.y,r=t.x-i.x,o=t.y-i.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+n*c,!0}function Q(e,t){return e?t?4:3:t?3:2}class U{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const J=[1];export{E as QueryEngineResult};
5
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as i}from"../../../geometry/support/centroid.js";import{getPolygonExtent as s,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as r,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as m}from"./geometryUtils.js";import{project as d}from"./projectionSupport.js";import{getDateInNumber as f}from"./queryUtils.js";import{SnappingCandidateEdge as p,SnappingCandidateVertex as h}from"./SnappingCandidate.js";import{isDateField as y,isDateOnlyField as g,isTimestampOffsetField as x,isStringField as T,isTimeOnlyField as F}from"../../support/fieldUtils.js";import I from"../../../rest/support/AutoIntervalBinParameters.js";import _ from"../../../rest/support/DateBinParameters.js";import{unitsDict as S}from"../../../rest/support/DateBinUtils.js";import V from"../../../rest/support/FixedBoundariesBinParameters.js";import v from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as b,calculateStringStatistics as R,calculateStatistics as B,processSummaryStatisticsResult as z,calculateUniqueValuesCount as M,createUVResult as A,calculateClassBreaks as N,resolveCBResult as w,calculateHistogram as D,getAttributeComparator as P,calculatePercentile as q,binIndex as j,getBinParams as Z}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as C}from"luxon";const O="bin";class E{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasM=i.hasM,this.hasZ=i.hasZ,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const n=new Map,r=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!r.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,n);i.push(t)}r.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:s,items:a}=u[t],n=s.join(",");i&&!e.validateItems(a,i)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;r(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...d(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,a=Q(this.hasZ,this.hasM),{point:n,mode:r}=e,o="number"==typeof e.distance?e.distance:e.distance.x,l="number"==typeof e.distance?e.distance:e.distance.y,u={candidates:[]},c="esriGeometryPolygon"===this.geometryType,m="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,d=this._getPointCreator(r,t,this.spatialReference,i),f=new U(null,0),y=new U(null,0),g={x:0,y:0,z:0};for(const x of this.items){const t=s.getGeometry(x);if(null==t)continue;const{coords:i}=t,r=t.isPoint?J:t.lengths;if(f.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const r=f;r.coordsIndex=e;const h=y;h.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,n,r,h))continue;const F=(n.x-T.x)/o,I=(n.y-T.y)/l,_=F*F+I*I;_<=1&&u.candidates.push(new p(s.getObjectId(x),d(T),Math.sqrt(_),d(r),d(h)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],m=e,p=y;p.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=f;if(a.coordsIndex=e,c&&t===i-1&&a.x===p.x&&a.y===p.y)continue;const r=(n.x-a.x)/o,m=(n.y-a.y)/l,y=r*r+m*m;y<=1&&u.candidates.push(new h(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<r.length;i++){t.push(e);const s=r[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=f;e.coordsIndex=i;const t=(n.x-e.x)/o,a=(n.y-e.y)/l,r=t*t+a*a;r<=1&&u.candidates.push(new h(s.getObjectId(x),d(e),Math.sqrt(r)))}}}return u.candidates.sort((e,t)=>e.distance-t.distance),u}_getPointCreator(e,t,i,s){const a=null==s||o(i,s)?e=>e:e=>d(e,i,s),{hasZ:n}=this,r=0;return"3d"===e?n&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:r}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=y(m)||g(m)||x(m),f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),p=b({normalizationType:a,normalizationField:s,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},F=T(m)?R({values:f,supportsNullCount:p,percentileParams:h,outStatisticTypes:c}):B({values:f,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:p,percentileParams:h,outStatisticTypes:c});return z(F,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:n,timeZone:r},this.items,!1),l=M(o);return A(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),p=N(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return w(p,r)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,f=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return D(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const t=s.split(" "),a=t[0],n=this.fieldsIndex.get(a),r=!!t[1]&&"desc"===t[1].toLowerCase(),o=P(n?.type,r,"case-sensitive");e.sort((e,t)=>{const s=i(e,a,n),r=i(t,a,n);return o(s,r)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:f,returnZ:p,returnM:h}=e,y=null!=d&&t.length>(f||0)+d,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&h,hasZ:a&&p,objectIdFieldName:r,spatialReference:u(c||o),transform:m&&n(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:f,resultOffset:p,resultRecordCount:h,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,r,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),n=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:c(this.geometryType,a,f,e,x,T)});t&&a&&!n.geometry&&(n.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),F[I++]=n}else if(!u&&d)for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of _)F[I++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e),geometry:c(this.geometryType,this.featureAdapter.getGeometry(s),f,e,x,T)})}else for(const n of _){const e=i.getAttributes(n);e&&(F[I++]=this._addFeatureJSONMetadata(n,{attributes:e}))}const S=p||0;if(null!=h){const e=S+h;F=F.slice(S,Math.min(F.length,e))}return F}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{const t=Q(this.hasZ,this.hasM),i=this.featureAdapter;e=this.items.reduce((e,t)=>{const s=i.getGeometry(t);return e+(null!=s&&s.coords.length||0)},0)/t>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,n=new Map,r=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:f,resultRecordCount:p}=e,h=m?.length,y=!!h,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,f=l,p="exceedslimit"!==c?l.onStatisticField:void 0,F="percentile_disc"===c||"percentile_cont"===c,I="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===h&&(p===g||x)&&"count"===c;if(y){if(!r.has(p)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}r.set(p,this._calculateUniqueValues(e,t,!I&&u.returnDistinctValues))}const i=r.get(p);if(!i)continue;const s=Object.keys(i);for(const n of s){const{count:s,data:r,items:l,itemPositions:c}=i[n],h=r.join(",");if(!d||u.validateItems(l,d)){const i=o.get(h)||{attributes:{}};if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(f,l);i.aggregateGeometries[t]=e}else{let n=null;if(_)n=s;else{const e=this._getAttributeValues(u,p,t,a),i=c.map(t=>e[t]);n=F&&"statisticParameters"in f?this._getPercentileValue(f,i):this._getStatisticValue(f,i,null,u.returnDistinctValues)}i.attributes[e]=n}let n=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,i)}}}else if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(f,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,p,t,a);i.attributes[e]=F&&"statisticParameters"in f?this._getPercentileValue(f,s):this._getStatisticValue(f,s,n,u.returnDistinctValues)}const S="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(p))&&!this._isAnyDateField(p)?null:this.fieldsIndex.get(p)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,f,(e,t)=>e.attributes[t]),p&&(F.length=Math.min(p,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return y(t)||g(t)||x(t)||F(t)}async _getAggregateGeometry(e,n){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:f}=this,p=n.map(e=>c(f,m.getGeometry(e))),h=r(d,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=h?s(h):a(o(d,p));y.aggregateGeometries={...e,spatialReference:d},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=h?t(h):i(a(o(d,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=h,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:n}=e;let r=null;r=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?R({values:t,returnDistinct:s}):B({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:n,orderBy:r}=s,o=this.fieldsIndex.get(i);return q(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),n=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,n),n}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==s[o]?s[o]={count:1,data:r,items:[a],itemPositions:[n]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(n))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=t;return n?a.getExpressionValues(i,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(i,e(t),s)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,n=t.max??0,r=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=n){const e=j(s,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,n=[],r=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:O,alias:O,type:"esriFieldTypeInteger"}],o=new l(e,this.featureAdapter,this.fieldsIndex),u=new Map,c=[...this.items];this._sortFeatures(c,[i],(e,t,i)=>o.getFieldValue(e,t,i));const m=this._getAttributeValues(o,i,c,u),d=this._calculateUniqueValues([m],c,o.returnDistinctValues);for(const l in d){const{items:t}=d[l],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(I.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(_.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(V.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(v.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=Z(c,{field:s,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:f(l,!1),maxValue:f(u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l}=e,u=a.unit,c=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},i),m=F(this.fieldsIndex.get(s)),d=S.toJSON(u),p=c.filter(Boolean).sort((e,t)=>e-t),h=null!=n?f(n,m):p[0],y=null!=r?f(r,m):p[p.length-1],g=[];if(null!=h&&null!=y){const e={zone:t.outTimeReference?.ianaTimeZone??G},i=C.fromMillis(h,e),s=C.fromMillis(y,e);if("last"===o){let e=s;for(;e>i;){const t=e.minus({[d]:a.value});if(t<i){g.unshift([l?t.toMillis():i.toMillis(),e.toMillis()]);break}g.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?i:i.startOf(d);for(;e<=s;){const t=e.plus({[d]:a.value});if(t>s){g.push([e.toMillis(),l?t.toMillis():s.toMillis()]);break}g.push([e.toMillis(),t.toMillis()]),e=t}}}const x=this._calculateHistogramBins(c,{intervals:g,min:h,max:y},i);return this._createFeaturesFromHistogramBins(x,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),n=F(this.fieldsIndex.get(s)),r=e.boundaries.map(e=>f(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:n,end:r}=e,o=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),l=F(this.fieldsIndex.get(s)),u=Z(o,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:f(n,l),maxValue:f(r,l)},!0),c=this._calculateHistogramBins(o,u,i);return this._createFeaturesFromHistogramBins(c,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",n=i||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:O,alias:O,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const f of e){const{minValue:e,maxValue:i,items:s}=f,p={attributes:{}};let h;if(p.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,p.attributes[n]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),p.attributes[O]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...p.attributes}:{...t,...p.attributes}}))):(p.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(p))):(t.bin?.splitBy&&(p.attributes[O]=++c),h=await this._createStatisticsQueryResponse(t,s,p),r.push(p)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function H(e,t,i,s){const a=s.x-i.x,n=s.y-i.y,r=t.x-i.x,o=t.y-i.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+n*c,!0}function Q(e,t){return e?t?4:3:t?3:2}class U{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const J=[1];export{E as QueryEngineResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{throwIfAborted as t,after as r,throwIfAbortError as o}from"../../../../core/promiseUtils.js";import{Milliseconds as n}from"../../../../core/time.js";import{join as a,parseData as i}from"../../../../core/urlUtils.js";import{generateBracedUUID as c}from"../../../../core/uuid.js";import u from"../../../../geometry/SpatialReference.js";import{externalIsOnService as l,externalSourceToMultiPart as p,assetFormatId as m,ServiceAsset as f,ServiceAssetPart as d}from"../../../../geometry/support/meshUtils/External.js";import{UnsupportedError as g,NoSupportedSourceError as y,NoGlbSupportError as w,Convert3DFailedError as h,UnsupportedFormatUploadedError as P,BadResponseError as b,UploadFailedError as j,NotBase64Error as T,UnableToPrepareOptionsError as v}from"./uploadAssetErrors.js";import{uploadProgressWeights as A}from"./uploadProgressWeights.js";import{uploadItem as S}from"./uploads.js";import{getPrjFormatId as F,getWorldFileFormatId as R,getGlbFormatId as U,getMimeTypeFormatId as x,getFormatIdMimeType as D}from"../../../support/infoFor3D.js";import{getMeshTransformForMetersToSpatialReference as N}from"../../../support/meshSpatialReferenceScaleUtils.js";import{extractMeshFeatureTransform as E,extractMeshFeatureOrigin as C}from"../../../../rest/support/meshFeatureAttributes.js";import{makeProgressManager as O,estimatedConversionTime as k,simulateProgress as I}from"../../../../support/progressUtils.js";async function B(e,s,t){const r=e.length;if(!r)return t?.onProgress?.(1),[];const o=O(r,t?.onProgress,"uploadAssets");return Promise.all(e.map((e,r)=>q(e,s,{...t,onProgress:o.makeOnProgress(r)})))}async function q(e,{layer:s,ongoingUploads:t},r){const o=t.get(e);if(o)return o;if(!ne(s))throw new g;if(L(e,s))return r?.onProgress?.(1),e;const n=H(e,s,r);t.set(e,n);try{await n}finally{t.delete(e)}return e}function L(e,s){const{parsedUrl:t}=s;return null!=t&&e.metadata.externalSources.some(e=>l(e,t))}async function H(e,s,r){const{metadata:o}=e,{displaySource:n}=o,a=W(n?.source,s,{checkForConversionRequired:!has("disable-feature:georeferenced-uploads")}),i=null!=a?$(a,s,r):o.externalSources.length>0?J(e,s,r):z(e,s,r),c=await i;return t(r),e.addExternalSources([c]),e}async function $(e,s,t){return{source:{type:"service",assets:await Q(e,s,t)},original:!0,unitConversionDisabled:!0}}async function J(e,s,t){const r=ae(s),{externalSources:o}=e.metadata,n=M(o,s);if(!n)throw new y;const a=O(A.uploadConvertibleSource,t?.onProgress,"uploadConvertibleSource"),i={type:"service",assets:await Q(n,s,{onProgress:a.makeOnProgress("uploadEditSource")})};e.addExternalSources([{source:i,original:!0}]);const c=n.reduce((e,{asset:s})=>s instanceof File?e+s.size:e,0),u=a.simulate("serviceAssetsToGlb",k(c));try{const{source:o,transform:n,origin:a}=await se(i,s,r);return e.transform=n,a&&(e.metadata.georeferenced=!0,t?.useAssetOrigin&&(e.vertexSpace.origin=[a.x,a.y,a.z??0],e.spatialReference=a.spatialReference)),{source:o,unitConversionDisabled:!0}}finally{u.remove()}}async function z(e,s,t){const r=O(A.uploadLocalMesh,t?.onProgress,"uploadLocalMesh"),o=G(e,s,{...t,onProgress:r.makeOnProgress("meshToAssetBlob")});return{source:{type:"service",assets:await V([o],s,{...t,onProgress:r.makeOnProgress("uploadAssetBlobs")})},extent:e.extent.clone(),original:!0}}async function G(e,s,r){const o=ae(s),n=await e.load(r),a=await n.toBinaryGLTF({origin:n.origin,signal:r?.signal,ignoreLocalTransform:!0,unitConversionDisabled:!0});return t(r),{blob:new Blob([a],{type:"model/gltf-binary"}),assetName:`${c()}.glb`,assetType:o}}function M(e,s){for(const t of e){const e=W(t.source,s);if(e)return e}return null}function W(e,{infoFor3D:s},t={}){if(!e)return null;const r=p(e);if(!r)return null;const{supportedFormats:o,editFormats:n}=s,a=new Array,i=F(s),c=R(s);let u=!1;for(const l of r){const e=K(l,o);if(!e)return null;const{assetType:s}=e;if(t.checkForConversionRequired&&(s===i||s===c))return null;n.includes(s)&&(u=!0),a.push(e)}return u?a:null}function K(e,s){const t=m(e,s);return t?{asset:e,assetType:t}:null}async function Q(e,s,t){return V(e.map(e=>X(e,t)),s,t)}async function V(e,s,r){const o=O(A.uploadAssetBlobs,r?.onProgress,"uploadAssetBlobs"),n=await Z(e,s,{...r,onProgress:o.makeOnProgress("prepareAssetItems")});t(r);const a=n.map(({item:e})=>e),{uploadResults:i}=await _(a,s,{...r,onProgress:o.makeOnProgress("uploadAssetItems")});return t(r),e.map((e,t)=>ee(n[t],i[t],s))}async function X(e,s){const{asset:r,assetType:o}=e;if(r instanceof File)return{blob:r,assetName:r.name,assetType:o};const n=await r.toBlob(s);return t(s),{blob:n,assetName:r.assetName,assetType:o}}async function Y(e,s,r){const{blob:n,assetType:a,assetName:c}=e;let u=null;try{const e=await S({data:n,name:c},s.url,r);t(r),u={assetType:a,assetUploadId:e.itemID}}catch(l){o(l),ie().warnOnce(`Service ${s.url} does not support the REST Uploads API.`)}if(!u){const e=await i(n);if(t(r),!e.isBase64)throw new T;u={assetType:a,assetData:e.data}}if(!u)throw new v;return{item:u,assetName:c}}function Z(e,s,r){const o=O(e.length,r?.onProgress,"prepareAssetItems");return Promise.all(e.map(async(e,n)=>{const a=Y(await e,s,{...r,onProgress:o.makeOnProgress(n)});return t(r),a}))}async function _(s,r,o){const n=I(o?.onProgress);try{const n=await e(a(r.parsedUrl.path,"uploadAssets"),{timeout:0,query:{f:"json",assets:JSON.stringify(s)},method:"post",responseType:"json"});if(t(o),n.data.uploadResults.length!==s.length)throw new b(s.length,n.data.uploadResults.length);return n.data}finally{n.remove()}}function ee(e,s,t){const{success:r}=s;if(!r){const{error:t}=s;throw new j(e.assetName,t)}const{assetHash:o}=s,{assetName:n,item:{assetType:a}}=e,{infoFor3D:{supportedFormats:i}}=t,c=D(a,i);if(!c)throw new P(a);return new f(n,c,[new d(`${t.parsedUrl.path}/assets/${o}`,o)])}async function se({assets:e},s,t){const r=e.map(({assetName:e,parts:s})=>({assetName:e,assetHash:s[0].partHash}));let o;try{const e=a(s.parsedUrl.path,"convert3D"),n=s.capabilities?.operations.supportsAsyncConvert3D;o=(await(n?oe:re)(e,{query:{f:"json",assets:JSON.stringify(r),transportType:"esriTransportTypeUrl",targetFormat:t,async:n},responseType:"json",timeout:0})).data}catch(n){throw new h}return te(s,o)}function te(e,s){const t={source:{type:"service",assets:s.assets.map(s=>{const t=x(s.contentType,e.infoFor3D.supportedFormats);if(!t)throw new P(t);return new f(s.assetName,s.contentType,[new d(s.assetURL,s.assetHash)])})},origin:void 0,transform:void 0};if(!has("disable-feature:georeferenced-uploads")&&s.transform){if(t.transform=E(s.transform),s.spatialReference){const e=u.fromJSON(s.spatialReference);t.origin=C(s.transform,e)}}else t.transform=N(e.spatialReference);return t}function re(s,t){return e(s,t)}async function oe(s,t){const o=(await e(s,t)).data.statusUrl;for(;;){const s=(await e(o,{query:{f:"json"},responseType:"json"})).data;switch(s.status){case"Completed":return e(s.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new Error(s.status);case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new Error}await r(ce)}}function ne(e){return!!e.infoFor3D&&!!e.url}function ae({infoFor3D:e}){const s=U(e);if(!s)throw new w;return s}function ie(){return s.getLogger("esri.layers.graphics.sources.support.uploadAssets")}const ce=n(1e3);export{B as uploadAssets};
5
+ import e from"../../../../request.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{throwIfAborted as t,after as r,throwIfAbortError as o}from"../../../../core/promiseUtils.js";import{Milliseconds as n}from"../../../../core/time.js";import{join as a,parseData as i}from"../../../../core/urlUtils.js";import{generateBracedUUID as c}from"../../../../core/uuid.js";import{projectWithZConversion as u}from"../../../../geometry/projectionUtils.js";import l from"../../../../geometry/SpatialReference.js";import{externalIsOnService as p,externalSourceToMultiPart as m,assetFormatId as f,ServiceAsset as g,ServiceAssetPart as d}from"../../../../geometry/support/meshUtils/External.js";import{UnsupportedError as y,NoSupportedSourceError as h,NoGlbSupportError as w,Convert3DFailedError as P,UnsupportedFormatUploadedError as j,BadResponseError as b,UploadFailedError as T,NotBase64Error as v,UnableToPrepareOptionsError as x}from"./uploadAssetErrors.js";import{uploadProgressWeights as A}from"./uploadProgressWeights.js";import{uploadItem as S}from"./uploads.js";import{getPrjFormatId as F,getWorldFileFormatId as U,getGlbFormatId as R,getMimeTypeFormatId as D,getFormatIdMimeType as N}from"../../../support/infoFor3D.js";import{getMeshTransformForMetersToSpatialReference as E}from"../../../support/meshSpatialReferenceScaleUtils.js";import{extractMeshFeatureTransform as C,extractMeshFeatureOrigin as O}from"../../../../rest/support/meshFeatureAttributes.js";import{makeProgressManager as k,estimatedConversionTime as I,simulateProgress as B}from"../../../../support/progressUtils.js";async function q(e,s,t){const r=e.length;if(!r)return t?.onProgress?.(1),[];const o=k(r,t?.onProgress,"uploadAssets");return Promise.all(e.map((e,r)=>L(e,s,{...t,onProgress:o.makeOnProgress(r)})))}async function L(e,{layer:s,ongoingUploads:t},r){const o=t.get(e);if(o)return o;if(!ae(s))throw new y;if(H(e,s))return r?.onProgress?.(1),{mesh:e};const n=$(e,s,r);t.set(e,n);try{return await n}finally{t.delete(e)}}function H(e,s){const{parsedUrl:t}=s;return null!=t&&e.metadata.externalSources.some(e=>p(e,t))}async function $(e,s,r){const{metadata:o}=e,{displaySource:n}=o,a=K(n?.source,s,{checkForConversionRequired:!0}),i=null!=a?J(e,a,s,r):o.externalSources.length>0?z(e,s,r):G(e,s,r),{external:c,info:u}=await i;return t(r),e.addExternalSources([c]),u}async function J(e,s,t,r){return{external:{source:{type:"service",assets:await V(s,t,r)},original:!0,unitConversionDisabled:!0},info:{mesh:e}}}async function z(e,s,t){const r=ie(s),{externalSources:o}=e.metadata,n=W(o,s);if(!n)throw new h;const a=k(A.uploadConvertibleSource,t?.onProgress,"uploadConvertibleSource"),i={type:"service",assets:await V(n,s,{onProgress:a.makeOnProgress("uploadEditSource")})};e.addExternalSources([{source:i,original:!0}]);const c=n.reduce((e,{asset:s})=>s instanceof File?e+s.size:e,0),l=a.simulate("serviceAssetsToGlb",I(c));try{const{source:o,transform:n,origin:a}=await te(i,s,r);if(e.transform=n,a&&t?.useAssetOrigin){const s=await u(a,e.spatialReference,t);e.vertexSpace.origin=[s.x,s.y,s.z??0]}return{external:{source:o,unitConversionDisabled:!0},info:{mesh:e,georeferenceInfo:a?{origin:a}:void 0}}}finally{l.remove()}}async function G(e,s,t){const r=k(A.uploadLocalMesh,t?.onProgress,"uploadLocalMesh"),o=M(e,s,{...t,onProgress:r.makeOnProgress("meshToAssetBlob")});return{external:{source:{type:"service",assets:await X([o],s,{...t,onProgress:r.makeOnProgress("uploadAssetBlobs")})},extent:e.extent.clone(),original:!0},info:{mesh:e}}}async function M(e,s,r){const o=ie(s),n=await e.load(r),a=await n.toBinaryGLTF({origin:n.origin,signal:r?.signal,ignoreLocalTransform:!0,unitConversionDisabled:!0});return t(r),{blob:new Blob([a],{type:"model/gltf-binary"}),assetName:`${c()}.glb`,assetType:o}}function W(e,s){for(const t of e){const e=K(t.source,s);if(e)return e}return null}function K(e,{infoFor3D:s},t={}){if(!e)return null;const r=m(e);if(!r)return null;const{supportedFormats:o,editFormats:n}=s,a=new Array,i=F(s),c=U(s);let u=!1;for(const l of r){const e=Q(l,o);if(!e)return null;const{assetType:s}=e;if(t.checkForConversionRequired&&(s===i||s===c))return null;n.includes(s)&&(u=!0),a.push(e)}return u?a:null}function Q(e,s){const t=f(e,s);return t?{asset:e,assetType:t}:null}async function V(e,s,t){return X(e.map(e=>Y(e,t)),s,t)}async function X(e,s,r){const o=k(A.uploadAssetBlobs,r?.onProgress,"uploadAssetBlobs"),n=await _(e,s,{...r,onProgress:o.makeOnProgress("prepareAssetItems")});t(r);const a=n.map(({item:e})=>e),{uploadResults:i}=await ee(a,s,{...r,onProgress:o.makeOnProgress("uploadAssetItems")});return t(r),e.map((e,t)=>se(n[t],i[t],s))}async function Y(e,s){const{asset:r,assetType:o}=e;if(r instanceof File)return{blob:r,assetName:r.name,assetType:o};const n=await r.toBlob(s);return t(s),{blob:n,assetName:r.assetName,assetType:o}}async function Z(e,s,r){const{blob:n,assetType:a,assetName:c}=e;let u=null;try{const e=await S({data:n,name:c},s.url,r);t(r),u={assetType:a,assetUploadId:e.itemID}}catch(l){o(l),ce().warnOnce(`Service ${s.url} does not support the REST Uploads API.`)}if(!u){const e=await i(n);if(t(r),!e.isBase64)throw new v;u={assetType:a,assetData:e.data}}if(!u)throw new x;return{item:u,assetName:c}}function _(e,s,r){const o=k(e.length,r?.onProgress,"prepareAssetItems");return Promise.all(e.map(async(e,n)=>{const a=Z(await e,s,{...r,onProgress:o.makeOnProgress(n)});return t(r),a}))}async function ee(s,r,o){const n=B(o?.onProgress);try{const n=await e(a(r.parsedUrl.path,"uploadAssets"),{timeout:0,query:{f:"json",assets:JSON.stringify(s)},method:"post",responseType:"json"});if(t(o),n.data.uploadResults.length!==s.length)throw new b(s.length,n.data.uploadResults.length);return n.data}finally{n.remove()}}function se(e,s,t){const{success:r}=s;if(!r){const{error:t}=s;throw new T(e.assetName,t)}const{assetHash:o}=s,{assetName:n,item:{assetType:a}}=e,{infoFor3D:{supportedFormats:i}}=t,c=N(a,i);if(!c)throw new j(a);return new g(n,c,[new d(`${t.parsedUrl.path}/assets/${o}`,o)])}async function te({assets:e},s,t){const r=e.map(({assetName:e,parts:s})=>({assetName:e,assetHash:s[0].partHash}));let o;try{const e=a(s.parsedUrl.path,"convert3D"),n=s.capabilities?.operations.supportsAsyncConvert3D;o=(await(n?ne:oe)(e,{query:{f:"json",assets:JSON.stringify(r),transportType:"esriTransportTypeUrl",targetFormat:t,async:n},responseType:"json",timeout:0})).data}catch(n){throw new P}return re(s,o)}function re(e,s){const t={source:{type:"service",assets:s.assets.map(s=>{const t=D(s.contentType,e.infoFor3D.supportedFormats);if(!t)throw new j(t);return new g(s.assetName,s.contentType,[new d(s.assetURL,s.assetHash)])})},origin:void 0,transform:void 0};if(s.transform){if(t.transform=C(s.transform),s.spatialReference){const e=l.fromJSON(s.spatialReference);t.origin=O(s.transform,e)}}else t.transform=E(e.spatialReference);return t}function oe(s,t){return e(s,t)}async function ne(s,t){const o=(await e(s,t)).data.statusUrl;for(;;){const s=(await e(o,{query:{f:"json"},responseType:"json"})).data;switch(s.status){case"Completed":return e(s.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new Error(s.status);case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new Error}await r(ue)}}function ae(e){return!!e.infoFor3D&&!!e.url}function ie({infoFor3D:e}){const s=R(e);if(!s)throw new w;return s}function ce(){return s.getLogger("esri.layers.graphics.sources.support.uploadAssets")}const ue=n(1e3);export{q as uploadAssets};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.0.0-next.34",
3
+ "version": "5.0.0-next.35",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{getDataValues as i,quantizeFeatures as a,calculateHeatmapStats as e}from"./utils.js";import{isNullCountSupported as n,calculateStringStatistics as t,calculateStatistics as o,processSummaryStatisticsResult as l,calculateUniqueValuesCount as s,createUVResult as r,calculateClassBreaks as m,resolveCBResult as u,calculateHistogram as f}from"../../../statistics/utils.js";async function d(a){const{attribute:e,features:s}=a,{normalizationType:r,normalizationField:m,minValue:u,maxValue:f,fieldType:d,outStatisticTypes:p}=e,c=await i({field:e.field,valueExpression:e.valueExpression,normalizationType:r,normalizationField:m,normalizationTotal:e.normalizationTotal,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},s),v=n({normalizationType:r,normalizationField:m,minValue:u,maxValue:f}),z={value:.5,fieldType:d},T="esriFieldTypeString"===d?t({values:c,supportsNullCount:v,percentileParams:z,outStatisticTypes:p}):o({values:c,minValue:u,maxValue:f,useSampleStdDev:!r,supportsNullCount:v,percentileParams:z,outStatisticTypes:p});return l(T,p,"esriFieldTypeDate"===d)}async function p(a){const{attribute:e,features:n}=a,t=await i({field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:e.valueExpression,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n,!1),o=s(t);return r(o,e.domains,e.returnAllCodedValues,e.fieldDelimiter)}async function c(a){const{attribute:e,features:n}=a,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r}=e,f=await i({field:t,valueExpression:e.valueExpression,normalizationType:o,normalizationField:l,normalizationTotal:s,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n),d=m(f,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r,standardDeviationInterval:e.standardDeviationInterval,numClasses:e.numClasses,minValue:e.minValue,maxValue:e.maxValue});return u(d,r)}async function v(a){const{attribute:e,features:n}=a,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r}=e,m=await i({field:t,valueExpression:e.valueExpression,normalizationType:o,normalizationField:l,normalizationTotal:s,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n);return f(m,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r,standardDeviationInterval:e.standardDeviationInterval,numBins:e.numBins,minValue:e.minValue,maxValue:e.maxValue})}async function z(i){const{attribute:n,features:t}=i,{field:o,radius:l,transform:s,spatialReference:r}=n,m=n.size??[0,0],u=a(t??[],s,r,m);return e(u,l??void 0,o,m[0],m[1])}export{c as classBreaks,z as heatmapStatistics,v as histogram,d as summaryStatistics,p as uniqueValues};
5
+ import{getDataValues as i,quantizeFeatures as a,calculateHeatmapStats as e}from"./utils.js";import{calculateStringStatistics as n,calculateStatistics as t,processSummaryStatisticsResult as o,calculateUniqueValuesCount as l,createUVResult as s,calculateClassBreaks as r,resolveCBResult as m,calculateHistogram as u,isNullCountSupported as f}from"../../../statistics/utils.js";async function d(a){const{attribute:e,features:l}=a,{normalizationType:s,normalizationField:r,minValue:m,maxValue:u,fieldType:d,outStatisticTypes:p}=e,c=await i({field:e.field,valueExpression:e.valueExpression,normalizationType:s,normalizationField:r,normalizationTotal:e.normalizationTotal,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},l),v=f({normalizationType:s,normalizationField:r,minValue:m,maxValue:u}),z={value:.5,fieldType:d},T="esriFieldTypeString"===d?n({values:c,supportsNullCount:v,percentileParams:z,outStatisticTypes:p}):t({values:c,minValue:m,maxValue:u,useSampleStdDev:!s,supportsNullCount:v,percentileParams:z,outStatisticTypes:p});return o(T,p,"esriFieldTypeDate"===d)}async function p(a){const{attribute:e,features:n}=a,t=await i({field:e.field,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:e.valueExpression,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n,!1),o=l(t);return s(o,e.domains,e.returnAllCodedValues,e.fieldDelimiter)}async function c(a){const{attribute:e,features:n}=a,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:u}=e,f=await i({field:t,valueExpression:e.valueExpression,normalizationType:o,normalizationField:l,normalizationTotal:s,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n),d=r(f,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:u,standardDeviationInterval:e.standardDeviationInterval,numClasses:e.numClasses,minValue:e.minValue,maxValue:e.maxValue});return m(d,u)}async function v(a){const{attribute:e,features:n}=a,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r}=e,m=await i({field:t,valueExpression:e.valueExpression,normalizationType:o,normalizationField:l,normalizationTotal:s,viewInfoParams:e.viewInfoParams,timeZone:e.timeZone,fieldInfos:e.fieldInfos},n);return u(m,{field:t,normalizationType:o,normalizationField:l,normalizationTotal:s,classificationMethod:r,standardDeviationInterval:e.standardDeviationInterval,numBins:e.numBins,minValue:e.minValue,maxValue:e.maxValue})}async function z(i){const{attribute:n,features:t}=i,{field:o,radius:l,transform:s,spatialReference:r}=n,m=n.size??[0,0],u=a(t??[],s,r,m);return e(u,l??void 0,o,m[0],m[1])}export{c as classBreaks,z as heatmapStatistics,v as histogram,d as summaryStatistics,p as uniqueValues};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- const a="20251104",f="61bfaf78a8fb0d16386253622f29c8e7189aa9c2";export{a as buildDate,f as commitHash};
5
+ const b="20251105",e="3926b71eb72b07cba3bc4668ef47fe58b5a05db9";export{b as buildDate,e as commitHash};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import{createScreenPointArray as t}from"../../../core/screenUtils.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{G as o}from"../../../chunks/vec32.js";import{getEndpoint as s}from"../../../geometry/support/curves/curveUtils.js";import{SegmentLabels as n}from"../../interactive/SegmentLabels.js";let i=class extends n{getCameraOrExtent({view:e}){return e.extent}toScreenPointArray({view:e,editGeometryOperations:r},o,s=t()){const{coordinateHelper:n}=r.data,i=e.toScreen(n.arrayToPoint(o));return i&&(s[0]=i.x,s[1]=i.y),s}getRing(e,t,r,n,i){const a=[];for(const o of t.parts[i].iterateVertices())o.leftSegment?a.push(o.leftSegment.toCurveOrCoordinate()):a.push(o.pos);if(0===i&&null!=r&&a.push(n.vectorToArray(r)),a.length<2)return a;const c=a[0],p=a.at(-1),m=n.toXYZ(n.arrayToVector(s(c))),l=n.toXYZ(n.arrayToVector(s(p)));return"polygon"===e.type&&a.length>2&&!o(m,l)&&a.push(c),a}};i=e([r("esri.views.2d.interactive.SegmentLabels2D")],i);export{i as SegmentLabels2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{createScreenPointArray as r}from"../../../core/screenUtils.js";import{subclass as t}from"../../../core/accessorSupport/decorators.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{vectorToRender as s}from"./support/viewUtils.js";import{SegmentLabels as i}from"../../interactive/SegmentLabels.js";let a=class extends i{getCameraOrExtent({view:e}){return e.state.camera}toScreenPointArray({view:e,elevationInfo:t,editGeometryOperations:o},i,a=r()){const{spatialReference:m}=o.data.coordinateHelper;return s(i,m,t,e,c),e.state.camera.projectToScreen(c,a),a}};a=e([t("esri.views.3d.interactive.SegmentLabels3D")],a);const c=o();export{a as SegmentLabels3D};
5
+ import{__decorate as e}from"tslib";import{createScreenPointArray as t}from"../../../core/screenUtils.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{G as o}from"../../../chunks/vec32.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as i}from"../../../geometry/support/vectorStacks.js";import{vectorToRender as n}from"./support/viewUtils.js";import{SegmentLabels as a}from"../../interactive/SegmentLabels.js";let c=class extends a{getCameraOrExtent({view:e}){return e.state.camera}toScreenPointArray({view:e,elevationInfo:r,editGeometryOperations:o},s,i=t()){const{spatialReference:a}=o.data.coordinateHelper;return n(s,a,r,e,p),e.state.camera.projectToScreen(p,i),i}getRing(e,t,r,s,n){const a=[];for(const o of t.parts[n].iterateVertices())a.push(s.toXYZ(o.pos,i.get()));if(0===n&&null!=r&&a.push(s.toXYZ(r,i.get())),a.length<2)return a;const c=a[0],p=a[a.length-1];return"polygon"===e.type&&a.length>2&&!o(c,p)&&a.push(c),a}};c=e([r("esri.views.3d.interactive.SegmentLabels3D")],c);const p=s();export{c as SegmentLabels3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{destroyMaybe as e}from"../../../../../core/maybe.js";import{s as t,h as o,t as r,i as a}from"../../../../../chunks/vec32.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as n}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as l}from"../../../support/orientedBoundingBox.js";import{UniformComponentParameters as m}from"./UniformComponentParameters.js";import{ComponentParametersVarying as c,ComponentParametersUniform as h}from"./Material/ComponentMaterial.js";import{olidEnabled as d}from"../../effects/geometry/olidUtils.js";class u{constructor(e,t,o,r,a){this.transform=e,this.obb=t,this._componentData=o,this._renderable=r,this._intersectionGeometry=a,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e){e(this._renderable.material)}updateCameraDerivedParameters(e){const{eye:o}=e;this._renderable.meta.cameraDepthSquared=t(o,this.obb.center)}setComponentData(e,t){const o=this._componentData,{materialDataBuffer:r,materialDataIndices:a}=o,i=new m,s=r.textureBuffer,u=s.getVec5Field("colorAndCastShadows"),p=s.getScalarField("elevationOffset"),b=s.getScalarField("emissiveStrength"),g=s.getScalarField("emissiveSourceMode"),v=s.getVec4Field("olidColor"),C=new Uint8Array(4),x=new Uint32Array(C.buffer);let S=0,_=0,M=0,y=0,w=0,D=o.verticalOffsets,O=1/0,B=-1/0,j=!1,k=!1,A=!1,I=0,W=!1;for(let l=0;l<o.count;l++){e(l,i),S+=+(i.externalColor[3]<1),_+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),y+=+(i.emissiveStrength>0),w+=+(1===i.emissiveSource),k||=1!==i.emissiveStrength,M+=+i.castShadows,n(i.externalColor,i.externalColorMixMode,C),u.setValues(a[l],C[0],C[1],C[2],C[3],+i.castShadows),j||=l>0&&(I!==x[0]||W!==i.castShadows),I=x[0],W=i.castShadows,A||=0!==i.elevationOffset,A&&null==D&&(D=new Array(l).fill(0)),null!=D&&(D[l]=i.elevationOffset),O=Math.min(O,i.elevationOffset),B=Math.max(B,i.elevationOffset),p.set(a[l],i.elevationOffset),b.set(a[l],i.emissiveStrength),g.set(a[l],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&v.setArray(a[l],t),i.pickable!==o.isPickable(l)&&o.updatePickabilityWithCount(l,i.pickable)}o.verticalOffsets=A?D:null,this.offsetObb=A?l(this.obb,O,B,t,this.offsetObb??this.obb.clone()):null,this.updateMaterial(e=>{if(j||A||d()||(k||w>0)&&y>0){const t=new c;t.castShadows=f(M,o.count),t.transparent=f(S,o.count),t.opaqueOverride=f(_,o.count),t.emissiveOverride=f(y,o.count),t.emissiveSourceOverride=f(w,o.count),e.textureBackedBuffer=s,e.componentParameters=t,s.updateTexture()}else{const t=new h;t.castShadows=i.castShadows?0:2,t.externalColor=i.externalColor,t.externalColorMixMode=i.externalColorMixMode,t.emissiveStrength=i.emissiveStrength,t.emissiveSource=i.emissiveSource,e.textureBackedBuffer=null,e.componentParameters=t}})}addComponentHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeComponentHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}destroy(){this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=s(),{positions:t}=this._intersectionGeometry;if(Math.floor(t.length/3)>0){const{rotationScale:s,position:n}=this.transform;let l=1/0,m=1/0,c=1/0,h=-1/0,d=-1/0,u=-1/0;const f=i();for(let e=0;e<t.length;e+=3)o(f,t[e+0],t[e+1],t[e+2]),r(f,f,s),a(f,f,n),l=Math.min(l,f[0]),m=Math.min(m,f[1]),c=Math.min(c,f[2]),h=Math.max(h,f[0]),d=Math.max(d,f[1]),u=Math.max(u,f[2]);e[0]=l,e[1]=m,e[2]=c,e[3]=h,e[4]=d,e[5]=u}return e}}function f(e,t){return e===t?0:0===e?2:1}export{u as ComponentObject};
5
+ import{destroyMaybe as e}from"../../../../../core/maybe.js";import{s as t,h as o,t as r,i}from"../../../../../chunks/vec32.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as n}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as l}from"../../../support/orientedBoundingBox.js";import{UniformComponentParameters as m}from"./UniformComponentParameters.js";import{ComponentParametersVarying as c,ComponentParametersUniform as h}from"./Material/ComponentMaterial.js";import{olidEnabled as d}from"../../effects/geometry/olidUtils.js";class f{constructor(e,t,o,r,i){this.transform=e,this.obb=t,this._componentData=o,this._renderable=r,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e){e(this._renderable.material)}updateCameraDerivedParameters(e){const{eye:o}=e;this._renderable.meta.cameraDepthSquared=t(o,this.obb.center)}setComponentData(e,t){const o=this._componentData,{materialDataBuffer:r,materialDataIndices:i}=o,a=new m,s=r.textureBuffer,f=s.getVec4Field("colorAndCastShadows"),p=s.getScalarField("elevationOffset"),b=s.getScalarField("emissiveStrength"),g=s.getScalarField("emissiveSourceMode"),v=s.getVec4Field("olidColor"),C=new Uint8Array(4),x=new Uint32Array(C.buffer);let _=0,S=0,M=0,y=0,D=0,O=o.verticalOffsets,w=1/0,B=-1/0,j=!1,A=!1,k=!1,I=0;for(let l=0;l<o.count;l++){e(l,a),_+=+(a.externalColor[3]<1),S+=+(3===a.externalColorMixMode&&1===a.externalColor[3]),y+=+(a.emissiveStrength>0),D+=+(1===a.emissiveSource),A||=1!==a.emissiveStrength,M+=+a.castShadows,n(a.externalColor,a.externalColorMixMode,C),C[2]=254&C[2]|+a.castShadows,f.setArray(i[l],C),j||=l>0&&I!==x[0],I=x[0],k||=0!==a.elevationOffset,k&&null==O&&(O=new Array(l).fill(0)),null!=O&&(O[l]=a.elevationOffset),w=Math.min(w,a.elevationOffset),B=Math.max(B,a.elevationOffset),p.set(i[l],a.elevationOffset),b.set(i[l],a.emissiveStrength),g.set(i[l],0===a.emissiveSource?0:255);const t=a.olidColor;null!=t&&v.setArray(i[l],t),a.pickable!==o.isPickable(l)&&o.updatePickabilityWithCount(l,a.pickable)}o.verticalOffsets=k?O:null,this.offsetObb=k?l(this.obb,w,B,t,this.offsetObb??this.obb.clone()):null,this.updateMaterial(e=>{if(j||k||d()||(A||D>0)&&y>0){const t=new c;t.castShadows=u(M,o.count),t.transparent=u(_,o.count),t.opaqueOverride=u(S,o.count),t.emissiveOverride=u(y,o.count),t.emissiveSourceOverride=u(D,o.count),e.textureBackedBuffer=s,e.componentParameters=t,s.updateTexture()}else{const t=new h;t.castShadows=a.castShadows?0:2,t.externalColor=a.externalColor,t.externalColorMixMode=a.externalColorMixMode,t.emissiveStrength=a.emissiveStrength,t.emissiveSource=a.emissiveSource,e.textureBackedBuffer=null,e.componentParameters=t}})}addComponentHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeComponentHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}destroy(){this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=s(),{positions:t}=this._intersectionGeometry;if(Math.floor(t.length/3)>0){const{rotationScale:s,position:n}=this.transform;let l=1/0,m=1/0,c=1/0,h=-1/0,d=-1/0,f=-1/0;const u=a();for(let e=0;e<t.length;e+=3)o(u,t[e+0],t[e+1],t[e+2]),r(u,u,s),i(u,u,n),l=Math.min(l,u[0]),m=Math.min(m,u[1]),c=Math.min(c,u[2]),h=Math.max(h,u[0]),d=Math.max(d,u[1]),f=Math.max(f,u[2]);e[0]=l,e[1]=m,e[2]=c,e[3]=h,e[4]=d,e[5]=f}return e}}function u(e,t){return e===t?0:0===e?2:1}export{f as ComponentObject};
@@ -2,24 +2,30 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as o}from"../../../../../../core/compilerUtils.js";import{DecodeSymbolColor as e}from"./DecodeSymbolColor.glsl.js";import{TextureBackedBufferModule as r}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{Float4DrawUniform as t}from"../../../core/shaderModules/Float4DrawUniform.js";import{FloatDrawUniform as a}from"../../../core/shaderModules/FloatDrawUniform.js";import{glsl as d,If as n}from"../../../core/shaderModules/glsl.js";import{IntegerDrawUniform as l}from"../../../core/shaderModules/IntegerDrawUniform.js";import{Texture2DDrawUniform as i}from"../../../core/shaderModules/Texture2DDrawUniform.js";import{olidEnabled as s}from"../../../effects/geometry/olidUtils.js";import{componentDataLayout as c,componentDataOlidLayout as m}from"../../../materials/DefaultLayouts.js";function u(e,r){switch(r.componentData){case 1:return p(e,r);case 0:return w(e,r);case 2:return;default:o(r.componentData)}}const v=(o,e)=>"emissiveSourceMode"===o||"emissiveStrength"===o?e.hasEmission:"olidColor"!==o||9===e.output,f=new i("componentColorTex",o=>o.textureBackedBuffer.texture),x=new r(c,"componentIndex",f,v),C=new r(m,"componentIndex",f,v);function M(){return s()?C:x}function p(o,r){const{vertex:t,fragment:a}=o,{output:l,hasEmission:i}=r,s=9===l,{getTextureAttribute:c,TextureBackedBufferModule:m}=M();o.include(m,r),o.attributes.add("componentIndex","float"),o.varyings.add("vExternalColorMixMode","mediump float"),o.varyings.add("vExternalColor","vec4"),s&&o.varyings.add("vObjectAndLayerIdColor","vec4"),i&&(o.varyings.add("emissiveStrength","float"),o.varyings.add("emissiveSource","int")),o.include(e),t.code.add(d`
5
+ import{neverReached as o}from"../../../../../../core/compilerUtils.js";import{DecodeSymbolColor as e}from"./DecodeSymbolColor.glsl.js";import{TextureBackedBufferModule as r}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{Float4DrawUniform as t}from"../../../core/shaderModules/Float4DrawUniform.js";import{FloatDrawUniform as d}from"../../../core/shaderModules/FloatDrawUniform.js";import{glsl as n,If as a}from"../../../core/shaderModules/glsl.js";import{IntegerDrawUniform as l}from"../../../core/shaderModules/IntegerDrawUniform.js";import{Texture2DUintDrawUniform as i}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{olidEnabled as s}from"../../../effects/geometry/olidUtils.js";import{componentDataLayout as c,componentDataOlidLayout as m}from"../../../materials/DefaultLayouts.js";function u(e,r){switch(r.componentData){case 1:return M(e,r);case 0:return h(e,r);case 2:return;default:o(r.componentData)}}const v=(o,e)=>"emissiveSourceMode"===o||"emissiveStrength"===o?e.hasEmission:"olidColor"!==o||9===e.output,f=new i("componentTextureBuffer",o=>o.textureBackedBuffer.texture),C=new r(c,"componentIndex",f,v),x=new r(m,"componentIndex",f,v);function p(){return s()?x:C}function M(o,r){const{vertex:t,fragment:d}=o,{output:l,hasEmission:i}=r,s=9===l,{getTextureAttribute:c,TextureBackedBufferModule:m}=p();o.include(m,r),o.attributes.add("componentIndex","float"),o.varyings.add("vExternalColorMixMode","mediump float"),o.varyings.add("vExternalColor","vec4"),s&&o.varyings.add("vObjectAndLayerIdColor","vec4"),i&&(o.varyings.add("emissiveStrength","float"),o.varyings.add("emissiveSource","int")),o.include(e),t.code.add(n`
6
6
  float readElevationOffset() {
7
7
  return ${c("elevationOffset")};
8
8
  }
9
9
 
10
10
  void forwardEmissiveStrength() {
11
- ${n(i,d`emissiveStrength = ${c("emissiveStrength")};
12
- emissiveSource = ${c("emissiveSourceMode")} == 0.0 ? 0 : 1;`)}
11
+ ${a(i,n`emissiveStrength = ${c("emissiveStrength")};
12
+ emissiveSource = ${c("emissiveSourceMode")} == 0u ? 0 : 1;`)}
13
13
  }
14
14
 
15
15
  void forwardObjectAndLayerIdColor() {
16
- ${n(s,d`vObjectAndLayerIdColor = ${c("olidColor")};`)}
16
+ ${a(s,n`vObjectAndLayerIdColor = vec4(${c("olidColor")})/255.0;`)}
17
+ }
18
+
19
+ void decodeColorAndCastShadow(uvec4 colorAndCastShadowEncoded, out vec4 color, out bool castShadow) {
20
+ uvec4 componentColor = colorAndCastShadowEncoded;
21
+ castShadow = bool(componentColor.b & 1u);
22
+ componentColor.b = componentColor.b & 254u;
23
+ color = vec4(componentColor);
17
24
  }
18
25
 
19
26
  vec4 forwardExternalColor(out bool castShadows) {
20
- vec5 colorAndCastShadow = ${c("colorAndCastShadows")};
21
- vec4 componentColor = vec4(colorAndCastShadow.x, colorAndCastShadow.y, colorAndCastShadow.z, colorAndCastShadow.w);
22
- castShadows = colorAndCastShadow.v >= 1.0;
27
+ vec4 componentColor;
28
+ decodeColorAndCastShadow(${c("colorAndCastShadows")}, componentColor, castShadows);
23
29
 
24
30
  int decodedColorMixMode;
25
31
  vExternalColor = decodeSymbolColor(componentColor, decodedColorMixMode) * 0.003921568627451; // = 1/255;
@@ -27,16 +33,16 @@ import{neverReached as o}from"../../../../../../core/compilerUtils.js";import{De
27
33
 
28
34
  return vExternalColor;
29
35
  }
30
- `),a.code.add(d`
36
+ `),d.code.add(n`
31
37
  void readExternalColor(out vec4 externalColor, out int externalColorMixMode) {
32
38
  externalColor = vExternalColor;
33
39
  externalColorMixMode = int(vExternalColorMixMode);
34
40
  }
35
41
 
36
42
  void outputObjectAndLayerIdColor() {
37
- ${s?d`fragColor = vObjectAndLayerIdColor;`:""}
43
+ ${s?n`fragColor = vObjectAndLayerIdColor;`:""}
38
44
  }
39
- `)}function w(o,e){const{vertex:r,fragment:i}=o;o.varyings.add("vExternalColor","vec4"),i.uniforms.add(new a("emissiveStrength",o=>o.componentParameters.emissiveStrength)),r.uniforms.add(new t("externalColor",o=>o.componentParameters.externalColor)).code.add(d`float readElevationOffset() {
45
+ `)}function h(o,e){const{vertex:r,fragment:i}=o;o.varyings.add("vExternalColor","vec4"),i.uniforms.add(new d("emissiveStrength",o=>o.componentParameters.emissiveStrength)),r.uniforms.add(new t("externalColor",o=>o.componentParameters.externalColor)).code.add(n`float readElevationOffset() {
40
46
  return 0.0;
41
47
  }
42
48
  void forwardObjectAndLayerIdColor() {}
@@ -45,13 +51,13 @@ vec4 forwardExternalColor(out bool castShadows) {
45
51
  vExternalColor = externalColor;
46
52
  castShadows = true;
47
53
  return externalColor;
48
- }`);const s=9===e.output;i.uniforms.add(new l("externalColorMixMode",o=>o.componentParameters.externalColorMixMode)).code.add(d`
54
+ }`);const s=9===e.output;i.uniforms.add(new l("externalColorMixMode",o=>o.componentParameters.externalColorMixMode)).code.add(n`
49
55
  void readExternalColor(out vec4 color, out int colorMixMode) {
50
56
  color = vExternalColor;
51
57
  colorMixMode = externalColorMixMode;
52
58
  }
53
59
 
54
60
  void outputObjectAndLayerIdColor() {
55
- ${n(s,"fragColor = vec4(0, 0, 0, 0);")}
61
+ ${a(s,"fragColor = vec4(0, 0, 0, 0);")}
56
62
  }
57
63
  `)}export{u as ComponentData};
@@ -2,13 +2,13 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{generateUID as e}from"../../../../../core/uid.js";import{vec5Type as t,decode_u8u8u7xu8 as o,glslType as d,glslDecodeField as a}from"./TextureBackedBufferFields.glsl.js";import{RgbaFloatEncoding as r}from"./util/RgbaFloatEncoding.glsl.js";import{glsl as n}from"../shaderModules/glsl.js";import{assert as i}from"../../lib/Util.js";class c{constructor(t,o,d,a=()=>!0){this.moduleId=e(),this.namespace=`_tbb_${this.moduleId}_`,this.TextureBackedBufferModule=(e,r)=>l(this.namespace,e,r,o,d,t,a),this.getTextureAttribute=s(this.namespace)}}function l(e,c,l,s,m,u,$){const{vertex:x}=c,h=`${e}tbbStride`,g=`${e}TextureBackedBufferItemData`,p=`${e}fetchTextureBackedBufferItemData`,T=f(e);for(const t of[h,g,p,T])i(t.length<1024,"Identifiers do not have a valid length");x.constants.add(h,"float",u.numTexels),x.uniforms.add(m);const B=u.fields.filter(e=>$(e.name,l));if(0===B.length)return;const I=[];for(let t=0;t<u.numTexels;++t)I.push(!1);for(const t of B)for(let e=0;e<t.numTexels;++e)I[t.startTexel+e]=!0;x.include(r),x.include(t),x.include(o),x.code.add(n`
6
- struct ${g} {`);for(const t of B)x.code.add(n`\t${d(t)} ${t.name};`);x.code.add(n`};`),x.code.add(n`
7
- ${g} ${p}(float itemIndex) {
8
- ${g} itemData;
9
- float index = itemIndex * ${h};
10
- float texSize = float(textureSize(${m.name}, 0).x);
5
+ import{generateUID as e}from"../../../../../core/uid.js";import{unpackFloat4x8 as t,unpackHalf2x8 as o,glslType as d,glslDecodeField as a}from"./TextureBackedBufferFields.glsl.js";import{glsl as r}from"../shaderModules/glsl.js";import{assert as n}from"../../lib/Util.js";class i{constructor(t,o,d,a=()=>!0){this.moduleId=e(),this.namespace=`_tbb_${this.moduleId}_`,this.TextureBackedBufferModule=(e,r)=>c(this.namespace,e,r,o,d,t,a),this.getTextureAttribute=s(this.namespace)}}function c(e,i,c,s,l,u,m){const{vertex:$}=i;$.include(t),$.include(o);const x=`${e}tbbStride`,h=`${e}TextureBackedBufferItemData`,p=`${e}fetchTextureBackedBufferItemData`,T=f(e);for(const t of[x,h,p,T])n(t.length<1024,"Identifiers do not have a valid length");$.constants.add(x,"float",u.numTexels),$.uniforms.add(l);const B=u.fields.filter(e=>m(e.name,c));if(0===B.length)return;const I=[];for(let t=0;t<u.numTexels;++t)I.push(!1);for(const t of B)for(let e=0;e<t.numTexels;++e)I[t.startTexel+e]=!0;$.code.add(r`
6
+ struct ${h} {`);for(const t of B)$.code.add(r`\t${d(t)} ${t.name};`);$.code.add(r`};`),$.code.add(r`
7
+ ${h} ${p}(float itemIndex) {
8
+ ${h} itemData;
9
+ float index = itemIndex * ${x};
10
+ float texSize = float(textureSize(${l.name}, 0).x);
11
11
  float coordX = mod(index, texSize) + 0.5;
12
12
  float coordY = floor(index / texSize) + 0.5;
13
- `);for(let t=0;t<I.length;++t)!1!==I[t]&&x.code.add(n`\tvec4 texel${n.int(t)} = texelFetch(${m.name}, ivec2(coordX + ${n.float(t)}, coordY), 0);`);for(const t of B)x.code.add(n`\titemData.${t.name} = ${a(t)};`);x.code.add(n`return itemData;
14
- }`),x.code.add(n`${g} ${T};`),x.main.add(n`${T} = ${p}(${s});`)}function s(e){const t=f(e);return e=>n`${t}.${e}`}function f(e){return`${e}ItemData`}export{c as TextureBackedBufferModule};
13
+ `);for(let t=0;t<I.length;++t)!1!==I[t]&&$.code.add(r`lowp uvec4 texel${r.int(t)} = texelFetch(${l.name}, ivec2(coordX + ${r.float(t)}, coordY), 0);`);for(const t of B)$.code.add(r`itemData.${t.name} = ${a(t)};`);$.code.add(r`return itemData;
14
+ }`),$.code.add(r`${h} ${T};`),$.main.add(r`${T} = ${p}(${s});`)}function s(e){const t=f(e);return e=>r`${t}.${e}`}function f(e){return`${e}ItemData`}export{i as TextureBackedBufferModule};