@arcgis/core 4.26.2 → 4.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/1693ccb22ddb0e075cb7.js +1 -0
- package/assets/esri/core/workers/chunks/18feb69bb066f529f4a5.js +1 -0
- package/assets/esri/core/workers/chunks/413046749019790fd00f.js +1 -0
- package/assets/esri/core/workers/chunks/{1fcc385a9a8904354a67.js → 61cdba0e7382d176510b.js} +1 -1
- package/assets/esri/core/workers/chunks/{3cc8526d3c0bb08be773.js → 8440b51d07263ad5bd50.js} +1 -1
- package/assets/esri/core/workers/chunks/{8111fc49f8e8f260981d.js → c24df96ab71c44dac45c.js} +1 -1
- package/assets/esri/core/workers/chunks/cb80cf1c614ae3b2f5d6.js +1 -0
- package/assets/esri/core/workers/chunks/d363d6dda0043430bc69.js +1 -0
- package/chunks/ComponentShader.glsl.js +16 -12
- package/chunks/Terrain.glsl.js +39 -42
- package/config.js +1 -1
- package/layers/graphics/editingSupport.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
- package/package.json +1 -1
- package/rest/imageService.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +17 -5
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Terrain.glsl.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/assets/esri/core/workers/chunks/186f2d0c94fa1eca4959.js +0 -1
- package/assets/esri/core/workers/chunks/4cb41045be4ee7ac0455.js +0 -1
- package/assets/esri/core/workers/chunks/843a8b87ebecc246598a.js +0 -1
- package/assets/esri/core/workers/chunks/9dd3522e39e522158049.js +0 -1
- package/assets/esri/core/workers/chunks/cb177fb86cf8cec95e87.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[6502],{3388:(e,t,s)=>{var r;s.d(t,{i:()=>r}),function(e){e[e.PROJECT_VERTICES=1]="PROJECT_VERTICES"}(r||(r={}))},61159:(e,t,s)=>{s.d(t,{g:()=>r});const r={supportsStatistics:!0,supportsPercentileStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsCentroid:!0,supportsCacheHint:!1,supportsDistance:!0,supportsDistinct:!0,supportsExtent:!0,supportsGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryGeometry:!0,supportsResultType:!1,supportsSqlExpression:!0,supportsMaxRecordCountFactor:!1,supportsStandardizedQueriesOnly:!0,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!0,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!0,supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,maxRecordCountFactor:void 0,maxRecordCount:void 0,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0}},6502:(e,t,s)=>{s.r(t),s.d(t,{default:()=>E});var r=s(43697),a=(s(66577),s(38171)),o=s(40330),n=s(3172),i=s(92835),u=s(20102),l=s(80442),d=s(35454),c=s(83379),p=s(70586),h=s(78286),y=s(95330),f=s(17452),m=s(5600),g=(s(75215),s(67676),s(52011)),_=s(6570),b=s(33955),F=s(3388),R=s(25278),S=s(74654),C=s(66677),I=s(59431),q=s(82971);const O=new d.X({originalAndCurrentFeatures:"original-and-current-features",none:"none"});async function w(e){return"string"==typeof e?(0,f.sJ)(e)||{data:e}:new Promise(((t,s)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t((0,f.sJ)(r.result)),r.onerror=e=>s(e)}))}const x=new Set(["Feature Layer","Table"]),T=new d.X({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let A=class extends c.Z{constructor(){super(...arguments),this.type="feature-layer",this.refresh=(0,y.Ds)((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}}))}load(e){const t=(0,p.pC)(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:o,fieldsIndex:n}=this.layer,i=(0,l.Z)("featurelayer-pbf")&&e?.query.supportsFormatPBF&&(0,p.Wi)(r),u=e?.operations?.supportsQueryAttachments??!1;return new S.Z({url:t.path,pbfSupported:i,fieldsIndex:n,infoFor3D:r,dynamicDataSource:s,gdbVersion:a,sourceSpatialReference:o,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/addAttachment",a=this._getLayerRequestOptions(),o=this._getFormDataForAttachment(t,a.query);try{const e=await(0,n.default)(r,{body:o});return this._createFeatureEditResult(e.data.addAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(s,e)}}async updateAttachment(e,t,s){await this.load();const r=e.attributes[this.layer.objectIdField],a=this.layer.parsedUrl.path+"/"+r+"/updateAttachment",o=this._getLayerRequestOptions({query:{attachmentId:t}}),i=this._getFormDataForAttachment(s,o.query);try{const e=await(0,n.default)(a,{body:i});return this._createFeatureEditResult(e.data.updateAttachmentResult)}catch(e){throw this._createAttachmentErrorResult(r,e)}}async applyEdits(e,t){await this.load();const s=this.layer.infoFor3D,r=(0,p.pC)(s),a=r||(t?.globalIdUsed??!1),i=e.addFeatures?.map((e=>this._serializeFeature(e,s))).filter(p.pC)??[],u=e.updateFeatures?.map((e=>this._serializeFeature(e,s))).filter(p.pC)??[],l=this._getFeatureIds(e.deleteFeatures,a);(0,I.P)(i,u,this.layer.spatialReference);const d=[],c=[],h=[...e.deleteAttachments??[]];for(const t of e.addAttachments??[])d.push(await this._serializeAttachment(t));for(const t of e.updateAttachments??[])c.push(await this._serializeAttachment(t));const y=d.length||c.length||h.length?{adds:d,updates:c,deletes:h}:null;let f,m=null;if(r){m=new Map;const t=[];for(const s of e.addAssets??[])t.push(this._serializeAssetMapEditAndUploadAssets(s,m));const s=await Promise.all(t);f=s.length?{adds:s,updates:[],deletes:[]}:void 0}const g={gdbVersion:t?.gdbVersion||this.layer.gdbVersion,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:a,returnEditMoment:t?.returnEditMoment,usePreviousEditMoment:t?.usePreviousEditMoment,sessionId:t?.sessionId};t?.returnServiceEditsOption?(g.edits=JSON.stringify([{id:this.layer.layerId,adds:i,updates:u,deletes:l,attachments:y,assetMaps:(0,p.Wg)(f)}]),g.returnServiceEditsOption=O.toJSON(t?.returnServiceEditsOption),g.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(g.adds=i.length?JSON.stringify(i):null,g.updates=u.length?JSON.stringify(u):null,g.deletes=l.length?a?JSON.stringify(l):l.join(","):null,g.attachments=y&&JSON.stringify(y),g.assetMaps=(0,p.pC)(f)?JSON.stringify(f):void 0);const _=this._getLayerRequestOptions({method:"post",query:g}),b=t?.returnServiceEditsOption?this.layer.url:this.layer.parsedUrl.path,F=await(0,n.default)(b+"/applyEdits",_);if(!this.layer.capabilities.operations?.supportsEditing&&this.layer.effectiveCapabilities?.operations?.supportsEditing){const e=o.id?.findCredential(this.layer.url);await(e?.refreshToken())}if(r&&null!=F.data&&null!=F.data.assetMaps){const e=F.data,t=this.layer.objectIdField,s=[];for(const t of e.addResults)t.success&&s.push(t.objectId);for(const t of e.updateResults)t.success&&s.push(t.objectId);const r=this._createRequestQueryOptions(),a=await(0,n.default)(b+"/query",{...r,query:{f:"json",formatOf3DObjects:"3D_glb",where:`OBJECTID IN (${s.join(",")})`,outFields:`${t}`}});if(a&&a.data&&a.data.assetMaps&&(0,p.pC)(m)){const e=a.data.assetMaps;for(const t of e){const e=m.get(t.parentGlobalId).geometry;(0,p.pC)(e)&&"mesh"===e.type&&e.updateExternalSource({source:[{name:t.assetName,source:t.assetName}],extent:e.extent})}}}return this._createEditsResult(F)}async deleteAttachments(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/deleteAttachments";try{return(await(0,n.default)(r,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(this._createFeatureEditResult)}catch(e){throw this._createAttachmentErrorResult(s,e)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:r}=this.layer,{data:a}=await(0,n.default)(`${r}/${s}`,t),{id:o,extent:u,fullExtent:l,timeExtent:d}=a,c=u||l;return{id:o,fullExtent:c&&_.Z.fromJSON(c),timeExtent:d&&i.Z.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(!(0,C.M8)(this.layer.url))return"unavailable";const e=(0,f.v_)(this.layer.url,"status"),t=await(0,n.default)(e,{query:{f:"json"}});return T.fromJSON(t.data.status)}_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(0,n.default)(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:(0,l.Z)("featurelayer-advanced-symbols")?{returnAdvancedSymbols:!0}:{},signal:t}));e=s}this.sourceJSON=this._patchServiceJSON(e);const s=e.type;if(!x.has(s))throw new u.Z("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=(0,R.bU)(e.geometryType).renderer;(0,h.RB)("drawingInfo.renderer",t,e)}return"esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),e}_serializeFeature(e,t){const{geometry:s,attributes:r}=e;if((0,p.pC)(t)&&(0,p.pC)(e.geometry)&&"mesh"===e.geometry.type){const s={...r},a=e.geometry,o=a.origin,n=a.transform;if(s[t.transformFieldRoles.originX]=o.x,s[t.transformFieldRoles.originY]=o.y,s[t.transformFieldRoles.originZ]=o.z,(0,p.pC)(n)){const e=n.translation,r=n.scale,a=n.rotation;s[t.transformFieldRoles.translationX]=e[0],s[t.transformFieldRoles.translationY]=-e[2],s[t.transformFieldRoles.translationZ]=e[1],s[t.transformFieldRoles.scaleX]=r[0],s[t.transformFieldRoles.scaleY]=r[1],s[t.transformFieldRoles.scaleZ]=r[2],s[t.transformFieldRoles.rotationX]=a[0],s[t.transformFieldRoles.rotationY]=a[2],s[t.transformFieldRoles.rotationZ]=a[1],s[t.transformFieldRoles.rotationDeg]=a[3]}return{geometry:null,attributes:s}}return(0,p.Wi)(s)?{attributes:r}:"mesh"===s.type||"extent"===s.type?null:{geometry:s.toJSON(),attributes:r}}async _serializeAttachment(e){const{feature:t,attachment:s}=e,{globalId:r,name:a,contentType:o,data:n,uploadId:i}=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),i)u.uploadId=i;else if(n){const e=await w(n);e&&(u.contentType=e.mediaType,u.data=e.data),n instanceof File&&(u.name=n.name)}return a&&(u.name=a),o&&(u.contentType=o),u}async _serializeAssetMapEditAndUploadAssets(e,t){const s=this.layer.url;let r=null;try{const t=new Blob([e.data],{type:e.mimeType}),a=new FormData;a.append("f","json"),a.append("file",t,`${e.assetName}`);const o={body:a,method:"post",responseType:"json"},{data:i}=await(0,n.default)(`${s}/uploads/upload`,o);if(!i.success)throw new u.Z("feature-layer-source:upload-failure","Expected upload to be successfull.");r={assetType:e.assetType,assetUploadId:i.item.itemID}}catch(e){r=null}if((0,p.Wi)(r)){const t=await w(new Blob([e.data]));if(!t.isBase64)throw new u.Z("feature-layer-source:uploadAssets-failure","Expected gltf data in base64 format after conversion.");r={assetType:e.assetType,assetData:t.data}}if((0,p.Wi)(r))throw new u.Z("feature-layer-source:uploadAssets-failure","Unable to prepare uploadAsset request options.");const a={method:"post",query:{f:"json",assets:JSON.stringify([r])},responseType:"json"},o=await(0,n.default)((0,f.v_)(this.layer.parsedUrl.path,"uploadAssets"),a);if(1!==o.data.uploadResults.length||!o.data.uploadResults[0].success)throw new u.Z("feature-layer-source:uploadAssets-failure","Bad response.");const i=o.data.uploadResults[0].assetHash,l=[];e.flags&F.i.PROJECT_VERTICES&&l.push("PROJECT_VERTICES");const d={globalId:e.assetMapGlobalId,parentGlobalId:e.featureGlobalId,assetName:e.assetName,assetHash:i,flags:l};return t.set(e.featureGlobalId,e.feature),d}_getFeatureIds(e,t){const s=e?.[0];return s?this._canUseGlobalIds(t,e)?this._getGlobalIdsFromFeatureIdentifier(e):"objectId"in s?this._getObjectIdsFromFeatureIdentifier(e):this._getIdsFromFeatures(e):[]}_getIdsFromFeatures(e){const t=this.layer.objectIdField;return e.map((e=>e.attributes&&e.attributes[t]))}_canUseGlobalIds(e,t){return e&&"globalId"in t[0]}_getObjectIdsFromFeatureIdentifier(e){return e.map((e=>e.objectId))}_getGlobalIdsFromFeatureIdentifier(e){return e.map((e=>e.globalId))}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,r=[];let a=null;if(Array.isArray(t))for(const e of t)r.push({id:e.id,editedFeatures:e.editedFeatures}),e.id===s&&(a={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment});else a=t;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 q.Z(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,t){return new a.Z({attributes:e.attributes,geometry:(0,b.im)({...e.geometry,spatialReference:t})})}_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 u.Z("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 u.Z("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 e in t){const r=t[e];null!=r&&(s.set?s.set(e,r):s.append(e,r))}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"}}};(0,r._)([(0,m.Cb)()],A.prototype,"type",void 0),(0,r._)([(0,m.Cb)({constructOnly:!0})],A.prototype,"layer",void 0),(0,r._)([(0,m.Cb)({readOnly:!0})],A.prototype,"queryTask",null),A=(0,r._)([(0,g.j)("esri.layers.graphics.sources.FeatureLayerSource")],A);const E=A},74654:(e,t,s)=>{s.d(t,{Z:()=>E});var r=s(43697),a=s(15923),o=s(20102),n=s(80442),i=s(70586),u=s(95330),l=s(17452),d=s(5600),c=(s(75215),s(67676),s(52011)),p=s(10158),h=s(11282),y=s(41818),f=(s(66577),s(34599)),m=s(14165),g=s(6570),_=s(5396),b=s(4967),F=s(69285),R=s(98732);function S(e,t){return t}function C(e,t,s,r){switch(s){case 0:return w(e,t+r,0);case 1:return"lowerLeft"===e.originPosition?w(e,t+r,1):function({translate:e,scale:t},s,r){return e[r]-s*t[r]}(e,t+r,1)}}function I(e,t,s,r){return 2===s?w(e,t,2):C(e,t,s,r)}function q(e,t,s,r){return 2===s?w(e,t,3):C(e,t,s,r)}function O(e,t,s,r){return 3===s?w(e,t,3):I(e,t,s,r)}function w({translate:e,scale:t},s,r){return e[r]+s*t[r]}class x{constructor(e){this._options=e,this.geometryTypes=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"],this._previousCoordinate=[0,0],this._transform=null,this._applyTransform=S,this._lengths=[],this._currentLengthIndex=0,this._toAddInCurrentPath=0,this._vertexDimension=0,this._coordinateBuffer=null,this._coordinateBufferPtr=0,this._attributesConstructor=class{}}createFeatureResult(){return{fields:[],features:[]}}finishFeatureResult(e){if(this._options.applyTransform&&(e.transform=null),this._attributesConstructor=class{},this._coordinateBuffer=null,this._lengths.length=0,!e.hasZ)return;const t=(0,F.k)(e.geometryType,this._options.sourceSpatialReference,e.spatialReference);if(!(0,i.Wi)(t))for(const s of e.features)t(s.geometry)}createSpatialReference(){return{}}addField(e,t){const s=e.fields;(0,i.O3)(s),s.push(t);const r=s.map((e=>e.name));this._attributesConstructor=function(){for(const e of r)this[e]=null}}addFeature(e,t){e.features.push(t)}prepareFeatures(e){switch(this._transform=e.transform,this._options.applyTransform&&e.transform&&(this._applyTransform=this._deriveApplyTransform(e)),this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++,e.geometryType){case"esriGeometryPoint":this.addCoordinate=(e,t,s)=>this.addCoordinatePoint(e,t,s),this.createGeometry=e=>this.createPointGeometry(e);break;case"esriGeometryPolygon":this.addCoordinate=(e,t,s)=>this._addCoordinatePolygon(e,t,s),this.createGeometry=e=>this._createPolygonGeometry(e);break;case"esriGeometryPolyline":this.addCoordinate=(e,t,s)=>this._addCoordinatePolyline(e,t,s),this.createGeometry=e=>this._createPolylineGeometry(e);break;case"esriGeometryMultipoint":this.addCoordinate=(e,t,s)=>this._addCoordinateMultipoint(e,t,s),this.createGeometry=e=>this._createMultipointGeometry(e)}}createFeature(){return this._lengths.length=0,this._currentLengthIndex=0,this._previousCoordinate[0]=0,this._previousCoordinate[1]=0,this._coordinateBuffer=null,this._coordinateBufferPtr=0,{attributes:new this._attributesConstructor}}allocateCoordinates(){}addLength(e,t,s){0===this._lengths.length&&(this._toAddInCurrentPath=t),this._lengths.push(t)}addQueryGeometry(e,t){const{queryGeometry:s,queryGeometryType:r}=t,a=(0,R.$g)(s.clone(),s,!1,!1,this._transform),o=(0,R.di)(a,r,!1,!1);e.queryGeometryType=r,e.queryGeometry={...o}}createPointGeometry(e){const t={x:0,y:0,spatialReference:e.spatialReference};return e.hasZ&&(t.z=0),e.hasM&&(t.m=0),t}addCoordinatePoint(e,t,s){const r=(0,i.s3)(this._transform,"transform");switch(t=this._applyTransform(r,t,s,0),s){case 0:e.x=t;break;case 1:e.y=t;break;case 2:"z"in e?e.z=t:e.m=t;break;case 3:e.m=t}}_transformPathLikeValue(e,t){let s=0;t<=1&&(s=this._previousCoordinate[t],this._previousCoordinate[t]+=e);const r=(0,i.s3)(this._transform,"transform");return this._applyTransform(r,e,t,s)}_addCoordinatePolyline(e,t,s){this._dehydratedAddPointsCoordinate(e.paths,t,s)}_addCoordinatePolygon(e,t,s){this._dehydratedAddPointsCoordinate(e.rings,t,s)}_addCoordinateMultipoint(e,t,s){0===s&&e.points.push([]);const r=this._transformPathLikeValue(t,s);e.points[e.points.length-1].push(r)}_createPolygonGeometry(e){return{rings:[[]],spatialReference:e.spatialReference,hasZ:!!e.hasZ,hasM:!!e.hasM}}_createPolylineGeometry(e){return{paths:[[]],spatialReference:e.spatialReference,hasZ:!!e.hasZ,hasM:!!e.hasM}}_createMultipointGeometry(e){return{points:[],spatialReference:e.spatialReference,hasZ:!!e.hasZ,hasM:!!e.hasM}}_dehydratedAddPointsCoordinate(e,t,s){0===s&&0==this._toAddInCurrentPath--&&(e.push([]),this._toAddInCurrentPath=this._lengths[++this._currentLengthIndex]-1,this._previousCoordinate[0]=0,this._previousCoordinate[1]=0);const r=this._transformPathLikeValue(t,s),a=e[e.length-1];0===s&&(this._coordinateBufferPtr=0,this._coordinateBuffer=new Array(this._vertexDimension),a.push(this._coordinateBuffer)),this._coordinateBuffer[this._coordinateBufferPtr++]=r}_deriveApplyTransform(e){const{hasZ:t,hasM:s}=e;return t&&s?O:t?I:s?q:C}}var T=s(74889);let A=class extends a.Z{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.queryAttachmentsSupported=!1,this.sourceSpatialReference=null,this.url=null}get parsedUrl(){return(0,l.mN)(this.url)}async execute(e,t){const s=await this.executeJSON(e,t);return this.featureSetFromJSON(e,s,t)}async executeJSON(e,t){const s=this._normalizeQuery(e),r=null!=e.outStatistics?.[0],a=(0,n.Z)("featurelayer-pbf-statistics"),o=!r||a;let i;if(this.pbfSupported&&o)try{i=await async function(e,t,s){const r=(0,h.en)(e),a={...s},o=m.Z.from(t),n=!o.quantizationParameters,{data:i}=await(0,f.qp)(r,o,new x({sourceSpatialReference:o.sourceSpatialReference,applyTransform:n}),a);return i}(this.url,s,t)}catch(e){if("query:parsing-pbf"!==e.name)throw e;this.pbfSupported=!1}return this.pbfSupported&&o||(i=await(0,b.F)(this.url,s,t)),this._normalizeFields(i.fields),i}async featureSetFromJSON(e,t,r){if(!this._queryIs3DObjectFormat(e)||(0,i.Wi)(this.infoFor3D)||!t.assetMaps||!t.features||!t.features.length)return T.Z.fromJSON(t);const{meshFeatureSetFromJSON:a}=await(0,u.Hl)(Promise.all([s.e(6481),s.e(6459),s.e(1932)]).then(s.bind(s,21932)),r);return a(e,this.infoFor3D,t)}executeForCount(e,t){return(0,y.P)(this.url,this._normalizeQuery(e),t)}executeForExtent(e,t){return async function(e,t,s){const r=(0,h.en)(e);return(0,f.Vr)(r,m.Z.from(t),{...s}).then((e=>({count:e.data.count,extent:g.Z.fromJSON(e.data.extent)})))}(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return(0,_.G)(this.url,this._normalizeQuery(e),t)}async executeRelationshipQuery(e,t){const[{default:r},{executeRelationshipQuery:a}]=await(0,u.Hl)(Promise.all([s.e(5935).then(s.bind(s,75935)),s.e(1073).then(s.bind(s,81073))]),t);return e=r.from(e),(this.gdbVersion||this.dynamicDataSource)&&((e=e.clone()).gdbVersion=e.gdbVersion||this.gdbVersion,e.dynamicDataSource=e.dynamicDataSource||this.dynamicDataSource),a(this.url,e,t)}async executeRelationshipQueryForCount(e,t){const[{default:r},{executeRelationshipQueryForCount:a}]=await(0,u.Hl)(Promise.all([s.e(5935).then(s.bind(s,75935)),s.e(1073).then(s.bind(s,81073))]),t);return e=r.from(e),(this.gdbVersion||this.dynamicDataSource)&&((e=e.clone()).gdbVersion=e.gdbVersion||this.gdbVersion,e.dynamicDataSource=e.dynamicDataSource||this.dynamicDataSource),a(this.url,e,t)}async executeAttachmentQuery(e,t){const{executeAttachmentQuery:r,fetchAttachments:a,processAttachmentQueryResult:o}=await(0,u.Hl)(s.e(540).then(s.bind(s,30540)),t),n=(0,h.en)(this.url);return o(n,await(this.queryAttachmentsSupported?r(n,e,t):a(n,e,t)))}async executeTopFeaturesQuery(e,t){const{executeTopFeaturesQuery:r}=await(0,u.Hl)(s.e(1158).then(s.bind(s,71158)),t);return r(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){const{executeForTopIds:r}=await(0,u.Hl)(s.e(3992).then(s.bind(s,33992)),t);return r(this.parsedUrl,e,t)}async executeForTopExtents(e,t){const{executeForTopExtents:r}=await(0,u.Hl)(s.e(1790).then(s.bind(s,21790)),t);return r(this.parsedUrl,e,t)}async executeForTopCount(e,t){const{executeForTopCount:r}=await(0,u.Hl)(s.e(4371).then(s.bind(s,14371)),t);return r(this.parsedUrl,e,t)}_normalizeQuery(e){let t=m.Z.from(e);if(t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource?p.n.from(e.dynamicDataSource):this.dynamicDataSource),(0,i.pC)(this.infoFor3D)&&this._queryIs3DObjectFormat(e)){t=t===e?t.clone():t,t.formatOf3DObjects=null;for(const e of this.infoFor3D.queryFormats){if("3D_glb"===e){t.formatOf3DObjects=e;break}"3D_gltf"!==e||t.formatOf3DObjects||(t.formatOf3DObjects=e)}if(!t.formatOf3DObjects)throw new o.Z("query:unsupported-3d-query-formats","Could not find any supported 3D object query format. Only supported formats are 3D_glb and 3D_gltf");if((0,i.Wi)(t.outFields)||!t.outFields.includes("*")){t=t===e?t.clone():t,(0,i.Wi)(t.outFields)&&(t.outFields=[]);const{originX:s,originY:r,originZ:a,translationX:o,translationY:n,translationZ:u,scaleX:l,scaleY:d,scaleZ:c,rotationX:p,rotationY:h,rotationZ:y,rotationDeg:f}=this.infoFor3D.transformFieldRoles;t.outFields.push(s,r,a,o,n,u,l,d,c,p,h,y,f)}}return t}_normalizeFields(e){if((0,i.pC)(this.fieldsIndex)&&(0,i.pC)(e))for(const t of e){const e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryIs3DObjectFormat(e){return(0,i.pC)(this.infoFor3D)&&!0===e.returnGeometry&&"xyFootprint"!==e.multipatchOption&&!e.outStatistics}};(0,r._)([(0,d.Cb)({type:p.n})],A.prototype,"dynamicDataSource",void 0),(0,r._)([(0,d.Cb)()],A.prototype,"fieldsIndex",void 0),(0,r._)([(0,d.Cb)()],A.prototype,"gdbVersion",void 0),(0,r._)([(0,d.Cb)()],A.prototype,"infoFor3D",void 0),(0,r._)([(0,d.Cb)({readOnly:!0})],A.prototype,"parsedUrl",null),(0,r._)([(0,d.Cb)()],A.prototype,"pbfSupported",void 0),(0,r._)([(0,d.Cb)()],A.prototype,"queryAttachmentsSupported",void 0),(0,r._)([(0,d.Cb)()],A.prototype,"sourceSpatialReference",void 0),(0,r._)([(0,d.Cb)({type:String})],A.prototype,"url",void 0),A=(0,r._)([(0,c.j)("esri.tasks.QueryTask")],A);const E=A},25278:(e,t,s)=>{s.d(t,{Dm:()=>d,Hq:()=>c,MS:()=>p,bU:()=>i});var r=s(80442),a=s(22974),o=s(61159),n=s(58333);function i(e){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===e||"esriGeometryMultipoint"===e?n.I4:"esriGeometryPolyline"===e?n.ET:n.lF}}}const u=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let l=1;function d(e,t){if((0,r.Z)("esri-csp-restrictions"))return()=>({[t]:null,...e});try{let s=`this.${t} = null;`;for(const t in e)s+=`this${u.test(t)?`.${t}`:`["${t}"]`} = ${JSON.stringify(e[t])};`;const r=new Function(`\n return class AttributesClass$${l++} {\n constructor() {\n ${s};\n }\n }\n `)();return()=>new r}catch(s){return()=>({[t]:null,...e})}}function c(e={}){return[{name:"New Feature",description:"",prototype:{attributes:(0,a.d9)(e)}}]}function p(e,t){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:t,supportsDelete:t,supportsEditing:t,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:t,supportsExceedsLimitStatistics:!0},query:o.g,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsGeometryUpdate:t,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1}}}},41818:(e,t,s)=>{s.d(t,{P:()=>n});var r=s(11282),a=s(34599),o=s(14165);async function n(e,t,s){const n=(0,r.en)(e);return(0,a.hH)(n,o.Z.from(t),{...s}).then((e=>e.data.count))}},5396:(e,t,s)=>{s.d(t,{G:()=>n});var r=s(11282),a=s(34599),o=s(14165);async function n(e,t,s){const n=(0,r.en)(e);return(0,a.Ev)(n,o.Z.from(t),{...s}).then((e=>e.data.objectIds))}},4967:(e,t,s)=>{s.d(t,{F:()=>u,e:()=>i});var r=s(11282),a=s(34599),o=s(74889),n=s(14165);async function i(e,t,s){const r=await u(e,t,s);return o.Z.fromJSON(r)}async function u(e,t,s){const o=(0,r.en)(e),i={...s},u=n.Z.from(t),{data:l}=await(0,a.JT)(o,u,u.sourceSpatialReference,i);return l}}}]);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";import{OverlayIndex as a,RenderTargetType as i}from"../views/3d/terrain/interfaces.js";import{IntegratedMeshMode as l}from"../views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js";import{ComponentData as t,ComponentDataType as d}from"../views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js";import{VertexDiscardByOpacity as n}from"../views/3d/webgl-engine/collections/Component/Material/shader/VertexDiscardByOpacity.glsl.js";import{ForwardLinearDepth as s}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SlicePass as m}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{NormalAttributeType as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as v}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as u}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VertexNormal as h}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js";import{VertexPosition as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js";import{OutputDepth as C}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as w}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{ReadLinearDepth as b}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadLinearDepth.glsl.js";import{ComputeMaterialColor as y}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import{ComputeNormalTexture as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import{ComputeShadingNormal as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import{EvaluateSceneLighting as L,addLightingGlobalFactor as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightIntensity as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as T}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PBRMode as
|
|
5
|
+
import{earth as e,mars as o,moon as r}from"../geometry/support/Ellipsoid.js";import{OverlayIndex as a,RenderTargetType as i}from"../views/3d/terrain/interfaces.js";import{IntegratedMeshMode as l}from"../views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js";import{ComponentData as t,ComponentDataType as d}from"../views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js";import{VertexDiscardByOpacity as n}from"../views/3d/webgl-engine/collections/Component/Material/shader/VertexDiscardByOpacity.glsl.js";import{ForwardLinearDepth as s}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as c}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SlicePass as m}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{NormalAttributeType as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as v}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexColor as u}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js";import{VertexNormal as h}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js";import{VertexPosition as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js";import{OutputDepth as C}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as w}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{ReadLinearDepth as b}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadLinearDepth.glsl.js";import{ComputeMaterialColor as y}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import{ComputeNormalTexture as x}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import{ComputeShadingNormal as f}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js";import{EvaluateSceneLighting as L,addLightingGlobalFactor as M}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightIntensity as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{multipassTerrainTest as T}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{PBRMode as O,PhysicallyBasedRenderingParameters as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadBaseColorTexture as N}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import{ReadShadowMapPass as W}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{OverlayIM as A,getColorTexture as P}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{symbolAlphaCutoff as B}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{DiscardOrAdjustAlphaDraw as R}from"../views/3d/webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js";import{EllipsoidMode as _}from"../views/3d/webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{glsl as D}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{ShaderBuilder as $}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as z}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{TransparencyPassType as F}from"../views/3d/webgl-engine/lib/TransparencyPassType.js";function E(a){const i=new $;i.include(p,a),i.include(h,a),i.include(u,a),i.include(v,a),i.include(s,a),i.include(t,a),i.include(R,a),i.include(m,a),i.include(N,a),i.include(n,a);const{vertex:E,fragment:I}=i;a.pbrMode!==O.Normal&&a.pbrMode!==O.Schematic||(i.include(S,a),a.hasNormalTexture&&i.include(x,a));const G=a.output===c.Shadow||a.output===c.ShadowHighlight||a.output===c.ShadowExcludeHighlight;G&&a.componentData===d.Varying?E.code.add(D`#define discardShadows(castShadows) { if(!castShadows) { gl_Position = vec4(1e38, 1e38, 1e38, 1.0); return; } }`):E.code.add(D`#define discardShadows(castShadows) {}`);const H=a.integratedMeshMode===l.ColorOverlay||a.integratedMeshMode===l.ColorOverlayWithWater,k=H&&a.output===c.Color&&a.pbrMode===O.WaterOnIntegratedMesh;return H&&(i.include(L,a),i.include(A,a),a.spherical?E.code.add(D`
|
|
6
6
|
const float invEllipsoidRadius = ${D.float(1/(a.ellipsoidMode===_.Earth?e.radius:a.ellipsoidMode===_.Mars?o.radius:r.radius))};
|
|
7
7
|
vec2 projectOverlay(vec3 pos) {
|
|
8
8
|
return pos.xy / (1.0 + invEllipsoidRadius * pos.z);
|
|
9
9
|
}
|
|
10
|
-
`):
|
|
10
|
+
`):E.code.add(D`vec2 projectOverlay(vec3 pos) { return pos.xy; }`)),k&&(i.varyings.add("tbnTangent","vec3"),i.varyings.add("tbnBiTangent","vec3"),i.varyings.add("groundNormal","vec3")),E.code.add(D`
|
|
11
11
|
void main() {
|
|
12
12
|
bool castShadows;
|
|
13
13
|
vec4 externalColor = forwardExternalColor(castShadows);
|
|
@@ -81,8 +81,8 @@ return readShadowMap(vPositionWorldCameraRelative, linearDepth);
|
|
|
81
81
|
externalColorMixMode
|
|
82
82
|
);
|
|
83
83
|
${H?D`vec4 overlayColor = getOverlayColor(ovColorTex, vtcOverlay);`:""}
|
|
84
|
-
`),a.pbrMode===
|
|
85
|
-
${a.pbrMode===
|
|
84
|
+
`),a.pbrMode===O.Normal||a.pbrMode===O.Schematic?(j(I),I.code.add(D`
|
|
85
|
+
${a.pbrMode===O.Normal?D`
|
|
86
86
|
applyPBRFactors();
|
|
87
87
|
if (int(externalColorMixMode) == 3) {
|
|
88
88
|
mrr = vec3(0.0, 0.6, 0.2);
|
|
@@ -131,7 +131,7 @@ materialColor.rgb = mix(materialColor.rgb, vec3(1), snow);`)),I.code.add(D`
|
|
|
131
131
|
}`:""}
|
|
132
132
|
`)),I.code.add(D`
|
|
133
133
|
gl_FragColor = highlightSlice(shadedColor, vPositionWorldCameraRelative);
|
|
134
|
-
${a.transparencyPassType===
|
|
134
|
+
${a.transparencyPassType===F.Color?"gl_FragColor = premultiplyAlpha(gl_FragColor);":""}
|
|
135
135
|
}
|
|
136
136
|
`)),(a.output===c.Depth||G)&&(i.include(C,a),I.code.add(D`void main() {
|
|
137
137
|
discardBySlice(vPositionWorldCameraRelative);
|
|
@@ -150,12 +150,16 @@ outputDepth(linearDepth);
|
|
|
150
150
|
float alpha = ${a.normalType===g.Ground?"0.0":"1.0"};
|
|
151
151
|
gl_FragColor = vec4(vec3(.5) + .5 * shadingNormal_view(), alpha);
|
|
152
152
|
}
|
|
153
|
-
`)),a.output===c.ObjectAndLayerIdColor&&i.fragment.code.add(D`
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
`)),a.output===c.ObjectAndLayerIdColor&&i.fragment.code.add(D`
|
|
154
|
+
void main() {
|
|
155
|
+
discardBySlice(vPositionWorldCameraRelative);
|
|
156
|
+
|
|
157
|
+
vec4 textureColor = readBaseColorTexture();
|
|
158
|
+
discardOrAdjustAlpha(textureColor);
|
|
159
|
+
|
|
160
|
+
${H?D`gl_FragColor = getOverlayColorTexel(vtcOverlay);`:"outputObjectAndLayerIdColor();"}
|
|
161
|
+
}
|
|
162
|
+
`),a.output===c.Highlight&&(i.include(w,a),I.code.add(D`
|
|
159
163
|
void main() {
|
|
160
164
|
discardBySlice(vPositionWorldCameraRelative);
|
|
161
165
|
|
|
@@ -171,4 +175,4 @@ outputObjectAndLayerIdColor();
|
|
|
171
175
|
|
|
172
176
|
outputHighlight();
|
|
173
177
|
}
|
|
174
|
-
`)),i}function V(e){return 0===e.overlays.length?null:e.overlays[a.INNER].getValidTexture(i.Water)}const I=Object.freeze(Object.defineProperty({__proto__:null,build:
|
|
178
|
+
`)),i}function V(e){return 0===e.overlays.length?null:e.overlays[a.INNER].getValidTexture(i.Water)}const I=Object.freeze(Object.defineProperty({__proto__:null,build:E,getOverlayNormalTexture:V},Symbol.toStringTag,{value:"Module"}));export{I as C,E as b,V as g};
|
package/chunks/Terrain.glsl.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{w as e}from"./mat4.js";import{c as r}from"./mat4f64.js";import{n as o,s as
|
|
5
|
+
import{w as e}from"./mat4.js";import{c as r}from"./mat4f64.js";import{n as o,s as a}from"./vec3.js";import{c as i}from"./vec3f64.js";import{OverlayIndex as l}from"../views/3d/terrain/interfaces.js";import{addLinearDepth as t,addNearFar as n,ForwardLinearDepth as s}from"../views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js";import{ShaderOutput as d}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SliceDraw as c}from"../views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js";import{Transform as v}from"../views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js";import{NormalAttribute as m}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{PositionAttribute as g}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js";import{TextureCoordinateAttribute as p}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexTangent as h}from"../views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTangent.glsl.js";import{OutputDepth as w}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js";import{OutputHighlight as u}from"../views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{EvaluateAmbientOcclusion as b}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import{EvaluateSceneLighting as f,addAmbientBoostFactor as y,addLightingGlobalFactor as C}from"../views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import{addMainLightDirection as x,addMainLightIntensity as L}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{NormalUtils as O}from"../views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js";import{PBRMode as S}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{ReadShadowMapDraw as j}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{OverlayMode as z}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{OverlayTerrainPassParameters as T,OverlayTerrain as _,TerrainTexture as F}from"../views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js";import{addProjViewLocalOrigin as P,addViewNormal as M,addCameraPosition as N}from"../views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js";import{Float3PassUniform as D}from"../views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js";import{glsl as $}from"../views/3d/webgl-engine/core/shaderModules/interfaces.js";import{Matrix4DrawUniform as W}from"../views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js";import{ShaderBuilder as U}from"../views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js";import{Texture2DPassUniform as V}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";class A extends T{}function k(r){const i=new U,{vertex:T,fragment:A,varyings:k}=i;i.include(g),i.include(m,r),i.include(p,r);const G=()=>{i.include(O,r),T.code.add($`
|
|
6
6
|
vec3 decodeNormalTerrain(vec2 e) {
|
|
7
7
|
float z = 1.0 - abs(e.x) - abs(e.y);
|
|
8
8
|
vec3 n = vec3(e + vec2(e.x >= 0.0 ? 1.0 : -1.0, e.y >= 0.0 ? 1.0 : -1.0) * min(z,0.0),z);
|
|
@@ -10,9 +10,9 @@ import{w as e}from"./mat4.js";import{c as r}from"./mat4f64.js";import{n as o,s a
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
vec3 getNormal() {
|
|
13
|
-
return ${r.shading
|
|
13
|
+
return ${r.shading?$`decodeNormalTerrain(normalCompressed)`:$`getLocalUp(position, localOrigin)`};
|
|
14
14
|
}
|
|
15
|
-
`)};P(
|
|
15
|
+
`)};P(T,r),i.include(v,r);const H=r.overlayMode!==z.Disabled;switch(r.output){case d.Color:{i.include(F,r),i.include(f,r),H&&i.include(_,{...r,pbrMode:r.pbrMode===S.Terrain?S.TerrainWithWater:S.Water});const t=r.overlayMode===z.EnabledWithWater;t&&i.include(h,r),k.add("vnormal","vec3"),k.add("vpos","vec3"),k.add("vup","vec3"),G(),(r.atmosphere||r.screenSizePerspective)&&M(T);const n=r.receiveShadows&&!r.renderOccluded;n&&i.include(s,r),r.atmosphere&&k.add("wnormal","vec3"),r.screenSizePerspective&&(k.add("screenSizeDistanceToCamera","float"),k.add("screenSizeCosAngle","float")),T.code.add($`
|
|
16
16
|
void main(void) {
|
|
17
17
|
//Position
|
|
18
18
|
vpos = position;
|
|
@@ -25,29 +25,29 @@ import{w as e}from"./mat4.js";import{c as r}from"./mat4f64.js";import{n as o,s a
|
|
|
25
25
|
//Up
|
|
26
26
|
vup = getLocalUp(position, localOrigin);
|
|
27
27
|
|
|
28
|
-
${t
|
|
28
|
+
${t?$`forwardVertexTangent(vnormal);`:$``}
|
|
29
29
|
|
|
30
|
-
${r.atmosphere
|
|
30
|
+
${r.atmosphere?$`wnormal = normalize((viewNormal * vec4(normalize(positionWorld), 1.0)).xyz);`:""}
|
|
31
31
|
|
|
32
32
|
//Texture UV
|
|
33
33
|
vec2 uv = getUV0();
|
|
34
34
|
forwardTextureCoordinatesWithTransform(uv);
|
|
35
|
-
${
|
|
36
|
-
${r.tileBorders
|
|
35
|
+
${H?$`setOverlayVTC(uv);`:""}
|
|
36
|
+
${r.tileBorders?$`forwardTextureCoordinates();`:""}
|
|
37
37
|
|
|
38
|
-
${r.screenSizePerspective
|
|
38
|
+
${r.screenSizePerspective?$`
|
|
39
39
|
vec3 viewPos = (view * vec4(vpos, 1.0)).xyz;
|
|
40
40
|
screenSizeDistanceToCamera = length(viewPos);
|
|
41
41
|
vec3 viewSpaceNormal = (viewNormal * vec4(normalize(positionWorld), 1.0)).xyz;
|
|
42
42
|
screenSizeCosAngle = abs(viewSpaceNormal.z);`:""}
|
|
43
43
|
|
|
44
|
-
${n
|
|
44
|
+
${n?$`forwardLinearDepth();`:""}
|
|
45
45
|
|
|
46
46
|
}
|
|
47
|
-
`),
|
|
47
|
+
`),i.extensions.add("GL_OES_standard_derivatives"),i.extensions.add("GL_EXT_shader_texture_lod"),i.include(c,r),i.include(f,r),i.include(b,r),i.include(j,r),N(A,r),y(A),C(A),A.uniforms.add([T.uniforms.get("localOrigin"),new D("viewDirection",((e,r)=>o(E,a(E,r.camera.viewMatrix[12],r.camera.viewMatrix[13],r.camera.viewMatrix[14]))))]),t&&A.uniforms.add([new V("ovWaterTex",((e,r)=>0===r.overlays.length?null:r.overlays[l.INNER].getNormalTexture(e.overlaySource))),new W("view",((r,o)=>e(B,o.camera.viewMatrix,r.origin)))]),A.code.add($`const float sliceOpacity = 0.2;
|
|
48
48
|
float lum(vec3 c) {
|
|
49
49
|
return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
50
|
-
}`),x(
|
|
50
|
+
}`),x(A),L(A),A.code.add($`
|
|
51
51
|
void main() {
|
|
52
52
|
vec3 normal = normalize(vnormal);
|
|
53
53
|
float vndl = dot(normal, mainLightDirection);
|
|
@@ -58,10 +58,10 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
58
58
|
float ssao = evaluateAmbientOcclusionInverse();
|
|
59
59
|
vec4 tileColor = getTileColor();
|
|
60
60
|
|
|
61
|
-
${
|
|
61
|
+
${H?$`
|
|
62
62
|
vec4 overlayColorOpaque = getOverlayColor(ovColorTex, vtcOverlay);
|
|
63
63
|
vec4 overlayColor = overlayOpacity * overlayColorOpaque;
|
|
64
|
-
${r.invisible
|
|
64
|
+
${r.invisible?$`if (overlayColor.a == 0.0) { discard; }`:""}
|
|
65
65
|
vec4 groundColor = tileColor;
|
|
66
66
|
tileColor = tileColor * (1.0 - overlayColor.a) + overlayColor;`:""}
|
|
67
67
|
|
|
@@ -75,21 +75,21 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
75
75
|
if (sliced) {
|
|
76
76
|
tileColor *= sliceOpacity;
|
|
77
77
|
}
|
|
78
|
-
${r.atmosphere
|
|
78
|
+
${r.atmosphere?$`
|
|
79
79
|
float ndotl = clamp(vndl, 0.0, 1.0);
|
|
80
80
|
vec3 atm = vec3(clamp(1.0 - dot(-viewDirection, wnormal), 0.0, 1.0));
|
|
81
81
|
atm *= clamp(1.0 - lum(tileColor.rgb) * 1.5, 0.0, 1.0); // avoid atmosphere on bright base maps
|
|
82
82
|
atm *= clamp(ndotl * 2.0, 0.0, 1.0); // avoid atmosphere on dark side of the globe
|
|
83
83
|
atm *= tileColor.a; // premultiply with tile alpha`:""}
|
|
84
84
|
|
|
85
|
-
vec3 albedo = ${r.atmosphere
|
|
85
|
+
vec3 albedo = ${r.atmosphere?$`atm + tileColor.rgb;`:$`tileColor.rgb;`}
|
|
86
86
|
|
|
87
87
|
// heuristic shading function used in the old terrain, now used to add ambient lighting
|
|
88
88
|
|
|
89
89
|
vec3 additionalLight = ssao * mainLightIntensity * additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor;
|
|
90
90
|
|
|
91
|
-
${r.pbrMode===S.Terrain||r.pbrMode===S.TerrainWithWater
|
|
92
|
-
${t
|
|
91
|
+
${r.pbrMode===S.Terrain||r.pbrMode===S.TerrainWithWater?$`gl_FragColor = vec4(evaluateTerrainLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight, normalize(vpos - cameraPosition), vup), tileColor.a);`:$`gl_FragColor = vec4(evaluateSceneLighting(normal, albedo, shadow, 1.0 - ssao, additionalLight), tileColor.a);`}
|
|
92
|
+
${t?$`
|
|
93
93
|
vec4 overlayWaterMask = getOverlayColor(ovWaterTex, vtcOverlay);
|
|
94
94
|
float waterNormalLength = length(overlayWaterMask);
|
|
95
95
|
if (waterNormalLength > 0.95) {
|
|
@@ -102,7 +102,7 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
102
102
|
// un-gamma the ground color to mix in linear space
|
|
103
103
|
gl_FragColor = mix(groundColor, waterColorNonLinear, waterColorLinear.w) * opacity;
|
|
104
104
|
}`:""}
|
|
105
|
-
${r.screenSizePerspective
|
|
105
|
+
${r.screenSizePerspective?$`
|
|
106
106
|
float perspectiveScale = screenSizePerspectiveScaleFloat(1.0, screenSizeCosAngle, screenSizeDistanceToCamera, vec4(0.0, 0.0, 0.0, 0.0));
|
|
107
107
|
if (perspectiveScale <= 0.25) {
|
|
108
108
|
gl_FragColor = mix(gl_FragColor, vec4(1.0, 0.0, 0.0, 1.0), perspectiveScale * 4.0);
|
|
@@ -116,69 +116,66 @@ return (min(min(c.r, c.g), c.b) + max(max(c.r, c.g), c.b)) * 0.5;
|
|
|
116
116
|
else {
|
|
117
117
|
gl_FragColor = mix(gl_FragColor, vec4(1.0, 0.0, 1.0, 1.0), (perspectiveScale - 0.5) * 2.0);
|
|
118
118
|
}`:""}
|
|
119
|
-
${r.visualizeNormals?r.spherical
|
|
119
|
+
${r.visualizeNormals?r.spherical?$`
|
|
120
120
|
vec3 localUp = normalize(vpos + localOrigin);
|
|
121
121
|
vec3 right = normalize(cross(vec3(0.0, 0.0, 1.0), localUp));
|
|
122
122
|
vec3 forward = normalize(cross(localUp, right));
|
|
123
123
|
mat3 tbn = mat3(right, forward, localUp);
|
|
124
124
|
vec3 tNormal = normalize(normal * tbn);
|
|
125
125
|
gl_FragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
126
|
-
|
|
126
|
+
`:$`
|
|
127
127
|
vec3 tNormal = normalize(normal);
|
|
128
128
|
gl_FragColor = vec4(vec3(0.5) + 0.5 * tNormal, 0.0);
|
|
129
129
|
`:""}
|
|
130
|
-
${r.tileBorders
|
|
130
|
+
${r.tileBorders?$`
|
|
131
131
|
vec2 dVuv = fwidth(vuv0);
|
|
132
132
|
vec2 edgeFactors = smoothstep(vec2(0.0), 1.5 * dVuv, min(vuv0, 1.0 - vuv0));
|
|
133
133
|
float edgeFactor = 1.0 - min(edgeFactors.x, edgeFactors.y);
|
|
134
134
|
gl_FragColor = mix(gl_FragColor, vec4(1.0, 0.0, 0.0, 1.0), edgeFactor);`:""}
|
|
135
135
|
gl_FragColor = highlightSlice(gl_FragColor, vpos);
|
|
136
136
|
}
|
|
137
|
-
`)}break;case d.Depth:
|
|
137
|
+
`)}break;case d.Depth:H&&i.include(_,r),i.include(w,r),t(i),n(i),T.code.add($`
|
|
138
138
|
void main(void) {
|
|
139
|
-
${
|
|
139
|
+
${H?$`setOverlayVTC(getUV0());`:""}
|
|
140
140
|
gl_Position = transformPositionWithDepth(proj, view, position, nearFar, linearDepth);
|
|
141
141
|
}
|
|
142
|
-
`),
|
|
142
|
+
`),A.code.add($`
|
|
143
143
|
void main() {
|
|
144
|
-
${
|
|
144
|
+
${H&&r.invisible?$`if (getCombinedOverlayColor().a == 0.0) { discard; }`:""}
|
|
145
145
|
outputDepth(linearDepth);
|
|
146
146
|
}
|
|
147
|
-
`);break;case d.Shadow:case d.ShadowHighlight:case d.ShadowExcludeHighlight:
|
|
147
|
+
`);break;case d.Shadow:case d.ShadowHighlight:case d.ShadowExcludeHighlight:i.include(w,r),t(i),n(i),T.code.add($`void main(void) {
|
|
148
148
|
gl_Position = transformPositionWithDepth(proj, view, position, nearFar, linearDepth);
|
|
149
|
-
}`),
|
|
149
|
+
}`),A.code.add($`void main() {
|
|
150
150
|
outputDepth(linearDepth);
|
|
151
|
-
}`);break;case d.Normal:
|
|
151
|
+
}`);break;case d.Normal:H&&i.include(_,r),k.add("vnormal","vec3"),M(T),G(),T.code.add($`
|
|
152
152
|
void main(void) {
|
|
153
|
-
${
|
|
153
|
+
${H?$`setOverlayVTC(getUV0());`:""}
|
|
154
154
|
gl_Position = transformPosition(proj, view, position);
|
|
155
155
|
vnormal = normalize((viewNormal * vec4(getNormal(), 1.0)).xyz);
|
|
156
156
|
}
|
|
157
|
-
`),
|
|
157
|
+
`),A.code.add($`
|
|
158
158
|
void main() {
|
|
159
|
-
${
|
|
159
|
+
${H&&r.invisible?$`if (getCombinedOverlayColor().a == 0.0) { discard; }`:""}
|
|
160
160
|
vec3 normal = normalize(vnormal);
|
|
161
161
|
if (gl_FrontFacing == false) {
|
|
162
162
|
normal = -normal;
|
|
163
163
|
}
|
|
164
164
|
gl_FragColor = vec4(vec3(0.5) + 0.5 * normal, 0.0);
|
|
165
165
|
}
|
|
166
|
-
`);break;case d.Highlight:
|
|
166
|
+
`);break;case d.Highlight:H&&i.include(_,r),T.code.add($`
|
|
167
167
|
void main() {
|
|
168
|
-
${
|
|
168
|
+
${H?$`setOverlayVTC(getUV0());`:""}
|
|
169
169
|
gl_Position = transformPosition(proj, view, position);
|
|
170
170
|
}
|
|
171
|
-
`),
|
|
171
|
+
`),i.include(u,r),A.code.add($`
|
|
172
172
|
void main() {
|
|
173
|
-
${
|
|
173
|
+
${H?$`if (getCombinedOverlayColor().a == 0.0) { discard; }`:""}
|
|
174
174
|
outputHighlight();
|
|
175
175
|
}
|
|
176
|
-
`)}return r.output===d.ObjectAndLayerIdColor&&(
|
|
176
|
+
`)}return r.output===d.ObjectAndLayerIdColor&&(i.include(_,{...r,pbrMode:S.Disabled}),T.code.add($`void main(void) {
|
|
177
177
|
gl_Position = transformPosition(proj, view, position);
|
|
178
178
|
setOverlayVTC(getUV0());
|
|
179
|
-
}`),
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
gl_FragColor = ${$(r,"ovColorTex","vec2(vtcOverlay.x * 0.5, vtcOverlay.y)*texDim")};
|
|
183
|
-
}
|
|
184
|
-
`)),a}const G=r(),H=a(),I=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:B,build:E},Symbol.toStringTag,{value:"Module"}));export{B as T,I as a,E as b};
|
|
179
|
+
}`),A.code.add($`void main() {
|
|
180
|
+
gl_FragColor = getOverlayColorTexel(vtcOverlay);
|
|
181
|
+
}`)),i}const B=r(),E=i(),G=Object.freeze(Object.defineProperty({__proto__:null,TerrainPassParameters:A,build:k},Symbol.toStringTag,{value:"Module"}));export{A as T,G as a,k as b};
|
package/config.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={analysisTheme:{accentColor:[255,128,0],textColor:"white"},apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!1,portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.26.
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={analysisTheme:{accentColor:[255,128,0],textColor:"white"},apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!1,portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.26.4";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.defaultAssetsPath=s.assetsPath}export{s 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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import{isSome as s,isNone as i}from"../../core/maybe.js";import{dataComponents as o}from"../../core/urlUtils.js";import{generateUUID as n}from"../../core/uuid.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";import{AssetMapEditFlags as l}from"./assetEditingSupport.js";import{isEditBusLayer as u,editEventBus as p}from"../mixins/EditBusLayer.js";import{AssetType as c}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as h,getEffectiveLayerCapabilities as m}from"../support/layerUtils.js";function y(e){return e&&null!=e.applyEdits}async function f(e,t,a,s={}){let i,o;const n={edits:a,result:new Promise(((e,t)=>{i=e,o=t}))};e.emit("apply-edits",n);try{const{results:o,edits:n}=await g(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:n,addedFeatures:d(o.addFeatureResults),updatedFeatures:d(o.updateFeatureResults),deletedFeatures:d(o.deleteFeatureResults),addedAttachments:d(o.addAttachmentResults),updatedAttachments:d(o.updateAttachmentResults),deletedAttachments:d(o.deleteAttachmentResults),exceededTransferLimit:!1};return o.editedFeatureResults?.length&&(l.editedFeatures=o.editedFeatureResults),(l.addedFeatures.length||l.updatedFeatures.length||l.deletedFeatures.length||l.addedAttachments.length||l.updatedAttachments.length||l.deletedAttachments.length)&&(e.emit("edits",l),u(e)&&p.emit("edits",{layer:e,event:l})),i(l),o}catch(d){throw o(d),d}}async function g(e,t,r,s){if(await e.load(),!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!h(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:i,options:o}=await b(e,r,s);return i.addFeatures?.length||i.updateFeatures?.length||i.deleteFeatures?.length||i.addAttachments?.length||i.updateAttachments?.length||i.deleteAttachments?.length?{edits:i,results:await t.applyEdits(i,o)}:{edits:i,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function b(e,r,i){const o=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),n=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments),d=s(e.infoFor3D);if(!r||!o&&!n)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");const l=m(e);if(!l.data.isVersioned&&i?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!l.editing.supportsRollbackOnFailure&&i?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!l.editing.supportsGlobalId&&i?.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!l.editing.supportsGlobalId&&n)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!i?.globalIdUsed&&n)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const u={...i};if(null!=u.rollbackOnFailureEnabled||l.editing.supportsRollbackOnFailure||(u.rollbackOnFailureEnabled=!0),!1===u.rollbackOnFailureEnabled&&"original-and-current-features"===u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");if(!l.editing.supportsReturnServiceEditsInSourceSpatialReference&&u.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(u.returnServiceEditsInSourceSR&&"original-and-current-features"!==u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'
|
|
5
|
+
import e from"../../Graphic.js";import t from"../../core/Collection.js";import a from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import{isSome as s,isNone as i}from"../../core/maybe.js";import{dataComponents as o}from"../../core/urlUtils.js";import{generateUUID as n}from"../../core/uuid.js";import{normalizeCentralMeridian as d}from"../../geometry/support/normalizeUtils.js";import{AssetMapEditFlags as l}from"./assetEditingSupport.js";import{isEditBusLayer as u,editEventBus as p}from"../mixins/EditBusLayer.js";import{AssetType as c}from"../support/infoFor3D.js";import{getEffectiveEditingEnabled as h,getEffectiveLayerCapabilities as m}from"../support/layerUtils.js";function y(e){return e&&null!=e.applyEdits}async function f(e,t,a,s={}){let i,o;const n={edits:a,result:new Promise(((e,t)=>{i=e,o=t}))};e.emit("apply-edits",n);try{const{results:o,edits:n}=await g(e,t,a,s),d=e=>e.filter((e=>!e.error)).map(r),l={edits:n,addedFeatures:d(o.addFeatureResults),updatedFeatures:d(o.updateFeatureResults),deletedFeatures:d(o.deleteFeatureResults),addedAttachments:d(o.addAttachmentResults),updatedAttachments:d(o.updateAttachmentResults),deletedAttachments:d(o.deleteAttachmentResults),exceededTransferLimit:!1};return o.editedFeatureResults?.length&&(l.editedFeatures=o.editedFeatureResults),(l.addedFeatures.length||l.updatedFeatures.length||l.deletedFeatures.length||l.addedAttachments.length||l.updatedAttachments.length||l.deletedAttachments.length)&&(e.emit("edits",l),u(e)&&p.emit("edits",{layer:e,event:l})),i(l),o}catch(d){throw o(d),d}}async function g(e,t,r,s){if(await e.load(),!y(t))throw new a(`${e.type}-layer:no-editing-support`,"Layer source does not support applyEdits capability",{layer:e});if(!h(e))throw new a(`${e.type}-layer:editing-disabled`,"Editing is disabled for layer",{layer:e});const{edits:i,options:o}=await b(e,r,s);return i.addFeatures?.length||i.updateFeatures?.length||i.deleteFeatures?.length||i.addAttachments?.length||i.updateAttachments?.length||i.deleteAttachments?.length?{edits:i,results:await t.applyEdits(i,o)}:{edits:i,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function b(e,r,i){const o=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),n=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments),d=s(e.infoFor3D);if(!r||!o&&!n)throw new a(`${e.type}-layer:missing-parameters`,"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");const l=m(e);if(!l.data.isVersioned&&i?.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");if(!l.editing.supportsRollbackOnFailure&&i?.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");if(!l.editing.supportsGlobalId&&i?.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");if(!l.editing.supportsGlobalId&&n)throw new a(`${e.type}-layer:invalid-parameter`,"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");if(!i?.globalIdUsed&&n)throw new a(`${e.type}-layer:invalid-parameter`,"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");const u={...i};if(null!=u.rollbackOnFailureEnabled||l.editing.supportsRollbackOnFailure||(u.rollbackOnFailureEnabled=!0),!1===u.rollbackOnFailureEnabled&&"original-and-current-features"===u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");if(!l.editing.supportsReturnServiceEditsInSourceSpatialReference&&u.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");if(u.returnServiceEditsInSourceSR&&"original-and-current-features"!==u.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,"'returnServiceEditsInSourceSR' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");const p={...r};if(p.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():p.addFeatures||[],p.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():p.updateFeatures||[],p.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():p.deleteFeatures||[],p.addFeatures.length&&!l.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support adding features.");if(p.updateFeatures.length&&!l.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support updating features.");if(p.deleteFeatures.length&&!l.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,"Layer does not support deleting features.");p.addAttachments=p.addAttachments||[],p.updateAttachments=p.updateAttachments||[],p.deleteAttachments=p.deleteAttachments||[],p.addFeatures=p.addFeatures.map(S),p.updateFeatures=p.updateFeatures.map(S),p.addAssets=[];const c=i?.globalIdUsed||d;p.addFeatures.forEach((t=>F(t,e,c))),p.updateFeatures.forEach((t=>I(t,e,c))),p.deleteFeatures.forEach((t=>A(t,e,c))),p.addAttachments.forEach((t=>v(t,e))),p.updateAttachments.forEach((t=>v(t,e))),d&&await R(p,e);return{edits:await E(p),options:u}}function w(e,t,r){if(r){if("attributes"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Feature should have 'globalId' when 'globalIdUsed' is true");if(!("attributes"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"'globalId' of the feature should be passed when 'globalIdUsed' is true")}if("geometry"in e&&s(e.geometry)){if(e.geometry.hasZ&&!1===t.capabilities?.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,"Layer does not support z values while feature has z values.");if(e.geometry.hasM&&!1===t.capabilities?.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,"Layer does not support m values while feature has m values.")}}function F(e,t,a){w(e,t,a)}function A(e,t,a){w(e,t,a)}function I(e,t,r){w(e,t,r);const i=m(t);if("geometry"in e&&s(e.geometry)&&!i?.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,"Layer does not support geometry updates.")}function v(e,t){const{feature:r,attachment:s}=e;if(!r||"attributes"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to a feature with 'globalId'");if(!("attributes"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have reference to 'globalId' of the parent feature");if(!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'globalId'");if(!s.data&&!s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment should have 'data' or 'uploadId'");if(!(s.data instanceof File&&!!s.data.name)&&!s.name)throw new a(`${t.type}-layer:invalid-parameter`,"'name' is required when attachment is specified as Base64 encoded string using 'data'");if(!t.capabilities?.editing.supportsUploadWithItemId&&s.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");if("string"==typeof s.data){const e=o(s.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,"Attachment 'data' should be a Blob, File or Base64 encoded string")}}async function E(e){const t=e.addFeatures??[],a=e.updateFeatures??[],r=t.concat(a).map((e=>e.geometry)),s=await d(r),i=t.length,o=a.length;return s.slice(0,i).forEach(((e,a)=>t[a].geometry=e)),s.slice(i,i+o).forEach(((e,t)=>a[t].geometry=e)),e}function S(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}async function R(e,t){if(i(t.infoFor3D))return;const{infoFor3D:a}=t;let r=!1;for(const i of a.editFormats)if(i===c.GLTF_BINARY){r=!0;break}const s=[];for(const i of e.addFeatures??[])s.push($(i,e,t,r));for(const i of e.updateFeatures??[])s.push($(i,e,t,r));const o=await Promise.allSettled(s);for(const i of o)if("rejected"===i.status)throw i.reason}async function $(e,t,r,o){if(i(e.geometry)||"mesh"!==e.geometry.type)return;const d=e.geometry,u=r.globalIdField;if(s(r.parsedUrl)&&s(d.external)&&Array.isArray(d.external.source)&&1===d.external.source.length&&"source"in d.external.source[0]&&"string"==typeof d.external.source[0].source&&d.external.source[0].source.startsWith(r.parsedUrl.path))return;if(!o)throw new a(`${r.type}-layer:binary-gltf-asset-not-supported`,"3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");const p=await d.toBinaryGLTF({ignoreLocalTransform:!0}),h=await p.buffer(),m=`{${n()}}`,y=`${m}.glb`;t.addAssets?.push({featureGlobalId:e.getAttribute(u),assetMapGlobalId:m,assetName:y,flags:s(d.transform)&&d.transform.geographic?l.PROJECT_VERTICES:0,data:h.data,mimeType:h.type,assetType:c.GLTF_BINARY,feature:e})}export{f as applyEdits};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/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 a from"../../../request.js";import r from"../../../TimeExtent.js";import o from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as i}from"../../../core/jsonMap.js";import n from"../../../core/Loadable.js";import{isSome as u,isNone as l,unwrap as d}from"../../../core/maybe.js";import{setDeepValue as c}from"../../../core/object.js";import{debounce as p}from"../../../core/promiseUtils.js";import{join as h,dataComponents as y}from"../../../core/urlUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Extent.js";import{fromJSON as R}from"../../../geometry/support/jsonUtils.js";import{AssetMapEditFlags as F}from"../assetEditingSupport.js";import{createDrawingInfo as b}from"./support/clientSideDefaults.js";import q from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{unapplyEditsZUnitScaling as _}from"../../../rest/query/operations/editsZScale.js";import w from"../../../geometry/SpatialReference.js";const E=new i({originalAndCurrentFeatures:"original-and-current-features",none:"none"});async function S(e){if("string"==typeof e){const t=y(e);return t||{data:e}}return new Promise(((t,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(y(a.result)),a.onerror=e=>s(e)}))}const O=new Set(["Feature Layer","Table"]),j=new i({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let T=class extends n{constructor(){super(...arguments),this.type="feature-layer",this.refresh=p((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}}))}load(e){const t=u(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:a,gdbVersion:r,spatialReference:o,fieldsIndex:i}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&l(a),u=e?.operations?.supportsQueryAttachments??!1;return new q({url:t.path,pbfSupported:n,fieldsIndex:i,infoFor3D:a,dynamicDataSource:s,gdbVersion:r,sourceSpatialReference:o,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/addAttachment",o=this._getLayerRequestOptions(),i=this._getFormDataForAttachment(t,o.query);try{const e=await a(r,{body:i});return this._createFeatureEditResult(e.data.addAttachmentResult)}catch(n){throw this._createAttachmentErrorResult(s,n)}}async updateAttachment(e,t,s){await this.load();const r=e.attributes[this.layer.objectIdField],o=this.layer.parsedUrl.path+"/"+r+"/updateAttachment",i=this._getLayerRequestOptions({query:{attachmentId:t}}),n=this._getFormDataForAttachment(s,i.query);try{const e=await a(o,{body:n});return this._createFeatureEditResult(e.data.updateAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(r,u)}}async applyEdits(e,t){await this.load();const r=this.layer.infoFor3D,o=u(r),i=o||(t?.globalIdUsed??!1),n=e.addFeatures?.map((e=>this._serializeFeature(e,r))).filter(u)??[],l=e.updateFeatures?.map((e=>this._serializeFeature(e,r))).filter(u)??[],c=this._getFeatureIds(e.deleteFeatures,i);_(n,l,this.layer.spatialReference);const p=[],h=[],y=[...e.deleteAttachments??[]];for(const s of e.addAttachments??[])p.push(await this._serializeAttachment(s));for(const s of e.updateAttachments??[])h.push(await this._serializeAttachment(s));const m=p.length||h.length||y.length?{adds:p,updates:h,deletes:y}:null;let f,g=null;if(o){g=new Map;const t=[];for(const a of e.addAssets??[])t.push(this._serializeAssetMapEditAndUploadAssets(a,g));const s=await Promise.all(t);f=s.length?{adds:s,updates:[],deletes:[]}:void 0}const R={gdbVersion:t?.gdbVersion||this.layer.gdbVersion,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:i,returnEditMoment:t?.returnEditMoment,usePreviousEditMoment:t?.usePreviousEditMoment,sessionId:t?.sessionId};t?.returnServiceEditsOption?(R.edits=JSON.stringify([{id:this.layer.layerId,adds:n,updates:l,deletes:c,attachments:m,assetMaps:d(f)}]),R.returnServiceEditsOption=E.toJSON(t?.returnServiceEditsOption),R.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(R.adds=n.length?JSON.stringify(n):null,R.updates=l.length?JSON.stringify(l):null,R.deletes=c.length?i?JSON.stringify(c):c.join(","):null,R.attachments=m&&JSON.stringify(m),R.assetMaps=u(f)?JSON.stringify(f):void 0);const F=this._getLayerRequestOptions({method:"post",query:R}),b=t?.returnServiceEditsOption?this.layer.url:this.layer.parsedUrl.path,q=await a(b+"/applyEdits",F);if(!this.layer.capabilities.operations?.supportsEditing&&this.layer.effectiveCapabilities?.operations?.supportsEditing){const e=s?.findCredential(this.layer.url);await(e?.refreshToken())}if(o&&null!=q.data&&null!=q.data.assetMaps){const e=q.data,t=this.layer.objectIdField,s=[];for(const a of e.addResults)a.success&&s.push(a.objectId);for(const a of e.updateResults)a.success&&s.push(a.objectId);const r=this._createRequestQueryOptions(),o=await a(b+"/query",{...r,query:{f:"json",formatOf3DObjects:"3D_glb",where:`OBJECTID IN (${s.join(",")})`,outFields:`${t}`}});if(o&&o.data&&o.data.assetMaps&&u(g)){const e=o.data.assetMaps;for(const t of e){const e=g.get(t.parentGlobalId).geometry;u(e)&&"mesh"===e.type&&e.updateExternalSource({source:[{name:t.assetName,source:t.assetName}],extent:e.extent})}}}return this._createEditsResult(q)}async deleteAttachments(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/deleteAttachments";try{return(await a(r,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(this._createFeatureEditResult)}catch(o){throw this._createAttachmentErrorResult(s,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:o}=this.layer,{data:i}=await a(`${o}/${s}`,t),{id:n,extent:u,fullExtent:l,timeExtent:d}=i,c=u||l;return{id:n,fullExtent:c&&g.fromJSON(c),timeExtent:d&&r.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 a(e,{query:{f:"json"}});return j.fromJSON(t.data.status)}_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 a(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(!O.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=b(e.geometryType).renderer;c("drawingInfo.renderer",t,e)}return"esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),e}_serializeFeature(e,t){const{geometry:s,attributes:a}=e;if(u(t)&&u(e.geometry)&&"mesh"===e.geometry.type){const s={...a},r=e.geometry,o=r.origin,i=r.transform;if(s[t.transformFieldRoles.originX]=o.x,s[t.transformFieldRoles.originY]=o.y,s[t.transformFieldRoles.originZ]=o.z,u(i)){const e=i.translation,a=i.scale,r=i.rotation;s[t.transformFieldRoles.translationX]=e[0],s[t.transformFieldRoles.translationY]=-e[2],s[t.transformFieldRoles.translationZ]=e[1],s[t.transformFieldRoles.scaleX]=a[0],s[t.transformFieldRoles.scaleY]=a[1],s[t.transformFieldRoles.scaleZ]=a[2],s[t.transformFieldRoles.rotationX]=r[0],s[t.transformFieldRoles.rotationY]=r[2],s[t.transformFieldRoles.rotationZ]=r[1],s[t.transformFieldRoles.rotationDeg]=r[3]}return{geometry:null,attributes:s}}return l(s)?{attributes:a}:"mesh"===s.type||"extent"===s.type?null:{geometry:s.toJSON(),attributes:a}}async _serializeAttachment(e){const{feature:t,attachment:s}=e,{globalId:a,name:r,contentType:o,data:i,uploadId:n}=s,u={globalId:a,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(i){const e=await S(i);e&&(u.contentType=e.mediaType,u.data=e.data),i instanceof File&&(u.name=i.name)}return r&&(u.name=r),o&&(u.contentType=o),u}async _serializeAssetMapEditAndUploadAssets(e,t){const s=this.layer.url;let r=null;try{const t=new Blob([e.data],{type:e.mimeType}),i=new FormData;i.append("f","json"),i.append("file",t,`${e.assetName}`);const n={body:i,method:"post",responseType:"json"},{data:u}=await a(`${s}/uploads/upload`,n);if(!u.success)throw new o("feature-layer-source:upload-failure","Expected upload to be successfull.");r={assetType:e.assetType,assetUploadId:u.item.itemID}}catch(p){r=null}if(l(r)){const t=await S(new Blob([e.data]));if(!t.isBase64)throw new o("feature-layer-source:uploadAssets-failure","Expected gltf data in base64 format after conversion.");r={assetType:e.assetType,assetData:t.data}}if(l(r))throw new o("feature-layer-source:uploadAssets-failure","Unable to prepare uploadAsset request options.");const i={method:"post",query:{f:"json",assets:JSON.stringify([r])},responseType:"json"},n=await a(h(this.layer.parsedUrl.path,"uploadAssets"),i);if(1!==n.data.uploadResults.length||!n.data.uploadResults[0].success)throw new o("feature-layer-source:uploadAssets-failure","Bad response.");const u=n.data.uploadResults[0].assetHash,d=[];e.flags&F.PROJECT_VERTICES&&d.push("PROJECT_VERTICES");const c={globalId:e.assetMapGlobalId,parentGlobalId:e.featureGlobalId,assetName:e.assetName,assetHash:u,flags:d};return t.set(e.featureGlobalId,e.feature),c}_getFeatureIds(e,t){const s=e?.[0];return s?this._canUseGlobalIds(t,e)?this._getGlobalIdsFromFeatureIdentifier(e):"objectId"in s?this._getObjectIdsFromFeatureIdentifier(e):this._getIdsFromFeatures(e):[]}_getIdsFromFeatures(e){const t=this.layer.objectIdField;return e.map((e=>e.attributes&&e.attributes[t]))}_canUseGlobalIds(e,t){return e&&"globalId"in t[0]}_getObjectIdsFromFeatureIdentifier(e){return e.map((e=>e.objectId))}_getGlobalIdsFromFeatureIdentifier(e){return e.map((e=>e.globalId))}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,a=[];let r=null;if(Array.isArray(t))for(const n of t)a.push({id:n.id,editedFeatures:n.editedFeatures}),n.id===s&&(r={addResults:n.addResults??[],updateResults:n.updateResults??[],deleteResults:n.deleteResults??[],attachments:n.attachments,editMoment:n.editMoment});else r=t;const o=r?.attachments,i={addFeatureResults:r?.addResults?.map(this._createFeatureEditResult,this)??[],updateFeatureResults:r?.updateResults?.map(this._createFeatureEditResult,this)??[],deleteFeatureResults:r?.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(r?.editMoment&&(i.editMoment=r.editMoment),a.length>0){i.editedFeatureResults=[];for(const e of a){const{adds:t,updates:s,deletes:a,spatialReference:r}=e.editedFeatures,o=r?new w(r):null;i.editedFeatureResults.push({layerId:e.id,editedFeatures:{adds:t?.map((e=>this._createEditedFeature(e,o)))||[],updates:s?.map((e=>({original:this._createEditedFeature(e[0],o),current:this._createEditedFeature(e[1],o)})))||[],deletes:a?.map((e=>this._createEditedFeature(e,o)))||[],spatialReference:o}})}}return i}_createEditedFeature(e,s){return new t({attributes:e.attributes,geometry:R({...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,a=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new o("feature-layer-source:attachment-failure",s,{code:a})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const a in t){const e=t[a];null!=e&&(s.set?s.set(a,e):s.append(a,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:a}=this.layer;return{...e,query:{gdbVersion:s,layer:a?JSON.stringify({source:a}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}};e([m()],T.prototype,"type",void 0),e([m({constructOnly:!0})],T.prototype,"layer",void 0),e([m({readOnly:!0})],T.prototype,"queryTask",null),T=e([f("esri.layers.graphics.sources.FeatureLayerSource")],T);const A=T;export{A 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 a from"../../../request.js";import r from"../../../TimeExtent.js";import o from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as i}from"../../../core/jsonMap.js";import n from"../../../core/Loadable.js";import{isSome as u,isNone as l,unwrap as d}from"../../../core/maybe.js";import{setDeepValue as c}from"../../../core/object.js";import{debounce as p}from"../../../core/promiseUtils.js";import{join as h,dataComponents as y}from"../../../core/urlUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Extent.js";import{fromJSON as R}from"../../../geometry/support/jsonUtils.js";import{AssetMapEditFlags as F}from"../assetEditingSupport.js";import{createDrawingInfo as b}from"./support/clientSideDefaults.js";import q from"./support/QueryTask.js";import{isHostedAgolService as I}from"../../support/arcgisLayerUrl.js";import{unapplyEditsZUnitScaling as _}from"../../../rest/query/operations/editsZScale.js";import w from"../../../geometry/SpatialReference.js";const E=new i({originalAndCurrentFeatures:"original-and-current-features",none:"none"});async function S(e){if("string"==typeof e){const t=y(e);return t||{data:e}}return new Promise(((t,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(y(a.result)),a.onerror=e=>s(e)}))}const O=new Set(["Feature Layer","Table"]),j=new i({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let T=class extends n{constructor(){super(...arguments),this.type="feature-layer",this.refresh=p((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}}))}load(e){const t=u(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:a,gdbVersion:r,spatialReference:o,fieldsIndex:i}=this.layer,n=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&l(a),u=e?.operations?.supportsQueryAttachments??!1;return new q({url:t.path,pbfSupported:n,fieldsIndex:i,infoFor3D:a,dynamicDataSource:s,gdbVersion:r,sourceSpatialReference:o,queryAttachmentsSupported:u})}async addAttachment(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/addAttachment",o=this._getLayerRequestOptions(),i=this._getFormDataForAttachment(t,o.query);try{const e=await a(r,{body:i});return this._createFeatureEditResult(e.data.addAttachmentResult)}catch(n){throw this._createAttachmentErrorResult(s,n)}}async updateAttachment(e,t,s){await this.load();const r=e.attributes[this.layer.objectIdField],o=this.layer.parsedUrl.path+"/"+r+"/updateAttachment",i=this._getLayerRequestOptions({query:{attachmentId:t}}),n=this._getFormDataForAttachment(s,i.query);try{const e=await a(o,{body:n});return this._createFeatureEditResult(e.data.updateAttachmentResult)}catch(u){throw this._createAttachmentErrorResult(r,u)}}async applyEdits(e,t){await this.load();const r=this.layer.infoFor3D,o=u(r),i=o||(t?.globalIdUsed??!1),n=e.addFeatures?.map((e=>this._serializeFeature(e,r))).filter(u)??[],l=e.updateFeatures?.map((e=>this._serializeFeature(e,r))).filter(u)??[],c=this._getFeatureIds(e.deleteFeatures,i);_(n,l,this.layer.spatialReference);const p=[],h=[],y=[...e.deleteAttachments??[]];for(const s of e.addAttachments??[])p.push(await this._serializeAttachment(s));for(const s of e.updateAttachments??[])h.push(await this._serializeAttachment(s));const m=p.length||h.length||y.length?{adds:p,updates:h,deletes:y}:null;let f,g=null;if(o){g=new Map;const t=[];for(const a of e.addAssets??[])t.push(this._serializeAssetMapEditAndUploadAssets(a,g));const s=await Promise.all(t);f=s.length?{adds:s,updates:[],deletes:[]}:void 0}const R={gdbVersion:t?.gdbVersion||this.layer.gdbVersion,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:i,returnEditMoment:t?.returnEditMoment,usePreviousEditMoment:t?.usePreviousEditMoment,sessionId:t?.sessionId};t?.returnServiceEditsOption?(R.edits=JSON.stringify([{id:this.layer.layerId,adds:n,updates:l,deletes:c,attachments:m,assetMaps:d(f)}]),R.returnServiceEditsOption=E.toJSON(t?.returnServiceEditsOption),R.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(R.adds=n.length?JSON.stringify(n):null,R.updates=l.length?JSON.stringify(l):null,R.deletes=c.length?i?JSON.stringify(c):c.join(","):null,R.attachments=m&&JSON.stringify(m),R.assetMaps=u(f)?JSON.stringify(f):void 0);const F=this._getLayerRequestOptions({method:"post",query:R}),b=t?.returnServiceEditsOption?this.layer.url:this.layer.parsedUrl.path,q=await a(b+"/applyEdits",F);if(!this.layer.capabilities.operations?.supportsEditing&&this.layer.effectiveCapabilities?.operations?.supportsEditing){const e=s?.findCredential(this.layer.url);await(e?.refreshToken())}if(o&&null!=q.data&&null!=q.data.assetMaps){const e=q.data,t=this.layer.objectIdField,s=[];for(const a of e.addResults)a.success&&s.push(a.objectId);for(const a of e.updateResults)a.success&&s.push(a.objectId);const r=this._createRequestQueryOptions(),o=await a(b+"/query",{...r,query:{f:"json",formatOf3DObjects:"3D_glb",where:`OBJECTID IN (${s.join(",")})`,outFields:`${t}`}});if(o&&o.data&&o.data.assetMaps&&u(g)){const e=o.data.assetMaps;for(const t of e){const e=g.get(t.parentGlobalId).geometry;u(e)&&"mesh"===e.type&&e.updateExternalSource({source:[{name:t.assetName,source:t.assetName}],extent:e.extent})}}}return this._createEditsResult(q)}async deleteAttachments(e,t){await this.load();const s=e.attributes[this.layer.objectIdField],r=this.layer.parsedUrl.path+"/"+s+"/deleteAttachments";try{return(await a(r,this._getLayerRequestOptions({query:{attachmentIds:t.join(",")},method:"post"}))).data.deleteAttachmentResults.map(this._createFeatureEditResult)}catch(o){throw this._createAttachmentErrorResult(s,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then((async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:o}=this.layer,{data:i}=await a(`${o}/${s}`,t),{id:n,extent:u,fullExtent:l,timeExtent:d}=i,c=u||l;return{id:n,fullExtent:c&&g.fromJSON(c),timeExtent:d&&r.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 a(e,{query:{f:"json"}});return j.fromJSON(t.data.status)}_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 a(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(!O.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=b(e.geometryType).renderer;c("drawingInfo.renderer",t,e)}return"esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),e}_serializeFeature(e,t){const{geometry:s,attributes:a}=e;if(u(t)&&u(e.geometry)&&"mesh"===e.geometry.type){const s={...a},r=e.geometry,o=r.origin,i=r.transform;if(s[t.transformFieldRoles.originX]=o.x,s[t.transformFieldRoles.originY]=o.y,s[t.transformFieldRoles.originZ]=o.z,u(i)){const e=i.translation,a=i.scale,r=i.rotation;s[t.transformFieldRoles.translationX]=e[0],s[t.transformFieldRoles.translationY]=-e[2],s[t.transformFieldRoles.translationZ]=e[1],s[t.transformFieldRoles.scaleX]=a[0],s[t.transformFieldRoles.scaleY]=a[1],s[t.transformFieldRoles.scaleZ]=a[2],s[t.transformFieldRoles.rotationX]=r[0],s[t.transformFieldRoles.rotationY]=r[2],s[t.transformFieldRoles.rotationZ]=r[1],s[t.transformFieldRoles.rotationDeg]=r[3]}return{geometry:null,attributes:s}}return l(s)?{attributes:a}:"mesh"===s.type||"extent"===s.type?null:{geometry:s.toJSON(),attributes:a}}async _serializeAttachment(e){const{feature:t,attachment:s}=e,{globalId:a,name:r,contentType:o,data:i,uploadId:n}=s,u={globalId:a,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(i){const e=await S(i);e&&(u.contentType=e.mediaType,u.data=e.data),i instanceof File&&(u.name=i.name)}return r&&(u.name=r),o&&(u.contentType=o),u}async _serializeAssetMapEditAndUploadAssets(e,t){const s=this.layer.url;let r=null;try{const t=new Blob([e.data],{type:e.mimeType}),i=new FormData;i.append("f","json"),i.append("file",t,`${e.assetName}`);const n={body:i,method:"post",responseType:"json"},{data:u}=await a(`${s}/uploads/upload`,n);if(!u.success)throw new o("feature-layer-source:upload-failure","Expected upload to be successfull.");r={assetType:e.assetType,assetUploadId:u.item.itemID}}catch(p){r=null}if(l(r)){const t=await S(new Blob([e.data]));if(!t.isBase64)throw new o("feature-layer-source:uploadAssets-failure","Expected gltf data in base64 format after conversion.");r={assetType:e.assetType,assetData:t.data}}if(l(r))throw new o("feature-layer-source:uploadAssets-failure","Unable to prepare uploadAsset request options.");const i={method:"post",query:{f:"json",assets:JSON.stringify([r])},responseType:"json"},n=await a(h(this.layer.parsedUrl.path,"uploadAssets"),i);if(1!==n.data.uploadResults.length||!n.data.uploadResults[0].success)throw new o("feature-layer-source:uploadAssets-failure","Bad response.");const u=n.data.uploadResults[0].assetHash,d=[];e.flags&F.PROJECT_VERTICES&&d.push("PROJECT_VERTICES");const c={globalId:e.assetMapGlobalId,parentGlobalId:e.featureGlobalId,assetName:e.assetName,assetHash:u,flags:d};return t.set(e.featureGlobalId,e.feature),c}_getFeatureIds(e,t){const s=e?.[0];return s?this._canUseGlobalIds(t,e)?this._getGlobalIdsFromFeatureIdentifier(e):"objectId"in s?this._getObjectIdsFromFeatureIdentifier(e):this._getIdsFromFeatures(e):[]}_getIdsFromFeatures(e){const t=this.layer.objectIdField;return e.map((e=>e.attributes&&e.attributes[t]))}_canUseGlobalIds(e,t){return e&&"globalId"in t[0]}_getObjectIdsFromFeatureIdentifier(e){return e.map((e=>e.objectId))}_getGlobalIdsFromFeatureIdentifier(e){return e.map((e=>e.globalId))}_createEditsResult(e){const t=e.data,{layerId:s}=this.layer,a=[];let r=null;if(Array.isArray(t))for(const n of t)a.push({id:n.id,editedFeatures:n.editedFeatures}),n.id===s&&(r={addResults:n.addResults??[],updateResults:n.updateResults??[],deleteResults:n.deleteResults??[],attachments:n.attachments,editMoment:n.editMoment});else r=t;const o=r?.attachments,i={addFeatureResults:r?.addResults?.map(this._createFeatureEditResult,this)??[],updateFeatureResults:r?.updateResults?.map(this._createFeatureEditResult,this)??[],deleteFeatureResults:r?.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(r?.editMoment&&(i.editMoment=r.editMoment),a.length>0){i.editedFeatureResults=[];for(const e of a){const{editedFeatures:t}=e,s=t?.spatialReference?new w(t.spatialReference):null;i.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 i}_createEditedFeature(e,s){return new t({attributes:e.attributes,geometry:R({...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,a=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new o("feature-layer-source:attachment-failure",s,{code:a})}}_getFormDataForAttachment(e,t){const s=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(s)for(const a in t){const e=t[a];null!=e&&(s.set?s.set(a,e):s.append(a,e))}return s}_getLayerRequestOptions(e={}){const{parsedUrl:t,gdbVersion:s,dynamicDataSource:a}=this.layer;return{...e,query:{gdbVersion:s,layer:a?JSON.stringify({source:a}):void 0,...t.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}};e([m()],T.prototype,"type",void 0),e([m({constructOnly:!0})],T.prototype,"layer",void 0),e([m({readOnly:!0})],T.prototype,"queryTask",null),T=e([f("esri.layers.graphics.sources.FeatureLayerSource")],T);const A=T;export{A as default};
|