@arcgis/core 4.27.0-next.20230521 → 4.27.0-next.20230522
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/Graphic.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0d02856e55d20b99fc8b.js +1 -0
- package/assets/esri/core/workers/chunks/{69242c66492717c7388c.js → 0fcb8d408696075338e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{1edc5c06874cb12c5478.js → 17f313e548281bb5db3e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b91c155de9a89e4e6971.js → 187c3b971ed0fc4363ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{85c6ce93aa41e6b65997.js → 18db07d739a713cc0465.js} +1 -1
- package/assets/esri/core/workers/chunks/28286014a575042619ee.js +1 -0
- package/assets/esri/core/workers/chunks/{692dfeb2e255fdc0ade2.js → 39288fa69561d21f04f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2b9d3e60977934a6d471.js → 3bc6b5f0643364749ef8.js} +1 -1
- package/assets/esri/core/workers/chunks/45e5ad704d18dd0857ce.js +1 -0
- package/assets/esri/core/workers/chunks/{62d9d15f0d00a75da42c.js → 4670b17ae2ed3c13d344.js} +1 -1
- package/assets/esri/core/workers/chunks/4d24efa01d1accc5a5f0.js +1 -0
- package/assets/esri/core/workers/chunks/52575f021a14dd961de8.js +1 -0
- package/assets/esri/core/workers/chunks/{6312783626bacf52df7a.js → 55486c644e8b01326a0d.js} +1 -1
- package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +1 -0
- package/assets/esri/core/workers/chunks/5a4c04bf4f57e74457c5.js +1 -0
- package/assets/esri/core/workers/chunks/70d6e5edf05ef7079fa8.js +1 -0
- package/assets/esri/core/workers/chunks/71bdf8f10aee0077f681.js +1 -0
- package/assets/esri/core/workers/chunks/72b2c3c8e76da699690c.js +1 -0
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +1 -0
- package/assets/esri/core/workers/chunks/791f529e90135398b3d5.js +1 -0
- package/assets/esri/core/workers/chunks/8d3abfe6fdc5ac8d6cb7.js +1 -0
- package/assets/esri/core/workers/chunks/96d339abcd917f1f0ae1.js +1 -0
- package/assets/esri/core/workers/chunks/97cdbec7532cfcdf9ad2.js +1 -0
- package/assets/esri/core/workers/chunks/{f3f6035a17f7dcd19675.js → 9ab400a89dd701778d2c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1488b3d48232844b8bb4.js → 9fe349f43d5ff5a4ac2d.js} +1 -1
- package/assets/esri/core/workers/chunks/{22396dd3717d17a5d235.js → a1c31bb8c12831539328.js} +1 -1
- package/assets/esri/core/workers/chunks/b4e2dc6b3d06b426e596.js +1 -0
- package/assets/esri/core/workers/chunks/{48abcb2d88f22e6e9fde.js → c2cb9fa18c77f0c5104e.js} +1 -1
- package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +1 -0
- package/assets/esri/core/workers/chunks/d725dbbdeb05322e6d88.js +1 -0
- package/assets/esri/core/workers/chunks/df3e497d12ed77bae168.js +1 -0
- package/assets/esri/core/workers/chunks/{4d5f71d84c85f45c97ea.js → ed6f6e539a915ba9e64d.js} +1 -1
- package/assets/esri/core/workers/chunks/fb080339bfaf32731ca6.js +1 -0
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_FloorFilter.scss +6 -0
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +40 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
- package/chunks/mat4.js +1 -1
- package/core/accessorSupport/write.js +1 -1
- package/core/fontUtils.js +1 -1
- package/core/libs/gl-matrix-2/math/mat4.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedRelativeVertexSpace.js +5 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +4 -0
- package/geometry/support/MeshGeoreferencedVertexSpace.js +5 -0
- package/geometry/support/MeshLocalVertexSpace.d.ts +4 -0
- package/geometry/support/MeshLocalVertexSpace.js +5 -0
- package/geometry/support/MeshTransform.d.ts +4 -0
- package/geometry/support/MeshTransform.js +1 -1
- package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
- package/geometry/support/meshUtils/centerAt.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/geographicUtils.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/offset.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/interfaces.d.ts +227 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/networks/support/TopologyValidationJobInfo.js +1 -1
- package/package.json +1 -1
- package/popup/FieldInfo.js +1 -1
- package/portal/Portal.js +1 -1
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/meshFeatureSet.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +5 -0
- package/widgets/UtilityNetworkValidateTopology.js +5 -0
- package/assets/esri/core/workers/chunks/163bf2e13abbdd298374.js +0 -1
- package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +0 -1
- package/assets/esri/core/workers/chunks/2640204c4655aa535ccb.js +0 -1
- package/assets/esri/core/workers/chunks/2bf42d060f877566b989.js +0 -1
- package/assets/esri/core/workers/chunks/34ec9623a1bece86a82b.js +0 -1
- package/assets/esri/core/workers/chunks/3bf52139340827794c3b.js +0 -1
- package/assets/esri/core/workers/chunks/52d02021e858820bc4fa.js +0 -1
- package/assets/esri/core/workers/chunks/64b8f65e2ef6cbf08380.js +0 -1
- package/assets/esri/core/workers/chunks/78aede1e114deefacb54.js +0 -1
- package/assets/esri/core/workers/chunks/7ef100158ca28631fcaf.js +0 -1
- package/assets/esri/core/workers/chunks/93ad67930aa7d4a4b0ac.js +0 -1
- package/assets/esri/core/workers/chunks/964795dfb57f0d0635d0.js +0 -1
- package/assets/esri/core/workers/chunks/99ce0a202dcd3d7dc290.js +0 -1
- package/assets/esri/core/workers/chunks/abe6c99a1a719543dbe8.js +0 -1
- package/assets/esri/core/workers/chunks/c3bf44146fddfe8990f7.js +0 -1
- package/assets/esri/core/workers/chunks/cbe817e966b57599bafd.js +0 -1
- package/assets/esri/core/workers/chunks/e15b5d7e46a834eacc57.js +0 -1
- package/assets/esri/core/workers/chunks/e1e0b3580e2c3098c9f4.js +0 -1
- package/assets/esri/core/workers/chunks/e305d20e4424451cab5b.js +0 -1
- package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{id as s}from"../../../kernel.js";import r from"../../../request.js";import a from"../../../TimeExtent.js";import{isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as n}from"../../../core/jsonMap.js";import u from"../../../core/Loadable.js";import l from"../../../core/Logger.js";import{setDeepValue as d}from"../../../core/object.js";import{debounce as c,after as p}from"../../../core/promiseUtils.js";import{join as h,parseData as y}from"../../../core/urlUtils.js";import{generateBracedUUID as m}from"../../../core/uuid.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../geometry/Extent.js";import{initializeProjection as b,project as F}from"../../../geometry/projection.js";import{fromJSON as S}from"../../../geometry/support/jsonUtils.js";import{isOriginalExternal as E}from"../../../geometry/support/meshUtils/External.js";import{isFeatureIdentifierArrayWithGlobalId as q,isFeatureIdentifierArrayWithObjectId as w}from"../editingSupport.js";import{createDrawingInfo as _}from"./support/clientSideDefaults.js";import O from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{getAssetMapTable as A}from"../../support/infoFor3D.js";import{executeQueryJSON as j}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as T}from"../../../rest/query/operations/editsZScale.js";import x from"../../../rest/support/Query.js";import N from"../../../geometry/SpatialReference.js";const J=new n({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),v=new Set(["Feature Layer","Table"]),k=new n({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let M=class extends u{constructor(){super(...arguments),this.type="feature-layer",this.refresh=c((async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}})),this._ongoingAssetUploads=new Map}load(e){const t=null!=e?e.signal:null,s=this.layer.sourceJSON;return this.addResolvingPromise(this._fetchService(s,t)),Promise.resolve(this)}get queryTask(){const{capabilities:e,parsedUrl:t,dynamicDataSource:s,infoFor3D:r,gdbVersion:a,spatialReference:i,fieldsIndex:o}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==r,u=e?.operations?.supportsQueryAttachments??!1;return new O({url:t.path,pbfSupported:n,fieldsIndex:o,infoFor3D:r,dynamicDataSource:s,gdbVersion:a,sourceSpatialReference:i,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],a=this.layer.parsedUrl.path+"/"+s+"/addAttachment",i=this._getLayerRequestOptions(),o=this._getFormDataForAttachment(t,i.query);try{const e=await r(a,{body:o});return this._createFeatureEditResult(e.data.addAttachmentResult)}catch(n){throw this._createAttachmentErrorResult(s,n)}}async updateAttachment(e,t,s){await this.load();const a=e.attributes[this.layer.objectIdField],i=this.layer.parsedUrl.path+"/"+a+"/updateAttachment",o=this._getLayerRequestOptions({query:{attachmentId:t}}),n=this._getFormDataForAttachment(s,o.query);try{const e=await r(i,{body:n});return this._createFeatureEditResult(e.data.updateAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(a,u)}}async applyEdits(e,t){await this.load();const{layer:a}=this,o=a.infoFor3D,n=null!=o,u=n||(t?.globalIdUsed??!1),l=e.addFeatures?.map((e=>this._getFeatureJSON(e,o)))??[],d=(await Promise.all(l)).filter(i),c=e.updateFeatures?.map((e=>this._getFeatureJSON(e,o)))??[],p=(await Promise.all(c)).filter(i),h=this._getFeatureIds(e.deleteFeatures,u);T(d,p,a.spatialReference);const y=await this._getAttachmentEditsJSON(e),m=n?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,g=a.capabilities.editing.supportsAsyncApplyEdits&&null!=m&&(0!==m.adds.length||0!==m.updates.length),f={gdbVersion:t?.gdbVersion||a.gdbVersion,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:u,returnEditMoment:t?.returnEditMoment,usePreviousEditMoment:t?.usePreviousEditMoment,sessionId:t?.sessionId,async:g};t?.returnServiceEditsOption?(f.edits=JSON.stringify([{id:a.layerId,adds:d,updates:p,deletes:h,attachments:y,assetMaps:m}]),f.returnServiceEditsOption=J.toJSON(t?.returnServiceEditsOption),f.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(f.adds=d.length?JSON.stringify(d):null,f.updates=p.length?JSON.stringify(p):null,f.deletes=h.length?u?JSON.stringify(h):h.join(","):null,f.attachments=y&&JSON.stringify(y),f.assetMaps=null!=m?JSON.stringify(m):void 0);const R=this._getLayerRequestOptions({method:"post",query:f}),b=t?.returnServiceEditsOption?a.url:a.parsedUrl.path,F=g?await this._asyncApplyEdits(b+"/applyEdits",R):await r(b+"/applyEdits",R);if(!a.capabilities.operations?.supportsEditing&&a.effectiveCapabilities?.operations?.supportsEditing){const e=s?.findCredential(a.url);await(e?.refreshToken())}return this._createEditsResult(F)}async deleteAttachments(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],a=this.layer.parsedUrl.path+"/"+s+"/deleteAttachments";try{return(await r(a,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(this._createFeatureEditResult)}catch(i){throw this._createAttachmentErrorResult(s,i)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:i}=this.layer,{data:o}=await r(`${i}/${s}`,t),{id:n,extent:u,fullExtent:l,timeExtent:d}=o,c=u||l;return{id:n,fullExtent:c&&R.fromJSON(c),timeExtent:d&&a.fromJSON({start:d[0],end:d[1]})}}))}async queryAttachments(e,t={}){await this.load();const s=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,s)}async queryFeatures(e,t){return await this.load(),this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!I(this.layer.url))return"unavailable";const e=h(this.layer.url,"status"),t=await r(e,{query:{f:"json"}});return k.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:s}=await import("./support/uploadAssets.js");return s(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}async _asyncApplyEdits(e,t){const s=(await r(e,t)).data.statusUrl;for(;;){const e=(await r(s,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return r(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new o("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new o("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await p(U)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const{data:s}=await r(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:has("featurelayer-advanced-symbols")?{returnAdvancedSymbols:!0}:{},signal:t}));e=s}this.sourceJSON=this._patchServiceJSON(e);const s=e.type;if(!v.has(s))throw new o("feature-layer-source:unsupported-type",`Source type "${s}" is not supported`)}_patchServiceJSON(e){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=_(e.geometryType).renderer;d("drawingInfo.renderer",t,e)}return"esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),e}async _getFeatureJSON(e,t){const{geometry:s}=e,r={...e.attributes};if(null!=t&&null!=e.geometry&&"mesh"===e.geometry.type){const{transformFieldRoles:s}=t,{origin:a,spatialReference:i,transform:o}=e.geometry,n=this.layer.spatialReference;await b(i,n);const u=F(a,n);if(r[s.originX]=u.x,r[s.originY]=u.y,r[s.originZ]=u.z,null!=o){const{translation:e,scale:t,rotation:a}=o;r[s.translationX]=e[0],r[s.translationY]=-e[2],r[s.translationZ]=e[1],r[s.scaleX]=t[0],r[s.scaleY]=t[1],r[s.scaleZ]=t[2],r[s.rotationX]=a[0],r[s.rotationY]=a[2],r[s.rotationZ]=a[1],r[s.rotationDeg]=a[3]}return{geometry:null,attributes:r}}return null==s?{attributes:r}:"mesh"===s.type||"extent"===s.type?null:{geometry:s.toJSON(),attributes:r}}async _getAttachmentEditsJSON(e){const t=await Promise.all((e.addAttachments??[]).map((e=>this._getAttachmentEditJSON(e)))),s=await Promise.all((e.updateAttachments??[]).map((e=>this._getAttachmentEditJSON(e)))),r=e.deleteAttachments??[];return t.length||s.length||r.length?{adds:t,updates:s,deletes:[...r]}:null}async _getAttachmentEditJSON(e){const{feature:t,attachment:s}=e,{globalId:r,name:a,contentType:i,data:o,uploadId:n}=s,u={globalId:r,parentGlobalId:null,contentType:null,name:null,uploadId:null,data:null};if(t&&(u.parentGlobalId="attributes"in t?t.attributes&&t.attributes[this.layer.globalIdField]:t.globalId),n)u.uploadId=n;else if(o){const e=await y(o);e&&(u.contentType=e.mediaType,u.data=e.data),o instanceof File&&(u.name=o.name)}return a&&(u.name=a),i&&(u.contentType=i),u}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;const s=await this._filterRedundantAssetMaps(t);if(!t?.length)return null;const r=s.map((e=>e.geometry));return await this.uploadAssets(r),{adds:this._getAssetMapEditsJSON(s),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,s=this.layer.globalIdField,r=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,o=i.getExternalSourcesOnService(r),n=a.getAttribute(s);if(0===o.length){l.getLogger(this).error(`Skipping feature ${n}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:u}=o.find(E)??o[0],{transform:d}=e,c=!d||!d.geographic?["PROJECT_VERTICES"]:[];for(const s of u)1===s.parts.length?t.push({globalId:m(),parentGlobalId:n,assetName:s.assetName,assetHash:s.parts[0].partHash,flags:c}):l.getLogger(this).error(`Skipping asset ${s.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_getFeatureIds(e,t){if(!e||0===e.length)return[];if(t&&q(e))return e.map((e=>e.globalId));if(w(e))return e.map((e=>e.objectId));const{layer:s}=this,r=t?s.globalIdField:s.objectIdField;return r?e.map((e=>e.getAttribute(r))):[]}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,r=[];let a=null;if(Array.isArray(t))for(const u of t)r.push({id:u.id,editedFeatures:u.editedFeatures}),u.id===s&&(a={addResults:u.addResults??[],updateResults:u.updateResults??[],deleteResults:u.deleteResults??[],attachments:u.attachments,editMoment:u.editMoment});else a=t;const i=a?.assetMaps;if(i){for(const e of i.addResults)e.success||l.getLogger(this).error(`Failed to map asset to feature with globalId ${e.globalId}.`);for(const e of i.updateResults)e.success||l.getLogger(this).error(`Failed to map asset to feature with globalId ${e.globalId}.`)}const o=a?.attachments,n={addFeatureResults:a?.addResults?.map(this._createFeatureEditResult,this)??[],updateFeatureResults:a?.updateResults?.map(this._createFeatureEditResult,this)??[],deleteFeatureResults:a?.deleteResults?.map(this._createFeatureEditResult,this)??[],addAttachmentResults:o&&o.addResults?o.addResults.map(this._createFeatureEditResult,this):[],updateAttachmentResults:o&&o.updateResults?o.updateResults.map(this._createFeatureEditResult,this):[],deleteAttachmentResults:o&&o.deleteResults?o.deleteResults.map(this._createFeatureEditResult,this):[]};if(a?.editMoment&&(n.editMoment=a.editMoment),r.length>0){n.editedFeatureResults=[];for(const e of r){const{editedFeatures:t}=e,s=t?.spatialReference?new N(t.spatialReference):null;n.editedFeatureResults.push({layerId:e.id,editedFeatures:{adds:t?.adds?.map((e=>this._createEditedFeature(e,s)))||[],updates:t?.updates?.map((e=>({original:this._createEditedFeature(e[0],s),current:this._createEditedFeature(e[1],s)})))||[],deletes:t?.deletes?.map((e=>this._createEditedFeature(e,s)))||[],spatialReference:s}})}}return n}_createEditedFeature(e,s){return new t({attributes:e.attributes,geometry:S({...e.geometry,spatialReference:s})})}_createFeatureEditResult(e){const t=!0===e.success?null:e.error||{code:void 0,description:void 0};return{objectId:e.objectId,globalId:e.globalId,error:t?new o("feature-layer-source:edit-failure",t.description,{code:t.code}):null}}_createAttachmentErrorResult(e,t){const s=t.details.messages&&t.details.messages[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new o("feature-layer-source:attachment-failure",s,{code:r})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const r in t){const e=t[r];null!=e&&(s.set?s.set(r,e):s.append(r,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:r}=this.layer;return{...e,query:{gdbVersion:s,layer:r?JSON.stringify({source:r}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _filterRedundantAssetMaps(e){const{layer:t}=this,{globalIdField:s,infoFor3D:r,parsedUrl:a}=t;if(null==r||null==s)return e;const o=A(r);if(null==o)return e;const n=h(a.path,`../${o.id}`),u=e.map((e=>e.getAttribute(s))).filter(i);if(0===u.length)return e;const{assetMapFieldRoles:{parentGlobalId:l,assetHash:d}}=r,c=new x;c.where=`${l} IN (${u.map((e=>`'${e}'`))})`,c.outFields=[d,l],c.returnGeometry=!1;const p=await j(n,c),{features:y}=p;return 0===y.length?e:e.filter((e=>{const t=e.getAttribute(s);if(!t)return!0;const{metadata:r}=e.geometry,i=y.filter((e=>e.getAttribute(l)===t));if(0===i.length)return!0;const o=i.map((e=>e.getAttribute(d)));return r.getExternalSourcesOnService(a).flatMap((({source:e})=>e.flatMap((e=>e.parts.map((e=>e.partHash)))))).some((e=>o.every((t=>e!==t))))}))}};e([g()],M.prototype,"type",void 0),e([g({constructOnly:!0})],M.prototype,"layer",void 0),e([g({readOnly:!0})],M.prototype,"queryTask",null),M=e([f("esri.layers.graphics.sources.FeatureLayerSource")],M);const U=1e3,Q=M;export{Q as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{id as s}from"../../../kernel.js";import r from"../../../request.js";import a from"../../../TimeExtent.js";import{isSome as i}from"../../../core/arrayUtils.js";import o from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as n}from"../../../core/jsonMap.js";import u from"../../../core/Loadable.js";import l from"../../../core/Logger.js";import{setDeepValue as d}from"../../../core/object.js";import{debounce as c,after as p}from"../../../core/promiseUtils.js";import{join as h,parseData as y}from"../../../core/urlUtils.js";import{generateBracedUUID as m}from"../../../core/uuid.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../geometry/Extent.js";import{initializeProjection as b,project as F}from"../../../geometry/projection.js";import{fromJSON as S}from"../../../geometry/support/jsonUtils.js";import{isOriginalExternal as E}from"../../../geometry/support/meshUtils/External.js";import{isFeatureIdentifierArrayWithGlobalId as q,isFeatureIdentifierArrayWithObjectId as w}from"../editingSupport.js";import{createDrawingInfo as _}from"./support/clientSideDefaults.js";import O from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{getAssetMapTable as A}from"../../support/infoFor3D.js";import{executeQueryJSON as j}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as T}from"../../../rest/query/operations/editsZScale.js";import x from"../../../rest/support/Query.js";import N from"../../../geometry/SpatialReference.js";const J=new n({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),v=new Set(["Feature Layer","Table"]),k=new n({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let M=class extends u{constructor(){super(...arguments),this.type="feature-layer",this.refresh=c((async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}})),this._ongoingAssetUploads=new Map}load(e){const t=null!=e?e.signal:null,s=this.layer.sourceJSON;return this.addResolvingPromise(this._fetchService(s,t)),Promise.resolve(this)}get queryTask(){const{capabilities:e,parsedUrl:t,dynamicDataSource:s,infoFor3D:r,gdbVersion:a,spatialReference:i,fieldsIndex:o}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==r,u=e?.operations?.supportsQueryAttachments??!1;return new O({url:t.path,pbfSupported:n,fieldsIndex:o,infoFor3D:r,dynamicDataSource:s,gdbVersion:a,sourceSpatialReference:i,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],a=this.layer.parsedUrl.path+"/"+s+"/addAttachment",i=this._getLayerRequestOptions(),o=this._getFormDataForAttachment(t,i.query);try{const e=await r(a,{body:o});return this._createFeatureEditResult(e.data.addAttachmentResult)}catch(n){throw this._createAttachmentErrorResult(s,n)}}async updateAttachment(e,t,s){await this.load();const a=e.attributes[this.layer.objectIdField],i=this.layer.parsedUrl.path+"/"+a+"/updateAttachment",o=this._getLayerRequestOptions({query:{attachmentId:t}}),n=this._getFormDataForAttachment(s,o.query);try{const e=await r(i,{body:n});return this._createFeatureEditResult(e.data.updateAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(a,u)}}async applyEdits(e,t){await this.load();const{layer:a}=this,o=a.infoFor3D,n=null!=o,u=n||(t?.globalIdUsed??!1),l=e.addFeatures?.map((e=>this._getFeatureJSON(e,o)))??[],d=(await Promise.all(l)).filter(i),c=e.updateFeatures?.map((e=>this._getFeatureJSON(e,o)))??[],p=(await Promise.all(c)).filter(i),h=this._getFeatureIds(e.deleteFeatures,u);T(d,p,a.spatialReference);const y=await this._getAttachmentEditsJSON(e),m=n?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,g=a.capabilities.editing.supportsAsyncApplyEdits&&null!=m&&(0!==m.adds.length||0!==m.updates.length),f={gdbVersion:t?.gdbVersion||a.gdbVersion,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:u,returnEditMoment:t?.returnEditMoment,usePreviousEditMoment:t?.usePreviousEditMoment,sessionId:t?.sessionId,async:g};t?.returnServiceEditsOption?(f.edits=JSON.stringify([{id:a.layerId,adds:d,updates:p,deletes:h,attachments:y,assetMaps:m}]),f.returnServiceEditsOption=J.toJSON(t?.returnServiceEditsOption),f.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(f.adds=d.length?JSON.stringify(d):null,f.updates=p.length?JSON.stringify(p):null,f.deletes=h.length?u?JSON.stringify(h):h.join(","):null,f.attachments=y&&JSON.stringify(y),f.assetMaps=null!=m?JSON.stringify(m):void 0);const R=this._getLayerRequestOptions({method:"post",query:f}),b=t?.returnServiceEditsOption?a.url:a.parsedUrl.path,F=g?await this._asyncApplyEdits(b+"/applyEdits",R):await r(b+"/applyEdits",R);if(!a.capabilities.operations?.supportsEditing&&a.effectiveCapabilities?.operations?.supportsEditing){const e=s?.findCredential(a.url);await(e?.refreshToken())}return this._createEditsResult(F)}async deleteAttachments(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],a=this.layer.parsedUrl.path+"/"+s+"/deleteAttachments";try{return(await r(a,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(this._createFeatureEditResult)}catch(i){throw this._createAttachmentErrorResult(s,i)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:i}=this.layer,{data:o}=await r(`${i}/${s}`,t),{id:n,extent:u,fullExtent:l,timeExtent:d}=o,c=u||l;return{id:n,fullExtent:c&&R.fromJSON(c),timeExtent:d&&a.fromJSON({start:d[0],end:d[1]})}}))}async queryAttachments(e,t={}){await this.load();const s=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,s)}async queryFeatures(e,t){return await this.load(),this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!I(this.layer.url))return"unavailable";const e=h(this.layer.url,"status"),t=await r(e,{query:{f:"json"}});return k.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:s}=await import("./support/uploadAssets.js");return s(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}async _asyncApplyEdits(e,t){const s=(await r(e,t)).data.statusUrl;for(;;){const e=(await r(s,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return r(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new o("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new o("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await p(U)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const{data:s}=await r(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:has("featurelayer-advanced-symbols")?{returnAdvancedSymbols:!0}:{},signal:t}));e=s}this.sourceJSON=this._patchServiceJSON(e);const s=e.type;if(!v.has(s))throw new o("feature-layer-source:unsupported-type",`Source type "${s}" is not supported`)}_patchServiceJSON(e){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=_(e.geometryType).renderer;d("drawingInfo.renderer",t,e)}return"esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),e}async _getFeatureJSON(e,t){const{geometry:s}=e,r={...e.attributes};if(null!=t&&null!=e.geometry&&"mesh"===e.geometry.type){const{transformFieldRoles:s}=t,{origin:a,spatialReference:i,transform:o}=e.geometry,n=this.layer.spatialReference;await b(i,n);const u=F(a,n);if(r[s.originX]=u.x,r[s.originY]=u.y,r[s.originZ]=u.z??0,null!=o){const{translation:e,scale:t,rotation:a}=o;r[s.translationX]=e[0],r[s.translationY]=-e[2],r[s.translationZ]=e[1],r[s.scaleX]=t[0],r[s.scaleY]=t[1],r[s.scaleZ]=t[2],r[s.rotationX]=a[0],r[s.rotationY]=a[2],r[s.rotationZ]=a[1],r[s.rotationDeg]=a[3]}return{geometry:null,attributes:r}}return null==s?{attributes:r}:"mesh"===s.type||"extent"===s.type?null:{geometry:s.toJSON(),attributes:r}}async _getAttachmentEditsJSON(e){const t=await Promise.all((e.addAttachments??[]).map((e=>this._getAttachmentEditJSON(e)))),s=await Promise.all((e.updateAttachments??[]).map((e=>this._getAttachmentEditJSON(e)))),r=e.deleteAttachments??[];return t.length||s.length||r.length?{adds:t,updates:s,deletes:[...r]}:null}async _getAttachmentEditJSON(e){const{feature:t,attachment:s}=e,{globalId:r,name:a,contentType:i,data:o,uploadId:n}=s,u={globalId:r,parentGlobalId:null,contentType:null,name:null,uploadId:null,data:null};if(t&&(u.parentGlobalId="attributes"in t?t.attributes&&t.attributes[this.layer.globalIdField]:t.globalId),n)u.uploadId=n;else if(o){const e=await y(o);e&&(u.contentType=e.mediaType,u.data=e.data),o instanceof File&&(u.name=o.name)}return a&&(u.name=a),i&&(u.contentType=i),u}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;const s=await this._filterRedundantAssetMaps(t);if(!t?.length)return null;const r=s.map((e=>e.geometry));return await this.uploadAssets(r),{adds:this._getAssetMapEditsJSON(s),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,s=this.layer.globalIdField,r=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,o=i.getExternalSourcesOnService(r),n=a.getAttribute(s);if(0===o.length){l.getLogger(this).error(`Skipping feature ${n}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:u}=o.find(E)??o[0],{vertexSpace:d}=e,c=d.isGeoreferenced?["PROJECT_VERTICES"]:[];for(const s of u)1===s.parts.length?t.push({globalId:m(),parentGlobalId:n,assetName:s.assetName,assetHash:s.parts[0].partHash,flags:c}):l.getLogger(this).error(`Skipping asset ${s.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_getFeatureIds(e,t){if(!e||0===e.length)return[];if(t&&q(e))return e.map((e=>e.globalId));if(w(e))return e.map((e=>e.objectId));const{layer:s}=this,r=t?s.globalIdField:s.objectIdField;return r?e.map((e=>e.getAttribute(r))):[]}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,r=[];let a=null;if(Array.isArray(t))for(const u of t)r.push({id:u.id,editedFeatures:u.editedFeatures}),u.id===s&&(a={addResults:u.addResults??[],updateResults:u.updateResults??[],deleteResults:u.deleteResults??[],attachments:u.attachments,editMoment:u.editMoment});else a=t;const i=a?.assetMaps;if(i){for(const e of i.addResults)e.success||l.getLogger(this).error(`Failed to map asset to feature with globalId ${e.globalId}.`);for(const e of i.updateResults)e.success||l.getLogger(this).error(`Failed to map asset to feature with globalId ${e.globalId}.`)}const o=a?.attachments,n={addFeatureResults:a?.addResults?.map(this._createFeatureEditResult,this)??[],updateFeatureResults:a?.updateResults?.map(this._createFeatureEditResult,this)??[],deleteFeatureResults:a?.deleteResults?.map(this._createFeatureEditResult,this)??[],addAttachmentResults:o&&o.addResults?o.addResults.map(this._createFeatureEditResult,this):[],updateAttachmentResults:o&&o.updateResults?o.updateResults.map(this._createFeatureEditResult,this):[],deleteAttachmentResults:o&&o.deleteResults?o.deleteResults.map(this._createFeatureEditResult,this):[]};if(a?.editMoment&&(n.editMoment=a.editMoment),r.length>0){n.editedFeatureResults=[];for(const e of r){const{editedFeatures:t}=e,s=t?.spatialReference?new N(t.spatialReference):null;n.editedFeatureResults.push({layerId:e.id,editedFeatures:{adds:t?.adds?.map((e=>this._createEditedFeature(e,s)))||[],updates:t?.updates?.map((e=>({original:this._createEditedFeature(e[0],s),current:this._createEditedFeature(e[1],s)})))||[],deletes:t?.deletes?.map((e=>this._createEditedFeature(e,s)))||[],spatialReference:s}})}}return n}_createEditedFeature(e,s){return new t({attributes:e.attributes,geometry:S({...e.geometry,spatialReference:s})})}_createFeatureEditResult(e){const t=!0===e.success?null:e.error||{code:void 0,description:void 0};return{objectId:e.objectId,globalId:e.globalId,error:t?new o("feature-layer-source:edit-failure",t.description,{code:t.code}):null}}_createAttachmentErrorResult(e,t){const s=t.details.messages&&t.details.messages[0]||t.message,r=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new o("feature-layer-source:attachment-failure",s,{code:r})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const r in t){const e=t[r];null!=e&&(s.set?s.set(r,e):s.append(r,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:r}=this.layer;return{...e,query:{gdbVersion:s,layer:r?JSON.stringify({source:r}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _filterRedundantAssetMaps(e){const{layer:t}=this,{globalIdField:s,infoFor3D:r,parsedUrl:a}=t;if(null==r||null==s)return e;const o=A(r);if(null==o)return e;const n=h(a.path,`../${o.id}`),u=e.map((e=>e.getAttribute(s))).filter(i);if(0===u.length)return e;const{assetMapFieldRoles:{parentGlobalId:l,assetHash:d}}=r,c=new x;c.where=`${l} IN (${u.map((e=>`'${e}'`))})`,c.outFields=[d,l],c.returnGeometry=!1;const p=await j(n,c),{features:y}=p;return 0===y.length?e:e.filter((e=>{const t=e.getAttribute(s);if(!t)return!0;const{metadata:r}=e.geometry,i=y.filter((e=>e.getAttribute(l)===t));if(0===i.length)return!0;const o=i.map((e=>e.getAttribute(d)));return r.getExternalSourcesOnService(a).flatMap((({source:e})=>e.flatMap((e=>e.parts.map((e=>e.partHash)))))).some((e=>o.every((t=>e!==t))))}))}};e([g()],M.prototype,"type",void 0),e([g({constructOnly:!0})],M.prototype,"layer",void 0),e([g({readOnly:!0})],M.prototype,"queryTask",null),M=e([f("esri.layers.graphics.sources.FeatureLayerSource")],M);const U=1e3,Q=M;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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import"../../core/has.js";import{strict as s}from"../../core/jsonMap.js";import{createAbortError as r}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../rest/networks/support/ValidateNetworkTopologyResult.js";const n=s()({Pending:"job-waiting",InProgress:"job-executing",Completed:"job-succeeded"});let p=class extends c{constructor(t){super(t),this.statusUrl=null,this.status=null,this.submissionTime=null,this.lastUpdatedTime=null,this._timer=void 0}destroy(){clearInterval(this._timer)}async checkJobStatus(t){const s={...t,query:{f:"json"}},{data:r}=await e(this.statusUrl,s);return this.read(r),
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import"../../core/has.js";import{strict as s}from"../../core/jsonMap.js";import{createAbortError as r}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{enumeration as i}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import c from"../../rest/networks/support/ValidateNetworkTopologyResult.js";const n=s()({Pending:"job-waiting",InProgress:"job-executing",Completed:"job-succeeded"});let p=class extends c{constructor(t){super(t),this.statusUrl=null,this.status=null,this.submissionTime=null,this.lastUpdatedTime=null,this._timer=void 0}destroy(){clearInterval(this._timer)}async checkJobStatus(t){const s={...t,query:{f:"json"}},{data:r}=await e(this.statusUrl,s);return this.read(r),this.editsResolver&&this.editsResolver.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:!0}),this}async waitForJobCompletion(t={}){const{interval:e=1e3,statusCallback:s}=t;return new Promise(((t,o)=>{this._clearTimer();const i=setInterval((()=>{this._timer||o(r()),this.checkJobStatus().then((e=>{const{status:r}=e;switch(this.status=r,r){case"job-succeeded":this._clearTimer(),t(this);break;case"job-waiting":case"job-executing":s&&s(this)}}),(t=>{this._clearTimer(),o(t)}))}),e);this._timer=i}))}_clearTimer(){clearInterval(this._timer),this._timer=void 0}};t([o()],p.prototype,"editsResolver",void 0),t([o({type:String,json:{write:!0}})],p.prototype,"statusUrl",void 0),t([i(n)],p.prototype,"status",void 0),t([o({type:Date,json:{type:Number,write:{writer:(t,e)=>{e.submissionTime=t?t.getTime():null}}}})],p.prototype,"submissionTime",void 0),t([o({type:Date,json:{type:Number,write:{writer:(t,e)=>{e.lastUpdatedTime=t?t.getTime():null}}}})],p.prototype,"lastUpdatedTime",void 0),p=t([a("esri.networks.support.TopologyValidationJobInfo")],p);const l=p;export{l as default};
|
package/package.json
CHANGED
package/popup/FieldInfo.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import{JSONMap as o}from"../core/jsonMap.js";import{JSONSupport as e}from"../core/JSONSupport.js";import{clone as i}from"../core/lang.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as s}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import l from"./support/FieldInfoFormat.js";var a;let n=a=class extends e{constructor(t){super(t),this.fieldName=null,this.format=null,this.isEditable=!0,this.label=null,this.stringFieldOption="text-box",this.statisticType=null,this.tooltip=null,this.visible=!0}clone(){return new a({fieldName:this.fieldName,format:this.format?i(this.format):null,isEditable:this.isEditable,label:this.label,stringFieldOption:this.stringFieldOption,statisticType:this.statisticType,tooltip:this.tooltip,visible:this.visible})}};t([r({type:String,json:{write:!0}})],n.prototype,"fieldName",void 0),t([r({type:l,json:{write:!0}})],n.prototype,"format",void 0),t([r({type:Boolean,json:{write:!0,default:!0}})],n.prototype,"isEditable",void 0),t([r({type:String,json:{write:!0}})],n.prototype,"label",void 0),t([s(new o({richtext:"rich-text",textarea:"text-area",textbox:"text-box"}),{default:"text-box"})],n.prototype,"stringFieldOption",void 0),t([r({type:["count","sum","min","max","avg","stddev","var"],json:{write:!0}})],n.prototype,"statisticType",void 0),t([r({type:String,json:{write:!0}})],n.prototype,"tooltip",void 0),t([r({type:Boolean,json:{write:!0}})],n.prototype,"visible",void 0),n=a=t([p("esri.popup.FieldInfo")],n);const c=n;export{c as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{JSONMap as o}from"../core/jsonMap.js";import{JSONSupport as e}from"../core/JSONSupport.js";import{clone as i}from"../core/lang.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as s}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import l from"./support/FieldInfoFormat.js";var a;let n=a=class extends e{constructor(t){super(t),this.fieldName=null,this.format=null,this.isEditable=!0,this.label=null,this.stringFieldOption="text-box",this.statisticType=null,this.tooltip=null,this.visible=!0}clone(){return new a({fieldName:this.fieldName,format:this.format?i(this.format):null,isEditable:this.isEditable,label:this.label,stringFieldOption:this.stringFieldOption,statisticType:this.statisticType,tooltip:this.tooltip,visible:this.visible})}};t([r({type:String,json:{write:!0}})],n.prototype,"fieldName",void 0),t([r({type:l,json:{write:!0}})],n.prototype,"format",void 0),t([r({type:Boolean,json:{write:{alwaysWriteDefaults:!0},default:!0}})],n.prototype,"isEditable",void 0),t([r({type:String,json:{write:!0}})],n.prototype,"label",void 0),t([s(new o({richtext:"rich-text",textarea:"text-area",textbox:"text-box"}),{default:"text-box"})],n.prototype,"stringFieldOption",void 0),t([r({type:["count","sum","min","max","avg","stddev","var"],json:{write:!0}})],n.prototype,"statisticType",void 0),t([r({type:String,json:{write:!0}})],n.prototype,"tooltip",void 0),t([r({type:Boolean,json:{write:!0}})],n.prototype,"visible",void 0),n=a=t([p("esri.popup.FieldInfo")],n);const c=n;export{c as default};
|
package/portal/Portal.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import{id as r}from"../kernel.js";import o from"../request.js";import s from"../core/Error.js";import{JSONSupportMixin as i}from"../core/JSONSupport.js";import a from"../core/Loadable.js";import{destroyMaybe as l,removeMaybe as n}from"../core/maybe.js";import{throwIfAborted as u,isAborted as p,createAbortError as d,throwIfAbortError as h}from"../core/promiseUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{ensureType as c}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Extent.js";import{getLocale as S}from"../intl/locale.js";import{ensureDefaultPortalInstance as g}from"./portalDefault.js";import P from"./PortalQueryParams.js";import G from"./PortalQueryResult.js";import O from"./PortalUser.js";import{supportsApiKey as B}from"../support/apiKeyUtils.js";var D;let U;const b={PortalGroup:()=>import("./PortalGroup.js"),PortalItem:()=>import("./PortalItem.js"),PortalUser:()=>import("./PortalUser.js")};let Q=D=class extends(i(a)){constructor(e){super(e),this._esriIdCredentialCreateHandle=null,this.access=null,this.allSSL=!1,this.authMode="auto",this.authorizedCrossOriginDomains=null,this.basemapGalleryGroupQuery=null,this.basemapGalleryGroupQuery3D=null,this.bingKey=null,this.canListApps=!1,this.canListData=!1,this.canListPreProvisionedItems=!1,this.canProvisionDirectPurchase=!1,this.canSearchPublic=!0,this.canShareBingPublic=!1,this.canSharePublic=!1,this.canSignInArcGIS=!1,this.canSignInIDP=!1,this.colorSetsGroupQuery=null,this.commentsEnabled=!1,this.created=null,this.culture=null,this.customBaseUrl=null,this.defaultBasemap=null,this.defaultDevBasemap=null,this.defaultExtent=null,this.defaultVectorBasemap=null,this.description=null,this.devBasemapGalleryGroupQuery=null,this.eueiEnabled=null,this.featuredGroups=null,this.featuredItemsGroupQuery=null,this.galleryTemplatesGroupQuery=null,this.livingAtlasGroupQuery=null,this.hasCategorySchema=!1,this.helperServices=null,this.homePageFeaturedContent=null,this.homePageFeaturedContentCount=null,this.httpPort=null,this.httpsPort=null,this.id=null,this.ipCntryCode=null,this.isPortal=!1,this.isReadOnly=!1,this.layerTemplatesGroupQuery=null,this.maxTokenExpirationMinutes=null,this.modified=null,this.name=null,this.portalHostname=null,this.portalMode=null,this.portalProperties=null,this.region=null,this.rotatorPanels=null,this.showHomePageDescription=!1,this.sourceJSON=null,this.supportsHostedServices=!1,this.symbolSetsGroupQuery=null,this.templatesGroupQuery=null,this.units=null,this.url=t.portalUrl,this.urlKey=null,this.user=null,this.useStandardizedQuery=!1,this.useVectorBasemaps=!1,this.vectorBasemapGalleryGroupQuery=null}normalizeCtorArgs(e){return"string"==typeof e?{url:e}:e}destroy(){C.unregister(this),this.defaultBasemap=l(this.defaultBasemap),this.defaultDevBasemap=l(this.defaultDevBasemap),this.defaultVectorBasemap=l(this.defaultVectorBasemap),this._esriIdCredentialCreateHandle=n(this._esriIdCredentialCreateHandle)}readAuthorizedCrossOriginDomains(e){if(e)for(const r of e)t.request.trustedServers.includes(r)||t.request.trustedServers.push(r);return e}readDefaultBasemap(e){return this._readBasemap(e)}readDefaultDevBasemap(e){return this._readBasemap(e)}readDefaultVectorBasemap(e){return this._readBasemap(e)}get extraQuery(){const e=!(this.user&&this.user.orgId)||this.canSearchPublic;return this.id&&!e?` AND orgid:${this.id}`:null}get isOrganization(){return!!this.access}get itemPageUrl(){return this.url?`${this.url}/home/item.html`:null}get restUrl(){let e=this.url;if(e){const t=e.indexOf("/sharing");e=t>0?e.substring(0,t):this.url.replace(/\/+$/,""),e+="/sharing/rest"}return e}get thumbnailUrl(){const e=this.restUrl,t=this.thumbnail;return e&&t?this._normalizeSSL(e+"/portals/self/resources/"+t):null}readUrlKey(e){return e?e.toLowerCase():e}readUser(e){let t=null;return e&&(t=O.fromJSON(e),t.portal=this),t}load(e){const t=import("../Basemap.js").then((({default:t})=>{u(e),U=t})).then((()=>this.sourceJSON?this.sourceJSON:this.fetchSelf(this.authMode,!1,e))).then((e=>{if(r){const e=r;this.credential=e.findCredential(this.restUrl),this.credential||this.authMode!==D.AUTH_MODE_AUTO||(this._esriIdCredentialCreateHandle?.remove(),this._esriIdCredentialCreateHandle=e.on("credential-create",q(new WeakRef(this))),C.register(this,this._esriIdCredentialCreateHandle,this))}this.sourceJSON=e,this.read(e)}));return this.addResolvingPromise(t),Promise.resolve(this)}async createElevationLayers(){await this.load();const e=this._getHelperService("defaultElevationLayers"),t=(await import("../layers/ElevationLayer.js")).default;return e?e.map((e=>new t({id:e.id,url:e.url}))):[]}async fetchBasemaps(e,t){const r=await this._fetchBasemaps(e,t);if(t?.fetchBasemaps3D){const o=await this._fetchBasemaps3D(e,t);r.unshift(...o)}return r}fetchCategorySchema(e){return this.hasCategorySchema?this.request(this.restUrl+"/portals/self/categorySchema",e).then((e=>e.categorySchema)):p(e)?Promise.reject(d()):Promise.resolve([])}fetchFeaturedGroups(e){const t=this.featuredGroups,r=new P;if(r.num=100,r.sortField="title",t&&t.length){const o=[];for(const e of t)o.push(`(title:"${e.title}" AND owner:${e.owner})`);return r.query=o.join(" OR "),this.queryGroups(r,e).then((e=>e.results))}return p(e)?Promise.reject(d()):Promise.resolve([])}fetchRegions(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/regions",{...e,query:{culture:t}})}fetchSettings(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/self/settings",{...e,query:{culture:t}})}static getDefault(){return g((()=>new D))}queryGroups(e,t){return this.queryPortal("/community/groups",e,"PortalGroup",t)}queryItems(e,t){return this.queryPortal("/search",e,"PortalItem",t)}queryUsers(e,t){return e.sortField||(e.sortField="username"),this.queryPortal("/community/users",e,"PortalUser",t)}fetchSelf(e=this.authMode,t=!1,r){const o=this.restUrl+"/portals/self",s={authMode:e,query:{culture:S().toLowerCase()},...r};return"auto"===s.authMode&&(s.authMode="no-prompt"),t&&(s.query.default=!0),this.request(o,s)}queryPortal(e,t,r,o){const s=c(P,t),i=t=>this.request(this.restUrl+e,{...s.toRequestOptions(this),...o}).then((e=>{const r=s.clone();return r.start=e.nextStart,new G({nextQueryParams:r,queryParams:s,total:e.total,results:D._resultsToTypedArray(t,{portal:this},e,o)})})).then((e=>Promise.all(e.results.map((t=>"function"==typeof t.when?t.when():e))).then((()=>e),(t=>(h(t),e)))));return r&&b[r]?b[r]().then((({default:e})=>(u(o),i(e)))):i()}signIn(){if(this.authMode===D.AUTH_MODE_ANONYMOUS)return Promise.reject(new s("portal:invalid-auth-mode",`Current "authMode"' is "${this.authMode}"`));if("failed"===this.loadStatus)return Promise.reject(this.loadError);const e=e=>Promise.resolve().then((()=>"not-loaded"===this.loadStatus?(e||(this.authMode="immediate"),this.load().then((()=>null))):"loading"===this.loadStatus?this.load().then((()=>this.credential?null:(this.credential=e,this.fetchSelf("immediate")))):this.user&&this.credential===e?null:(this.credential=e,this.fetchSelf("immediate")))).then((e=>{e&&(this.sourceJSON=e,this.read(e))}));return r?r.getCredential(this.restUrl).then((t=>e(t))):e(this.credential)}normalizeUrl(e){const t=this.credential&&this.credential.token;return this._normalizeSSL(t?e+(e.includes("?")?"&":"?")+"token="+t:e)}requestToTypedArray(e,t,r){return this.request(e,t).then((e=>{const t=D._resultsToTypedArray(r,{portal:this},e);return Promise.all(t.map((t=>"function"==typeof t.when?t.when():e))).then((()=>t),(()=>t))}))}request(e,t={}){const r={f:"json",...t.query},{authMode:s=(this.authMode===D.AUTH_MODE_ANONYMOUS?"anonymous":"auto"),body:i=null,cacheBust:a=!1,method:l="auto",responseType:n="json",signal:u}=t,p={authMode:s,body:i,cacheBust:a,method:l,query:r,responseType:n,timeout:0,signal:u};return o(this._normalizeSSL(e),p).then((e=>e.data))}toJSON(){throw new s("internal:not-yet-implemented","Portal.toJSON is not yet implemented")}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new D({sourceJSON:e})}_getHelperService(e){const t=this.helperServices&&this.helperServices[e];if(!t)throw new s("portal:service-not-found",`The \`helperServices\` do not include an entry named "${e}"`);return t}async _fetchBasemaps(e,r){const o=new P;o.query=e||(t.apiKey&&B(this.url)?this.devBasemapGalleryGroupQuery:this.useVectorBasemaps?this.vectorBasemapGalleryGroupQuery:this.basemapGalleryGroupQuery),o.disableExtraQuery=!0;const s=await this.queryGroups(o,r);if(!s.total)return[];const i=s.results[0];o.num=100,o.query='type:"Web Map" -type:"Web Application"',o.sortField=i.sortField||"name",o.sortOrder=i.sortOrder||"desc";const a=await i.queryItems(o,r);if(!a.total)return[];return a.results.filter((e=>"Web Map"===e.type)).map((e=>new U({portalItem:e})))}async _fetchBasemaps3D(e,t){const r=e||this.basemapGalleryGroupQuery3D;if(!r)return[];const o=new P({query:r,disableExtraQuery:!0}),s=await this.queryGroups(o,t);if(!s.total)return[];const i=s.results[0];o.num=100,o.query='type:"Web Scene"',o.sortField=i.sortField||"name",o.sortOrder=i.sortOrder||"desc";const a=await i.queryItems(o,t);if(!a.total)return[];return a.results.filter((e=>"Web Scene"===e.type)).map((e=>new U({portalItem:e})))}_normalizeSSL(e){return e.replace(/^http:/i,"https:").replace(":7080",":7443")}_readBasemap(e){if(e){const t=U.fromJSON(e);return t.portalItem={portal:this},t}return null}static _resultsToTypedArray(e,t,r,o){let s=[];if(r){const i=null!=o?o.signal:null;s=r.listings||r.notifications||r.userInvitations||r.tags||r.items||r.groups||r.comments||r.provisions||r.results||r.relatedItems||r,(e||t)&&(s=s.map((r=>{const o=Object.assign(e?e.fromJSON(r):r,t);return"function"==typeof o.load&&o.load(i),o})))}else s=[];return s}};Q.AUTH_MODE_ANONYMOUS="anonymous",Q.AUTH_MODE_AUTO="auto",Q.AUTH_MODE_IMMEDIATE="immediate",e([y()],Q.prototype,"access",void 0),e([y()],Q.prototype,"allSSL",void 0),e([y()],Q.prototype,"authMode",void 0),e([y()],Q.prototype,"authorizedCrossOriginDomains",void 0),e([m("authorizedCrossOriginDomains")],Q.prototype,"readAuthorizedCrossOriginDomains",null),e([y()],Q.prototype,"basemapGalleryGroupQuery",void 0),e([y({json:{name:"3DBasemapGalleryGroupQuery"}})],Q.prototype,"basemapGalleryGroupQuery3D",void 0),e([y()],Q.prototype,"bingKey",void 0),e([y()],Q.prototype,"canListApps",void 0),e([y()],Q.prototype,"canListData",void 0),e([y()],Q.prototype,"canListPreProvisionedItems",void 0),e([y()],Q.prototype,"canProvisionDirectPurchase",void 0),e([y()],Q.prototype,"canSearchPublic",void 0),e([y()],Q.prototype,"canShareBingPublic",void 0),e([y()],Q.prototype,"canSharePublic",void 0),e([y()],Q.prototype,"canSignInArcGIS",void 0),e([y()],Q.prototype,"canSignInIDP",void 0),e([y()],Q.prototype,"colorSetsGroupQuery",void 0),e([y()],Q.prototype,"commentsEnabled",void 0),e([y({type:Date})],Q.prototype,"created",void 0),e([y()],Q.prototype,"credential",void 0),e([y()],Q.prototype,"culture",void 0),e([y()],Q.prototype,"currentVersion",void 0),e([y()],Q.prototype,"customBaseUrl",void 0),e([y()],Q.prototype,"defaultBasemap",void 0),e([m("defaultBasemap")],Q.prototype,"readDefaultBasemap",null),e([y()],Q.prototype,"defaultDevBasemap",void 0),e([m("defaultDevBasemap")],Q.prototype,"readDefaultDevBasemap",null),e([y({type:v})],Q.prototype,"defaultExtent",void 0),e([y()],Q.prototype,"defaultVectorBasemap",void 0),e([m("defaultVectorBasemap")],Q.prototype,"readDefaultVectorBasemap",null),e([y()],Q.prototype,"description",void 0),e([y()],Q.prototype,"devBasemapGalleryGroupQuery",void 0),e([y()],Q.prototype,"eueiEnabled",void 0),e([y({readOnly:!0})],Q.prototype,"extraQuery",null),e([y()],Q.prototype,"featuredGroups",void 0),e([y()],Q.prototype,"featuredItemsGroupQuery",void 0),e([y()],Q.prototype,"galleryTemplatesGroupQuery",void 0),e([y()],Q.prototype,"livingAtlasGroupQuery",void 0),e([y()],Q.prototype,"hasCategorySchema",void 0),e([y()],Q.prototype,"helpBase",void 0),e([y()],Q.prototype,"helperServices",void 0),e([y()],Q.prototype,"helpMap",void 0),e([y()],Q.prototype,"homePageFeaturedContent",void 0),e([y()],Q.prototype,"homePageFeaturedContentCount",void 0),e([y()],Q.prototype,"httpPort",void 0),e([y()],Q.prototype,"httpsPort",void 0),e([y()],Q.prototype,"id",void 0),e([y()],Q.prototype,"ipCntryCode",void 0),e([y({readOnly:!0})],Q.prototype,"isOrganization",null),e([y()],Q.prototype,"isPortal",void 0),e([y()],Q.prototype,"isReadOnly",void 0),e([y({readOnly:!0})],Q.prototype,"itemPageUrl",null),e([y()],Q.prototype,"layerTemplatesGroupQuery",void 0),e([y()],Q.prototype,"maxTokenExpirationMinutes",void 0),e([y({type:Date})],Q.prototype,"modified",void 0),e([y()],Q.prototype,"name",void 0),e([y()],Q.prototype,"portalHostname",void 0),e([y()],Q.prototype,"portalMode",void 0),e([y()],Q.prototype,"portalProperties",void 0),e([y()],Q.prototype,"region",void 0),e([y({readOnly:!0})],Q.prototype,"restUrl",null),e([y()],Q.prototype,"rotatorPanels",void 0),e([y()],Q.prototype,"showHomePageDescription",void 0),e([y()],Q.prototype,"sourceJSON",void 0),e([y()],Q.prototype,"staticImagesUrl",void 0),e([y({json:{name:"2DStylesGroupQuery"}})],Q.prototype,"stylesGroupQuery2d",void 0),e([y({json:{name:"stylesGroupQuery"}})],Q.prototype,"stylesGroupQuery3d",void 0),e([y()],Q.prototype,"supportsHostedServices",void 0),e([y()],Q.prototype,"symbolSetsGroupQuery",void 0),e([y()],Q.prototype,"templatesGroupQuery",void 0),e([y()],Q.prototype,"thumbnail",void 0),e([y({readOnly:!0})],Q.prototype,"thumbnailUrl",null),e([y()],Q.prototype,"units",void 0),e([y()],Q.prototype,"url",void 0),e([y()],Q.prototype,"urlKey",void 0),e([m("urlKey")],Q.prototype,"readUrlKey",null),e([y()],Q.prototype,"user",void 0),e([m("user")],Q.prototype,"readUser",null),e([y()],Q.prototype,"useStandardizedQuery",void 0),e([y()],Q.prototype,"useVectorBasemaps",void 0),e([y()],Q.prototype,"vectorBasemapGalleryGroupQuery",void 0),Q=D=e([f("esri.portal.Portal")],Q);const j=Q,C=new FinalizationRegistry((e=>{e.remove()}));function q(e){const t=r;return()=>{const r=e.deref();r&&t.findCredential(r.restUrl)&&r.signIn().catch((()=>{}))}}export{j as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import{id as r}from"../kernel.js";import o from"../request.js";import s from"../core/Error.js";import{JSONSupportMixin as i}from"../core/JSONSupport.js";import a from"../core/Loadable.js";import{destroyMaybe as l,removeMaybe as u}from"../core/maybe.js";import{throwIfAborted as n,isAborted as p,createAbortError as d,throwIfAbortError as h}from"../core/promiseUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{ensureType as c}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Extent.js";import{getLocale as S}from"../intl/locale.js";import{ensureDefaultPortalInstance as g}from"./portalDefault.js";import P from"./PortalQueryParams.js";import G from"./PortalQueryResult.js";import B from"./PortalUser.js";import{supportsApiKey as O}from"../support/apiKeyUtils.js";var D;let U;const b={PortalGroup:()=>import("./PortalGroup.js"),PortalItem:()=>import("./PortalItem.js"),PortalUser:()=>import("./PortalUser.js")};let Q=D=class extends(i(a)){constructor(e){super(e),this._esriIdCredentialCreateHandle=null,this.access=null,this.allSSL=!1,this.authMode="auto",this.authorizedCrossOriginDomains=null,this.basemapGalleryGroupQuery=null,this.basemapGalleryGroupQuery3D=null,this.bingKey=null,this.canListApps=!1,this.canListData=!1,this.canListPreProvisionedItems=!1,this.canProvisionDirectPurchase=!1,this.canSearchPublic=!0,this.canShareBingPublic=!1,this.canSharePublic=!1,this.canSignInArcGIS=!1,this.canSignInIDP=!1,this.colorSetsGroupQuery=null,this.commentsEnabled=!1,this.created=null,this.culture=null,this.customBaseUrl=null,this.defaultBasemap=null,this.defaultDevBasemap=null,this.defaultExtent=null,this.defaultVectorBasemap=null,this.description=null,this.devBasemapGalleryGroupQuery=null,this.eueiEnabled=null,this.featuredGroups=null,this.featuredItemsGroupQuery=null,this.galleryTemplatesGroupQuery=null,this.livingAtlasGroupQuery=null,this.hasCategorySchema=!1,this.helperServices=null,this.homePageFeaturedContent=null,this.homePageFeaturedContentCount=null,this.httpPort=null,this.httpsPort=null,this.id=null,this.ipCntryCode=null,this.isPortal=!1,this.isReadOnly=!1,this.layerTemplatesGroupQuery=null,this.maxTokenExpirationMinutes=null,this.modified=null,this.name=null,this.portalHostname=null,this.portalMode=null,this.portalProperties=null,this.region=null,this.rotatorPanels=null,this.showHomePageDescription=!1,this.sourceJSON=null,this.supportsHostedServices=!1,this.symbolSetsGroupQuery=null,this.templatesGroupQuery=null,this.units=null,this.url=t.portalUrl,this.urlKey=null,this.user=null,this.use3dBasemaps=!0,this.useStandardizedQuery=!1,this.useVectorBasemaps=!1,this.vectorBasemapGalleryGroupQuery=null}normalizeCtorArgs(e){return"string"==typeof e?{url:e}:e}destroy(){C.unregister(this),this.defaultBasemap=l(this.defaultBasemap),this.defaultDevBasemap=l(this.defaultDevBasemap),this.defaultVectorBasemap=l(this.defaultVectorBasemap),this._esriIdCredentialCreateHandle=u(this._esriIdCredentialCreateHandle)}readAuthorizedCrossOriginDomains(e){if(e)for(const r of e)t.request.trustedServers.includes(r)||t.request.trustedServers.push(r);return e}readDefaultBasemap(e){return this._readBasemap(e)}readDefaultDevBasemap(e){return this._readBasemap(e)}readDefaultVectorBasemap(e){return this._readBasemap(e)}get extraQuery(){const e=!(this.user&&this.user.orgId)||this.canSearchPublic;return this.id&&!e?` AND orgid:${this.id}`:null}get isOrganization(){return!!this.access}get itemPageUrl(){return this.url?`${this.url}/home/item.html`:null}get restUrl(){let e=this.url;if(e){const t=e.indexOf("/sharing");e=t>0?e.substring(0,t):this.url.replace(/\/+$/,""),e+="/sharing/rest"}return e}get thumbnailUrl(){const e=this.restUrl,t=this.thumbnail;return e&&t?this._normalizeSSL(e+"/portals/self/resources/"+t):null}readUrlKey(e){return e?e.toLowerCase():e}readUser(e){let t=null;return e&&(t=B.fromJSON(e),t.portal=this),t}load(e){const t=import("../Basemap.js").then((({default:t})=>{n(e),U=t})).then((()=>this.sourceJSON?this.sourceJSON:this.fetchSelf(this.authMode,!1,e))).then((e=>{if(r){const e=r;this.credential=e.findCredential(this.restUrl),this.credential||this.authMode!==D.AUTH_MODE_AUTO||(this._esriIdCredentialCreateHandle?.remove(),this._esriIdCredentialCreateHandle=e.on("credential-create",q(new WeakRef(this))),C.register(this,this._esriIdCredentialCreateHandle,this))}this.sourceJSON=e,this.read(e)}));return this.addResolvingPromise(t),Promise.resolve(this)}async createElevationLayers(){await this.load();const e=this._getHelperService("defaultElevationLayers"),t=(await import("../layers/ElevationLayer.js")).default;return e?e.map((e=>new t({id:e.id,url:e.url}))):[]}async fetchBasemaps(e,t){const r=await this._fetchBasemaps(e,t);if(!0===t?.include3d&&!1!==this.use3dBasemaps){const o=await this._fetchBasemaps3D(e,t);r.unshift(...o)}return r}fetchCategorySchema(e){return this.hasCategorySchema?this.request(this.restUrl+"/portals/self/categorySchema",e).then((e=>e.categorySchema)):p(e)?Promise.reject(d()):Promise.resolve([])}fetchFeaturedGroups(e){const t=this.featuredGroups,r=new P;if(r.num=100,r.sortField="title",t&&t.length){const o=[];for(const e of t)o.push(`(title:"${e.title}" AND owner:${e.owner})`);return r.query=o.join(" OR "),this.queryGroups(r,e).then((e=>e.results))}return p(e)?Promise.reject(d()):Promise.resolve([])}fetchRegions(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/regions",{...e,query:{culture:t}})}fetchSettings(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/self/settings",{...e,query:{culture:t}})}static getDefault(){return g((()=>new D))}queryGroups(e,t){return this.queryPortal("/community/groups",e,"PortalGroup",t)}queryItems(e,t){return this.queryPortal("/search",e,"PortalItem",t)}queryUsers(e,t){return e.sortField||(e.sortField="username"),this.queryPortal("/community/users",e,"PortalUser",t)}fetchSelf(e=this.authMode,t=!1,r){const o=this.restUrl+"/portals/self",s={authMode:e,query:{culture:S().toLowerCase()},...r};return"auto"===s.authMode&&(s.authMode="no-prompt"),t&&(s.query.default=!0),this.request(o,s)}queryPortal(e,t,r,o){const s=c(P,t),i=t=>this.request(this.restUrl+e,{...s.toRequestOptions(this),...o}).then((e=>{const r=s.clone();return r.start=e.nextStart,new G({nextQueryParams:r,queryParams:s,total:e.total,results:D._resultsToTypedArray(t,{portal:this},e,o)})})).then((e=>Promise.all(e.results.map((t=>"function"==typeof t.when?t.when():e))).then((()=>e),(t=>(h(t),e)))));return r&&b[r]?b[r]().then((({default:e})=>(n(o),i(e)))):i()}signIn(){if(this.authMode===D.AUTH_MODE_ANONYMOUS)return Promise.reject(new s("portal:invalid-auth-mode",`Current "authMode"' is "${this.authMode}"`));if("failed"===this.loadStatus)return Promise.reject(this.loadError);const e=e=>Promise.resolve().then((()=>"not-loaded"===this.loadStatus?(e||(this.authMode="immediate"),this.load().then((()=>null))):"loading"===this.loadStatus?this.load().then((()=>this.credential?null:(this.credential=e,this.fetchSelf("immediate")))):this.user&&this.credential===e?null:(this.credential=e,this.fetchSelf("immediate")))).then((e=>{e&&(this.sourceJSON=e,this.read(e))}));return r?r.getCredential(this.restUrl).then((t=>e(t))):e(this.credential)}normalizeUrl(e){const t=this.credential&&this.credential.token;return this._normalizeSSL(t?e+(e.includes("?")?"&":"?")+"token="+t:e)}requestToTypedArray(e,t,r){return this.request(e,t).then((e=>{const t=D._resultsToTypedArray(r,{portal:this},e);return Promise.all(t.map((t=>"function"==typeof t.when?t.when():e))).then((()=>t),(()=>t))}))}request(e,t={}){const r={f:"json",...t.query},{authMode:s=(this.authMode===D.AUTH_MODE_ANONYMOUS?"anonymous":"auto"),body:i=null,cacheBust:a=!1,method:l="auto",responseType:u="json",signal:n}=t,p={authMode:s,body:i,cacheBust:a,method:l,query:r,responseType:u,timeout:0,signal:n};return o(this._normalizeSSL(e),p).then((e=>e.data))}toJSON(){throw new s("internal:not-yet-implemented","Portal.toJSON is not yet implemented")}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new D({sourceJSON:e})}_getHelperService(e){const t=this.helperServices&&this.helperServices[e];if(!t)throw new s("portal:service-not-found",`The \`helperServices\` do not include an entry named "${e}"`);return t}async _fetchBasemaps(e,r){const o=new P;o.query=e||(t.apiKey&&O(this.url)?this.devBasemapGalleryGroupQuery:this.useVectorBasemaps?this.vectorBasemapGalleryGroupQuery:this.basemapGalleryGroupQuery),o.disableExtraQuery=!0;const s=await this.queryGroups(o,r);if(!s.total)return[];const i=s.results[0];o.num=100,o.query='type:"Web Map" -type:"Web Application"',o.sortField=i.sortField||"name",o.sortOrder=i.sortOrder||"desc";const a=await i.queryItems(o,r);if(!a.total)return[];return a.results.filter((e=>"Web Map"===e.type)).map((e=>new U({portalItem:e})))}async _fetchBasemaps3D(e,t){const r=e||this.basemapGalleryGroupQuery3D;if(!r)return[];const o=new P({query:r,disableExtraQuery:!0}),s=await this.queryGroups(o,t);if(!s.total)return[];const i=s.results[0];o.num=100,o.query='type:"Web Scene"',o.sortField=i.sortField||"name",o.sortOrder=i.sortOrder||"desc";const a=await i.queryItems(o,t);if(!a.total)return[];return a.results.filter((e=>"Web Scene"===e.type)).map((e=>new U({portalItem:e})))}_normalizeSSL(e){return e.replace(/^http:/i,"https:").replace(":7080",":7443")}_readBasemap(e){if(e){const t=U.fromJSON(e);return t.portalItem={portal:this},t}return null}static _resultsToTypedArray(e,t,r,o){let s=[];if(r){const i=null!=o?o.signal:null;s=r.listings||r.notifications||r.userInvitations||r.tags||r.items||r.groups||r.comments||r.provisions||r.results||r.relatedItems||r,(e||t)&&(s=s.map((r=>{const o=Object.assign(e?e.fromJSON(r):r,t);return"function"==typeof o.load&&o.load(i),o})))}else s=[];return s}};Q.AUTH_MODE_ANONYMOUS="anonymous",Q.AUTH_MODE_AUTO="auto",Q.AUTH_MODE_IMMEDIATE="immediate",e([y()],Q.prototype,"access",void 0),e([y()],Q.prototype,"allSSL",void 0),e([y()],Q.prototype,"authMode",void 0),e([y()],Q.prototype,"authorizedCrossOriginDomains",void 0),e([m("authorizedCrossOriginDomains")],Q.prototype,"readAuthorizedCrossOriginDomains",null),e([y()],Q.prototype,"basemapGalleryGroupQuery",void 0),e([y({json:{name:"3DBasemapGalleryGroupQuery"}})],Q.prototype,"basemapGalleryGroupQuery3D",void 0),e([y()],Q.prototype,"bingKey",void 0),e([y()],Q.prototype,"canListApps",void 0),e([y()],Q.prototype,"canListData",void 0),e([y()],Q.prototype,"canListPreProvisionedItems",void 0),e([y()],Q.prototype,"canProvisionDirectPurchase",void 0),e([y()],Q.prototype,"canSearchPublic",void 0),e([y()],Q.prototype,"canShareBingPublic",void 0),e([y()],Q.prototype,"canSharePublic",void 0),e([y()],Q.prototype,"canSignInArcGIS",void 0),e([y()],Q.prototype,"canSignInIDP",void 0),e([y()],Q.prototype,"colorSetsGroupQuery",void 0),e([y()],Q.prototype,"commentsEnabled",void 0),e([y({type:Date})],Q.prototype,"created",void 0),e([y()],Q.prototype,"credential",void 0),e([y()],Q.prototype,"culture",void 0),e([y()],Q.prototype,"currentVersion",void 0),e([y()],Q.prototype,"customBaseUrl",void 0),e([y()],Q.prototype,"defaultBasemap",void 0),e([m("defaultBasemap")],Q.prototype,"readDefaultBasemap",null),e([y()],Q.prototype,"defaultDevBasemap",void 0),e([m("defaultDevBasemap")],Q.prototype,"readDefaultDevBasemap",null),e([y({type:v})],Q.prototype,"defaultExtent",void 0),e([y()],Q.prototype,"defaultVectorBasemap",void 0),e([m("defaultVectorBasemap")],Q.prototype,"readDefaultVectorBasemap",null),e([y()],Q.prototype,"description",void 0),e([y()],Q.prototype,"devBasemapGalleryGroupQuery",void 0),e([y()],Q.prototype,"eueiEnabled",void 0),e([y({readOnly:!0})],Q.prototype,"extraQuery",null),e([y()],Q.prototype,"featuredGroups",void 0),e([y()],Q.prototype,"featuredItemsGroupQuery",void 0),e([y()],Q.prototype,"galleryTemplatesGroupQuery",void 0),e([y()],Q.prototype,"livingAtlasGroupQuery",void 0),e([y()],Q.prototype,"hasCategorySchema",void 0),e([y()],Q.prototype,"helpBase",void 0),e([y()],Q.prototype,"helperServices",void 0),e([y()],Q.prototype,"helpMap",void 0),e([y()],Q.prototype,"homePageFeaturedContent",void 0),e([y()],Q.prototype,"homePageFeaturedContentCount",void 0),e([y()],Q.prototype,"httpPort",void 0),e([y()],Q.prototype,"httpsPort",void 0),e([y()],Q.prototype,"id",void 0),e([y()],Q.prototype,"ipCntryCode",void 0),e([y({readOnly:!0})],Q.prototype,"isOrganization",null),e([y()],Q.prototype,"isPortal",void 0),e([y()],Q.prototype,"isReadOnly",void 0),e([y({readOnly:!0})],Q.prototype,"itemPageUrl",null),e([y()],Q.prototype,"layerTemplatesGroupQuery",void 0),e([y()],Q.prototype,"maxTokenExpirationMinutes",void 0),e([y({type:Date})],Q.prototype,"modified",void 0),e([y()],Q.prototype,"name",void 0),e([y()],Q.prototype,"portalHostname",void 0),e([y()],Q.prototype,"portalMode",void 0),e([y()],Q.prototype,"portalProperties",void 0),e([y()],Q.prototype,"region",void 0),e([y({readOnly:!0})],Q.prototype,"restUrl",null),e([y()],Q.prototype,"rotatorPanels",void 0),e([y()],Q.prototype,"showHomePageDescription",void 0),e([y()],Q.prototype,"sourceJSON",void 0),e([y()],Q.prototype,"staticImagesUrl",void 0),e([y({json:{name:"2DStylesGroupQuery"}})],Q.prototype,"stylesGroupQuery2d",void 0),e([y({json:{name:"stylesGroupQuery"}})],Q.prototype,"stylesGroupQuery3d",void 0),e([y()],Q.prototype,"supportsHostedServices",void 0),e([y()],Q.prototype,"symbolSetsGroupQuery",void 0),e([y()],Q.prototype,"templatesGroupQuery",void 0),e([y()],Q.prototype,"thumbnail",void 0),e([y({readOnly:!0})],Q.prototype,"thumbnailUrl",null),e([y()],Q.prototype,"units",void 0),e([y()],Q.prototype,"url",void 0),e([y()],Q.prototype,"urlKey",void 0),e([m("urlKey")],Q.prototype,"readUrlKey",null),e([y()],Q.prototype,"user",void 0),e([m("user")],Q.prototype,"readUser",null),e([y()],Q.prototype,"use3dBasemaps",void 0),e([y()],Q.prototype,"useStandardizedQuery",void 0),e([y()],Q.prototype,"useVectorBasemaps",void 0),e([y()],Q.prototype,"vectorBasemapGalleryGroupQuery",void 0),Q=D=e([f("esri.portal.Portal")],Q);const j=Q,C=new FinalizationRegistry((e=>{e.remove()}));function q(e){const t=r;return()=>{const r=e.deref();r&&t.findCredential(r.restUrl)&&r.signIn().catch((()=>{}))}}export{j 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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{geometryTypes as t}from"../../geometry.js";import r from"../../Graphic.js";import{JSONMap as o}from"../../core/jsonMap.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{geometryTypes as t}from"../../geometry.js";import r from"../../Graphic.js";import{JSONMap as o}from"../../core/jsonMap.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as n}from"../../core/lang.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{reader as l}from"../../core/accessorSupport/decorators/reader.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import m from"../../geometry/SpatialReference.js";import{fromJSON as c,isPolygon as u}from"../../geometry/support/jsonUtils.js";import y from"../../layers/support/Field.js";var f;const h=new o({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryEnvelope:"extent",mesh:"mesh","":null});let g=f=class extends s{constructor(e){super(e),this.displayFieldName=null,this.exceededTransferLimit=!1,this.features=[],this.fields=null,this.geometryType=null,this.hasM=!1,this.hasZ=!1,this.queryGeometry=null,this.spatialReference=null}readFeatures(e,t){const o=m.fromJSON(t.spatialReference),s=[];for(let n=0;n<e.length;n++){const t=e[n],i=r.fromJSON(t),l=t.geometry&&t.geometry.spatialReference;null==i.geometry||l||(i.geometry.spatialReference=o);const a=t.aggregateGeometries,p=i.aggregateGeometries;if(a&&null!=p)for(const e in p){const t=p[e],r=a[e],s=r?.spatialReference;null==t||s||(t.spatialReference=o)}s.push(i)}return s}writeGeometryType(e,t,r,o){if(e)return void h.write(e,t,r,o);const{features:s}=this;if(s)for(const n of s)if(n&&null!=n.geometry)return void h.write(n.geometry.type,t,r,o)}readQueryGeometry(e,t){if(!e)return null;const r=!!e.spatialReference,o=c(e);return o&&!r&&t.spatialReference&&(o.spatialReference=m.fromJSON(t.spatialReference)),o}writeSpatialReference(e,t){if(e)return void(t.spatialReference=e.toJSON());const{features:r}=this;if(r)for(const o of r)if(o&&null!=o.geometry&&o.geometry.spatialReference)return void(t.spatialReference=o.geometry.spatialReference.toJSON())}clone(){return new f(this.cloneProperties())}cloneProperties(){return n({displayFieldName:this.displayFieldName,exceededTransferLimit:this.exceededTransferLimit,features:this.features,fields:this.fields,geometryType:this.geometryType,hasM:this.hasM,hasZ:this.hasZ,queryGeometry:this.queryGeometry,spatialReference:this.spatialReference,transform:this.transform})}toJSON(e){const t=this.write();if(t.features&&Array.isArray(e)&&e.length>0)for(let r=0;r<t.features.length;r++){const o=t.features[r];if(o.geometry){const t=e&&e[r];o.geometry=t&&t.toJSON()||o.geometry}}return t}quantize(e){const{scale:[t,r],translate:[o,s]}=e,n=e=>Math.round((e-o)/t),i=e=>Math.round((s-e)/r),l=this.features,a=this._getQuantizationFunction(this.geometryType,n,i);for(let p=0,m=l.length;p<m;p++)a?.(l[p].geometry)||(l.splice(p,1),p--,m--);return this.transform=e,this}unquantize(){const{geometryType:e,features:t,transform:r}=this;if(!r)return this;const{translate:[o,s],scale:[n,i]}=r,l=e=>e*n+o,a=e=>s-e*i;let p=null,m=null;if(this.hasZ&&null!=r?.scale?.[2]){const{translate:[,,e],scale:[,,t]}=r;p=r=>r*t+e}if(this.hasM&&null!=r?.scale?.[3]){const{translate:[,,,e],scale:[,,,t]}=r;m=r=>null==r?r:r*t+e}const c=this._getHydrationFunction(e,l,a,p,m);for(const{geometry:u}of t)null!=u&&c&&c(u);return this.transform=null,this}_quantizePoints(e,t,r){let o,s;const n=[];for(let i=0,l=e.length;i<l;i++){const l=e[i];if(i>0){const e=t(l[0]),i=r(l[1]);e===o&&i===s||(n.push([e-o,i-s]),o=e,s=i)}else o=t(l[0]),s=r(l[1]),n.push([o,s])}return n.length>0?n:null}_getQuantizationFunction(e,t,r){return"point"===e?e=>(e.x=t(e.x),e.y=r(e.y),e):"polyline"===e||"polygon"===e?e=>{const o=u(e)?e.rings:e.paths,s=[];for(let n=0,i=o.length;n<i;n++){const e=o[n],i=this._quantizePoints(e,t,r);i&&s.push(i)}return s.length>0?(u(e)?e.rings=s:e.paths=s,e):null}:"multipoint"===e?e=>{const o=this._quantizePoints(e.points,t,r);return o&&o.length>0?(e.points=o,e):null}:"extent"===e?e=>e:null}_getHydrationFunction(e,t,r,o,s){return"point"===e?e=>{e.x=t(e.x),e.y=r(e.y),o&&(e.z=o(e.z))}:"polyline"===e||"polygon"===e?e=>{const n=u(e)?e.rings:e.paths;let i,l;for(let o=0,s=n.length;o<s;o++){const e=n[o];for(let o=0,s=e.length;o<s;o++){const s=e[o];o>0?(i+=s[0],l+=s[1]):(i=s[0],l=s[1]),s[0]=t(i),s[1]=r(l)}}if(o&&s)for(let t=0,r=n.length;t<r;t++){const e=n[t];for(let t=0,r=e.length;t<r;t++){const r=e[t];r[2]=o(r[2]),r[3]=s(r[3])}}else if(o)for(let t=0,r=n.length;t<r;t++){const e=n[t];for(let t=0,r=e.length;t<r;t++){const r=e[t];r[2]=o(r[2])}}else if(s)for(let t=0,r=n.length;t<r;t++){const e=n[t];for(let t=0,r=e.length;t<r;t++){const r=e[t];r[2]=s(r[2])}}}:"extent"===e?e=>{e.xmin=t(e.xmin),e.ymin=r(e.ymin),e.xmax=t(e.xmax),e.ymax=r(e.ymax),o&&null!=e.zmax&&null!=e.zmin&&(e.zmax=o(e.zmax),e.zmin=o(e.zmin)),s&&null!=e.mmax&&null!=e.mmin&&(e.mmax=s(e.mmax),e.mmin=s(e.mmin))}:"multipoint"===e?e=>{const n=e.points;let i,l;for(let o=0,s=n.length;o<s;o++){const e=n[o];o>0?(i+=e[0],l+=e[1]):(i=e[0],l=e[1]),e[0]=t(i),e[1]=r(l)}if(o&&s)for(let t=0,r=n.length;t<r;t++){const e=n[t];e[2]=o(e[2]),e[3]=s(e[3])}else if(o)for(let t=0,r=n.length;t<r;t++){const e=n[t];e[2]=o(e[2])}else if(s)for(let t=0,r=n.length;t<r;t++){const e=n[t];e[2]=s(e[2])}}:null}};e([i({type:String,json:{write:!0}})],g.prototype,"displayFieldName",void 0),e([i({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],g.prototype,"exceededTransferLimit",void 0),e([i({type:[r],json:{write:!0}})],g.prototype,"features",void 0),e([l("features")],g.prototype,"readFeatures",null),e([i({type:[y],json:{write:!0}})],g.prototype,"fields",void 0),e([i({type:["point","multipoint","polyline","polygon","extent","mesh"],json:{read:{reader:h.read}}})],g.prototype,"geometryType",void 0),e([p("geometryType")],g.prototype,"writeGeometryType",null),e([i({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],g.prototype,"hasM",void 0),e([i({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],g.prototype,"hasZ",void 0),e([i({types:t,json:{write:!0}})],g.prototype,"queryGeometry",void 0),e([l("queryGeometry")],g.prototype,"readQueryGeometry",null),e([i({type:m,json:{write:!0}})],g.prototype,"spatialReference",void 0),e([p("spatialReference")],g.prototype,"writeSpatialReference",null),e([i({json:{write:!0}})],g.prototype,"transform",void 0),g=f=e([a("esri.rest.support.FeatureSet")],g),g.prototype.toJSON.isDefaultToJSON=!0;const d=g;export{d as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Graphic.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import o from"../../geometry/Extent.js";import s from"../../geometry/Mesh.js";import
|
|
5
|
+
import e from"../../Graphic.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as r}from"../../core/MapUtils.js";import{f as o}from"../../chunks/vec3f64.js";import n from"../../geometry/Extent.js";import s from"../../geometry/Mesh.js";import i from"../../geometry/Point.js";import a from"../../geometry/SpatialReference.js";import u from"../../geometry/support/MeshGeoreferencedRelativeVertexSpace.js";import c from"../../geometry/support/MeshLocalVertexSpace.js";import f from"../../geometry/support/MeshTransform.js";import{ServiceAssetPart as p,ServiceAsset as m}from"../../geometry/support/meshUtils/External.js";import{getFormatIdMimeType as l}from"../../layers/support/infoFor3D.js";import g from"./FeatureSet.js";function y(t,r,o){const n=o.features;o.features=[],delete o.geometryType;const s=g.fromJSON(o);if(s.geometryType="mesh",!o.assetMaps)return s;const i=M(r,o.assetMaps),u=t.sourceSpatialReference??a.WGS84,c=o.globalIdFieldName,{outFields:f}=t,p=null!=f&&f.length>0?E(f.includes("*")?null:new Set(f)):()=>({});for(const a of n){const t=h(a,c,u,r,i);null!=t&&s.features.push(new e({geometry:t,attributes:p(a)}))}return s}function E(e){return({attributes:t})=>{if(!t)return{};if(!e)return t;for(const r in t)e.has(r)||delete t[r];return t}}function h(e,t,r,o,i){const a=e.attributes[t],f=i.get(a);if(null==f)return null;const{originPoint:p,originVector:m}=S(e,r,o),l=n.fromJSON(e.geometry);l.spatialReference=r;const g=j(e.attributes,o),y=f.projectVertices?new u({origin:m}):new c({origin:m}),E=T(f);return E?s.createWithExternalSource(p,E,{extent:l,transform:g,vertexSpace:y}):s.createIncomplete(p,{extent:l,transform:g,vertexSpace:y})}function S({attributes:e},t,{transformFieldRoles:r}){const n=e[r.originX],s=e[r.originY],a=e[r.originZ];return{originPoint:new i({x:n,y:s,z:a,spatialReference:t}),originVector:o(n,s,a)}}function j(e,{transformFieldRoles:t}){return new f({translation:[e[t.translationX],-e[t.translationZ],e[t.translationY]],rotationAxis:[e[t.rotationX],e[t.rotationZ],e[t.rotationY]],rotationAngle:e[t.rotationDeg],scale:[e[t.scaleX],e[t.scaleY],e[t.scaleZ]]})}var d;function M(e,o){const n=new Map;for(const s of o){const o=s.parentGlobalId;if(null==o)continue;const i=s.assetName,a=s.assetType,u=s.assetHash,c=s.assetURL,f=s.conversionStatus,p=s.seqNo,m=l(a,e.supportedFormats);if(!m){t.getLogger("esri.rest.support.meshFeatureSet").error("mesh-feature-set:unknown-format",`Service returned an asset of type ${a}, but it does not list it as a supported type`);continue}const g=r(n,o,(()=>({projectVertices:D(s.flags).projectVertices,files:new Map})));r(g.files,i,(()=>({name:i,type:a,mimeType:m,status:w(f),parts:[]}))).parts[p]={hash:u,url:c}}return n}function T(e){const t=Array.from(e.files.values()),r=new Array;for(const o of t){if(o.status!==d.COMPLETED)return null;const e=new Array;for(const t of o.parts){if(!t)return null;e.push(new p(t.url,t.hash))}r.push(new m(o.name,o.mimeType,e))}return r}function w(e){switch(e){case"COMPLETED":case"SUBMITTED":return d.COMPLETED;case"INPROGRESS":return d.PENDING;default:return d.FAILED}}function D(e){return{projectVertices:e.includes("PROJECT_VERTICES")}}!function(e){e[e.FAILED=0]="FAILED",e[e.PENDING=1]="PENDING",e[e.COMPLETED=2]="COMPLETED"}(d||(d={}));export{M as assetMapFromAssetMapsJSON,h as extractMesh,y as meshFeatureSetFromJSON};
|
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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const a="20230522",d="f88656d0392258a643d6a48db3237d9aabfc9898";export{a as buildDate,d as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import{getFontFamily as t}from"../../core/fontUtils.js";import{clone as i}from"../../core/lang.js";import r from"../../core/Logger.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{numericHash as a}from"../../core/string.js";import{createRendererExpression as s,ArcadeExpression as l}from"../../support/arcadeOnDemand.js";import{DEFAULT_PICTURE_FILL_HEIGHT as c,DEFAULT_HATCH_FILL_SEPARATION as m,DEFAULT_STROKE_WIDTH as f,DEFAULT_MARKER_SIZE as p,DEFAULT_TEXT_HEIGHT as h}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as u,OverrideHelper as y}from"./CIMSymbolHelper.js";import{Alignment as d,CapType as v,JoinType as _}from"./enums.js";import{quantizeIfNeeded as S}from"./quantizeTime.js";import{getExtent as O,getSDFMetrics as g}from"./SDFHelper.js";import{fromCIMColor as M,getTintColor as b,getValue as N,getFillColor as k,getStrokeColor as P,getStrokeWidth as z,fromCIMFontDecoration as C,fromCIMFontStyle as L,adjustTextCase as F,createLabelOverrideFunction as I,evaluateValueOrFunction as w,fromCIMHorizontalAlignment as x,fromCIMVerticalAlignment as A,isFeatureValueFn as R}from"./utils.js";import{CIMEffectHelper as X}from"./effects/CIMEffectHelper.js";import H from"../../views/2d/arcade/callExpressionWithFeature.js";import{RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as J}from"../../views/2d/engine/webgl/definitions.js";import{getMaterialGroup as Y}from"../../views/2d/engine/webgl/grouping.js";const E=r.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){switch(e){case"Butt":return v.BUTT;case"Square":return v.SQUARE;default:return v.ROUND}}function $(e){switch(e){case"Bevel":return _.BEVEL;case"Miter":return _.MITER;default:return _.ROUND}}function j(e){const t=e.markerPlacement;return t&&t.angleToLine?d.MAP:d.SCREEN}class G{constructor(e,t){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._resourceManager=e,this._info=t}async analyzeSymbolReference(e,t,i){if(this._cimLayers=i??[],!e)return this._cimLayers;if(e.primitiveOverrides){this._primitiveOverrides=e.primitiveOverrides,this._poMap={};const t=[],i=this._info;for(const e of this._primitiveOverrides){const r=e.valueExpressionInfo;if(r&&i){const o=r.expression,n=s(o,i.spatialReference,i.fields).then((t=>{null!=t&&this._setPoMap(e.primitiveName,e.propertyName,t)}));t.push(n)}else null!=e.value&&this._setPoMap(e.primitiveName,e.propertyName,e.value);t.length>0&&await Promise.all(t)}}const r=e.symbol,o=[];return u.fetchResources(r,this._resourceManager,o),o.length>0&&await Promise.all(o),this._analyzeSymbol(r,t),this._cimLayers}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t,1,0,0,0)}}_analyzeMultiLayerSymbol(e,t,i,r,o,n){const a=e?.symbolLayers;if(!a)return;const s=e.effects;let l=d.SCREEN;const c=u.getSize(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(l=d.MAP);const m="CIMPolygonSymbol"===e.type;let f=a.length;for(;f--;){const p=a[f];if(!p||!1===p.enable)continue;let h;s&&s.length&&(h=[...s]);const u=p.effects;u&&u.length&&(s?h.push(...u):h=[...u]);const d=[];let v;y.findEffectOverrides(h,this._primitiveOverrides,d),v=d.length>0?this._createEffectsOverrideFunction(h,d):h;const _=[];switch(y.findApplicableOverrides(p,this._primitiveOverrides,_),p.type){case"CIMSolidFill":this._analyzeSolidFill(p,v);break;case"CIMPictureFill":this._analyzePictureFill(p,v);break;case"CIMHatchFill":this._analyzeHatchFill(p,v);break;case"CIMGradientFill":this._analyzeGradientFill(p,v);break;case"CIMSolidStroke":this._analyzeSolidStroke(p,v,m,c);break;case"CIMPictureStroke":this._analyzePictureStroke(p,v,m,c);break;case"CIMGradientStroke":this._analyzeGradientStroke(p,v,m,c);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"===e.type&&(l=j(p));const a=[],s=p.primitiveName;s&&a.push(s),this._analyzeMarker(p,v,null,a,l,c,1,t,i,r,o,n);break}default:E.error("Cannot analyze CIM layer",p.type)}}}_analyzeSolidFill(e,t){const i=e.primitiveName,r=M(e.color),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString();this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>s:s,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,color:this._createOverrideFunction(i,"Color",r,U),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0})}_analyzePictureFill(e,t){const i=e.primitiveName,r=b(e),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString(),l=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),m=N(e.height,c);let f=N(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height),f/=i*(m/t)}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>l:l,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(i,"TintColor",r,U),height:this._createOverrideFunction(i,"Height",m),scaleX:this._createOverrideFunction(i,"ScaleX",f),angle:this._createOverrideFunction(i,"Rotation",N(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",N(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",N(e.offsetY)),url:e.url,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeHatchFill(e,t){const i=e.primitiveName,r=this._analyzeMaterialOverrides(i,["Rotation","OffsetX","OffsetY"]);let[o,n]=this._analyzePrimitiveOverrides(i,t,null,null);const s=a(JSON.stringify(e)+n).toString(),l=a(`${e.separation}${JSON.stringify(e.lineSymbol)}`).toString();let c={r:255,g:255,b:255,a:1},f=!1;const p=e.lineSymbol?.symbolLayers?.find((e=>"CIMSolidStroke"===e.type&&null!=this._poMap[e.primitiveName]?.Color));if(p){c=M(p.color),c=this._createOverrideFunction(p.primitiveName,"Color",c,U);const e="function"==typeof c;o=o||e,f=null!=p.color||e}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o&&r?this._createMaterialHashFunction(l,r):l,cim:e,materialOverrides:r,colorLocked:!!e.colorLocked,effects:t,color:c,height:this._createOverrideFunction(i,"Separation",N(e.separation,m)),scaleX:1,angle:this._createOverrideFunction(i,"Rotation",N(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",N(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",N(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!f})}_analyzeGradientFill(e,t){const i=e.primitiveName,[r,o]=this._analyzePrimitiveOverrides(i,t,null,null),n=a(JSON.stringify(e)+o).toString();this._cimLayers.push({type:"fill",templateHash:n,materialHash:r?()=>n:n,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeSolidStroke(e,t,i,r){const o=e.primitiveName,n=M(e.color),s=N(e.width,f),l=T(e.capStyle),c=$(e.joinStyle),m=e.miterLimit,[p,h]=this._analyzePrimitiveOverrides(o,t,null,null),u=a(JSON.stringify(e)+h).toString();let y,d;if(t&&t instanceof Array&&t.length>0){const e=t[t.length-1];if("CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine){const e=(t=[...t]).pop();y=e.dashTemplate,d=e.scaleDash}}this._cimLayers.push({type:"line",templateHash:u,materialHash:p?()=>u:u,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(o,"Color",n,U),width:this._createOverrideFunction(o,"Width",s),cap:this._createOverrideFunction(o,"CapStyle",l),join:this._createOverrideFunction(o,"JoinStyle",c),miterLimit:m&&this._createOverrideFunction(o,"MiterLimit",m),referenceWidth:r,zOrder:D(e.name),dashTemplate:y,scaleDash:d,sampleAlphaOnly:!0})}_analyzePictureStroke(e,t,i,r){const o=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),n=e.primitiveName,s=b(e),l=N(e.width,f),c=T(e.capStyle),m=$(e.joinStyle),p=e.miterLimit,[h,u]=this._analyzePrimitiveOverrides(n,t,null,null),y=a(JSON.stringify(e)+u).toString();this._cimLayers.push({type:"line",templateHash:y,materialHash:h?()=>o:o,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(n,"TintColor",s,U),width:this._createOverrideFunction(n,"Width",l),cap:this._createOverrideFunction(n,"CapStyle",c),join:this._createOverrideFunction(n,"JoinStyle",m),miterLimit:p&&this._createOverrideFunction(n,"MiterLimit",p),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,url:e.url,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,t,i,r){const o=e.primitiveName,n=N(e.width,f),s=T(e.capStyle),l=$(e.joinStyle),c=e.miterLimit,[m,p]=this._analyzePrimitiveOverrides(o,t,null,null),h=a(JSON.stringify(e)+p).toString();this._cimLayers.push({type:"line",templateHash:h,materialHash:m?()=>h:h,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},width:this._createOverrideFunction(o,"Width",n),cap:this._createOverrideFunction(o,"CapStyle",s),join:this._createOverrideFunction(o,"JoinStyle",l),miterLimit:c&&this._createOverrideFunction(o,"MiterLimit",c),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,t,i,r,o,n,a,s,l,c,m,f){if(this._analyzeMarkerInsidePolygon(e,t))return;const h=N(e.size,p),u=N(e.rotation),y=N(e.offsetX),d=N(e.offsetY);let v=this._createOverrideFunction(e.primitiveName,"Size",h),_=this._createOverrideFunction(e.primitiveName,"Rotation",u),S=this._createOverrideFunction(e.primitiveName,"OffsetX",y),O=this._createOverrideFunction(e.primitiveName,"OffsetY",d);v=this._transformSize(v,a),_=this._transformRotation(_,!!e.rotateClockwise,c);const g=this._transformOffsetX(S,O,c,a,m),M=this._transformOffsetY(S,O,c,a,f);switch(S=g,O=M,e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,i,r,o,n,v,_,S,O);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,i,r,o,n,a,s,v,_,S,O)}}_analyzeMarkerInsidePolygon(e,t){const{markerPlacement:i,type:r}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===r||"CIMPictureMarker"===r){const o=e.primitiveName;if(o){const[e,i]=this._analyzePrimitiveOverrides([o],t,null,null);if(e)return!1}const n=i.primitiveName;if(n){const[e,i]=this._analyzePrimitiveOverrides([n],t,null,null);if(e)return!1}if("CIMVectorMarker"===r){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const o=i,s=Math.abs(o.stepX),l=Math.abs(o.stepY);if(0===s||0===l)return!0;const c=["Rotation","OffsetX","OffsetY"],m=this._primitiveOverrides.filter((t=>t.primitiveName!==e.primitiveName||!c.includes(t.propertyName))),f="url"in e&&"string"==typeof e.url?e.url:void 0,p=a(JSON.stringify(e)).toString();let h,u,y=null;if("Random"===i.gridType){const e=n(J),t=Math.max(Math.floor(e/s),1),i=Math.max(Math.floor(e/l),1);h=l*i,y=e=>e?e*i:0;u=t*s/h}else i.shiftOddRows?(h=2*l,y=e=>e?2*e:0,u=s/l*.5):(h=l,y=null,u=s/l);const d=b(e);return this._cimLayers.push({type:"fill",templateHash:p,materialHash:p,cim:e,materialOverrides:m,colorLocked:!!e.colorLocked,effects:t,color:d,height:this._createOverrideFunction(o.primitiveName,"StepY",h,y),scaleX:u,angle:o.gridAngle,offsetX:N(o.offsetX),offsetY:N(o.offsetY),url:f,applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:!f,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,r,o,n,s,l,c,m){let f=N(e.scaleX,1);const p=b(e),h=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}${JSON.stringify(e.animatedSymbolProperties)}`).toString();i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));const u=this._createAnimatedSymbolPropertiesOverrideFunction(e.animatedSymbolProperties),[y,d]=this._analyzePrimitiveOverrides(r,t,i,u),v=a(JSON.stringify(e)+d).toString(),_=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height);f/=i*(N(e.size)/t)}function S(e,t){return null!=u?w(u,e,t):null}const O=e.animatedSymbolProperties&&!0===e.animatedSymbolProperties.randomizeStartTime?(e,t,i,r)=>{const o=Y(r??0),n=S(e,t);return h+`-MATERIALGROUP(${o})`+`-ASP(${JSON.stringify(n)})`}:y?(e,t)=>{const i=S(e,t);return h+`-ASP(${JSON.stringify(i)})`}:h;this._cimLayers.push({type:"marker",templateHash:v,materialHash:O,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!1,alignment:o,size:s,scaleX:this._createOverrideFunction(e.primitiveName,"ScaleX",f),rotation:l,offsetX:c,offsetY:m,color:this._createOverrideFunction(e.primitiveName,"TintColor",p,U),anchorPoint:{x:_.x,y:_.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,frameHeight:0,rotateClockwise:!1,referenceSize:n,sizeRatio:1,markerPlacement:i,url:e.url,animatedSymbolProperties:u})}_analyzeVectorMarker(e,t,i,r,o,n,a,s,l,c,m,f){const p=e.markerGraphics;if(!p)return;let h,u=0,y=1;e.scaleSymbolsProportionally&&(h=e.frame,h&&(u=h.ymax-h.ymin,y=this._transformSize(l,1/u))),y=this._transformSize(y,a),i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));for(const d of p)if(d){const a=d.symbol;if(!a)continue;const p=d.primitiveName;p&&r.push(p);let v=m,_=f;if(("CIMPointSymbol"===a.type||"CIMTextSymbol"===a.type)&&h){let t=0,i=0;const r=d.geometry;"x"in r&&"y"in r&&(t+=r.x-.5*(h.xmin+h.xmax),i+=r.y-.5*(h.ymin+h.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,i-=o.y):h&&(t-=(h.xmax-h.xmin)*o.x,i-=(h.ymax-h.ymin)*o.y)),v=this._transformOffsetX(t,i,c,y,m),_=this._transformOffsetY(t,i,c,y,f)}switch(a.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":s?this._analyzeMultiLayerGraphicNonSDF(e,t,i,null,d,r,o,n,u):this._analyzeMultiLayerGraphic(e,t,i,null,d,r,o,n,u,y,l,c,v,_);break;case"CIMTextSymbol":this._analyzeTextGraphic(e,t,i,d,r,o,n,u,y,l,c,v,_)}p&&r.pop()}}_analyzeMultiLayerGraphic(e,t,i,r,o,n,s,l,c,m,f,p,h,u){const y=o.symbol,d=y.symbolLayers;if(!d)return;let v=d.length;if(B(d))return void this._analyzeCompositeMarkerGraphic(e,t,i,r,o,d,n,s,l,c,f,p,h,u);const _=this._resourceManager.geometryEngine,S=X.applyEffects(y.effects,o.geometry,_);if(S)for(;v--;){const y=d[v];if(!y||!1===y.enable)continue;const b=y.primitiveName;switch(b&&n.push(b),y.type){case"CIMSolidFill":case"CIMSolidStroke":{const m=X.applyEffects(y.effects,S,_),d=O(m);if(!d)continue;const v="Relative"!==e.anchorPointUnits,[N,C,L]=g(d,e.frame,e.size,e.anchorPoint,v),F="CIMSolidFill"===y.type,I={type:"sdf",geom:m,asFill:F},w=y.path,x=M(F?k(y):P(y)),A=F?{r:0,g:0,b:0,a:0}:M(P(y)),H=z(y)??0;if(!F&&!H)break;let J=!1,Y="";for(const e of this._primitiveOverrides)n.includes(e.primitiveName)&&(null!=e.value?Y+=`-${e.primitiveName}-${e.propertyName}-${JSON.stringify(e.value)}`:e.valueExpressionInfo&&(J=!0));(null!=t&&"function"==typeof t||null!=i&&"function"==typeof i)&&(J=!0),(R(f)||R(p)||R(h)||R(u))&&(J=!0);const E=JSON.stringify({...e,markerGraphics:null}),T=a(JSON.stringify(I)+w).toString(),$=a(JSON.stringify(o)+JSON.stringify(y)+E+Y).toString();this._cimLayers.push({type:"marker",templateHash:$,materialHash:J?()=>T:T,cim:I,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:C,y:L},isAbsoluteAnchorPoint:v,size:f,rotation:p,offsetX:h,offsetY:u,scaleX:1,frameHeight:c,rotateClockwise:!1,referenceSize:l,sizeRatio:N,color:this._createOverrideFunction(b,"Color",x,U),outlineColor:this._createOverrideFunction(b,"Color",A,U),outlineWidth:this._createOverrideFunction(b,"Width",H),markerPlacement:i,animatedSymbolProperties:r,path:w});break}case"CIMVectorMarker":y.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c):this._analyzeMarker(y,t,i,n,s,l,m,!1,f,p,h,u);break;default:this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c)}b&&n.pop()}}_analyzeTextGraphic(e,i,r,o,n,s,l,c,m,p,u,d,v){const _=[];y.findApplicableOverrides(o,this._primitiveOverrides,_);const S=o.geometry;if(!("x"in S)||!("y"in S))return;const O=o.symbol,g=C(O),b=L(O.fontStyleName),R=t(O.fontFamilyName);O.font={family:R,decoration:g,...b};let X=N(O.height,h),H=N(O.angle),J=N(O.offsetX),Y=N(O.offsetY);X=this._transformSize(X,m),H=this._transformRotation(H,!1,u);const E=this._transformOffsetX(J,Y,u,m,d),T=this._transformOffsetY(J,Y,u,m,v);J=E,Y=T;const $=M(k(O));let j=M(P(O)),G=z(O)??0;G||(j=M(k(O.haloSymbol)),G=N(O.haloSize)),G=this._transformSize(G,m);let D=null,U=null,W=0;if(O.callout&&"CIMBackgroundCallout"===O.callout.type){const e=O.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?D=M(e.color):"CIMSolidStroke"===e.type&&(U=M(e.color),W=N(e.width,f))}}const[V,B]=this._analyzePrimitiveOverrides(n,i,r,null),q=JSON.stringify(e.effects)+Number(e.colorLocked).toString()+JSON.stringify(e.anchorPoint)+e.anchorPointUnits+JSON.stringify(e.markerPlacement)+e.size.toString(),K=a(JSON.stringify(o)+q+B).toString();let Q=this._createOverrideFunction(o.primitiveName,"TextString",o.textString??"",F,O.textCase);if(null==Q)return;const{fontStyleName:Z}=O,ee=R+(Z?"-"+Z.toLowerCase():"-regular"),te=ee;"string"==typeof Q&&Q.includes("[")&&O.fieldMap&&(Q=I(O.fieldMap,Q,O.textCase)),this._cimLayers.push({type:"text",templateHash:K,materialHash:V||"function"==typeof Q||/\[(.*?)\]/.test(Q)?(e,t,i)=>te+"-"+w(Q,e,t,i):te+"-"+a(Q),cim:O,materialOverrides:null,colorLocked:!!e.colorLocked,effects:i,alignment:s,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,fontName:ee,decoration:g,weight:b.weight,style:b.style,size:X,angle:H,offsetX:J,offsetY:Y,horizontalAlignment:x(O.horizontalAlignment),verticalAlignment:A(O.verticalAlignment),text:Q,color:$,outlineColor:j,outlineSize:G,backgroundColor:D,borderLineColor:U,borderLineWidth:W,referenceSize:l,sizeRatio:1,markerPlacement:r})}_analyzeMultiLayerGraphicNonSDF(e,t,i,r,n,s,l,c,m){const f=this._buildSimpleMarker(e,n),h=e.primitiveName,y=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),[d,v]=this._analyzePrimitiveOverrides(s,null,null,null),[_,S,O]=u.getTextureAnchor(f,this._resourceManager),g=N(e.rotation),M=N(e.offsetX),b=N(e.offsetY),k=a(JSON.stringify(f)+v).toString(),P=y&&y.length>0||null!=t&&"function"==typeof t;this._cimLayers.push({type:"marker",templateHash:k,materialHash:P&&y?this._createMaterialHashFunction(k,y):k,cim:f,materialOverrides:y,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:_,y:S},isAbsoluteAnchorPoint:!1,size:N(e.size,p),rotation:this._createOverrideFunction(h,"Rotation",g),offsetX:this._createOverrideFunction(h,"OffsetX",M),offsetY:this._createOverrideFunction(h,"OffsetY",b),color:{r:255,g:255,b:255,a:1},outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,scaleX:1,frameHeight:m,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:O/o(e.size),markerPlacement:i,animatedSymbolProperties:r,avoidSDFRasterization:!0})}_buildSimpleMarker(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}_analyzeCompositeMarkerGraphic(e,t,i,r,o,n,s,l,c,m,p,h,u,y){const d=o.geometry,v=n[0],_=n[1],S=O(d);if(!S)return;const b="Relative"!==e.anchorPointUnits,[k,P,z]=g(S,e.frame,e.size,e.anchorPoint,b),C={type:"sdf",geom:d,asFill:!0},L=_.path,F=_.primitiveName,I=v.primitiveName,w=M(_.color),x=M(v.color),A=N(v.width,f);let X=!1,H="";for(const a of this._primitiveOverrides)(a.primitiveName===F||a.primitiveName===I||s.includes(a.primitiveName))&&(null!=a.value?H+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(X=!0));null!=i&&"function"==typeof i&&(X=!0),(R(p)||R(h)||R(u)||R(y))&&(X=!0);const J=JSON.stringify({...e,markerGraphics:null}),Y=a(JSON.stringify(C)+L).toString(),E=a(JSON.stringify(o)+JSON.stringify(_)+JSON.stringify(v)+J+H).toString();this._cimLayers.push({type:"marker",templateHash:E,materialHash:X?()=>Y:Y,cim:C,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:P,y:z},isAbsoluteAnchorPoint:b,size:p,rotation:h,offsetX:u,offsetY:y,scaleX:1,frameHeight:m,rotateClockwise:!1,referenceSize:c,sizeRatio:k,color:this._createOverrideFunction(F,"Color",w,U),outlineColor:this._createOverrideFunction(I,"Color",x,U),outlineWidth:this._createOverrideFunction(I,"Width",A),markerPlacement:i,path:L,animatedSymbolProperties:r})}_createMaterialHashFunction(e,t){const i=this._info?.geometryType;if(i){const e=this._poMap;for(const r of t){if(r.valueExpressionInfo){const t=e[r.primitiveName]&&e[r.primitiveName][r.propertyName];t instanceof l&&(r.fn=(e,r,o)=>H(t,e,{$view:o},i,r))}}}return(i,r,o)=>{for(const e of t)e.fn&&(e.value=e.fn(i,r,o));return a(e+y.buildOverrideKey(t)).toString()}}_setPoMap(e,t,i){let r;this._poMap[e]?r=this._poMap[e]:(r={},this._poMap[e]=r),r[t]=i}_createOverrideFunction(e,t,i,r,o){if(null==e)return i;const n=this._poMap[e];if(null==n)return i;const a=n[t];if("string"==typeof a||"number"==typeof a||a instanceof Array)return r?r.call(null,a,o):a;const s=this._info?.geometryType;return null!=a&&a instanceof l&&null!=s?(e,t,n)=>{let l=H(a,e,{$view:n},s,t);return null!==l&&r&&(l=r.call(null,l,o)),null!==l?l:i}:i}_createEffectsOverrideFunction(e,t){const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=[];for(let s of e){const e=s?.primitiveName;if(e){let r=!1;for(const o of t)if(o.primitiveName===e){const e=W(o.propertyName);null!=o.value&&o.value!==s[e]&&(r||(s=i(s),r=!0),s[e]=o.value)}}a.push(s)}return a}}_createMarkerPlacementOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);null!=e.value&&e.value!==a[t]&&(a[t]=e.value)}return a}}_createAnimatedSymbolPropertiesOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._info?.geometryType;if(r){const e=this._poMap;for(const i of t){if(i.valueExpressionInfo){const t=e[i.primitiveName]&&e[i.primitiveName][i.propertyName];t instanceof l&&(i.fn=(e,i,o)=>H(t,e,{$view:o},r,i))}}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);if(null!=e.value){const i=S(e.value,e.propertyName);i!==a[t]&&(a[t]=i)}}return a}}_analyzePrimitiveOverrides(e,t,i,r){let o=!1,n="";"string"==typeof e&&(e=[e]);for(const a of this._primitiveOverrides)e?.includes(a.primitiveName)&&(null!=a.value?n+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(o=!0));return null!=t&&"function"==typeof t&&(o=!0),null!=i&&"function"==typeof i&&(o=!0),null!=r&&"function"==typeof r&&(o=!0),[o,n]}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter((i=>i.primitiveName!==e||!t.includes(i.propertyName)))}_transformSize(e,t){return R(e)||R(t)?(i,r,o)=>(R(e)?e(i,r,o):e)*(R(t)?t(i,r,o):t):e*t}_transformRotation(e,t,i){return R(e)||R(i)?(r,o,n)=>{const a=R(e)?e(r,o,n):e,s=R(i)?i(r,o,n):i;return t?s-a:s+a}:t?i-e:i+e}_transformOffsetX(e,t,i,r,o){if(!(R(e)||R(t)||R(i)||R(r)||R(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n),a=Math.sin(n);return(i*e-a*t)*r+o}return e*r+o}return(n,a,s)=>{let l=R(i)?i(n,a,s):i;const c=R(r)?r(n,a,s):r,m=R(e)?e(n,a,s):e,f=R(o)?o(n,a,s):o;if(l){l*=Math.PI/180;return(Math.cos(l)*m-Math.sin(l)*(R(t)?t(n,a,s):t))*c+f}return m*c+f}}_transformOffsetY(e,t,i,r,o){if(!(R(e)||R(t)||R(i)||R(r)||R(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n);return(Math.sin(n)*e+i*t)*r+o}return t*r+o}return(n,a,s)=>{let l=R(i)?i(n,a,s):i;const c=R(r)?r(n,a,s):r,m=R(t)?t(n,a,s):t,f=R(o)?o(n,a,s):o;if(l){l*=Math.PI/180;const t=Math.cos(l);return(Math.sin(l)*(R(e)?e(n,a,s):e)+t*m)*c+f}return m*c+f}}}function D(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.substr(6),10);if(!isNaN(t))return t}return 0}function U(t){if(!t||0===t.length)return null;const i=new e(t).toRgba();return{r:i[0],g:i[1],b:i[2],a:i[3]}}function W(e){return e?e.charAt(0).toLowerCase()+e.substr(1):e}function V(e,t){if(!t||0===t.length)return e;const r=i(e);return y.applyOverrides(r,t),r}const B=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&!e[0].effects&&!e[1].effects;export{G as CIMAnalyzer,V as analyzeCIMResource};
|
|
5
|
+
import e from"../../Color.js";import{getFontFamily as t}from"../../core/fontUtils.js";import{clone as i}from"../../core/lang.js";import r from"../../core/Logger.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{numericHash as a}from"../../core/string.js";import{createRendererExpression as s,ArcadeExpression as l}from"../../support/arcadeOnDemand.js";import{DEFAULT_PICTURE_FILL_HEIGHT as c,DEFAULT_HATCH_FILL_SEPARATION as m,DEFAULT_STROKE_WIDTH as f,DEFAULT_MARKER_SIZE as h,DEFAULT_TEXT_HEIGHT as p}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as u,OverrideHelper as y}from"./CIMSymbolHelper.js";import{Alignment as d,CapType as v,JoinType as _}from"./enums.js";import{quantizeIfNeeded as O}from"./quantizeTime.js";import{getExtent as S,getSDFMetrics as g}from"./SDFHelper.js";import{fromCIMColor as M,getTintColor as k,getValue as b,getFillColor as N,getStrokeColor as P,getStrokeWidth as z,isFeatureValueFn as C,fromCIMFontDecoration as F,fromCIMFontStyle as L,adjustTextCase as I,createLabelOverrideFunction as w,evaluateValueOrFunction as x,fromCIMHorizontalAlignment as A,fromCIMVerticalAlignment as R}from"./utils.js";import{CIMEffectHelper as X}from"./effects/CIMEffectHelper.js";import H from"../../views/2d/arcade/callExpressionWithFeature.js";import{RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as J}from"../../views/2d/engine/webgl/definitions.js";import{getMaterialGroup as Y}from"../../views/2d/engine/webgl/grouping.js";const E=r.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){switch(e){case"Butt":return v.BUTT;case"Square":return v.SQUARE;default:return v.ROUND}}function $(e){switch(e){case"Bevel":return _.BEVEL;case"Miter":return _.MITER;default:return _.ROUND}}function j(e){const t=e.markerPlacement;return t&&t.angleToLine?d.MAP:d.SCREEN}class G{constructor(e,t){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._resourceManager=e,this._info=t}async analyzeSymbolReference(e,t,i){if(this._cimLayers=i??[],!e)return this._cimLayers;if(e.primitiveOverrides){this._primitiveOverrides=e.primitiveOverrides,this._poMap={};const t=[],i=this._info;for(const e of this._primitiveOverrides){const r=e.valueExpressionInfo;if(r&&i){const o=r.expression,n=s(o,i.spatialReference,i.fields).then((t=>{null!=t&&this._setPoMap(e.primitiveName,e.propertyName,t)}));t.push(n)}else null!=e.value&&this._setPoMap(e.primitiveName,e.propertyName,e.value);t.length>0&&await Promise.all(t)}}const r=e.symbol,o=[];return u.fetchResources(r,this._resourceManager,o),o.length>0&&await Promise.all(o),this._analyzeSymbol(r,t),this._cimLayers}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t,1,0,0,0)}}_analyzeMultiLayerSymbol(e,t,i,r,o,n){const a=e?.symbolLayers;if(!a)return;const s=e.effects;let l=d.SCREEN;const c=u.getSize(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(l=d.MAP);const m="CIMPolygonSymbol"===e.type;let f=a.length;for(;f--;){const h=a[f];if(!h||!1===h.enable)continue;let p;s&&s.length&&(p=[...s]);const u=h.effects;u&&u.length&&(s?p.push(...u):p=[...u]);const d=[];let v;y.findEffectOverrides(p,this._primitiveOverrides,d),v=d.length>0?this._createEffectsOverrideFunction(p,d):p;const _=[];switch(y.findApplicableOverrides(h,this._primitiveOverrides,_),h.type){case"CIMSolidFill":this._analyzeSolidFill(h,v);break;case"CIMPictureFill":this._analyzePictureFill(h,v);break;case"CIMHatchFill":this._analyzeHatchFill(h,v);break;case"CIMGradientFill":this._analyzeGradientFill(h,v);break;case"CIMSolidStroke":this._analyzeSolidStroke(h,v,m,c);break;case"CIMPictureStroke":this._analyzePictureStroke(h,v,m,c);break;case"CIMGradientStroke":this._analyzeGradientStroke(h,v,m,c);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"===e.type&&(l=j(h));const a=[],s=h.primitiveName;s&&a.push(s),this._analyzeMarker(h,v,null,a,l,c,1,t,i,r,o,n);break}default:E.error("Cannot analyze CIM layer",h.type)}}}_analyzeSolidFill(e,t){const i=e.primitiveName,r=M(e.color),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString();this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>s:s,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,color:this._createOverrideFunction(i,"Color",r,U),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0})}_analyzePictureFill(e,t){const i=e.primitiveName,r=k(e),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString(),l=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),m=b(e.height,c);let f=b(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height),f/=i*(m/t)}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>l:l,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(i,"TintColor",r,U),height:this._createOverrideFunction(i,"Height",m),scaleX:this._createOverrideFunction(i,"ScaleX",f),angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),url:e.url,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeHatchFill(e,t){const i=e.primitiveName,r=this._analyzeMaterialOverrides(i,["Rotation","OffsetX","OffsetY"]);let[o,n]=this._analyzePrimitiveOverrides(i,t,null,null);const s=a(JSON.stringify(e)+n).toString(),l=a(`${e.separation}${JSON.stringify(e.lineSymbol)}`).toString();let c={r:255,g:255,b:255,a:1},f=!1;const h=e.lineSymbol?.symbolLayers?.find((e=>"CIMSolidStroke"===e.type&&null!=this._poMap[e.primitiveName]?.Color));if(h){c=M(h.color),c=this._createOverrideFunction(h.primitiveName,"Color",c,U);const e="function"==typeof c;o=o||e,f=null!=h.color||e}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o&&r?this._createMaterialHashFunction(l,r):l,cim:e,materialOverrides:r,colorLocked:!!e.colorLocked,effects:t,color:c,height:this._createOverrideFunction(i,"Separation",b(e.separation,m)),scaleX:1,angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!f})}_analyzeGradientFill(e,t){const i=e.primitiveName,[r,o]=this._analyzePrimitiveOverrides(i,t,null,null),n=a(JSON.stringify(e)+o).toString();this._cimLayers.push({type:"fill",templateHash:n,materialHash:r?()=>n:n,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeSolidStroke(e,t,i,r){const o=e.primitiveName,n=M(e.color),s=b(e.width,f),l=T(e.capStyle),c=$(e.joinStyle),m=e.miterLimit,[h,p]=this._analyzePrimitiveOverrides(o,t,null,null),u=a(JSON.stringify(e)+p).toString();let y,d;if(t&&t instanceof Array&&t.length>0){const e=t[t.length-1];if("CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine){const e=(t=[...t]).pop();y=e.dashTemplate,d=e.scaleDash}}this._cimLayers.push({type:"line",templateHash:u,materialHash:h?()=>u:u,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(o,"Color",n,U),width:this._createOverrideFunction(o,"Width",s),cap:this._createOverrideFunction(o,"CapStyle",l),join:this._createOverrideFunction(o,"JoinStyle",c),miterLimit:m&&this._createOverrideFunction(o,"MiterLimit",m),referenceWidth:r,zOrder:D(e.name),dashTemplate:y,scaleDash:d,sampleAlphaOnly:!0})}_analyzePictureStroke(e,t,i,r){const o=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),n=e.primitiveName,s=k(e),l=b(e.width,f),c=T(e.capStyle),m=$(e.joinStyle),h=e.miterLimit,[p,u]=this._analyzePrimitiveOverrides(n,t,null,null),y=a(JSON.stringify(e)+u).toString();this._cimLayers.push({type:"line",templateHash:y,materialHash:p?()=>o:o,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(n,"TintColor",s,U),width:this._createOverrideFunction(n,"Width",l),cap:this._createOverrideFunction(n,"CapStyle",c),join:this._createOverrideFunction(n,"JoinStyle",m),miterLimit:h&&this._createOverrideFunction(n,"MiterLimit",h),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,url:e.url,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,t,i,r){const o=e.primitiveName,n=b(e.width,f),s=T(e.capStyle),l=$(e.joinStyle),c=e.miterLimit,[m,h]=this._analyzePrimitiveOverrides(o,t,null,null),p=a(JSON.stringify(e)+h).toString();this._cimLayers.push({type:"line",templateHash:p,materialHash:m?()=>p:p,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},width:this._createOverrideFunction(o,"Width",n),cap:this._createOverrideFunction(o,"CapStyle",s),join:this._createOverrideFunction(o,"JoinStyle",l),miterLimit:c&&this._createOverrideFunction(o,"MiterLimit",c),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,t,i,r,o,n,a,s,l,c,m,f){if(this._analyzeMarkerInsidePolygon(e,t))return;const p=b(e.size,h),u=b(e.rotation),y=b(e.offsetX),d=b(e.offsetY);let v=this._createOverrideFunction(e.primitiveName,"Size",p),_=this._createOverrideFunction(e.primitiveName,"Rotation",u),O=this._createOverrideFunction(e.primitiveName,"OffsetX",y),S=this._createOverrideFunction(e.primitiveName,"OffsetY",d);v=this._transformSize(v,a),_=this._transformRotation(_,!!e.rotateClockwise,c);const g=this._transformOffsetX(O,S,c,a,m),M=this._transformOffsetY(O,S,c,a,f);switch(O=g,S=M,e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,i,r,o,n,v,_,O,S);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,i,r,o,n,a,s,v,_,O,S)}}_analyzeMarkerInsidePolygon(e,t){const{markerPlacement:i,type:r}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===r||"CIMPictureMarker"===r){const o=e.primitiveName;if(o){const[e,i]=this._analyzePrimitiveOverrides([o],t,null,null);if(e)return!1}const n=i.primitiveName;if(n){const[e,i]=this._analyzePrimitiveOverrides([n],t,null,null);if(e)return!1}if("CIMVectorMarker"===r){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const o=i,s=Math.abs(o.stepX),l=Math.abs(o.stepY);if(0===s||0===l)return!0;const c=["Rotation","OffsetX","OffsetY"],m=this._primitiveOverrides.filter((t=>t.primitiveName!==e.primitiveName||!c.includes(t.propertyName))),f="url"in e&&"string"==typeof e.url?e.url:void 0,h=a(JSON.stringify(e)).toString();let p,u,y=null;if("Random"===i.gridType){const e=n(J),t=Math.max(Math.floor(e/s),1),i=Math.max(Math.floor(e/l),1);p=l*i,y=e=>e?e*i:0;u=t*s/p}else i.shiftOddRows?(p=2*l,y=e=>e?2*e:0,u=s/l*.5):(p=l,y=null,u=s/l);const d=k(e);return this._cimLayers.push({type:"fill",templateHash:h,materialHash:h,cim:e,materialOverrides:m,colorLocked:!!e.colorLocked,effects:t,color:d,height:this._createOverrideFunction(o.primitiveName,"StepY",p,y),scaleX:u,angle:o.gridAngle,offsetX:b(o.offsetX),offsetY:b(o.offsetY),url:f,applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:!f,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,r,o,n,s,l,c,m){let f=b(e.scaleX,1);const h=k(e),p=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}${JSON.stringify(e.animatedSymbolProperties)}`).toString();i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));const u=this._createAnimatedSymbolPropertiesOverrideFunction(e.animatedSymbolProperties),[y,d]=this._analyzePrimitiveOverrides(r,t,i,u),v=a(JSON.stringify(e)+d).toString(),_=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height);f/=i*(b(e.size)/t)}function O(e,t){return null!=u?x(u,e,t):null}const S=e.animatedSymbolProperties&&!0===e.animatedSymbolProperties.randomizeStartTime?(e,t,i,r)=>{const o=Y(r??0),n=O(e,t);return p+`-MATERIALGROUP(${o})`+`-ASP(${JSON.stringify(n)})`}:y?(e,t)=>{const i=O(e,t);return p+`-ASP(${JSON.stringify(i)})`}:p;this._cimLayers.push({type:"marker",templateHash:v,materialHash:S,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!1,alignment:o,size:s,scaleX:this._createOverrideFunction(e.primitiveName,"ScaleX",f),rotation:l,offsetX:c,offsetY:m,color:this._createOverrideFunction(e.primitiveName,"TintColor",h,U),anchorPoint:{x:_.x,y:_.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,frameHeight:0,rotateClockwise:!1,referenceSize:n,sizeRatio:1,markerPlacement:i,url:e.url,animatedSymbolProperties:u})}_analyzeVectorMarker(e,t,i,r,o,n,a,s,l,c,m,f){const h=e.markerGraphics;if(!h)return;let p,u=0,y=1;e.scaleSymbolsProportionally&&(p=e.frame,p&&(u=p.ymax-p.ymin,y=this._transformSize(l,1/u))),y=this._transformSize(y,a),i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));for(const d of h)if(d){const a=d.symbol;if(!a)continue;const h=d.primitiveName;h&&r.push(h);let v=m,_=f;if(("CIMPointSymbol"===a.type||"CIMTextSymbol"===a.type)&&p){let t=0,i=0;const r=d.geometry;"x"in r&&"y"in r&&(t+=r.x-.5*(p.xmin+p.xmax),i+=r.y-.5*(p.ymin+p.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,i-=o.y):p&&(t-=(p.xmax-p.xmin)*o.x,i-=(p.ymax-p.ymin)*o.y)),v=this._transformOffsetX(t,i,c,y,m),_=this._transformOffsetY(t,i,c,y,f)}switch(a.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":s?this._analyzeMultiLayerGraphicNonSDF(e,t,i,null,d,r,o,n,u):this._analyzeMultiLayerGraphic(e,t,i,null,d,r,o,n,u,y,l,c,v,_);break;case"CIMTextSymbol":this._analyzeTextGraphic(e,t,i,d,r,o,n,u,y,l,c,v,_)}h&&r.pop()}}_analyzeMultiLayerGraphic(e,t,i,r,o,n,s,l,c,m,f,h,p,u){const y=o.symbol,d=y.symbolLayers;if(!d)return;let v=d.length;if(B(d))return void this._analyzeCompositeMarkerGraphic(e,t,i,r,o,d,n,s,l,c,f,h,p,u);const _=this._resourceManager.geometryEngine,O=X.applyEffects(y.effects,o.geometry,_);if(O)for(;v--;){const y=d[v];if(!y||!1===y.enable)continue;const k=y.primitiveName;switch(k&&n.push(k),y.type){case"CIMSolidFill":case"CIMSolidStroke":{const m=X.applyEffects(y.effects,O,_),d=S(m);if(!d)continue;const v="Relative"!==e.anchorPointUnits,[b,F,L]=g(d,e.frame,e.size,e.anchorPoint,v),I="CIMSolidFill"===y.type,w={type:"sdf",geom:m,asFill:I},x=y.path,A=M(I?N(y):P(y)),R=I?{r:0,g:0,b:0,a:0}:M(P(y)),H=z(y)??0;if(!I&&!H)break;const J=o.primitiveName;let Y=null;I&&!y.colorLocked&&(Y=this._createOverrideFunction(J,"FillColor",A,U));let E=null;y.colorLocked||(E=this._createOverrideFunction(J,"StrokeColor",R,U));const T=this._createOverrideFunction(J,"StrokeWidth",H);let $=!1,j="";for(const e of this._primitiveOverrides)n.includes(e.primitiveName)&&(null!=e.value?j+=`-${e.primitiveName}-${e.propertyName}-${JSON.stringify(e.value)}`:e.valueExpressionInfo&&($=!0));(null!=t&&"function"==typeof t||null!=i&&"function"==typeof i)&&($=!0),(C(f)||C(h)||C(p)||C(u))&&($=!0);const G=JSON.stringify({...e,markerGraphics:null}),D=a(JSON.stringify(w)+x).toString(),W=a(JSON.stringify(o)+JSON.stringify(y)+G+j).toString();this._cimLayers.push({type:"marker",templateHash:W,materialHash:$?()=>D:D,cim:w,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:F,y:L},isAbsoluteAnchorPoint:v,size:f,rotation:h,offsetX:p,offsetY:u,scaleX:1,frameHeight:c,rotateClockwise:!1,referenceSize:l,sizeRatio:b,color:C(Y)?Y:this._createOverrideFunction(k,"Color",A,U),outlineColor:C(E)?E:this._createOverrideFunction(k,"Color",R,U),outlineWidth:C(T)?T:this._createOverrideFunction(k,"Width",H),markerPlacement:i,animatedSymbolProperties:r,path:x});break}case"CIMVectorMarker":y.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c):this._analyzeMarker(y,t,i,n,s,l,m,!1,f,h,p,u);break;default:this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c)}k&&n.pop()}}_analyzeTextGraphic(e,i,r,o,n,s,l,c,m,h,u,d,v){const _=[];y.findApplicableOverrides(o,this._primitiveOverrides,_);const O=o.geometry;if(!("x"in O)||!("y"in O))return;const S=o.symbol,g=F(S),k=L(S.fontStyleName),C=t(S.fontFamilyName);S.font={family:C,decoration:g,...k};let X=b(S.height,p),H=b(S.angle),J=b(S.offsetX),Y=b(S.offsetY);X=this._transformSize(X,m),H=this._transformRotation(H,!1,u);const E=this._transformOffsetX(J,Y,u,m,d),T=this._transformOffsetY(J,Y,u,m,v);J=E,Y=T;const $=M(N(S));let j=M(P(S)),G=z(S)??0;G||(j=M(N(S.haloSymbol)),G=b(S.haloSize)),G=this._transformSize(G,m);let D=null,U=null,W=0;if(S.callout&&"CIMBackgroundCallout"===S.callout.type){const e=S.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?D=M(e.color):"CIMSolidStroke"===e.type&&(U=M(e.color),W=b(e.width,f))}}const[V,B]=this._analyzePrimitiveOverrides(n,i,r,null),q=JSON.stringify(e.effects)+Number(e.colorLocked).toString()+JSON.stringify(e.anchorPoint)+e.anchorPointUnits+JSON.stringify(e.markerPlacement)+e.size.toString(),K=a(JSON.stringify(o)+q+B).toString();let Q=this._createOverrideFunction(o.primitiveName,"TextString",o.textString??"",I,S.textCase);if(null==Q)return;const{fontStyleName:Z}=S,ee=C+(Z?"-"+Z.toLowerCase():"-regular"),te=ee;"string"==typeof Q&&Q.includes("[")&&S.fieldMap&&(Q=w(S.fieldMap,Q,S.textCase)),this._cimLayers.push({type:"text",templateHash:K,materialHash:V||"function"==typeof Q||/\[(.*?)\]/.test(Q)?(e,t,i)=>te+"-"+x(Q,e,t,i):te+"-"+a(Q),cim:S,materialOverrides:null,colorLocked:!!e.colorLocked,effects:i,alignment:s,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,fontName:ee,decoration:g,weight:k.weight,style:k.style,size:X,angle:H,offsetX:J,offsetY:Y,horizontalAlignment:A(S.horizontalAlignment),verticalAlignment:R(S.verticalAlignment),text:Q,color:$,outlineColor:j,outlineSize:G,backgroundColor:D,borderLineColor:U,borderLineWidth:W,referenceSize:l,sizeRatio:1,markerPlacement:r})}_analyzeMultiLayerGraphicNonSDF(e,t,i,r,n,s,l,c,m){const f=this._buildSimpleMarker(e,n),p=e.primitiveName,y=this._analyzeMaterialOverrides(p,["Rotation","OffsetX","OffsetY"]),[d,v]=this._analyzePrimitiveOverrides(s,null,null,null),[_,O,S]=u.getTextureAnchor(f,this._resourceManager),g=b(e.rotation),M=b(e.offsetX),k=b(e.offsetY),N=a(JSON.stringify(f)+v).toString(),P=y&&y.length>0||null!=t&&"function"==typeof t;this._cimLayers.push({type:"marker",templateHash:N,materialHash:P&&y?this._createMaterialHashFunction(N,y):N,cim:f,materialOverrides:y,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:_,y:O},isAbsoluteAnchorPoint:!1,size:b(e.size,h),rotation:this._createOverrideFunction(p,"Rotation",g),offsetX:this._createOverrideFunction(p,"OffsetX",M),offsetY:this._createOverrideFunction(p,"OffsetY",k),color:{r:255,g:255,b:255,a:1},outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,scaleX:1,frameHeight:m,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:S/o(e.size),markerPlacement:i,animatedSymbolProperties:r,avoidSDFRasterization:!0})}_buildSimpleMarker(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}_analyzeCompositeMarkerGraphic(e,t,i,r,o,n,s,l,c,m,h,p,u,y){const d=o.geometry,v=n[0],_=n[1],O=S(d);if(!O)return;const k="Relative"!==e.anchorPointUnits,[N,P,z]=g(O,e.frame,e.size,e.anchorPoint,k),F={type:"sdf",geom:d,asFill:!0},L=_.path,I=_.primitiveName,w=v.primitiveName,x=M(_.color),A=M(v.color),R=b(v.width,f),X=o.primitiveName;let H=null;_.colorLocked||(H=this._createOverrideFunction(X,"FillColor",x,U));let J=null;v.colorLocked||(J=this._createOverrideFunction(X,"StrokeColor",A,U));const Y=this._createOverrideFunction(X,"StrokeWidth",R);let E=!1,T="";for(const a of this._primitiveOverrides)(a.primitiveName===I||a.primitiveName===w||s.includes(a.primitiveName))&&(null!=a.value?T+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(E=!0));null!=i&&"function"==typeof i&&(E=!0),(C(h)||C(p)||C(u)||C(y))&&(E=!0);const $=JSON.stringify({...e,markerGraphics:null}),j=a(JSON.stringify(F)+L).toString(),G=a(JSON.stringify(o)+JSON.stringify(_)+JSON.stringify(v)+$+T).toString();this._cimLayers.push({type:"marker",templateHash:G,materialHash:E?()=>j:j,cim:F,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:P,y:z},isAbsoluteAnchorPoint:k,size:h,rotation:p,offsetX:u,offsetY:y,scaleX:1,frameHeight:m,rotateClockwise:!1,referenceSize:c,sizeRatio:N,color:C(H)?H:this._createOverrideFunction(I,"Color",x,U),outlineColor:C(J)?J:this._createOverrideFunction(w,"Color",A,U),outlineWidth:C(Y)?Y:this._createOverrideFunction(w,"Width",R),markerPlacement:i,path:L,animatedSymbolProperties:r})}_createMaterialHashFunction(e,t){const i=this._info?.geometryType;if(i){const e=this._poMap;for(const r of t){if(r.valueExpressionInfo){const t=e[r.primitiveName]&&e[r.primitiveName][r.propertyName];t instanceof l&&(r.fn=(e,r,o)=>H(t,e,{$view:o},i,r))}}}return(i,r,o)=>{for(const e of t)e.fn&&(e.value=e.fn(i,r,o));return a(e+y.buildOverrideKey(t)).toString()}}_setPoMap(e,t,i){let r;this._poMap[e]?r=this._poMap[e]:(r={},this._poMap[e]=r),r[t]=i}_createOverrideFunction(e,t,i,r,o){if(null==e)return i;const n=this._poMap[e];if(null==n)return i;const a=n[t];if("string"==typeof a||"number"==typeof a||a instanceof Array)return r?r.call(null,a,o):a;const s=this._info?.geometryType;return null!=a&&a instanceof l&&null!=s?(e,t,n)=>{let l=H(a,e,{$view:n},s,t);return null!==l&&r&&(l=r.call(null,l,o)),null!==l?l:i}:i}_createEffectsOverrideFunction(e,t){const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=[];for(let s of e){const e=s?.primitiveName;if(e){let r=!1;for(const o of t)if(o.primitiveName===e){const e=W(o.propertyName);null!=o.value&&o.value!==s[e]&&(r||(s=i(s),r=!0),s[e]=o.value)}}a.push(s)}return a}}_createMarkerPlacementOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);null!=e.value&&e.value!==a[t]&&(a[t]=e.value)}return a}}_createAnimatedSymbolPropertiesOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._info?.geometryType;if(r){const e=this._poMap;for(const i of t){if(i.valueExpressionInfo){const t=e[i.primitiveName]&&e[i.primitiveName][i.propertyName];t instanceof l&&(i.fn=(e,i,o)=>H(t,e,{$view:o},r,i))}}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);if(null!=e.value){const i=O(e.value,e.propertyName);i!==a[t]&&(a[t]=i)}}return a}}_analyzePrimitiveOverrides(e,t,i,r){let o=!1,n="";"string"==typeof e&&(e=[e]);for(const a of this._primitiveOverrides)e?.includes(a.primitiveName)&&(null!=a.value?n+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(o=!0));return null!=t&&"function"==typeof t&&(o=!0),null!=i&&"function"==typeof i&&(o=!0),null!=r&&"function"==typeof r&&(o=!0),[o,n]}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter((i=>i.primitiveName!==e||!t.includes(i.propertyName)))}_transformSize(e,t){return C(e)||C(t)?(i,r,o)=>(C(e)?e(i,r,o):e)*(C(t)?t(i,r,o):t):e*t}_transformRotation(e,t,i){return C(e)||C(i)?(r,o,n)=>{const a=C(e)?e(r,o,n):e,s=C(i)?i(r,o,n):i;return t?s-a:s+a}:t?i-e:i+e}_transformOffsetX(e,t,i,r,o){if(!(C(e)||C(t)||C(i)||C(r)||C(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n),a=Math.sin(n);return(i*e-a*t)*r+o}return e*r+o}return(n,a,s)=>{let l=C(i)?i(n,a,s):i;const c=C(r)?r(n,a,s):r,m=C(e)?e(n,a,s):e,f=C(o)?o(n,a,s):o;if(l){l*=Math.PI/180;return(Math.cos(l)*m-Math.sin(l)*(C(t)?t(n,a,s):t))*c+f}return m*c+f}}_transformOffsetY(e,t,i,r,o){if(!(C(e)||C(t)||C(i)||C(r)||C(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n);return(Math.sin(n)*e+i*t)*r+o}return t*r+o}return(n,a,s)=>{let l=C(i)?i(n,a,s):i;const c=C(r)?r(n,a,s):r,m=C(t)?t(n,a,s):t,f=C(o)?o(n,a,s):o;if(l){l*=Math.PI/180;const t=Math.cos(l);return(Math.sin(l)*(C(e)?e(n,a,s):e)+t*m)*c+f}return m*c+f}}}function D(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.substr(6),10);if(!isNaN(t))return t}return 0}function U(t){if(!t||0===t.length)return null;const i=new e(t).toRgba();return{r:i[0],g:i[1],b:i[2],a:i[3]}}function W(e){return e?e.charAt(0).toLowerCase()+e.substr(1):e}function V(e,t){if(!t||0===t.length)return e;const r=i(e);return y.applyOverrides(r,t),r}const B=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&!e[0].effects&&!e[1].effects;export{G as CIMAnalyzer,V as analyzeCIMResource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as A,CloudsRenderingStages as x}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as j}from"./CloudsPresets.js";import{Fog as C,FogParameters as W}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as L}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as U}from"../webgl-engine/lib/RenderSlot.js";import{Update as q}from"../webgl-engine/lib/Update.js";var H;const Q=[U.POSTPROCESSING_ENVIRONMENT_OPAQUE,U.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let V=H=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new k,this._newWeatherParameters=new k,this._fadedWeatherParameters=new k,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(Q,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new C({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled,highQuality:this.view.qualitySettings.highQualityAtmosphere})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=A(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===x.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case U.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?.qualitySettings.highQualityAtmosphere||this.view?._stage?.renderer?.isFeatureEnabled(L.HighQualityAtmosphere)),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case U.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?.qualitySettings.highQualityAtmosphere||this.view?._stage?.renderer?.isFeatureEnabled(L.HighQualityAtmosphere)),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===q.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(j[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,G),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{B=H.prototype._getAtmosphereClass,H.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{H.prototype._getAtmosphereClass=B}}}};e([h({constructOnly:!0})],V.prototype,"view",void 0),e([h({readOnly:!0})],V.prototype,"atmosphere",null),e([h({readOnly:!0})],V.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],V.prototype,"updating",null),e([h({readOnly:!0})],V.prototype,"weatherVisible",null),e([h()],V.prototype,"_context",void 0),e([h()],V.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],V.prototype,"_stars",null),e([h({readOnly:!0})],V.prototype,"_precipitation",null),e([h({readOnly:!0})],V.prototype,"_clouds",null),e([h({readOnly:!0})],V.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],V.prototype,"_fog",null),e([h({readOnly:!0})],V.prototype,"weatherEnabled",null),e([h({readOnly:!0})],V.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],V.prototype,"_weatherUpdateParameters",null),V=H=e([l("esri.views.3d.environment.EnvironmentRenderer")],V);class k{constructor(){this.fog=new W,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const G=m(.5,.5,.5),D=m(1.5,1.5,1.5);let B;export{V as EnvironmentRenderer,k as WeatherParameters};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as A,CloudsRenderingStages as x}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as j}from"./CloudsPresets.js";import{Fog as C,FogParameters as W}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderFeature as L}from"../webgl-engine/lib/RenderFeature.js";import{RenderSlot as U}from"../webgl-engine/lib/RenderSlot.js";import{Update as q}from"../webgl-engine/lib/Update.js";var H;const V=[U.POSTPROCESSING_ENVIRONMENT_OPAQUE,U.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let k=H=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new G,this._newWeatherParameters=new G,this._fadedWeatherParameters=new G,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(V,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new C({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=A(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===x.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case U.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?.qualitySettings.highResolutionAtmosphere||this.view?._stage?.renderer?.isFeatureEnabled(L.HighResolutionAtmosphere)),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case U.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?.qualitySettings.highResolutionAtmosphere||this.view?._stage?.renderer?.isFeatureEnabled(L.HighResolutionAtmosphere)),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===q.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(j[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,B),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,B),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{Q=H.prototype._getAtmosphereClass,H.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{H.prototype._getAtmosphereClass=Q}}}};e([h({constructOnly:!0})],k.prototype,"view",void 0),e([h({readOnly:!0})],k.prototype,"atmosphere",null),e([h({readOnly:!0})],k.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([h({readOnly:!0})],k.prototype,"weatherVisible",null),e([h()],k.prototype,"_context",void 0),e([h()],k.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],k.prototype,"_stars",null),e([h({readOnly:!0})],k.prototype,"_precipitation",null),e([h({readOnly:!0})],k.prototype,"_clouds",null),e([h({readOnly:!0})],k.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],k.prototype,"_fog",null),e([h({readOnly:!0})],k.prototype,"weatherEnabled",null),e([h({readOnly:!0})],k.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],k.prototype,"_weatherUpdateParameters",null),k=H=e([l("esri.views.3d.environment.EnvironmentRenderer")],k);class G{constructor(){this.fog=new W,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const D=m(.5,.5,.5),B=m(1.5,1.5,1.5);let Q;export{k as EnvironmentRenderer,G as WeatherParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{handlesGroup as t,makeHandle as i}from"../../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{watch as r,
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{handlesGroup as t,makeHandle as i}from"../../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{watch as r,initial as n}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec3f64.js";import{getEffectiveElevationInfo as p,getEffectiveElevationMode as h}from"../../../../../support/elevationInfoUtils.js";import u from"../../../../../symbols/support/ElevationInfo.js";import{SegmentLabels3D as m}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as d}from"../../SnappingVisualizer3D.js";import{meshTransformFastUpdateHandles as v}from"../meshFastUpdateUtils.js";import{getSettings as f}from"../settings.js";import{ExtendedLineVisualElement as y}from"../../visualElements/ExtendedLineVisualElement.js";import{OutlineVisualElement as V}from"../../visualElements/OutlineVisualElement.js";import{VerticesVisualElement as E}from"../../visualElements/VerticesVisualElement.js";import{evaluateElevationAlignmentAtPoint as w}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as _}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as g}from"../../../layers/graphics/GraphicState.js";import{RenderOccludedFlag as j}from"../../../webgl-engine/lib/Material.js";import{DrawGraphicTool as G,geometryTypeToDrawOperationGeometryType as S}from"../../../../draw/DrawGraphicTool.js";import{DrawOperation as I}from"../../../../draw/DrawOperation.js";import{SceneDrawSurface as L,ElevationDrawSurface as O}from"../../../../draw/drawSurfaces.js";import{unitRGBAFromColor as x}from"../../../../support/colorUtils.js";let D=class extends G{constructor(e){super(e),this._activeVertexVisualElement=null,this._createGraphicState=null,this._outlineVisualElement=null,this._verticesVisualElement=null,this._verticalLineVisualElement=null,this.geometryType=null,this.type="draw-3d"}initialize(){const{mode:e,offset:t}=this.elevationInfo;this.internalGraphicsLayer.elevationInfo=new u({mode:e,offset:t})}normalizeCtorArgs(e){if(!e.elevationInfo){const t=e.hasZ??!0;return{...e,elevationInfo:p(t)}}return e}initializeGraphic(e){const i=this._createGraphicState=new g({graphic:e});return t([this.view.maskOccludee(e),this.view.trackGraphicState(i),r((()=>({element:this._outlineVisualElement,isDraped:i.isDraped,displaying:i.displaying})),(({element:e,isDraped:t,displaying:i})=>{e&&(e.isDraped=t),this.drawOperation.cursor=i?null:"progress"}),n),...v(i)])}makeDrawOperation(){const{geometryType:e}=this,t="circle"!==e&&"rectangle"!==e;return new I({view:this.view,manipulators:this.manipulators,geometryType:S(e),drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:new L(this.view,this.elevationInfo,[this.internalGraphicsLayer]),elevationDrawSurface:new O(this.elevationInfo,this.defaultZ,this.view,this.internalGraphicsLayer),hasM:!1,elevationInfo:this.elevationInfo,snappingManager:this.snappingManager,snappingVisualizer:new d,segmentLabels:t?new m:null,labelOptions:this.labelOptions,tooltipOptions:this.tooltipOptions,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===h(this.hasZ,this.elevationInfo)})}onActiveVertexChanged(e){const{view:t}=this,r=f(t);if(this._activeVertexVisualElement)return this._activeVertexVisualElement.vertices=[e],this._updateVerticalLineVisualElement(e),null;const n=r.manipulators,a=n.vertex;this._activeVertexVisualElement=new E({view:t,spatialReference:t.spatialReference,vertices:[e],elevationInfo:this.internalGraphicsLayer.elevationInfo,color:x(a.color),size:a.size,outlineColor:x(a.outlineColor),outlineSize:a.outlineSize,renderOccluded:a.renderOccluded,attached:!1}),this._activeVertexVisualElement.color=x(n.selected.color),this._activeVertexVisualElement.attached=!0;const o=r.visualElements.zVerticalLine;return this._verticalLineVisualElement=new y({view:t,extensionType:o.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:j.OccludeAndTransparent}),o.apply(this._verticalLineVisualElement),i((()=>{this._activeVertexVisualElement=s(this._activeVertexVisualElement),this._verticalLineVisualElement=s(this._verticalLineVisualElement)}))}_updateVerticalLineVisualElement(e){const t=this._verticalLineVisualElement;if(!t)return;const{renderCoordsHelper:i,elevationProvider:s}=this.view;l(z,e[0],e[1],e[2]),T.setFromElevationInfo(this.elevationInfo),z[2]=w(z,s,T,i);i.toRenderCoords(z,this.view.spatialReference,z)?(t.setStartEndFromWorldDownAtLocation(z),t.attached=!0):t.attached=!1}onOutlineChanged(e){if(this._outlineVisualElement)return this._outlineVisualElement.geometry=e,null;const t=this.internalGraphicsLayer.elevationInfo,{view:r}=this,n=f(r);return this._outlineVisualElement=new V({view:r,geometry:e,elevationInfo:t,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===h(this.hasZ,t),attached:!1}),n.visualElements.lineGraphics.outline.apply(this._outlineVisualElement),n.visualElements.lineGraphics.shadowStyle.apply(this._outlineVisualElement),this._outlineVisualElement.attached=!0,this._outlineVisualElement.laserlineEnabled=!0,i((()=>{this._outlineVisualElement=s(this._outlineVisualElement)}))}onRegularVerticesChanged(e){if(this._verticesVisualElement)return this._verticesVisualElement.vertices=e,null;const{view:t}=this,r=f(t).manipulators.vertex;return this._verticesVisualElement=new E({view:t,spatialReference:t.spatialReference,vertices:e,elevationInfo:this.internalGraphicsLayer.elevationInfo,color:x(r.color),size:r.size,outlineColor:x(r.outlineColor),outlineSize:r.outlineSize,renderOccluded:r.renderOccluded,attached:!1}),this._verticesVisualElement.attached=!0,i((()=>{this._verticesVisualElement=s(this._verticesVisualElement)}))}_updateGraphicGeometry(e,t){if("mesh"===this.geometryType&&"point"===t?.type){const i=this.geometryToPlace;return i&&i.centerAt(t),void(i&&e.geometry===i?i.vertexSpace.isGeoreferenced?e.notifyGeometryChanged():e.notifyMeshTransformChanged():e.geometry=i)}super._updateGraphicGeometry(e,t)}};e([a({constructOnly:!0})],D.prototype,"elevationInfo",void 0),e([a({constructOnly:!0})],D.prototype,"geometryType",void 0),e([a()],D.prototype,"type",void 0),e([a({constructOnly:!0})],D.prototype,"view",void 0),D=e([o("esri.views.3d.interactive.editingTools.draw.DrawGraphicTool3D")],D);const T=new _,z=c();export{D as DrawGraphicTool3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{makeHandle as e}from"../../../../core/handleUtils.js";import{watch as t,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{MeshTransformUpdateAction as n}from"../../../../layers/graphics/sources/interfaces.js";function o(n){const{graphic:o}=n;return[t((()=>n.displaying),(e=>{e?s(o):i(o)}),{...r}),e((()=>i(o)))]}function s(e){const{geometry:t}=e;a(t)&&e.notifyMeshTransformChanged({action:n.EnableFastUpdates})}function i(e){const{geometry:t}=e;a(t)&&e.notifyMeshTransformChanged({action:n.DisableFastUpdates})}function a(e){return"mesh"===e?.type&&!e.vertexSpace.isGeoreferenced}export{o as meshTransformFastUpdateHandles,i as tryDisableMeshTransformFastUpdates,s as tryEnableMeshTransformFastUpdates};
|