@arcgis/core 4.34.0-next.60 → 4.34.0-next.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0264905da9fa56166538.js +1 -0
- package/assets/esri/core/workers/chunks/{007721d1d99233046420.js → 188feb2bcbf8e48e3163.js} +1 -1
- package/assets/esri/core/workers/chunks/{0ff8b28a34b1825c227d.js → 220c8d6338f236298720.js} +1 -1
- package/assets/esri/core/workers/chunks/{54b43876ae6fb078eb38.js → 77e27f318b5863dd0f5c.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d74af2b383187bd59c3.js → 8005ae652361f506bc5f.js} +1 -1
- package/assets/esri/core/workers/chunks/{0468266dfe15ec41d60a.js → a35a439f053d1fe0541b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4e21a1116be0d6340163.js → bdc18ef9cdc8242f014e.js} +1 -1
- package/assets/esri/core/workers/chunks/d6f5297f7b323c340727.js +1 -0
- package/assets/esri/core/workers/chunks/f4167fc895d4009df1c7.js +1 -0
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_no.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
- package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ar.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bg.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_bs.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ca.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_cs.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_da.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_de.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_el.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_es.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_et.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fi.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_fr.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_he.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hr.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_hu.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_id.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_it.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ja.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ko.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lt.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_lv.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_nl.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_no.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pl.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-BR.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_pt-PT.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ro.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_ru.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sk.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sl.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sr.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_sv.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_th.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_tr.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_uk.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_vi.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-CN.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-HK.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_zh-TW.json +1 -1
- package/config.js +1 -1
- package/interfaces.d.ts +89 -47
- package/kernel.js +1 -1
- package/layers/OGCFeatureLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/layers/support/UpdateTracking2D.js +1 -1
- package/views/2d/navigation/actions/Pan.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/controllers/CameraController.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileResult.js +1 -1
- package/views/input/IViewEvents.js +5 -0
- package/views/interactive/Tooltip.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/webscene/SunLighting.js +1 -1
- package/webscene/VirtualLighting.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/18f878ec695617650a96.js +0 -1
- package/assets/esri/core/workers/chunks/981275b6f008431c983a.js +0 -1
- package/assets/esri/core/workers/chunks/e36d538915261ee0373f.js +0 -1
package/layers/SceneLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/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 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,isAbortError as y,throwIfNotAbortError as u}from"../core/promiseUtils.js";import{whenOnce as c}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Point.js";import b from"../graphic/SceneGraphicOrigin.js";import w from"./Layer.js";import{NoModelError as I,MultipleModelsError as L}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as j}from"./mixins/APIKeyMixin.js";import{ArcGISService as F}from"./mixins/ArcGISService.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as O}from"./mixins/EditBusLayer.js";import{OperationalLayer as _}from"./mixins/OperationalLayer.js";import{PortalLayer as P}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as A}from"./mixins/ScaleRangeLayer.js";import{SceneService as T}from"./mixins/SceneService.js";import{useViewTimeProperty as x}from"./mixins/TemporalLayer.js";import{TemporalSceneLayer as E}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as D}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as U}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as R}from"./support/capabilities.js";import{elevationInfo as q,labelsVisible as C,legendEnabled as G,popupEnabled as N,attributeTableTemplate as Q,screenSizePerspectiveEnabled as V}from"./support/commonProperties.js";import{getFieldDomain as M,computeEffectiveEditingEnabled as k,getGlobalIdToObjectIdMap as K}from"./support/featureLayerUtils.js";import{FeatureReduction as $}from"./support/FeatureReduction.js";import H from"./support/FeatureReductionSelection.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import W from"./support/FieldsIndex.js";import{fixRendererFields as Z,unpackFieldNames as B}from"./support/fieldUtils.js";import{I3SNodePageDefinition as J,I3SMaterialDefinition as X,I3STextureSetDefinition as Y,I3SGeometryDefinition as ee}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as te,isFileSupported as re}from"./support/infoFor3D.js";import ie from"./support/LabelClass.js";import{reader as se}from"./support/labelingInfo.js";import oe from"./support/LayerFloorInfo.js";import{layerLookupMap as ae}from"./support/lazyLayerLoader.js";import{getMeshTransformForMetersToSpatialReference as ne}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as le}from"./support/RangeInfo.js";import pe from"./support/SceneFilter.js";import{cacheIsOutOfSync as de}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ye}from"./support/sceneLayerStatistics.js";import{loadStyleRenderer as ue}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as ce}from"../renderers/support/typeUtils.js";import he from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as fe,elevationModeUnsupportedMessage as me,featureExpressionUnsupportedMessage as ge}from"../support/elevationInfoUtils.js";import{createPopupTemplate as ve}from"../support/popupUtils.js";import{extractZipFiles as be}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as we}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as Ie,getFetchPopupTemplate as Le}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as je}from"../webdoc/support/opacityUtils.js";const Fe=new Set(["3DObject","Point"]),Se=z();let Oe=class extends(E(O(T(F(_(P(A(p(S(j(i(w)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.graphicOrigin=new b(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?M(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 W(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:J.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 Pe[this.profile]||"mesh"}set renderer(e){Z(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&&_e[r]?_e[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=null!=e?e.signal:null;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 ue(this,{origin:"service"},t),Z(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 he;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;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=B(this.fieldsIndex,await Ie(this,Le(this)));return we(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}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 ve(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 D(s.url)&&n&&null!=e.deleteFeatures&&null!=a&&(i={...i,globalIdToObjectId:await K(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(),this.infoFor3D||r(new o("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e),s=i.reduce((e,t)=>te(this.infoFor3D,t)?e+1:e,0);0===s&&r(new I),s>1&&r(new L);const a=this.spatialReference,l=t.location??new v({x:0,y:0,z:0,spatialReference:a}),p=l.spatialReference.isGeographic?"local":"georeferenced",{default:d}=await import("../geometry/Mesh.js"),y=d.createWithExternalSource(l,{type:"client",files:i},{vertexSpace:p,transform:ne(l.spatialReference),unitConversionDisabled:!0}),[u]=await this.uploadAssets([y],{...t,useAssetOrigin:!t.location});return u}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await be(e)).filter(e=>re(t,e))}validateLayer(e){if(e.layerType&&!Fe.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=f(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||!D(this.associatedLayer?.url)||!de(this))return;f(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 U(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await ae.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){const e=new AbortController;this.addHandles(a(e));try{await c(()=>this.popupEnabled&&null!=this.popupTemplate,e.signal)}catch(r){return void u(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&&fe(n.getLogger(this),me("Mesh scene layers","relative-to-scene",e)),fe(n.getLogger(this),ge("Scene layers",e))}async fetchStatistics(e,t){return await ye({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:"scenelayer",fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??"",customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}};e([h({types:{key:"type",base:$,typeMap:{selection:H}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:{allowNull:!0}},"portal-item":{name:"layerDefinition.featureReduction",write:{allowNull:!0}}}}})],Oe.prototype,"featureReduction",void 0),e([h({type:[le],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}},clonable:!1})],Oe.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],Oe.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],Oe.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],Oe.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],Oe.prototype,"type",void 0),e([h({...Se.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"fields",void 0),e([h()],Oe.prototype,"types",null),e([h()],Oe.prototype,"typeIdField",null),e([h()],Oe.prototype,"templates",null),e([h()],Oe.prototype,"formTemplate",null),e([h({readOnly:!0})],Oe.prototype,"graphicOrigin",void 0),e([h({readOnly:!0,clonable:!1})],Oe.prototype,"fieldsIndex",null),e([h({type:oe,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Oe.prototype,"floorInfo",void 0),e([h(Se.outFields)],Oe.prototype,"outFields",void 0),e([h({type:J,readOnly:!0,json:{read:!1},clonable:!1})],Oe.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],Oe.prototype,"readNodePages",null),e([h({type:[X],readOnly:!0,clonable:!1})],Oe.prototype,"materialDefinitions",void 0),e([h({type:[Y],readOnly:!0,clonable:!1})],Oe.prototype,"textureSetDefinitions",void 0),e([h({type:[ee],readOnly:!0,clonable:!1})],Oe.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],Oe.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],Oe.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],Oe.prototype,"statisticsInfo",void 0),e([h({type:s.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Oe.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Oe.prototype,"definitionExpression",void 0),e([h({type:pe,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Oe.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Oe.prototype,"path",void 0),e([h(q)],Oe.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],Oe.prototype,"effectiveEditingEnabled",null),e([h({type:String})],Oe.prototype,"geometryType",null),e([h(C)],Oe.prototype,"labelsVisible",void 0),e([h({type:[ie],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:se},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:se},write:!0}})],Oe.prototype,"labelingInfo",void 0),e([h(G)],Oe.prototype,"legendEnabled",void 0),e([h({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?je(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Oe.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"semantic",void 0),e([h({types:ce,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Oe.prototype,"renderer",null),e([h({json:{read:!1}})],Oe.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],Oe.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],Oe.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Oe.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Oe.prototype,"relationships",null),e([h(N)],Oe.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],Oe.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"defaultPopupTemplate",null),e([h(Q)],Oe.prototype,"attributeTableTemplate",void 0),e([h({type:String,json:{read:!1}})],Oe.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],Oe.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],Oe.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],Oe.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],Oe.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],Oe.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],Oe.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Oe.prototype,"normalReferenceFrame",void 0),e([h(V)],Oe.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"serviceItemId",void 0),e([h(x)],Oe.prototype,"useViewTime",null),Oe=e([g("esri.layers.SceneLayer")],Oe);const _e={"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"},Pe={"mesh-pyramids":"mesh",points:"point"},Ae=Oe;export{Ae 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,isAbortError as y,throwIfNotAbortError as u}from"../core/promiseUtils.js";import{whenOnce as c}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{getProperties as f}from"../core/accessorSupport/utils.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Point.js";import b from"../graphic/SceneGraphicOrigin.js";import w from"./Layer.js";import{NoModelError as I,MultipleModelsError as L}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as j}from"./mixins/APIKeyMixin.js";import{ArcGISService as F}from"./mixins/ArcGISService.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as O}from"./mixins/EditBusLayer.js";import{OperationalLayer as _}from"./mixins/OperationalLayer.js";import{PortalLayer as P}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as A}from"./mixins/ScaleRangeLayer.js";import{SceneService as T}from"./mixins/SceneService.js";import{useViewTimeProperty as x}from"./mixins/TemporalLayer.js";import{TemporalSceneLayer as E}from"./mixins/TemporalSceneLayer.js";import{isHostedAgolService as D}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as U}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as R}from"./support/capabilities.js";import{elevationInfo as q,labelsVisible as C,legendEnabled as G,popupEnabled as N,attributeTableTemplate as Q,screenSizePerspectiveEnabled as V}from"./support/commonProperties.js";import{getFieldDomain as M,computeEffectiveEditingEnabled as k,getGlobalIdToObjectIdMap as K}from"./support/featureLayerUtils.js";import{FeatureReduction as $}from"./support/FeatureReduction.js";import H from"./support/FeatureReductionSelection.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import W from"./support/FieldsIndex.js";import{fixRendererFields as Z,unpackFieldNames as B}from"./support/fieldUtils.js";import{I3SNodePageDefinition as J,I3SMaterialDefinition as X,I3STextureSetDefinition as Y,I3SGeometryDefinition as ee}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as te,isFileSupported as re}from"./support/infoFor3D.js";import ie from"./support/LabelClass.js";import{reader as se}from"./support/labelingInfo.js";import oe from"./support/LayerFloorInfo.js";import{layerLookupMap as ae}from"./support/lazyLayerLoader.js";import{getMeshTransformForMetersToSpatialReference as ne}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as le}from"./support/RangeInfo.js";import pe from"./support/SceneFilter.js";import{cacheIsOutOfSync as de}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ye}from"./support/sceneLayerStatistics.js";import{loadStyleRenderer as ue}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as ce}from"../renderers/support/typeUtils.js";import he from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as fe,elevationModeUnsupportedMessage as me,featureExpressionUnsupportedMessage as ge}from"../support/elevationInfoUtils.js";import{createPopupTemplate as ve}from"../support/popupUtils.js";import{extractZipFiles as be}from"../support/zipUtils.js";import{queryAttributesFromCachedAttributesId as we}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as Ie,getFetchPopupTemplate as Le}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as je}from"../webdoc/support/opacityUtils.js";const Fe=new Set(["3DObject","Point"]),Se=z();let Oe=class extends(E(O(T(F(_(P(A(p(S(j(i(w)))))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.graphicOrigin=new b(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?M(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 W(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:J.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 Pe[this.profile]||"mesh"}set renderer(e){Z(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&&_e[r]?_e[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=null!=e?e.signal:null;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 ue(this,{origin:"service"},t),Z(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 he;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=B(this.fieldsIndex,await Ie(this,Le(this)));return we(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 ve(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 D(s.url)&&n&&null!=e.deleteFeatures&&null!=a&&(i={...i,globalIdToObjectId:await K(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(),this.infoFor3D||r(new o("invalid:layer","SceneLayer has no capability for mesh conversion"));const i=await this.extractAndFilterFiles(e),s=i.reduce((e,t)=>te(this.infoFor3D,t)?e+1:e,0);0===s&&r(new I),s>1&&r(new L);const a=this.spatialReference,l=t.location??new v({x:0,y:0,z:0,spatialReference:a}),p=l.spatialReference.isGeographic?"local":"georeferenced",{default:d}=await import("../geometry/Mesh.js"),y=d.createWithExternalSource(l,{type:"client",files:i},{vertexSpace:p,transform:ne(l.spatialReference),unitConversionDisabled:!0}),[u]=await this.uploadAssets([y],{...t,useAssetOrigin:!t.location});return u}async extractAndFilterFiles(e){await this.load();const t=this.infoFor3D;if(!t)return e;return(await be(e)).filter(e=>re(t,e))}validateLayer(e){if(e.layerType&&!Fe.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=f(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||!D(this.associatedLayer?.url)||!de(this))return;f(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 U(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),s=await ae.FeatureLayer();this.associatedLayer=new s({url:t,customParameters:this.customParameters,layerId:r,portalItem:i}),await this.associatedLayer.load()}catch(t){y(t)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){const e=new AbortController;this.addHandles(a(e));try{await c(()=>this.popupEnabled&&null!=this.popupTemplate,e.signal)}catch(r){return void u(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&&fe(n.getLogger(this),me("Mesh scene layers","relative-to-scene",e)),fe(n.getLogger(this),ge("Scene layers",e))}async fetchStatistics(e,t){return await ye({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:"scenelayer",fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??"",customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}};e([h({types:{key:"type",base:$,typeMap:{selection:H}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:{allowNull:!0}},"portal-item":{name:"layerDefinition.featureReduction",write:{allowNull:!0}}}}})],Oe.prototype,"featureReduction",void 0),e([h({type:[le],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}},clonable:!1})],Oe.prototype,"rangeInfos",void 0),e([h({json:{read:!1}})],Oe.prototype,"associatedLayer",void 0),e([h({type:["show","hide"]})],Oe.prototype,"listMode",void 0),e([h({type:["ArcGISSceneServiceLayer"]})],Oe.prototype,"operationalLayerType",void 0),e([h({json:{read:!1},readOnly:!0})],Oe.prototype,"type",void 0),e([h({...Se.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"fields",void 0),e([h()],Oe.prototype,"types",null),e([h()],Oe.prototype,"typeIdField",null),e([h()],Oe.prototype,"templates",null),e([h()],Oe.prototype,"formTemplate",null),e([h({readOnly:!0})],Oe.prototype,"graphicOrigin",void 0),e([h({readOnly:!0,clonable:!1})],Oe.prototype,"fieldsIndex",null),e([h({type:oe,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],Oe.prototype,"floorInfo",void 0),e([h(Se.outFields)],Oe.prototype,"outFields",void 0),e([h({type:J,readOnly:!0,json:{read:!1},clonable:!1})],Oe.prototype,"nodePages",void 0),e([m("service","nodePages",["nodePages","pointNodePages"])],Oe.prototype,"readNodePages",null),e([h({type:[X],readOnly:!0,clonable:!1})],Oe.prototype,"materialDefinitions",void 0),e([h({type:[Y],readOnly:!0,clonable:!1})],Oe.prototype,"textureSetDefinitions",void 0),e([h({type:[ee],readOnly:!0,clonable:!1})],Oe.prototype,"geometryDefinitions",void 0),e([h({readOnly:!0})],Oe.prototype,"serviceUpdateTimeStamp",void 0),e([h({readOnly:!0})],Oe.prototype,"attributeStorageInfo",void 0),e([h({readOnly:!0})],Oe.prototype,"statisticsInfo",void 0),e([h({type:s.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],Oe.prototype,"excludeObjectIds",void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Oe.prototype,"definitionExpression",void 0),e([h({type:pe,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Oe.prototype,"filter",void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Oe.prototype,"path",void 0),e([h(q)],Oe.prototype,"elevationInfo",null),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"effectiveCapabilities",null),e([h({readOnly:!0})],Oe.prototype,"effectiveEditingEnabled",null),e([h({type:String})],Oe.prototype,"geometryType",null),e([h(C)],Oe.prototype,"labelsVisible",void 0),e([h({type:[ie],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:se},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:se},write:!0}})],Oe.prototype,"labelingInfo",void 0),e([h(G)],Oe.prototype,"legendEnabled",void 0),e([h({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?je(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],Oe.prototype,"opacity",void 0),e([h({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"priority",void 0),e([h({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"semantic",void 0),e([h({types:ce,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],Oe.prototype,"renderer",null),e([h({json:{read:!1}})],Oe.prototype,"cachedDrawingInfo",void 0),e([m("service","cachedDrawingInfo")],Oe.prototype,"readCachedDrawingInfo",null),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"capabilities",null),e([h({type:Boolean,json:{read:!1}})],Oe.prototype,"editingEnabled",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Oe.prototype,"infoFor3D",null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Oe.prototype,"relationships",null),e([h(N)],Oe.prototype,"popupEnabled",void 0),e([h({type:r,json:{name:"popupInfo",write:!0}})],Oe.prototype,"popupTemplate",void 0),e([h({readOnly:!0,json:{read:!1}})],Oe.prototype,"defaultPopupTemplate",null),e([h(Q)],Oe.prototype,"attributeTableTemplate",void 0),e([h({type:String,json:{read:!1}})],Oe.prototype,"objectIdField",void 0),e([m("service","objectIdField",["objectIdField","fields"])],Oe.prototype,"readObjectIdField",null),e([h({type:String,json:{read:!1}})],Oe.prototype,"globalIdField",void 0),e([m("service","globalIdField",["globalIdField","fields"])],Oe.prototype,"readGlobalIdField",null),e([h({readOnly:!0,type:String,json:{read:!1}})],Oe.prototype,"displayField",null),e([h({type:String,json:{read:!1}})],Oe.prototype,"profile",void 0),e([m("service","profile",["store.profile"])],Oe.prototype,"readProfile",null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],Oe.prototype,"normalReferenceFrame",void 0),e([h(V)],Oe.prototype,"screenSizePerspectiveEnabled",void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Oe.prototype,"serviceItemId",void 0),e([h(x)],Oe.prototype,"useViewTime",null),Oe=e([g("esri.layers.SceneLayer")],Oe);const _e={"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"},Pe={"mesh-pyramids":"mesh",points:"point"},Ae=Oe;export{Ae as default};
|
package/layers/VoxelLayer.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import i from"../core/Collection.js";import o from"../core/Error.js";import r from"../core/Logger.js";import{MultiOriginJSONMixin as n}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{Integer as a}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as p}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{n as m}from"../chunks/vec32.js";import{fromValues as c}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../geometry/Extent.js";import y from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISService as h}from"./mixins/ArcGISService.js";import{CustomParametersMixin as v}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as b}from"./mixins/OperationalLayer.js";import{PortalLayer as g}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{SceneService as x}from"./mixins/SceneService.js";import{sanitizeUrl as V}from"./support/arcgisLayerUrl.js";import{legendEnabled as j,url as w}from"./support/commonProperties.js";import I from"./support/Field.js";import T from"./support/FieldsIndex.js";import D from"./support/TimeInfo.js";import L from"./voxel/VoxelSection.js";import F from"./voxel/VoxelSimpleShading.js";import P from"./voxel/VoxelVariable.js";import N from"./voxel/VoxelVariableStyle.js";import O from"./voxel/VoxelVolume.js";import E from"./voxel/VoxelVolumeIndex.js";import A from"./voxel/VoxelVolumeStyle.js";import{createPopupTemplate as R}from"../support/popupUtils.js";import{T as C}from"../chunks/TimeExtent.js";import{T as M}from"../chunks/TimeInterval.js";let z=class extends(x(h(b(g(S(n(v(f(y))))))))){constructor(e){super(e),this.serviceRoot="",this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=null,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.shading=new F,this.opacity=1,this.variables=new i,this.volumes=new i,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.fullExtent=null,this.popupEnabled=!1,this.popupTemplate=null,this.test=null,this.timeExtent=null,this.timeOffset=null,this.useViewTime=!0,this.volumeStyles=new(i.ofType(A)),this.variableStyles=new(i.ofType(N)),this.sections=new(i.ofType(L))}normalizeCtorArgs(e){return e?.constantUpscaling&&(this.test={constantUpscaling:!0},delete e.constantUpscaling),e}set url(e){this._set("url",V(e,r.getLogger(this)))}load(e){const t=null!=e?e.signal:null,i=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(s).then(()=>this._fetchService(t)).then(()=>this.serviceRoot=this.url);return this.addResolvingPromise(i),Promise.resolve(this)}read(e,t){super.read(e,t),"service"===t?.origin&&this.version.major<=3&&this.version.minor<=0&&!this.getAtOrigin("popupTemplate","service")&&this.setAtOrigin("popupTemplate",this.createPopupTemplate(),"service");for(const i of this.volumes)i.spatialReference=this.spatialReference}readVersion(e,t){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new o("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new o("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new o("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}readFullExtent(e,t,i){if(null!=e&&"object"==typeof e){const o=d.fromJSON(e,i);if(0===o.zmin&&0===o.zmax&&Array.isArray(t.volumes)){const e=O.fromJSON(t.volumes[0]);if(e.isValid&&"xyt"!==e.volumeType){const t=e.dimensions[2];if(t.isRegular){let e=t.regularSpacing.offset,i=t.regularSpacing.offset+t.regularSpacing.scale*(t.size-1);if(e>i){const t=e;e=i,i=t}o.zmin=e,o.zmax=i}}}return o}return null}get fields(){const e=[new I({name:"Voxel.Position",alias:"Voxel Position",domain:null,editable:!1,length:128,type:"string"}),new I({name:"Voxel.CurrentVariable",alias:"Current Variable",domain:null,editable:!1,length:128,type:"string"})];for(const i of this.variables){const t=new I({name:i.name,alias:i.description,domain:null,editable:!1,length:128,type:"discrete"===i.renderingFormat.continuity?"string":"double"});e.push(t)}const t=this.getVolume(null);if(null!=t){if("xyzt"===t.volumeType||"xyt"===t.volumeType){const t=new I({name:"Voxel.LocalTime",alias:"Local Time",domain:null,editable:!1,length:256,type:"date"});e.push(t);const i=new I({name:"Voxel.SourceTime",alias:"Source Time",domain:null,editable:!1,length:256,type:"string"});e.push(i)}if("xyt"!==t.volumeType){const t=new I({name:"Voxel.Depth",alias:"Depth",domain:null,editable:!1,length:128,type:"double"});e.push(t)}}return e}get fieldsIndex(){return this.loaded?new T(this.fields):null}getField(e){return this.fieldsIndex?.get(e)}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const t=this.fields;return R({fields:t,title:"{Voxel.Position}"},e)}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index?.toJSON(),sections:this.getSections(),style:{volumeStyles:this.getVolumeStyles(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.getVariableStyles(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index?.isValid()?JSON.stringify(e):""}getVariableStyle(e){let t=-1;t=null!=e?e:this.currentVariableId;if(!this.variableStyles||-1===t)return null;const i=this.variableStyles.findIndex(e=>e.variableId===t);return i<0?null:this.variableStyles.at(i)}getVariable(e){let t=-1;if(t=null!=e?e:this.currentVariableId,!this.variables||-1===t)return null;const i=this.variables.findIndex(e=>e.id===t);return i<0?null:this.variables.at(i)}getVolume(e){const t=this.getVariable(e);return null!=t?this.volumes.find(({id:e})=>e===t.volumeId):null}get timeInfo(){const e=this.getVolume(null);if("xyzt"!==e?.volumeType)return null;const t=e.timeStops;if(!t?.length)return null;const i=new C({start:t[0],end:t.at(-1)});return new D({fullTimeExtent:i,stops:t})}getVolumeStyle(e){const t=this.getVariable(e);return null!=t?this.volumeStyles.find(({volumeId:e})=>e===t.volumeId):null}getColorForContinuousDataValue(e,t,i){const o=this.getVariable(e);if(null==o||"continuous"!==o.renderingFormat?.continuity)return null;if(!this.variableStyles)return null;const r=this.variableStyles.findIndex(t=>t.variableId===e);if(r<0)return null;const n=this.variableStyles.at(r);return n?.transferFunction?n.transferFunction.getColorForContinuousDataValue(t,i):null}getSections(){const e=[];for(const t of this.sections)e.push(new L({enabled:t.enabled,href:t.href,id:t.id,label:t.label,normal:t.normal,point:t.point,sizeInPixel:t.sizeInPixel,slices:t.slices,timeId:t.timeId,variableId:t.variableId}));return e}getVariableStyles(){const e=[];for(const t of this.variableStyles){const i=this._getVariable(t);if(null!=i){const o=t.clone();o.isosurfaces.length>4&&(o.isosurfaces=o.isosurfaces.slice(0,3),r.getLogger(this).error("A maximum of 4 isosurfaces are supported for Voxel Layers."));for(const e of o.isosurfaces)if(!e.colorLocked){const t=this.getColorForContinuousDataValue(o.variableId,e.value,!1);null==t||t.equals(e.color)||(e.color=t)}if("continuous"===i.renderingFormat.continuity)(null===o.transferFunction||o.transferFunction.colorStops.length<2)&&r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. At least 2 color stops are required in the transferFunction for continuous Voxel Layer variables.`),null!==o.transferFunction&&(Array.isArray(o.transferFunction.stretchRange)&&2===o.transferFunction.stretchRange.length||(r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. The stretchRange of the transferFunction for continuous Voxel Layer variables must be of the form [minimumDataValue, maximumDataValue].`),o.transferFunction.stretchRange=[0,1],o.transferFunction.colorStops.removeAll()));else if("discrete"===i.renderingFormat.continuity)if(0===t.uniqueValues.length)r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. Unique values are required for discrete Voxel Layer variables.`);else for(const e of t.uniqueValues)null!==e.label&&void 0!==e.label||null===e.value||void 0===e.value||(e.label=e.value.toString());e.push(o)}else r.getLogger(this).error(`VoxelVariable ID=${t.variableId} doesn't exist, VoxelVariableStyle for this VoxelVariable will be ignored.`)}return e}getVolumeStyles(){const e=[];for(const t of this.volumeStyles){const i=this._getVolumeFromVolumeId(t.volumeId);if(null!=i){const o=t.clone();for(const e of o.slices)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");for(const e of o.dynamicSections)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");e.push(o)}else r.getLogger(this).error(`VoxelVolume ID=${t.volumeId} doesn't exist, VoxelVolumeStyle for this VoxelVolume will be ignored.`)}return e}_getVariable(e){const t=e.variableId;for(const i of this.variables)if(i.id===t)return i;return null}_getVolumeFromVolumeId(e){for(const t of this.volumes)if(t.id===e)return t;return null}_isPlaneValid(e,t,i){if(!e.point)return!1;if(!Array.isArray(e.point)||3!==e.point.length)return!1;if(!e.normal)return!1;if(!Array.isArray(e.normal)||3!==e.normal.length)return!1;const o=c(e.normal[0],e.normal[1],e.normal[2]);m(o,o);const r=1e-6;return!(Math.abs(o[0])+Math.abs(o[1])+Math.abs(o[2])<r)&&(e.normal[0]=o[0],e.normal[1]=o[1],e.normal[2]=o[2],!0)}};e([l({type:["Voxel"]})],z.prototype,"operationalLayerType",void 0),e([l(j)],z.prototype,"legendEnabled",void 0),e([l({json:{write:!0}})],z.prototype,"title",void 0),e([l(w)],z.prototype,"url",null),e([l({type:i.ofType(L),json:{origins:{"web-scene":{name:"layerDefinition.sections",write:!0}}}})],z.prototype,"sections",void 0),e([l({type:a,json:{origins:{"web-scene":{name:"layerDefinition.style.currentVariableId",write:{enabled:!0,isRequired:!0,ignoreOrigin:!0}},service:{name:"style.currentVariableId"}}}})],z.prototype,"currentVariableId",void 0),e([l({type:i.ofType(A),json:{origins:{"web-scene":{name:"layerDefinition.style.volumeStyles",write:!0},service:{name:"style.volumeStyles"}}}})],z.prototype,"volumeStyles",void 0),e([l({type:["volume","surfaces"],json:{origins:{"web-scene":{name:"layerDefinition.style.renderMode",write:!0},service:{name:"style.renderMode"}}}})],z.prototype,"renderMode",void 0),e([l({type:i.ofType(N),json:{origins:{"web-scene":{name:"layerDefinition.style.variableStyles",write:!0},service:{name:"style.variableStyles"}}}})],z.prototype,"variableStyles",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSlices",write:!0},service:{name:"style.enableSlices"}}}})],z.prototype,"enableSlices",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSections",write:!0},service:{name:"style.enableSections"}}}})],z.prototype,"enableSections",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableDynamicSections",write:!0},service:{name:"style.enableDynamicSections"}}}})],z.prototype,"enableDynamicSections",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableIsosurfaces",write:!0},service:{name:"style.enableIsosurfaces"}}}})],z.prototype,"enableIsosurfaces",void 0),e([l({type:F,json:{origins:{"web-scene":{name:"layerDefinition.style.shading",write:!0},service:{name:"style.shading"}}}})],z.prototype,"shading",void 0),e([l({type:["show","hide"]})],z.prototype,"listMode",void 0),e([l({type:Number,range:{min:0,max:1},nonNullable:!0,json:{read:!1,write:!1,origins:{"web-scene":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],z.prototype,"opacity",void 0),e([l({type:i.ofType(P)})],z.prototype,"variables",void 0),e([l({type:i.ofType(O)})],z.prototype,"volumes",void 0),e([l({type:E})],z.prototype,"index",void 0),e([l({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],z.prototype,"minScale",void 0),e([l({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],z.prototype,"maxScale",void 0),e([l({json:{read:!1},readOnly:!0})],z.prototype,"type",void 0),e([l({readOnly:!0,json:{name:"serviceVersion"}})],z.prototype,"version",void 0),e([p("service","version")],z.prototype,"readVersion",null),e([l({type:d})],z.prototype,"fullExtent",void 0),e([p("service","fullExtent",["fullExtent"])],z.prototype,"readFullExtent",null),e([l({readOnly:!0,clonable:!1,json:{read:!1}})],z.prototype,"fields",null),e([l({readOnly:!0})],z.prototype,"fieldsIndex",null),e([l({type:Boolean,json:{name:"disablePopup",read:{reader:(e,t)=>!t.disablePopup},write:{enabled:!0,ignoreOrigin:!0,writer(e,t,i){t[i]=!e}},origins:{"portal-item":{default:!0},"web-scene":{default:!0}}}})],z.prototype,"popupEnabled",void 0),e([l({type:t,json:{name:"popupInfo",write:!0}})],z.prototype,"popupTemplate",void 0),e([l({readOnly:!0,json:{read:!1}})],z.prototype,"defaultPopupTemplate",null),e([l({type:D,readOnly:!0,json:{read:!1}})],z.prototype,"timeInfo",null),e([l({type:C,json:{read:!1}})],z.prototype,"timeExtent",void 0),e([l({type:M,json:{read:!1}})],z.prototype,"timeOffset",void 0),e([l({type:Boolean,nonNullable:!0,json:{origins:{"web-scene":{name:"timeAnimation",write:!0},service:{read:!1}}}})],z.prototype,"useViewTime",void 0),z=e([u("esri.layers.VoxelLayer")],z);const _=z;export{_ as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../PopupTemplate.js";import i from"../core/Collection.js";import o from"../core/Error.js";import r from"../core/Logger.js";import{MultiOriginJSONMixin as n}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as s}from"../core/promiseUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import{Integer as a}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as p}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{n as m}from"../chunks/vec32.js";import{fromValues as c}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../geometry/Extent.js";import y from"../graphic/VoxelGraphicOrigin.js";import f from"./Layer.js";import{APIKeyMixin as h}from"./mixins/APIKeyMixin.js";import{ArcGISService as v}from"./mixins/ArcGISService.js";import{CustomParametersMixin as b}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as S}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{SceneService as V}from"./mixins/SceneService.js";import{sanitizeUrl as j}from"./support/arcgisLayerUrl.js";import{legendEnabled as w,url as I}from"./support/commonProperties.js";import T from"./support/Field.js";import D from"./support/FieldsIndex.js";import L from"./support/TimeInfo.js";import F from"./voxel/VoxelSection.js";import O from"./voxel/VoxelSimpleShading.js";import P from"./voxel/VoxelVariable.js";import N from"./voxel/VoxelVariableStyle.js";import E from"./voxel/VoxelVolume.js";import A from"./voxel/VoxelVolumeIndex.js";import R from"./voxel/VoxelVolumeStyle.js";import{createPopupTemplate as C}from"../support/popupUtils.js";import{T as M}from"../chunks/TimeExtent.js";import{T as z}from"../chunks/TimeInterval.js";let _=class extends(V(v(g(S(x(n(b(h(f))))))))){constructor(e){super(e),this.serviceRoot="",this.operationalLayerType="Voxel",this.legendEnabled=!0,this.title=null,this.sections=null,this.currentVariableId=0,this.volumeStyles=null,this.renderMode="volume",this.variableStyles=null,this.enableSlices=!0,this.enableSections=!0,this.enableDynamicSections=!0,this.enableIsosurfaces=!0,this.graphicOrigin=new y(this),this.shading=new O,this.opacity=1,this.variables=new i,this.volumes=new i,this.index=null,this.minScale=0,this.maxScale=0,this.type="voxel",this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.fullExtent=null,this.popupEnabled=!1,this.popupTemplate=null,this.test=null,this.timeExtent=null,this.timeOffset=null,this.useViewTime=!0,this.volumeStyles=new(i.ofType(R)),this.variableStyles=new(i.ofType(N)),this.sections=new(i.ofType(F))}normalizeCtorArgs(e){return e?.constantUpscaling&&(this.test={constantUpscaling:!0},delete e.constantUpscaling),e}set url(e){this._set("url",j(e,r.getLogger(this)))}load(e){const t=null!=e?e.signal:null,i=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(s).then(()=>this._fetchService(t)).then(()=>this.serviceRoot=this.url);return this.addResolvingPromise(i),Promise.resolve(this)}read(e,t){super.read(e,t),"service"===t?.origin&&this.version.major<=3&&this.version.minor<=0&&!this.getAtOrigin("popupTemplate","service")&&this.setAtOrigin("popupTemplate",this.createPopupTemplate(),"service");for(const i of this.volumes)i.spatialReference=this.spatialReference}readVersion(e,t){return super.parseVersionString(e)}validateLayer(e){if(e.layerType&&e.layerType!==this.operationalLayerType)throw new o("voxel-layer:layer-type-not-supported","VoxelLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor)||this.version.major<3)throw new o("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"});if(this.version.major>3)throw new o("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"3.x"})}readFullExtent(e,t,i){if(null!=e&&"object"==typeof e){const o=d.fromJSON(e,i);if(0===o.zmin&&0===o.zmax&&Array.isArray(t.volumes)){const e=E.fromJSON(t.volumes[0]);if(e.isValid&&"xyt"!==e.volumeType){const t=e.dimensions[2];if(t.isRegular){let e=t.regularSpacing.offset,i=t.regularSpacing.offset+t.regularSpacing.scale*(t.size-1);if(e>i){const t=e;e=i,i=t}o.zmin=e,o.zmax=i}}}return o}return null}get fields(){const e=[new T({name:"Voxel.Position",alias:"Voxel Position",domain:null,editable:!1,length:128,type:"string"}),new T({name:"Voxel.CurrentVariable",alias:"Current Variable",domain:null,editable:!1,length:128,type:"string"})];for(const i of this.variables){const t=new T({name:i.name,alias:i.description,domain:null,editable:!1,length:128,type:"discrete"===i.renderingFormat.continuity?"string":"double"});e.push(t)}const t=this.getVolume(null);if(null!=t){if("xyzt"===t.volumeType||"xyt"===t.volumeType){const t=new T({name:"Voxel.LocalTime",alias:"Local Time",domain:null,editable:!1,length:256,type:"date"});e.push(t);const i=new T({name:"Voxel.SourceTime",alias:"Source Time",domain:null,editable:!1,length:256,type:"string"});e.push(i)}if("xyt"!==t.volumeType){const t=new T({name:"Voxel.Depth",alias:"Depth",domain:null,editable:!1,length:128,type:"double"});e.push(t)}}return e}get fieldsIndex(){return this.loaded?new D(this.fields):null}getField(e){return this.fieldsIndex?.get(e)}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const t=this.fields;return C({fields:t,title:"{Voxel.Position}"},e)}getConfiguration(){const e={layerType:this.operationalLayerType,version:this.version.versionString,name:this.title,spatialReference:this.spatialReference,fullExtent:this.fullExtent,volumes:this.volumes.toJSON(),variables:this.variables.toJSON(),index:this.index?.toJSON(),sections:this.getSections(),style:{volumeStyles:this.getVolumeStyles(),currentVariableId:this.currentVariableId,renderMode:this.renderMode,variableStyles:this.getVariableStyles(),enableSections:this.enableSections,enableDynamicSections:this.enableDynamicSections,enableIsosurfaces:this.enableIsosurfaces,enableSlices:this.enableSlices,shading:this.shading}};return e.index&&this.index?.isValid()?JSON.stringify(e):""}getVariableStyle(e){let t=-1;t=null!=e?e:this.currentVariableId;if(!this.variableStyles||-1===t)return null;const i=this.variableStyles.findIndex(e=>e.variableId===t);return i<0?null:this.variableStyles.at(i)}getVariable(e){let t=-1;if(t=null!=e?e:this.currentVariableId,!this.variables||-1===t)return null;const i=this.variables.findIndex(e=>e.id===t);return i<0?null:this.variables.at(i)}getVolume(e){const t=this.getVariable(e);return null!=t?this.volumes.find(({id:e})=>e===t.volumeId):null}get timeInfo(){const e=this.getVolume(null);if("xyzt"!==e?.volumeType)return null;const t=e.timeStops;if(!t?.length)return null;const i=new M({start:t[0],end:t.at(-1)});return new L({fullTimeExtent:i,stops:t})}getVolumeStyle(e){const t=this.getVariable(e);return null!=t?this.volumeStyles.find(({volumeId:e})=>e===t.volumeId):null}getColorForContinuousDataValue(e,t,i){const o=this.getVariable(e);if(null==o||"continuous"!==o.renderingFormat?.continuity)return null;if(!this.variableStyles)return null;const r=this.variableStyles.findIndex(t=>t.variableId===e);if(r<0)return null;const n=this.variableStyles.at(r);return n?.transferFunction?n.transferFunction.getColorForContinuousDataValue(t,i):null}getSections(){const e=[];for(const t of this.sections)e.push(new F({enabled:t.enabled,href:t.href,id:t.id,label:t.label,normal:t.normal,point:t.point,sizeInPixel:t.sizeInPixel,slices:t.slices,timeId:t.timeId,variableId:t.variableId}));return e}getVariableStyles(){const e=[];for(const t of this.variableStyles){const i=this._getVariable(t);if(null!=i){const o=t.clone();o.isosurfaces.length>4&&(o.isosurfaces=o.isosurfaces.slice(0,3),r.getLogger(this).error("A maximum of 4 isosurfaces are supported for Voxel Layers."));for(const e of o.isosurfaces)if(!e.colorLocked){const t=this.getColorForContinuousDataValue(o.variableId,e.value,!1);null==t||t.equals(e.color)||(e.color=t)}if("continuous"===i.renderingFormat.continuity)(null===o.transferFunction||o.transferFunction.colorStops.length<2)&&r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. At least 2 color stops are required in the transferFunction for continuous Voxel Layer variables.`),null!==o.transferFunction&&(Array.isArray(o.transferFunction.stretchRange)&&2===o.transferFunction.stretchRange.length||(r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. The stretchRange of the transferFunction for continuous Voxel Layer variables must be of the form [minimumDataValue, maximumDataValue].`),o.transferFunction.stretchRange=[0,1],o.transferFunction.colorStops.removeAll()));else if("discrete"===i.renderingFormat.continuity)if(0===t.uniqueValues.length)r.getLogger(this).error(`VoxelVariableStyle for variable ${i.id} is invalid. Unique values are required for discrete Voxel Layer variables.`);else for(const e of t.uniqueValues)null!==e.label&&void 0!==e.label||null===e.value||void 0===e.value||(e.label=e.value.toString());e.push(o)}else r.getLogger(this).error(`VoxelVariable ID=${t.variableId} doesn't exist, VoxelVariableStyle for this VoxelVariable will be ignored.`)}return e}getVolumeStyles(){const e=[];for(const t of this.volumeStyles){const i=this._getVolumeFromVolumeId(t.volumeId);if(null!=i){const o=t.clone();for(const e of o.slices)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");for(const e of o.dynamicSections)this._isPlaneValid(e,[0,1,i.zDimension],i.dimensions)||(e.enabled=!1,e.label="invalid");e.push(o)}else r.getLogger(this).error(`VoxelVolume ID=${t.volumeId} doesn't exist, VoxelVolumeStyle for this VoxelVolume will be ignored.`)}return e}_getVariable(e){const t=e.variableId;for(const i of this.variables)if(i.id===t)return i;return null}_getVolumeFromVolumeId(e){for(const t of this.volumes)if(t.id===e)return t;return null}_isPlaneValid(e,t,i){if(!e.point)return!1;if(!Array.isArray(e.point)||3!==e.point.length)return!1;if(!e.normal)return!1;if(!Array.isArray(e.normal)||3!==e.normal.length)return!1;const o=c(e.normal[0],e.normal[1],e.normal[2]);m(o,o);const r=1e-6;return!(Math.abs(o[0])+Math.abs(o[1])+Math.abs(o[2])<r)&&(e.normal[0]=o[0],e.normal[1]=o[1],e.normal[2]=o[2],!0)}};e([l({type:["Voxel"]})],_.prototype,"operationalLayerType",void 0),e([l(w)],_.prototype,"legendEnabled",void 0),e([l({json:{write:!0}})],_.prototype,"title",void 0),e([l(I)],_.prototype,"url",null),e([l({type:i.ofType(F),json:{origins:{"web-scene":{name:"layerDefinition.sections",write:!0}}}})],_.prototype,"sections",void 0),e([l({type:a,json:{origins:{"web-scene":{name:"layerDefinition.style.currentVariableId",write:{enabled:!0,isRequired:!0,ignoreOrigin:!0}},service:{name:"style.currentVariableId"}}}})],_.prototype,"currentVariableId",void 0),e([l({type:i.ofType(R),json:{origins:{"web-scene":{name:"layerDefinition.style.volumeStyles",write:!0},service:{name:"style.volumeStyles"}}}})],_.prototype,"volumeStyles",void 0),e([l({type:["volume","surfaces"],json:{origins:{"web-scene":{name:"layerDefinition.style.renderMode",write:!0},service:{name:"style.renderMode"}}}})],_.prototype,"renderMode",void 0),e([l({type:i.ofType(N),json:{origins:{"web-scene":{name:"layerDefinition.style.variableStyles",write:!0},service:{name:"style.variableStyles"}}}})],_.prototype,"variableStyles",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSlices",write:!0},service:{name:"style.enableSlices"}}}})],_.prototype,"enableSlices",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableSections",write:!0},service:{name:"style.enableSections"}}}})],_.prototype,"enableSections",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableDynamicSections",write:!0},service:{name:"style.enableDynamicSections"}}}})],_.prototype,"enableDynamicSections",void 0),e([l({type:Boolean,json:{origins:{"web-scene":{name:"layerDefinition.style.enableIsosurfaces",write:!0},service:{name:"style.enableIsosurfaces"}}}})],_.prototype,"enableIsosurfaces",void 0),e([l({readOnly:!0})],_.prototype,"graphicOrigin",void 0),e([l({type:O,json:{origins:{"web-scene":{name:"layerDefinition.style.shading",write:!0},service:{name:"style.shading"}}}})],_.prototype,"shading",void 0),e([l({type:["show","hide"]})],_.prototype,"listMode",void 0),e([l({type:Number,range:{min:0,max:1},nonNullable:!0,json:{read:!1,write:!1,origins:{"web-scene":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],_.prototype,"opacity",void 0),e([l({type:i.ofType(P)})],_.prototype,"variables",void 0),e([l({type:i.ofType(E)})],_.prototype,"volumes",void 0),e([l({type:A})],_.prototype,"index",void 0),e([l({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],_.prototype,"minScale",void 0),e([l({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],_.prototype,"maxScale",void 0),e([l({json:{read:!1},readOnly:!0})],_.prototype,"type",void 0),e([l({readOnly:!0,json:{name:"serviceVersion"}})],_.prototype,"version",void 0),e([p("service","version")],_.prototype,"readVersion",null),e([l({type:d})],_.prototype,"fullExtent",void 0),e([p("service","fullExtent",["fullExtent"])],_.prototype,"readFullExtent",null),e([l({readOnly:!0,clonable:!1,json:{read:!1}})],_.prototype,"fields",null),e([l({readOnly:!0})],_.prototype,"fieldsIndex",null),e([l({type:Boolean,json:{name:"disablePopup",read:{reader:(e,t)=>!t.disablePopup},write:{enabled:!0,ignoreOrigin:!0,writer(e,t,i){t[i]=!e}},origins:{"portal-item":{default:!0},"web-scene":{default:!0}}}})],_.prototype,"popupEnabled",void 0),e([l({type:t,json:{name:"popupInfo",write:!0}})],_.prototype,"popupTemplate",void 0),e([l({readOnly:!0,json:{read:!1}})],_.prototype,"defaultPopupTemplate",null),e([l({type:L,readOnly:!0,json:{read:!1}})],_.prototype,"timeInfo",null),e([l({type:M,json:{read:!1}})],_.prototype,"timeExtent",void 0),e([l({type:z,json:{read:!1}})],_.prototype,"timeOffset",void 0),e([l({type:Boolean,nonNullable:!0,json:{origins:{"web-scene":{name:"timeAnimation",write:!0},service:{read:!1}}}})],_.prototype,"useViewTime",void 0),_=e([u("esri.layers.VoxelLayer")],_);const q=_;export{q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../request.js";import has from"../core/has.js";import s from"../core/Logger.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as r,initial as a}from"../core/reactiveUtils.js";import{convertTime as n}from"../core/timeUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{j as h}from"../chunks/vec32.js";import{create as d}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderSRFromViewSR as u}from"../geometry/support/coordinateSystem.js";import{loadVoxelWASM as _}from"../libs/vxl/VxlModule.js";import{VoxelGraphic as c}from"../views/3d/layers/VoxelGraphic.js";import{VoxelTarget as m}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as g}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as f}from"../views/3d/support/RenderCoordsHelper.js";import{SyncRenderPlugin as p}from"../views/3d/webgl-engine/effects/RenderPlugin.js";import{IntersectorResult as y}from"../views/3d/webgl-engine/lib/IntersectorResult.js";let x=class extends p{constructor(e){super(e),this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.produces=new Map([[20,()=>!!this._vxl&&"local"===this.view.viewingMode]]),this.type=7,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerViewUid=[]}_dbg(e,t){this._dbgFlags.has(e)&&(4===e?s.getLogger(this).error(t):s.getLogger(this).warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this.view.stage&&(this._dbg(1,"--removeRenderPlugin--"),this.view.stage.removeRenderPlugin(this)),this._pluginIsActive=!1}initialize(){this._dbg(1,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this.addHandles([r(()=>this.view.ready,e=>{e&&"local"===this.view.viewingMode?(this._dbg(1,"view ready status changed to ready on a local view, calling addRenderPlugin"),this.view.stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(1,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())},a),r(()=>this.view?.qualityProfile,e=>{this._dbg(3,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))},a),r(()=>this.view?.timeExtent,()=>{if(this._vxl){const e=this._getTimeArgs(this.view?.timeExtent);this._dbg(3,"sceneView timeExtent changed to useTime="+e.hasTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.hasTime),this._renderPluginContext.requestRender()}},a),r(()=>this.view?.stationary,e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()})])}initializeRenderContext(e){this._dbg(1,"--initializeRenderContext--");const t=e.renderContext.rctx;this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(1,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(4,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const s=!!this._rctx,i=!!this._renderTargetToRestore;if(!s||!i)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(4,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,s){if(!this._rctx)return void this._dbg(4,"modifyAllocation callback has no rendering context!");const i=e;1===s?this._rctx.instanceCounter.increment(i,t):this._rctx.instanceCounter.decrement(i,t)}_setBlendState(e,t,s,i){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,s),this._rctx.setBlendEquation(i)):this._dbg(4,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(4,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,s){this._rctx?(this._rctx.setDepthFunction(s),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(519,0,255),this._rctx.setStencilOpSeparate(1028,7680,7682,7680),this._rctx.setStencilOpSeparate(1029,7680,7683,7680)):this._dbg(4,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case 1:this._rctx.setFaceCullingEnabled(!1);break;case 3:this._rctx.setCullFace(1029),this._rctx.setFaceCullingEnabled(!0);break;case 2:this._rctx.setCullFace(1028),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(4,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,s,i){this._rctx?this._rctx.setViewport(e,t,s,i):this._dbg(4,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach((e,t)=>{if(e.needMemoryUsageUpdate){const s=this._vxl.estimate_memory_usage(t);s>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(s))}})}_syncRequestsResponses(){this._layers.forEach((e,s)=>{const r=[];e.responses.forEach((t,i)=>{r.push(i),this._dbg(2,"responding for requestID:"+i+" size:"+t.size),this._vxl.respond(s,i,t),0!==t.requestType&&4!==t.requestType||(e.needMemoryUsageUpdate=!0)});const a=e.responses;for(const t of r)a.delete(t);const n=this._vxl.get_new_requests(s),l=e.abortController.signal;for(const o in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const s=n[o],r={responseType:"array-buffer",signal:l,query:{...e.layerView.layer.customParameters,token:e.layerView.layer.apiKey}};this._dbg(2,"making requestID:"+o+" url:"+s.url),t(s.url,r).then(t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(2,"have response for requestID:"+o);let i=0;if(t.data.byteLength>0){i=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,i,t.data.byteLength),s=new Uint8Array(t.data);for(let i=0;i<t.data.byteLength;++i)e[i]=s[i]}a.set(+o,{responseType:s.responseType,ptr:i,size:t.data.byteLength,success:!0,requestType:s.requestType})}).catch(t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),i(t)||(this._dbg(4,`requestID:${o} failed, error=${t.toString()}`),a.set(+o,{responseType:s.responseType,ptr:0,size:0,success:!1,requestType:s.requestType}))})}})}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach((s,i)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){const s=this._vxl.get_layer_epoch_times(i,e.layer.currentVariableId);for(let e=0;e<s.length;++e)t.push(s[e])}}),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(i))}),t}setEnabled(e,t){this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(i,t),s.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())})}setIsInScaleRange(e,t){const s=this._layers.get(e.wasmLayerId);s&&t!==s.isInScaleRange&&(s.isInScaleRange=t,this._vxl.set_is_in_scale_range(e.wasmLayerId,t),s.needMemoryUsageUpdate=!t,this._renderPluginContext.requestRender())}setStaticSections(e,t){const s={mask:1,staticSections:t};return this._doMaskedUIUpdate(e,s,!0)}setCurrentVariable(e,t){const s={mask:1024,currentVariable:t};return this._doMaskedUIUpdate(e,s,!0)}setRenderMode(e,t){const s={mask:8192,renderMode:t};return this._doMaskedUIUpdate(e,s,!0)}setVerticalExaggerationAndOffset(e,t,s,i){const r={mask:256,volStyleDesc:{volumeId:t,verticalExaggeration:s,verticalOffset:i}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const s={mask:32768,variableStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setVolumeStyles(e,t){const s={mask:65536,volumeStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setEnableDynamicSections(e,t){const s={mask:4096,containerIsVisible:t,container:1};return this._doMaskedUIUpdate(e,s,!0)}setEnableIsosurfaces(e,t){const s={mask:4096,containerIsVisible:t,container:0};return this._doMaskedUIUpdate(e,s,!0)}setEnableSections(e,t){const s={mask:4096,containerIsVisible:t,container:2};return this._doMaskedUIUpdate(e,s,!0)}setAnalysisSlice(e,t,s,i){const r={mask:131072,analysisSlice:{point:s,normal:i,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}updateLayerTimeProperties(e){if(!this._vxl)return;const t=this._layers.get(e.wasmLayerId);if(t){const s=t.layerView.layer;let i=0;s.timeOffset&&(i=n(s.timeOffset.value,s.timeOffset.unit,"seconds"));const r=this._getTimeArgs(s.timeExtent);this._vxl.set_layer_time_properties(e.wasmLayerId,r.startTime,r.endTime,r.hasTime,s.useViewTime,i),this._renderPluginContext.requestRender()}}_doMaskedUIUpdate(e,t,s){if(!this._vxl)return!1;let i=!1;return this._layers.forEach((s,r)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(i=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}}),i&&s&&this._renderPluginContext.requestRender(),i}_addTriangleToWasmBuffer(e,t,s,i,r){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,s){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,s=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),i=new Float32Array(this._vxl.HEAPF32.buffer,s,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[0],l=this._frustum.points[1],o=this._frustum.points[2],h=this._frustum.points[3],d=this._frustum.points[4],u=this._frustum.points[5],_=this._frustum.points[6],c=this._frustum.points[7];let m=0,g=0;const f=this._frustum.planes[4];m=this._addTriangleToWasmBuffer(i,m,o,l,n),g=this._addNormalToWasmBuffer(a,g,f),m=this._addTriangleToWasmBuffer(i,m,n,h,o),g=this._addNormalToWasmBuffer(a,g,f);const p=this._frustum.planes[5];m=this._addTriangleToWasmBuffer(i,m,d,u,_),g=this._addNormalToWasmBuffer(a,g,p),m=this._addTriangleToWasmBuffer(i,m,_,c,d),g=this._addNormalToWasmBuffer(a,g,p);const y=this._frustum.planes[3];m=this._addTriangleToWasmBuffer(i,m,_,o,h),g=this._addNormalToWasmBuffer(a,g,y),m=this._addTriangleToWasmBuffer(i,m,h,c,_),g=this._addNormalToWasmBuffer(a,g,y);const x=this._frustum.planes[2];m=this._addTriangleToWasmBuffer(i,m,n,l,u),g=this._addNormalToWasmBuffer(a,g,x),m=this._addTriangleToWasmBuffer(i,m,u,d,n),g=this._addNormalToWasmBuffer(a,g,x);const v=this._frustum.planes[0];m=this._addTriangleToWasmBuffer(i,m,h,n,d),g=this._addNormalToWasmBuffer(a,g,v),m=this._addTriangleToWasmBuffer(i,m,d,c,h),g=this._addNormalToWasmBuffer(a,g,v);const b=this._frustum.planes[1];m=this._addTriangleToWasmBuffer(i,m,o,_,u),g=this._addNormalToWasmBuffer(a,g,b),m=this._addTriangleToWasmBuffer(i,m,u,l,o),g=this._addNormalToWasmBuffer(a,g,b),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(s,3*e,r,e,255,0,0,64),this._vxl._free(s),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=f.create(2,u(!1,this.view.spatialReference))),null===this._frustum&&(this._frustum=new g(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach((t,s)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(s),this._renderPluginContext.requestRender())})}dropQueryRenderTarget(){this._vxl&&this._vxl.drop_query_rt()}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},s=new Promise((e,s)=>{t.resolveCallback=e,t.rejectCallback=s});return this._newLayers.push(t),s}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex(t=>e.uid===t.layerView.uid);t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const s=this._newLayers.length;return 0===s&&(this._dbg(1," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),s}let t=-1;this._layers.forEach((s,i)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){t=i,s.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerViewUid.indexOf(e.uid);-1!==r&&this.layerViewUid.splice(r,1)}}),t>=0&&this._layers.delete(t);const s=this._layers.size;return 0===s&&(this._dbg(1," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),s}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,s=Number.MAX_VALUE,i=!1;return null!=e&&(e.isAllTime?i=!0:(null!=e.start&&(i=!0,t=e.start.getTime()/1e3),null!=e.end&&(i=!0,s=e.end.getTime()/1e3))),{startTime:t,endTime:s,hasTime:i}}_addVoxelLayer(e){const t=e.layer;let i=-1;const r=t.getConfiguration();if(r.length<1)return-1;const a={str:r,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(a))return-1;const l=this._getTimeArgs(t.timeExtent),o=this.view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;let h=0;if(t.timeOffset&&(h=n(t.timeOffset.value,t.timeOffset.unit,"seconds")),i=this._vxl.add_layer(t.serviceRoot,a.ptr,a.byteCount,o,o,l.startTime,l.endTime,l.hasTime,t.useViewTime,h,this._toWasmQuality(this.view.qualityProfile)),a.isReusable||this._vxl._free(a.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const r=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:r,needMemoryUsageUpdate:!1,isInScaleRange:!0}),this.layerViewUid.push(e.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&s.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&s.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&s.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&s.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&s.getLogger(this).warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bind.camera.viewForward,s=e.bind.camera.eye;this._vxl.update_camera_pos_and_direction(s[0],s[1],s[2],t[0],t[1],t[2]);const i=this._vxl.cull();this._dbg(2,"missingResourceCount="+i),this._moreToLoad=i>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}acquireTechniques(){return[]}render(e){if(!this._vxl)return;for(const s of this._newLayers){const e=this._addVoxelLayer(s.layerView);-1===e?s.rejectCallback(-1):s.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(4,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this.view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this.view.stage.renderer.isFeatureEnabled(2),e.bind.lighting.mainLight.direction[0],e.bind.lighting.mainLight.direction[1],e.bind.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach(e=>{e.needMemoryUsageUpdate=!0})),0===t.x&&0===t.y||this._dbg(4,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bind.camera),this._captureFrustum&&(this._frustum.update(e.bind.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(1,"--destroy--"),this._vxl&&(this._layers.forEach(e=>{e.abortController.abort()}),this._wasmMemBlocks.forEach(e=>{0!==e&&this._vxl._free(e)}),this._vxl.uninitialize_voxel_wasm(),this._removeRenderPlugin(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=_(e).then(e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(1," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this.view?.timeExtent),s=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),i=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),l=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),o=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),u=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(s,i,r,a,n,l,o,h,t.startTime,t.endTime,t.hasTime,d,u),this._renderPluginContext&&this._renderPluginContext.requestRender()}).catch(()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(4," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()})),this._vxlPromise)}pickDepth(e,t,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=s.viewport[3]-t;if(e<0||e>s.viewport[2]||t<0||t>s.viewport[3])return this._dbg(4,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${i.toFixed(0)}]]`),null;this._beforeDraw();const r=s.viewForward,a=s.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(s),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,i);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,s,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>s.viewport[2]||a<0||a>s.viewport[3])return this._dbg(4,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${s.viewport.toString()}]`),null;this._beforeDraw();const n=s.viewForward,l=s.eye;this._vxl.update_camera_pos_and_direction(l[0],l[1],l[2],n[0],n[1],n[2]),this.updateWasmCamera(s),this._vxl.begin_frame();let o=null;if(0===i.length)o=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:i}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(o=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),o}async getOtherFieldPopupValues(e,s){for(const i of e){const e=i.gpuResult;if(!e)continue;const r=this._layers.get(e.layerId);if(!r||!r.layerView.layer.url)continue;const a=r.layerView.layer,n={responseType:"array-buffer",signal:r.abortController.signal,query:{...r.layerView.layer.customParameters,token:r.layerView.layer.apiKey}},l=e.voxelSpacePosition,o=[Math.floor(l[0]/32),Math.floor(l[1]/32),Math.floor(l[2]/32)],h=[-4&o[0],-4&o[1],-4&o[2]];let d=0;if(e.epochTime){const t=this._vxl.get_layer_epoch_times(r.layerView.wasmLayerId,a.currentVariableId);for(let s=0;s<t.length;++s)if(t[s]===e.epochTime/1e3){d=s;break}}const u=[],_={varIds:[],ptrs:[],sizes:[]};for(const i of s){const e=a.variables.findIndex(e=>e.name===i);if(-1===e)continue;const s=a.variables.getItemAt(e)?.id;if(null==s)continue;const r=`${a.url}/variables/${s}/${d}/bundles/0/${h[0]}-${h[1]}-${h[2]}`;u.push(t(r,n).then(e=>e.data)),_.varIds.push(s)}const c=await Promise.allSettled(u),m=c.length;for(let t=0;t<m;++t){const e=c[t];if("fulfilled"===e.status){const t=e.value,s=this._vxl._malloc(t.byteLength);new Uint8Array(this._vxl.HEAPU8.buffer,s,t.byteLength).set(new Uint8Array(t)),_.ptrs.push(s),_.sizes.push(t.byteLength)}else _.varIds.splice(t,1)}const g=this._vxl.get_other_field_popup_values(e,_);for(let t=0;t<_.ptrs.length;++t)this._vxl._free(_.ptrs[t]);if(g.continuousValues)for(const t in g.continuousValues)i.attributes[t]=g.continuousValues[t];if(g.uniqueValues)for(const t in g.uniqueValues)i.attributes[t]=g.uniqueValues[t]}return e}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,s,i,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered||!e.camera)return;if(null==r||r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(4,r?`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`:"[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=null"),null;const a=[];this._layers.forEach(t=>{e.options.filteredLayerViewUids.includes(t.layerView.uid)&&a.push(t.layerView.wasmLayerId)});const n=this.pickObject(r[0],r[1],e.camera,a);if(null==n||-1===n.layerId)return;const l=this._layers.get(n.layerId);if(l){const t=l.layerView.layer.uid,r=n.distanceToCamera/h(s,i),a=d();a[0]=n.worldX,a[1]=n.worldY,a[2]=n.worldZ;const o={},u=l.layerView.layer,_=u.variables.findIndex(e=>e.id===u.currentVariableId);if(_>=0){const e=u.variables.getItemAt(_);null!=e&&(null!=n.continuousValue?o[e.name]=n.continuousValue:null!=n.uniqueValueLabel&&null!=n.uniqueValue?o[e.name]=`${n.uniqueValueLabel} (${n.uniqueValue})`:null!=n.uniqueValue&&(o[e.name]=`${n.uniqueValue}`),e.description.length>0?o["Voxel.CurrentVariable"]=e.description:e.name?.length>0&&(o["Voxel.CurrentVariable"]=e.name))}if(o["Voxel.Position"]=`[${n.voxelSpacePosition.toString()}]`,null!=n.epochTime&&null!=n.nativeTime&&null!=n.nativeTimeUnits){const e=new Date(n.epochTime);o["Voxel.LocalTime"]=e,o["Voxel.SourceTime"]=`${n.nativeTime.toLocaleString()} ${n.nativeTimeUnits}`}null!=n.depth&&(o["Voxel.Depth"]=n.depth);const c=n.faceNormal;o["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const g=e=>{const s=new m(a,t,()=>this._createVoxelGraphic(l.layerView.layer,o,n));e.set(this.type,s,r,c)},f=e.results,p=2===e.options.store;if((null==f.min.distance||r<f.min.distance)&&g(f.min),(null==f.max.distance||r>f.max.distance)&&g(f.max),p){const t=new y(e.ray);g(t),e.results.all.push(t)}}}_createVoxelGraphic(e,t,s){return new c({layer:e,sourceLayer:e,attributes:t,gpuResult:s})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,s){this._vxl&&this._vxl.set_upscaling_limits(e,t,s)}hasHighlight(){return!1}};e([l({constructOnly:!0})],x.prototype,"view",void 0),x=e([o("esri.layers.VoxelWasmPerSceneView")],x);const v=x;export{v as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../request.js";import has from"../core/has.js";import s from"../core/Logger.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as r,initial as a}from"../core/reactiveUtils.js";import{convertTime as n}from"../core/timeUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import{j as h}from"../chunks/vec32.js";import{create as d}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderSRFromViewSR as u}from"../geometry/support/coordinateSystem.js";import{loadVoxelWASM as _}from"../libs/vxl/VxlModule.js";import{VoxelGraphic as c}from"../views/3d/layers/VoxelGraphic.js";import{VoxelTarget as m}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as g}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as f}from"../views/3d/support/RenderCoordsHelper.js";import{SyncRenderPlugin as p}from"../views/3d/webgl-engine/effects/RenderPlugin.js";import{IntersectorResult as y}from"../views/3d/webgl-engine/lib/IntersectorResult.js";let x=class extends p{constructor(e){super(e),this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.produces=new Map([[20,()=>!!this._vxl&&"local"===this.view.viewingMode]]),this.type=7,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerViewUid=[]}_dbg(e,t){this._dbgFlags.has(e)&&(4===e?s.getLogger(this).error(t):s.getLogger(this).warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this.view.stage&&(this._dbg(1,"--removeRenderPlugin--"),this.view.stage.removeRenderPlugin(this)),this._pluginIsActive=!1}initialize(){this._dbg(1,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this.addHandles([r(()=>this.view.ready,e=>{e&&"local"===this.view.viewingMode?(this._dbg(1,"view ready status changed to ready on a local view, calling addRenderPlugin"),this.view.stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(1,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())},a),r(()=>this.view?.qualityProfile,e=>{this._dbg(3,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))},a),r(()=>this.view?.timeExtent,()=>{if(this._vxl){const e=this._getTimeArgs(this.view?.timeExtent);this._dbg(3,"sceneView timeExtent changed to useTime="+e.hasTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.hasTime),this._renderPluginContext.requestRender()}},a),r(()=>this.view?.stationary,e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()})])}initializeRenderContext(e){this._dbg(1,"--initializeRenderContext--");const t=e.renderContext.rctx;this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(1,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(4,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const s=!!this._rctx,i=!!this._renderTargetToRestore;if(!s||!i)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(4,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,s){if(!this._rctx)return void this._dbg(4,"modifyAllocation callback has no rendering context!");const i=e;1===s?this._rctx.instanceCounter.increment(i,t):this._rctx.instanceCounter.decrement(i,t)}_setBlendState(e,t,s,i){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,s),this._rctx.setBlendEquation(i)):this._dbg(4,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(4,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,s){this._rctx?(this._rctx.setDepthFunction(s),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(519,0,255),this._rctx.setStencilOpSeparate(1028,7680,7682,7680),this._rctx.setStencilOpSeparate(1029,7680,7683,7680)):this._dbg(4,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case 1:this._rctx.setFaceCullingEnabled(!1);break;case 3:this._rctx.setCullFace(1029),this._rctx.setFaceCullingEnabled(!0);break;case 2:this._rctx.setCullFace(1028),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(4,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,s,i){this._rctx?this._rctx.setViewport(e,t,s,i):this._dbg(4,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach((e,t)=>{if(e.needMemoryUsageUpdate){const s=this._vxl.estimate_memory_usage(t);s>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(s))}})}_syncRequestsResponses(){this._layers.forEach((e,s)=>{const r=[];e.responses.forEach((t,i)=>{r.push(i),this._dbg(2,"responding for requestID:"+i+" size:"+t.size),this._vxl.respond(s,i,t),0!==t.requestType&&4!==t.requestType||(e.needMemoryUsageUpdate=!0)});const a=e.responses;for(const t of r)a.delete(t);const n=this._vxl.get_new_requests(s),l=e.abortController.signal;for(const o in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const s=n[o],r={responseType:"array-buffer",signal:l,query:{...e.layerView.layer.customParameters,token:e.layerView.layer.apiKey}};this._dbg(2,"making requestID:"+o+" url:"+s.url),t(s.url,r).then(t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(2,"have response for requestID:"+o);let i=0;if(t.data.byteLength>0){i=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,i,t.data.byteLength),s=new Uint8Array(t.data);for(let i=0;i<t.data.byteLength;++i)e[i]=s[i]}a.set(+o,{responseType:s.responseType,ptr:i,size:t.data.byteLength,success:!0,requestType:s.requestType})}).catch(t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),i(t)||(this._dbg(4,`requestID:${o} failed, error=${t.toString()}`),a.set(+o,{responseType:s.responseType,ptr:0,size:0,success:!1,requestType:s.requestType}))})}})}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach((s,i)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){const s=this._vxl.get_layer_epoch_times(i,e.layer.currentVariableId);for(let e=0;e<s.length;++e)t.push(s[e])}}),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(i))}),t}setEnabled(e,t){this._layers.forEach((s,i)=>{s.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(i,t),s.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())})}setIsInScaleRange(e,t){const s=this._layers.get(e.wasmLayerId);s&&t!==s.isInScaleRange&&(s.isInScaleRange=t,this._vxl.set_is_in_scale_range(e.wasmLayerId,t),s.needMemoryUsageUpdate=!t,this._renderPluginContext.requestRender())}setStaticSections(e,t){const s={mask:1,staticSections:t};return this._doMaskedUIUpdate(e,s,!0)}setCurrentVariable(e,t){const s={mask:1024,currentVariable:t};return this._doMaskedUIUpdate(e,s,!0)}setRenderMode(e,t){const s={mask:8192,renderMode:t};return this._doMaskedUIUpdate(e,s,!0)}setVerticalExaggerationAndOffset(e,t,s,i){const r={mask:256,volStyleDesc:{volumeId:t,verticalExaggeration:s,verticalOffset:i}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const s={mask:32768,variableStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setVolumeStyles(e,t){const s={mask:65536,volumeStyles:t};return this._doMaskedUIUpdate(e,s,!0)}setEnableDynamicSections(e,t){const s={mask:4096,containerIsVisible:t,container:1};return this._doMaskedUIUpdate(e,s,!0)}setEnableIsosurfaces(e,t){const s={mask:4096,containerIsVisible:t,container:0};return this._doMaskedUIUpdate(e,s,!0)}setEnableSections(e,t){const s={mask:4096,containerIsVisible:t,container:2};return this._doMaskedUIUpdate(e,s,!0)}setAnalysisSlice(e,t,s,i){const r={mask:131072,analysisSlice:{point:s,normal:i,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}updateLayerTimeProperties(e){if(!this._vxl)return;const t=this._layers.get(e.wasmLayerId);if(t){const s=t.layerView.layer;let i=0;s.timeOffset&&(i=n(s.timeOffset.value,s.timeOffset.unit,"seconds"));const r=this._getTimeArgs(s.timeExtent);this._vxl.set_layer_time_properties(e.wasmLayerId,r.startTime,r.endTime,r.hasTime,s.useViewTime,i),this._renderPluginContext.requestRender()}}_doMaskedUIUpdate(e,t,s){if(!this._vxl)return!1;let i=!1;return this._layers.forEach((s,r)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(i=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}}),i&&s&&this._renderPluginContext.requestRender(),i}_addTriangleToWasmBuffer(e,t,s,i,r){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,s){return e[3*t]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,s=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),i=new Float32Array(this._vxl.HEAPF32.buffer,s,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[0],l=this._frustum.points[1],o=this._frustum.points[2],h=this._frustum.points[3],d=this._frustum.points[4],u=this._frustum.points[5],_=this._frustum.points[6],c=this._frustum.points[7];let m=0,g=0;const f=this._frustum.planes[4];m=this._addTriangleToWasmBuffer(i,m,o,l,n),g=this._addNormalToWasmBuffer(a,g,f),m=this._addTriangleToWasmBuffer(i,m,n,h,o),g=this._addNormalToWasmBuffer(a,g,f);const p=this._frustum.planes[5];m=this._addTriangleToWasmBuffer(i,m,d,u,_),g=this._addNormalToWasmBuffer(a,g,p),m=this._addTriangleToWasmBuffer(i,m,_,c,d),g=this._addNormalToWasmBuffer(a,g,p);const y=this._frustum.planes[3];m=this._addTriangleToWasmBuffer(i,m,_,o,h),g=this._addNormalToWasmBuffer(a,g,y),m=this._addTriangleToWasmBuffer(i,m,h,c,_),g=this._addNormalToWasmBuffer(a,g,y);const x=this._frustum.planes[2];m=this._addTriangleToWasmBuffer(i,m,n,l,u),g=this._addNormalToWasmBuffer(a,g,x),m=this._addTriangleToWasmBuffer(i,m,u,d,n),g=this._addNormalToWasmBuffer(a,g,x);const v=this._frustum.planes[0];m=this._addTriangleToWasmBuffer(i,m,h,n,d),g=this._addNormalToWasmBuffer(a,g,v),m=this._addTriangleToWasmBuffer(i,m,d,c,h),g=this._addNormalToWasmBuffer(a,g,v);const b=this._frustum.planes[1];m=this._addTriangleToWasmBuffer(i,m,o,_,u),g=this._addNormalToWasmBuffer(a,g,b),m=this._addTriangleToWasmBuffer(i,m,u,l,o),g=this._addNormalToWasmBuffer(a,g,b),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(s,3*e,r,e,255,0,0,64),this._vxl._free(s),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=f.create(2,u(!1,this.view.spatialReference))),null===this._frustum&&(this._frustum=new g(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach((t,s)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(s),this._renderPluginContext.requestRender())})}dropQueryRenderTarget(){this._vxl&&this._vxl.drop_query_rt()}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},s=new Promise((e,s)=>{t.resolveCallback=e,t.rejectCallback=s});return this._newLayers.push(t),s}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex(t=>e.uid===t.layerView.uid);t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const s=this._newLayers.length;return 0===s&&(this._dbg(1," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),s}let t=-1;this._layers.forEach((s,i)=>{if(s.layerView.wasmLayerId===e.wasmLayerId){t=i,s.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerViewUid.indexOf(e.uid);-1!==r&&this.layerViewUid.splice(r,1)}}),t>=0&&this._layers.delete(t);const s=this._layers.size;return 0===s&&(this._dbg(1," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),s}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,s=Number.MAX_VALUE,i=!1;return null!=e&&(e.isAllTime?i=!0:(null!=e.start&&(i=!0,t=e.start.getTime()/1e3),null!=e.end&&(i=!0,s=e.end.getTime()/1e3))),{startTime:t,endTime:s,hasTime:i}}_addVoxelLayer(e){const t=e.layer;let i=-1;const r=t.getConfiguration();if(r.length<1)return-1;const a={str:r,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(a))return-1;const l=this._getTimeArgs(t.timeExtent),o=this.view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;let h=0;if(t.timeOffset&&(h=n(t.timeOffset.value,t.timeOffset.unit,"seconds")),i=this._vxl.add_layer(t.serviceRoot,a.ptr,a.byteCount,o,o,l.startTime,l.endTime,l.hasTime,t.useViewTime,h,this._toWasmQuality(this.view.qualityProfile)),a.isReusable||this._vxl._free(a.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const r=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:r,needMemoryUsageUpdate:!1,isInScaleRange:!0}),this.layerViewUid.push(e.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&s.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&s.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&s.getLogger(this).error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&s.getLogger(this).warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&s.getLogger(this).warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bind.camera.viewForward,s=e.bind.camera.eye;this._vxl.update_camera_pos_and_direction(s[0],s[1],s[2],t[0],t[1],t[2]);const i=this._vxl.cull();this._dbg(2,"missingResourceCount="+i),this._moreToLoad=i>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}acquireTechniques(){return[]}render(e){if(!this._vxl)return;for(const s of this._newLayers){const e=this._addVoxelLayer(s.layerView);-1===e?s.rejectCallback(-1):s.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(4,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this.view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this.view.stage.renderer.isFeatureEnabled(2),e.bind.lighting.mainLight.direction[0],e.bind.lighting.mainLight.direction[1],e.bind.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach(e=>{e.needMemoryUsageUpdate=!0})),0===t.x&&0===t.y||this._dbg(4,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bind.camera),this._captureFrustum&&(this._frustum.update(e.bind.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(1,"--destroy--"),this._vxl&&(this._layers.forEach(e=>{e.abortController.abort()}),this._wasmMemBlocks.forEach(e=>{0!==e&&this._vxl._free(e)}),this._vxl.uninitialize_voxel_wasm(),this._removeRenderPlugin(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=_(e).then(e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(1," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this.view?.timeExtent),s=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),i=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),l=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),o=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),u=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(s,i,r,a,n,l,o,h,t.startTime,t.endTime,t.hasTime,d,u),this._renderPluginContext&&this._renderPluginContext.requestRender()}).catch(()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(4," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()})),this._vxlPromise)}pickDepth(e,t,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=s.viewport[3]-t;if(e<0||e>s.viewport[2]||t<0||t>s.viewport[3])return this._dbg(4,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${i.toFixed(0)}]]`),null;this._beforeDraw();const r=s.viewForward,a=s.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(s),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,i);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,s,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>s.viewport[2]||a<0||a>s.viewport[3])return this._dbg(4,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${s.viewport.toString()}]`),null;this._beforeDraw();const n=s.viewForward,l=s.eye;this._vxl.update_camera_pos_and_direction(l[0],l[1],l[2],n[0],n[1],n[2]),this.updateWasmCamera(s),this._vxl.begin_frame();let o=null;if(0===i.length)o=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:i}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(o=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),o}async getOtherFieldPopupValues(e,s){for(const i of e){const e=i.gpuResult;if(!e)continue;const r=this._layers.get(e.layerId);if(!r||!r.layerView.layer.url)continue;const a=r.layerView.layer,n={responseType:"array-buffer",signal:r.abortController.signal,query:{...r.layerView.layer.customParameters,token:r.layerView.layer.apiKey}},l=e.voxelSpacePosition,o=[Math.floor(l[0]/32),Math.floor(l[1]/32),Math.floor(l[2]/32)],h=[-4&o[0],-4&o[1],-4&o[2]];let d=0;if(e.epochTime){const t=this._vxl.get_layer_epoch_times(r.layerView.wasmLayerId,a.currentVariableId);for(let s=0;s<t.length;++s)if(t[s]===e.epochTime/1e3){d=s;break}}const u=[],_={varIds:[],ptrs:[],sizes:[]};for(const i of s){const e=a.variables.findIndex(e=>e.name===i);if(-1===e)continue;const s=a.variables.getItemAt(e)?.id;if(null==s)continue;const r=`${a.url}/variables/${s}/${d}/bundles/0/${h[0]}-${h[1]}-${h[2]}`;u.push(t(r,n).then(e=>e.data)),_.varIds.push(s)}const c=await Promise.allSettled(u),m=c.length;for(let t=0;t<m;++t){const e=c[t];if("fulfilled"===e.status){const t=e.value,s=this._vxl._malloc(t.byteLength);new Uint8Array(this._vxl.HEAPU8.buffer,s,t.byteLength).set(new Uint8Array(t)),_.ptrs.push(s),_.sizes.push(t.byteLength)}else _.varIds.splice(t,1)}const g=this._vxl.get_other_field_popup_values(e,_);for(let t=0;t<_.ptrs.length;++t)this._vxl._free(_.ptrs[t]);if(g.continuousValues)for(const t in g.continuousValues)i.attributes[t]=g.continuousValues[t];if(g.uniqueValues)for(const t in g.uniqueValues)i.attributes[t]=g.uniqueValues[t]}return e}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,s,i,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered||!e.camera)return;if(null==r||r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(4,r?`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`:"[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=null"),null;const a=[];this._layers.forEach(t=>{e.options.filteredLayerViewUids.includes(t.layerView.uid)&&a.push(t.layerView.wasmLayerId)});const n=this.pickObject(r[0],r[1],e.camera,a);if(null==n||-1===n.layerId)return;const l=this._layers.get(n.layerId);if(l){const t=l.layerView.layer.uid,r=n.distanceToCamera/h(s,i),a=d();a[0]=n.worldX,a[1]=n.worldY,a[2]=n.worldZ;const o={},u=l.layerView.layer,_=u.variables.findIndex(e=>e.id===u.currentVariableId);if(_>=0){const e=u.variables.getItemAt(_);null!=e&&(null!=n.continuousValue?o[e.name]=n.continuousValue:null!=n.uniqueValueLabel&&null!=n.uniqueValue?o[e.name]=`${n.uniqueValueLabel} (${n.uniqueValue})`:null!=n.uniqueValue&&(o[e.name]=`${n.uniqueValue}`),e.description.length>0?o["Voxel.CurrentVariable"]=e.description:e.name?.length>0&&(o["Voxel.CurrentVariable"]=e.name))}if(o["Voxel.Position"]=`[${n.voxelSpacePosition.toString()}]`,null!=n.epochTime&&null!=n.nativeTime&&null!=n.nativeTimeUnits){const e=new Date(n.epochTime);o["Voxel.LocalTime"]=e,o["Voxel.SourceTime"]=`${n.nativeTime.toLocaleString()} ${n.nativeTimeUnits}`}null!=n.depth&&(o["Voxel.Depth"]=n.depth);const c=n.faceNormal;o["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const g=e=>{const s=new m(a,t,()=>this._createVoxelGraphic(l.layerView.layer,o,n));e.set(this.type,s,r,c)},f=e.results,p=2===e.options.store;if((null==f.min.distance||r<f.min.distance)&&g(f.min),(null==f.max.distance||r>f.max.distance)&&g(f.max),p){const t=new y(e.ray);g(t),e.results.all.push(t)}}}_createVoxelGraphic(e,t,s){return new c({layer:e,sourceLayer:e,origin:e.graphicOrigin,attributes:t,gpuResult:s})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,s){this._vxl&&this._vxl.set_upscaling_limits(e,t,s)}hasHighlight(){return!1}};e([l({constructOnly:!0})],x.prototype,"view",void 0),x=e([o("esri.layers.VoxelWasmPerSceneView")],x);const v=x;export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import r from"../../PopupTemplate.js";import o from"../../request.js";import s from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import{LoadableMixin as a}from"../../core/Loadable.js";import n from"../../core/Logger.js";import{EsriPromiseMixin as p}from"../../core/Promise.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{enumeration as y}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../geometry/Extent.js";import m from"../../geometry/SpatialReference.js";import h from"../../graphic/BuildingGraphicOrigin.js";import f from"../FeatureLayer.js";import g from"./BuildingSublayer.js";import{zeroCapabilities as j}from"../support/capabilities.js";import{popupEnabled as v}from"../support/commonProperties.js";import{getFieldDomain as b}from"../support/featureLayerUtils.js";import{defineFieldProperties as L}from"../support/fieldProperties.js";import I from"../support/FieldsIndex.js";import{unpackFieldNames as S}from"../support/fieldUtils.js";import{fetchIndexInfo as F}from"../support/I3SIndexInfo.js";import{I3SNodePageDefinition as w,I3SMaterialDefinition as O,I3STextureSetDefinition as x,I3SGeometryDefinition as P}from"../support/I3SLayerDefinitions.js";import{webSceneRendererTypes as q}from"../../renderers/support/typeUtils.js";import T from"../../rest/support/Query.js";import{isNumber as Q}from"../../support/guards.js";import{createPopupTemplate as U}from"../../support/popupUtils.js";import E from"../../symbols/support/ElevationInfo.js";import{queryAttributesFromCachedAttributesId as D}from"../../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as R,getFetchPopupTemplate as A}from"../../views/layers/support/popupUtils.js";const _=L();let C=class extends(a(p(g))){constructor(e){super(e),this.type="building-component",this.nodePages=null,this.materialDefinitions=[],this.textureSetDefinitions=[],this.geometryDefinitions=[],this.indexInfo=null,this.serviceUpdateTimeStamp=null,this.store=null,this.attributeStorageInfo=[],this.fields=[],this.associatedLayer=null,this.outFields=null,this.listMode="show",this.renderer=null,this.definitionExpression=null,this.popupEnabled=!0,this.popupTemplate=null,this.layerType="3d-object"}initialize(){this._set("graphicOrigin",new h(this))}get parsedUrl(){return this.layer?{path:`${this.layer.parsedUrl?.path}/sublayers/${this.id}`,query:this.layer.parsedUrl?.query}:{path:""}}get fieldsIndex(){return new I(this.fields)}readAssociatedLayer(e,t){const r=this.layer.associatedFeatureServiceItem,o=t.associatedLayerID;return null!=r&&"number"==typeof o?new f({portalItem:r,customParameters:this.customParameters,layerId:o}):null}get objectIdField(){if(null!=this.fields)for(const e of this.fields)if("oid"===e.type)return e.name;return""}get globalIdField(){if(null!=this.fields)for(const e of this.fields)if("global-id"===e.type)return e.name;return""}get displayField(){return null!=this.associatedLayer?this.associatedLayer.displayField:void 0}get apiKey(){return this.layer.apiKey}get customParameters(){return this.layer.customParameters}get fullExtent(){return this.layer.fullExtent}get spatialReference(){return this.layer.spatialReference}get version(){return this.layer.version}get elevationInfo(){return this.layer.elevationInfo}get minScale(){return this.layer.minScale}get maxScale(){return this.layer.maxScale}get effectiveScaleRange(){return this.layer.effectiveScaleRange}get defaultPopupTemplate(){return this.createPopupTemplate()}load(e){const t=null!=e?e.signal:null,r=this._fetchService(t).then(()=>{this.indexInfo=F(this.parsedUrl.path,this.rootNode,this.nodePages,this.customParameters,this.apiKey,n.getLogger(this),t)});return this.addResolvingPromise(r),Promise.resolve(this)}createPopupTemplate(e){return U(this,e)}async _fetchService(e){const t=(await o(this.parsedUrl.path,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(t,{origin:"service",url:this.parsedUrl})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getField(e)?.domain??null;return this.associatedLayer?b(this.associatedLayer,e,t,r):r}getFeatureType(e){return e&&null!=this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return null!=this.associatedLayer?this.associatedLayer.types??[]:[]}get typeIdField(){return null!=this.associatedLayer?this.associatedLayer.typeIdField:null}get geometryType(){return"3d-object"===this.layerType?"mesh":"point"}get profile(){return"3d-object"===this.layerType?"mesh-pyramids":"points"}get capabilities(){const e=null!=this.associatedLayer&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:j,{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}=e;return{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}}createQuery(){const e=new T;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",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.layer,t.sourceLayer=this;return e})}async queryObjectIds(e,t){const r=await this._getAssociatedLayerForQuery();return(await r.queryObjectIds(e||this.createQuery(),t)).filter(Q)}async queryCachedAttributes(e,t){const r=S(this.fieldsIndex,await R(this,A(this)));return D(this.parsedUrl.path,this.attributeStorageInfo,e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const o=await this.queryCachedAttributes(e,[r]);if(!o||0===o.length)throw new s("scenelayer:feature-not-in-cached-data","Feature not found in cached data");return new t({attributes:o[0],layer:this,sourceLayer:this})}getFieldUsageInfo(e){return this.fieldsIndex.has(e)?{supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1}:{supportsLabelingInfo:!1,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:null!=this.associatedLayer}}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return null!=e&&e.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),null==this.associatedLayer)throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer component layer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}};e([l({readOnly:!0})],C.prototype,"parsedUrl",null),e([l({type:w,readOnly:!0})],C.prototype,"nodePages",void 0),e([l({type:[O],readOnly:!0})],C.prototype,"materialDefinitions",void 0),e([l({type:[x],readOnly:!0})],C.prototype,"textureSetDefinitions",void 0),e([l({type:[P],readOnly:!0})],C.prototype,"geometryDefinitions",void 0),e([l({readOnly:!0})],C.prototype,"serviceUpdateTimeStamp",void 0),e([l({readOnly:!0})],C.prototype,"store",void 0),e([l({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],C.prototype,"rootNode",void 0),e([l({readOnly:!0})],C.prototype,"attributeStorageInfo",void 0),e([l(_.fields)],C.prototype,"fields",void 0),e([l({readOnly:!0})],C.prototype,"fieldsIndex",null),e([l({readOnly:!0,type:f})],C.prototype,"associatedLayer",void 0),e([u("service","associatedLayer",["associatedLayerID"])],C.prototype,"readAssociatedLayer",null),e([l(_.outFields)],C.prototype,"outFields",void 0),e([l({type:String,readOnly:!0})],C.prototype,"objectIdField",null),e([l({type:String,readOnly:!0})],C.prototype,"globalIdField",null),e([l({readOnly:!0,type:String,json:{read:!1}})],C.prototype,"displayField",null),e([l({readOnly:!0,type:String})],C.prototype,"apiKey",null),e([l({readOnly:!0,type:String})],C.prototype,"customParameters",null),e([l({readOnly:!0,type:c})],C.prototype,"fullExtent",null),e([l({readOnly:!0,type:m})],C.prototype,"spatialReference",null),e([l({readOnly:!0})],C.prototype,"version",null),e([l({readOnly:!0,type:E})],C.prototype,"elevationInfo",null),e([l({readOnly:!0,type:Number})],C.prototype,"minScale",null),e([l({readOnly:!0,type:Number})],C.prototype,"maxScale",null),e([l({readOnly:!0,type:Number})],C.prototype,"effectiveScaleRange",null),e([l({type:["hide","show"],json:{write:!0}})],C.prototype,"listMode",void 0),e([l({types:q,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],C.prototype,"renderer",void 0),e([l({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],C.prototype,"definitionExpression",void 0),e([l(v)],C.prototype,"popupEnabled",void 0),e([l({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],C.prototype,"popupTemplate",void 0),e([l({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],C.prototype,"normalReferenceFrame",void 0),e([l({readOnly:!0,json:{read:!1}})],C.prototype,"defaultPopupTemplate",null),e([l({readOnly:!0})],C.prototype,"graphicOrigin",void 0),e([l()],C.prototype,"types",null),e([l()],C.prototype,"typeIdField",null),e([l({json:{write:!1}}),y(new i({"3DObject":"3d-object",Point:"point"}))],C.prototype,"layerType",void 0),e([l()],C.prototype,"geometryType",null),e([l()],C.prototype,"profile",null),e([l({readOnly:!0,json:{read:!1}})],C.prototype,"capabilities",null),e([l({readOnly:!0})],C.prototype,"statisticsInfo",void 0),C=e([d("esri.layers.buildingSublayers.BuildingComponentSublayer")],C);export{C as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import r from"../../PopupTemplate.js";import o from"../../request.js";import s from"../../core/Error.js";import{JSONMap as i}from"../../core/jsonMap.js";import{LoadableMixin as a}from"../../core/Loadable.js";import n from"../../core/Logger.js";import{EsriPromiseMixin as p}from"../../core/Promise.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{enumeration as y}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../geometry/Extent.js";import h from"../../geometry/SpatialReference.js";import m from"../../graphic/BuildingGraphicOrigin.js";import f from"../FeatureLayer.js";import g from"./BuildingSublayer.js";import{zeroCapabilities as j}from"../support/capabilities.js";import{popupEnabled as v}from"../support/commonProperties.js";import{getFieldDomain as b}from"../support/featureLayerUtils.js";import{defineFieldProperties as L}from"../support/fieldProperties.js";import I from"../support/FieldsIndex.js";import{unpackFieldNames as S}from"../support/fieldUtils.js";import{fetchIndexInfo as F}from"../support/I3SIndexInfo.js";import{I3SNodePageDefinition as O,I3SMaterialDefinition as w,I3STextureSetDefinition as x,I3SGeometryDefinition as P}from"../support/I3SLayerDefinitions.js";import{webSceneRendererTypes as q}from"../../renderers/support/typeUtils.js";import T from"../../rest/support/Query.js";import{isNumber as Q}from"../../support/guards.js";import{createPopupTemplate as U}from"../../support/popupUtils.js";import E from"../../symbols/support/ElevationInfo.js";import{queryAttributesFromCachedAttributesId as D}from"../../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as R,getFetchPopupTemplate as A}from"../../views/layers/support/popupUtils.js";const _=L();let C=class extends(a(p(g))){constructor(e){super(e),this.type="building-component",this.nodePages=null,this.materialDefinitions=[],this.textureSetDefinitions=[],this.geometryDefinitions=[],this.indexInfo=null,this.serviceUpdateTimeStamp=null,this.store=null,this.attributeStorageInfo=[],this.fields=[],this.associatedLayer=null,this.outFields=null,this.listMode="show",this.renderer=null,this.definitionExpression=null,this.popupEnabled=!0,this.popupTemplate=null,this.layerType="3d-object"}initialize(){this._set("graphicOrigin",new m(this))}get parsedUrl(){return this.layer?{path:`${this.layer.parsedUrl?.path}/sublayers/${this.id}`,query:this.layer.parsedUrl?.query}:{path:""}}get fieldsIndex(){return new I(this.fields)}readAssociatedLayer(e,t){const r=this.layer.associatedFeatureServiceItem,o=t.associatedLayerID;return null!=r&&"number"==typeof o?new f({portalItem:r,customParameters:this.customParameters,layerId:o}):null}get objectIdField(){if(null!=this.fields)for(const e of this.fields)if("oid"===e.type)return e.name;return""}get globalIdField(){if(null!=this.fields)for(const e of this.fields)if("global-id"===e.type)return e.name;return""}get displayField(){return null!=this.associatedLayer?this.associatedLayer.displayField:void 0}get apiKey(){return this.layer.apiKey}get customParameters(){return this.layer.customParameters}get fullExtent(){return this.layer.fullExtent}get spatialReference(){return this.layer.spatialReference}get version(){return this.layer.version}get elevationInfo(){return this.layer.elevationInfo}get minScale(){return this.layer.minScale}get maxScale(){return this.layer.maxScale}get effectiveScaleRange(){return this.layer.effectiveScaleRange}get defaultPopupTemplate(){return this.createPopupTemplate()}load(e){const t=null!=e?e.signal:null,r=this._fetchService(t).then(()=>{this.indexInfo=F(this.parsedUrl.path,this.rootNode,this.nodePages,this.customParameters,this.apiKey,n.getLogger(this),t)});return this.addResolvingPromise(r),Promise.resolve(this)}createPopupTemplate(e){return U(this,e)}async _fetchService(e){const t=(await o(this.parsedUrl.path,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(t,{origin:"service",url:this.parsedUrl})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getField(e)?.domain??null;return this.associatedLayer?b(this.associatedLayer,e,t,r):r}getFeatureType(e){return e&&null!=this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return null!=this.associatedLayer?this.associatedLayer.types??[]:[]}get typeIdField(){return null!=this.associatedLayer?this.associatedLayer.typeIdField:null}get geometryType(){return"3d-object"===this.layerType?"mesh":"point"}get profile(){return"3d-object"===this.layerType?"mesh-pyramids":"points"}get capabilities(){const e=null!=this.associatedLayer&&this.associatedLayer.capabilities?this.associatedLayer.capabilities:j,{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}=e;return{query:t,operations:{supportsQuery:r},data:{supportsZ:o,supportsM:s,isVersioned:i}}}createQuery(){const e=new T;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",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.layer,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryObjectIds(e,t){const r=await this._getAssociatedLayerForQuery();return(await r.queryObjectIds(e||this.createQuery(),t)).filter(Q)}async queryCachedAttributes(e,t){const r=S(this.fieldsIndex,await R(this,A(this)));return D(this.parsedUrl.path,this.attributeStorageInfo,e,t,r,this.apiKey,this.customParameters)}async queryCachedFeature(e,r){const o=await this.queryCachedAttributes(e,[r]);if(!o||0===o.length)throw new s("scenelayer:feature-not-in-cached-data","Feature not found in cached data");return new t({attributes:o[0],layer:this,sourceLayer:this})}getFieldUsageInfo(e){return this.fieldsIndex.has(e)?{supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1}:{supportsLabelingInfo:!1,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:null!=this.associatedLayer}}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return null!=e&&e.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),null==this.associatedLayer)throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer component layer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new s("buildingscenelayer:query-not-available","BuildingSceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}};e([l({readOnly:!0})],C.prototype,"parsedUrl",null),e([l({type:O,readOnly:!0})],C.prototype,"nodePages",void 0),e([l({type:[w],readOnly:!0})],C.prototype,"materialDefinitions",void 0),e([l({type:[x],readOnly:!0})],C.prototype,"textureSetDefinitions",void 0),e([l({type:[P],readOnly:!0})],C.prototype,"geometryDefinitions",void 0),e([l({readOnly:!0})],C.prototype,"serviceUpdateTimeStamp",void 0),e([l({readOnly:!0})],C.prototype,"store",void 0),e([l({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],C.prototype,"rootNode",void 0),e([l({readOnly:!0})],C.prototype,"attributeStorageInfo",void 0),e([l(_.fields)],C.prototype,"fields",void 0),e([l({readOnly:!0})],C.prototype,"fieldsIndex",null),e([l({readOnly:!0,type:f})],C.prototype,"associatedLayer",void 0),e([u("service","associatedLayer",["associatedLayerID"])],C.prototype,"readAssociatedLayer",null),e([l(_.outFields)],C.prototype,"outFields",void 0),e([l({type:String,readOnly:!0})],C.prototype,"objectIdField",null),e([l({type:String,readOnly:!0})],C.prototype,"globalIdField",null),e([l({readOnly:!0,type:String,json:{read:!1}})],C.prototype,"displayField",null),e([l({readOnly:!0,type:String})],C.prototype,"apiKey",null),e([l({readOnly:!0,type:String})],C.prototype,"customParameters",null),e([l({readOnly:!0,type:c})],C.prototype,"fullExtent",null),e([l({readOnly:!0,type:h})],C.prototype,"spatialReference",null),e([l({readOnly:!0})],C.prototype,"version",null),e([l({readOnly:!0,type:E})],C.prototype,"elevationInfo",null),e([l({readOnly:!0,type:Number})],C.prototype,"minScale",null),e([l({readOnly:!0,type:Number})],C.prototype,"maxScale",null),e([l({readOnly:!0,type:Number})],C.prototype,"effectiveScaleRange",null),e([l({type:["hide","show"],json:{write:!0}})],C.prototype,"listMode",void 0),e([l({types:q,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],C.prototype,"renderer",void 0),e([l({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],C.prototype,"definitionExpression",void 0),e([l(v)],C.prototype,"popupEnabled",void 0),e([l({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],C.prototype,"popupTemplate",void 0),e([l({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],C.prototype,"normalReferenceFrame",void 0),e([l({readOnly:!0,json:{read:!1}})],C.prototype,"defaultPopupTemplate",null),e([l({readOnly:!0})],C.prototype,"graphicOrigin",void 0),e([l()],C.prototype,"types",null),e([l()],C.prototype,"typeIdField",null),e([l({json:{write:!1}}),y(new i({"3DObject":"3d-object",Point:"point"}))],C.prototype,"layerType",void 0),e([l()],C.prototype,"geometryType",null),e([l()],C.prototype,"profile",null),e([l({readOnly:!0,json:{read:!1}})],C.prototype,"capabilities",null),e([l({readOnly:!0})],C.prototype,"statisticsInfo",void 0),C=e([d("esri.layers.buildingSublayers.BuildingComponentSublayer")],C);export{C as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{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 r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,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{makeEdgeCandidate as h,makeVertexCandidate as p}from"./SnappingCandidate.js";import{isDateField as y,isDateOnlyField as g,isTimestampOffsetField as x,isStringField as T,isTimeOnlyField as I}from"../../support/fieldUtils.js";import F from"../../../rest/support/AutoIntervalBinParameters.js";import _ from"../../../rest/support/DateBinParameters.js";import{unitsDict as V}from"../../../rest/support/DateBinUtils.js";import b from"../../../rest/support/FixedBoundariesBinParameters.js";import v from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as S,calculateStatistics as R,processSummaryStatisticsResult as B,calculateUniqueValuesCount as z,createUVResult as M,calculateClassBreaks as A,resolveCBResult as D,calculateHistogram as w,getAttributeComparator as P,calculatePercentile as N,binIndex as q,getBinParams as Z,isNullCountSupported as j}from"../../../statistics/utils.js";import{utc as G}from"../../../time/constants.js";import{DateTime as C}from"luxon";const E="bin";class O{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 r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}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;n(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:r,mode:n}=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(n,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,n=t.isPoint?k:t.lengths;if(f.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const n=f;n.coordsIndex=e;const p=y;p.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,r,n,p))continue;const I=(r.x-T.x)/o,F=(r.y-T.y)/l,_=I*I+F*F;_<=1&&u.candidates.push(h(s.getObjectId(x),d(T),Math.sqrt(_),d(n),d(p)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e,h=y;h.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=f;if(a.coordsIndex=e,c&&t===i-1&&a.x===h.x&&a.y===h.y)continue;const n=(r.x-a.x)/o,m=(r.y-a.y)/l,y=n*n+m*m;y<=1&&u.candidates.push(p(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=f;e.coordsIndex=i;const t=(r.x-e.x)/o,a=(r.y-e.y)/l,n=t*t+a*a;n<=1&&u.candidates.push(p(s.getObjectId(x),d(e),Math.sqrt(n)))}}}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:r}=this,n=0;return"3d"===e?r&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:n}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,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:r,scale:l,timeZone:u},this.items),h=j({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),p={value:.5,fieldType:m?.type},I=T(m)?S({values:f,supportsNullCount:h,percentileParams:p,outStatisticTypes:c}):R({values:f,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:h,percentileParams:p,outStatisticTypes:c});return B(I,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},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:r,classificationMethod:n,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:r,scale:m,timeZone:d},this.items),h=A(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return D(h,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,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:r,scale:m,timeZone:d},this.items);return w(f,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,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],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=P(r?.type,n);e.sort((e,t)=>{const s=i(e,a,r),n=i(t,a,r);return o(s,n)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:f,returnZ:h,returnM:p}=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&&p,hasZ:a&&h,objectIdFieldName:n,spatialReference:u(c||o),transform:m&&r(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:f,resultOffset:h,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let I=[],F=0;const _=[...t];if(this._sortFeatures(_,n,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=r(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),r={attributes:i.getAttributes(s),geometry:c(this.geometryType,this.hasZ,this.hasM,a,f,e,x,T),metadata:this.featureAdapter.getMetadata?.(s)};t&&a&&!r.geometry&&(r.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),I[F++]=r}else if(!u&&d)for(const s of _)I[F++]={attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e)};else for(const s of _)I[F++]={attributes:i.getAttributes(s),centroid:m(this,this.featureAdapter.getCentroid(s,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(s),f,e,x,T),metadata:this.featureAdapter.getMetadata?.(s)}}else for(const r of _){const e=i.getAttributes(r);e&&(I[F++]={attributes:e})}const V=h||0;if(null!=p){const e=V+p;I=I.slice(V,Math.min(I.length,e))}return I}_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,r=new Map,n=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:f,resultRecordCount:h}=e,p=m?.length,y=!!p,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,f=l,h="exceedslimit"!==c?l.onStatisticField:void 0,I="percentile_disc"===c||"percentile_cont"===c,F="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===p&&(h===g||x)&&"count"===c;if(y){if(!n.has(h)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}n.set(h,this._calculateUniqueValues(e,t,!F&&u.returnDistinctValues))}const i=n.get(h);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:l,itemPositions:c}=i[r],p=n.join(",");if(!d||u.validateItems(l,d)){const i=o.get(p)||{attributes:{}};if(F){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(f,l);i.aggregateGeometries[t]=e}else{let r=null;if(_)r=s;else{const e=this._getAttributeValues(u,h,t,a),i=c.map(t=>e[t]);r=I&&"statisticParameters"in f?this._getPercentileValue(f,i):this._getStatisticValue(f,i,null,u.returnDistinctValues)}i.attributes[e]=r}let r=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(p,i)}}}else if(F){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(f,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,h,t,a);i.attributes[e]=I&&"statisticParameters"in f?this._getPercentileValue(f,s):this._getStatisticValue(f,s,r,u.returnDistinctValues)}const V="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(h))&&!this._isAnyDateField(h)?null:this.fieldsIndex.get(h)?.type;s.push({name:e,alias:e,type:V||"esriFieldTypeDouble"})}const I=y?Array.from(o.values()):[i];return this._sortFeatures(I,f,(e,t)=>e.attributes[t]),h&&(I.length=Math.min(h,I.length)),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return y(t)||g(t)||x(t)||I(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:f,hasZ:h,hasM:p}=this,y=r.map(e=>c(f,h,p,m.getGeometry(e))),g=n(d,y,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=g?s(g):a(o(d,y));x.aggregateGeometries={...e,spatialReference:d},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=g?t(g):i(a(o(d,y)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=g,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?S({values:t,returnDistinct:s}):R({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return N(t,{value:r,orderBy:n,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),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:r,scale:n,timeZone:o}=t;return r?a.getExpressionValues(i,r,{viewingMode:"map",scale:n,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,r=t.max??0,n=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<=r){const e=q(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:E,alias:E,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(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(F.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(_.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(b.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:r,normalizationType:n,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:n,normalizationTotal:o,numBins:r,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:r,end:n,snapToData:o,returnFullIntervalBin:l}=e,u=a.unit,c=await this._getDataValues({field:e.field,timeZone:t.outTimeReference?.ianaTimeZone},i),m=I(this.fieldsIndex.get(s)),d=V.toJSON(u),h=c.filter(Boolean).sort((e,t)=>e-t),p=null!=r?f(r,m):h[0],y=null!=n?f(n,m):h[h.length-1],g={zone:t.outTimeReference?.ianaTimeZone??G},x=C.fromMillis(p,g),T=C.fromMillis(y,g),F=[];if("last"===o){let e=T;for(;e>x;){const t=e.minus({[d]:a.value});if(t<x){F.unshift([l?t.toMillis():x.toMillis(),e.toMillis()]);break}F.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?x:x.startOf(d);for(;e<=T;){const t=e.plus({[d]:a.value});if(t>T){F.push([e.toMillis(),l?t.toMillis():T.toMillis()]);break}F.push([e.toMillis(),t.toMillis()]),e=t}}const _=this._calculateHistogramBins(c,{intervals:F,min:p,max:y},i);return this._createFeaturesFromHistogramBins(_,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),r=I(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>f(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n}=e,o=await this._getDataValues({field:e.field,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),l=I(this.fieldsIndex.get(s)),u=Z(o,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:f(r,l),maxValue:f(n,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",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:E,alias:E,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,h={attributes:{}};let p;if(h.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,h.attributes[r]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(p=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),h.attributes[E]=++c,"flat"===t.bin.jsonStyle?n.push(...p.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...h.attributes}:{...t,...h.attributes}}))):(h.stackedAttributes=p.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(h))):(t.bin?.splitBy&&(h.attributes[E]=++c),p=await this._createStatisticsQueryResponse(t,s,h),n.push(h)),p.fields)for(const t of p.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function H(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*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 k=[1];export{O 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 r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,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 h}from"./queryUtils.js";import{makeEdgeCandidate as f,makeVertexCandidate as p}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 b from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as v,calculateStatistics as R,processSummaryStatisticsResult as B,calculateUniqueValuesCount as z,createUVResult as M,calculateClassBreaks as A,resolveCBResult as N,calculateHistogram as D,getAttributeComparator as w,calculatePercentile as P,binIndex as q,getBinParams as Z,isNullCountSupported as j}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 r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}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;n(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:r,mode:n}=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(n,t,this.spatialReference,i),h=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,n=t.isPoint?J:t.lengths;if(h.coords=i,y.coords=i,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e;for(let t=0;t<i;t++,e+=a){if(!c&&t===i-1)continue;const n=h;n.coordsIndex=e;const p=y;p.coordsIndex=t===i-1?m:e+a;const T=g;if(!H(g,r,n,p))continue;const F=(r.x-T.x)/o,I=(r.y-T.y)/l,_=F*F+I*I;_<=1&&u.candidates.push(f(s.getObjectId(x),d(T),Math.sqrt(_),d(n),d(p)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const i=n[t],m=e,f=y;f.coordsIndex=m;for(let t=0;t<i;t++,e+=a){const a=h;if(a.coordsIndex=e,c&&t===i-1&&a.x===f.x&&a.y===f.y)continue;const n=(r.x-a.x)/o,m=(r.y-a.y)/l,y=n*n+m*m;y<=1&&u.candidates.push(p(s.getObjectId(x),d(a),Math.sqrt(y)))}}}else if(m&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*a,!c&&s>1&&t.push(e-a)}for(const i of t){const e=h;e.coordsIndex=i;const t=(r.x-e.x)/o,a=(r.y-e.y)/l,n=t*t+a*a;n<=1&&u.candidates.push(p(s.getObjectId(x),d(e),Math.sqrt(n)))}}}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:r}=this,n=0;return"3d"===e?r&&t?({x:e,y:t,z:i})=>a({x:e,y:t,z:i}):({x:e,y:t})=>a({x:e,y:t,z:n}):({x:e,y:t})=>a({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=y(m)||g(m)||x(m),h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),f=j({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),p={value:.5,fieldType:m?.type},F=T(m)?v({values:h,supportsNullCount:f,percentileParams:p,outStatisticTypes:c}):R({values:h,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:p,outStatisticTypes:c});return B(F,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},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:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),f=A(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return N(f,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,h=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return D(h,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,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],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=w(r?.type,n);e.sort((e,t)=>{const s=i(e,a,r),n=i(t,a,r);return o(s,n)})}}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:m,resultRecordCount:d,resultOffset:h,returnZ:f,returnM:p}=e,y=null!=d&&t.length>(h||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&&p,hasZ:a&&f,objectIdFieldName:n,spatialReference:u(c||o),transform:m&&r(m)||null}}_createFeatures(e,t){const i=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:d,maxAllowableOffset:h,resultOffset:f,resultRecordCount:p,returnZ:y=!1,returnM:g=!1}=e,x=a&&y,T=s&&g;let F=[],I=0;const _=[...t];if(this._sortFeatures(_,n,(e,t,s)=>i.getFieldValue(e,t,s)),this.geometryType&&(u||d)){const e=r(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(u&&!d)for(const s of _){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:c(this.geometryType,this.hasZ,this.hasM,a,h,e,x,T)});t&&a&&!r.geometry&&(r.centroid=m(this,this.featureAdapter.getCentroid(s,this),e)),F[I++]=r}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.hasZ,this.hasM,this.featureAdapter.getGeometry(s),h,e,x,T)})}else for(const r of _){const e=i.getAttributes(r);e&&(F[I++]=this._addFeatureJSONMetadata(r,{attributes:e}))}const S=f||0;if(null!=p){const e=S+p;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,r=new Map,n=new Map,o=new Map,u=new l(e,this.featureAdapter,this.fieldsIndex),c=e.outStatistics,{groupByFieldsForStatistics:m,having:d,orderByFields:h,resultRecordCount:f}=e,p=m?.length,y=!!p,g=y?m[0]:null,x=y&&!this.fieldsIndex.get(g);for(const l of c??[]){const{outStatisticFieldName:e,statisticType:c}=l,h=l,f="exceedslimit"!==c?l.onStatisticField:void 0,F="percentile_disc"===c||"percentile_cont"===c,I="EnvelopeAggregate"===c||"CentroidAggregate"===c||"ConvexHullAggregate"===c,_=y&&1===p&&(f===g||x)&&"count"===c;if(y){if(!n.has(f)){const e=[];for(const i of m){const s=this._getAttributeValues(u,i,t,a);e.push(s)}n.set(f,this._calculateUniqueValues(e,t,!I&&u.returnDistinctValues))}const i=n.get(f);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:l,itemPositions:c}=i[r],p=n.join(",");if(!d||u.validateItems(l,d)){const i=o.get(p)||{attributes:{}};if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(h,l);i.aggregateGeometries[t]=e}else{let r=null;if(_)r=s;else{const e=this._getAttributeValues(u,f,t,a),i=c.map(t=>e[t]);r=F&&"statisticParameters"in h?this._getPercentileValue(h,i):this._getStatisticValue(h,i,null,u.returnDistinctValues)}i.attributes[e]=r}let r=0;m.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(p,i)}}}else if(I){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(h,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(u,f,t,a);i.attributes[e]=F&&"statisticParameters"in h?this._getPercentileValue(h,s):this._getStatisticValue(h,s,r,u.returnDistinctValues)}const S="min"!==c&&"max"!==c||!T(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,h,(e,t)=>e.attributes[t]),f&&(F.length=Math.min(f,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,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:m,spatialReference:d,geometryType:h,hasZ:f,hasM:p}=this,y=r.map(e=>c(h,f,p,m.getGeometry(e))),g=n(d,y,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=g?s(g):a(o(d,y));x.aggregateGeometries={...e,spatialReference:d},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=g?t(g):i(a(o(d,y)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:d},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=g,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):T(this.fieldsIndex.get(a))||this._isAnyDateField(a)?v({values:t,returnDistinct:s}):R({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return P(t,{value:r,orderBy:n,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),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,i,s=!0){const a=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:r,scale:n,timeZone:o}=t;return r?a.getExpressionValues(i,r,{viewingMode:"map",scale:n,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,r=t.max??0,n=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<=r){const e=q(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{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(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:l}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}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(b.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,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:n,normalizationTotal:o,numBins:r,minValue:h(l,!1),maxValue:h(u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,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),f=c.filter(Boolean).sort((e,t)=>e-t),p=null!=r?h(r,m):f[0],y=null!=n?h(n,m):f[f.length-1],g={zone:t.outTimeReference?.ianaTimeZone??G},x=C.fromMillis(p,g),T=C.fromMillis(y,g),I=[];if("last"===o){let e=T;for(;e>x;){const t=e.minus({[d]:a.value});if(t<x){I.unshift([l?t.toMillis():x.toMillis(),e.toMillis()]);break}I.unshift([t.toMillis(),e.toMillis()]),e=t}}else{let e="first"===o?x:x.startOf(d);for(;e<=T;){const t=e.plus({[d]:a.value});if(t>T){I.push([e.toMillis(),l?t.toMillis():T.toMillis()]);break}I.push([e.toMillis(),t.toMillis()]),e=t}}const _=this._calculateHistogramBins(c,{intervals:I,min:p,max:y},i);return this._createFeaturesFromHistogramBins(_,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s,timeZone:t.outTimeReference?.ianaTimeZone},i),r=F(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>h(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n}=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:h(r,l),maxValue:h(n,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",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,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 h of e){const{minValue:e,maxValue:i,items:s}=h,f={attributes:{}};let p;if(f.attributes[a]=m&&d&&null!=e?C.fromMillis(e,{zone:d}).toISO():e,f.attributes[r]=m&&d&&null!=i?C.fromMillis(i,{zone:d}).toISO():i,l?(p=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),f.attributes[O]=++c,"flat"===t.bin.jsonStyle?n.push(...p.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=p.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(f))):(t.bin?.splitBy&&(f.attributes[O]=++c),p=await this._createStatisticsQueryResponse(t,s,f),n.push(f)),p.fields)for(const t of p.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function H(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*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};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="
|
|
5
|
+
const e="20250816",a="6fa1a54711856824e699e89826240e2a4b37d908";export{e as buildDate,a as commitHash};
|