@arcgis/core 4.30.0-next.20240613 → 4.30.0-next.20240614
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/UndoRedo.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/31f7a3c8e1a5b4ca4a73.js +1 -0
- package/assets/esri/core/workers/chunks/{82f982d9dde0ab137403.js → 339929c10fa8366b1615.js} +1 -1
- package/assets/esri/core/workers/chunks/{de21dffe546dd45dd1fb.js → 7fd9134246a9dbfa603b.js} +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/package.json +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/effects/EffectDashes.js +1 -1
- package/symbols/cim/rasterizingUtils.js +1 -1
- package/undoredo/support/ServiceVersionInfo.js +1 -1
- package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/RelationshipColumn.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/OrientedImageryViewerViewModelAdapter2D.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/assets/esri/core/workers/chunks/5379a5f4cb36b8003dcc.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as b}from"../../../layers/graphics/featureConversionUtils.js";import F from"../../../layers/support/FeatureFilter.js";import{packFields as A}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as S}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as E}from"../../../layers/support/timeSupport.js";import x from"../../../rest/support/AggregateFeatureSet.js";import j from"../../../rest/support/FeatureSet.js";import V from"../../../rest/support/Query.js";import{getHighlightBits as C}from"../engine/highlightReasons.js";import{LayerView2DMixin as R}from"./LayerView2D.js";import{FeatureContainer as k}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as U}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as q}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as Q}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as I}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as O}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as L}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as H}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as W}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as T}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as D}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import M from"./support/FeatureCommandQueue.js";import{handleNoEngineError as N}from"./support/handleNoEngineError.js";import{HighlightCounter as J}from"./support/HighlightCounter.js";import{toJSONGeometryType as $}from"./support/util.js";import{FeatureTileSubscriptionManager as G}from"../tiling/FeatureTileSubscriptionManager.js";import z from"../../layers/FeatureLayerView.js";import B from"../../layers/LayerView.js";import Z from"../../layers/RefreshableLayerView.js";import K from"../../../geometry/Extent.js";function X(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const Y=4294967294;let ee=class extends(z(Z(R(B)))){constructor(){super(...arguments),this._commandsQueue=new M({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new J,this._lastAvailableFields=[],this.eventLog=new q,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new v}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===S(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await U(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view.featuresTilingScheme.tileInfo.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new O(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new O(this.layer);case"subtype-group":return new T(this.layer);case"ogc-feature":return new H(this.layer);case"stream":return new W(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new L(this.layer);case"catalog-footprint":return new Q(this.layer);default:a(this.layer)}return null}get timeExtent(){return E(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="highlight"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return N(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return N(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return N(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=j.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await N(r,{features:[]}),s=j.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await N(r,{features:[]}),s=x.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return N(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return N(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return N(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return N(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return N(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return N(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await N(r,{count:0,extent:null});return{count:i.count,extent:K.fromJSON(i.extent)}}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new k(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new G({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),d(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:t=>Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t)))),fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await D(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=V.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=V.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(y):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%Y+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%Y+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n){const e=!1,r=!1,i=$(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>b(t,i,e,r))),c=u.map((t=>b(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectIdField:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await this._updateRequiredFields(),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransitions(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=X(this._lastAvailableFields,e);return this._lastAvailableFields=t,A(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[te(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(i),r=C(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function te(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new F,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new F).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],ee.prototype,"_commandsQueue",void 0),e([w()],ee.prototype,"_sourceRefreshVersion",void 0),e([w()],ee.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],ee.prototype,"_pipelineUpdating",void 0),e([w({readOnly:!0})],ee.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],ee.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],ee.prototype,"hasFullGeometries",null),e([w()],ee.prototype,"featureEffectView",void 0),e([w()],ee.prototype,"labelingCollisionInfos",null),e([w()],ee.prototype,"layerAdapter",null),e([w({readOnly:!0})],ee.prototype,"timeExtent",null),e([w()],ee.prototype,"updating",void 0),ee=e([_("esri.views.2d.layers.FeatureLayerView2D")],ee);const re=ee;export{re as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as b}from"../../../layers/graphics/featureConversionUtils.js";import F from"../../../layers/support/FeatureFilter.js";import{packFields as A}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as S}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as E}from"../../../layers/support/timeSupport.js";import x from"../../../rest/support/AggregateFeatureSet.js";import j from"../../../rest/support/FeatureSet.js";import V from"../../../rest/support/Query.js";import{getHighlightBits as C}from"../engine/highlightReasons.js";import{LayerView2DMixin as R}from"./LayerView2D.js";import{FeatureContainer as k}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as U}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as q}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as Q}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as I}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as O}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as L}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as H}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{StreamLayerAdapter as W}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as T}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as D}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import M from"./support/FeatureCommandQueue.js";import{handleNoEngineError as N}from"./support/handleNoEngineError.js";import{HighlightCounter as J}from"./support/HighlightCounter.js";import{toJSONGeometryType as $}from"./support/util.js";import{FeatureTileSubscriptionManager as G}from"../tiling/FeatureTileSubscriptionManager.js";import z from"../../layers/FeatureLayerView.js";import B from"../../layers/LayerView.js";import Z from"../../layers/RefreshableLayerView.js";import K from"../../../geometry/Extent.js";function X(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const Y=4294967294;let ee=class extends(z(Z(R(B)))){constructor(){super(...arguments),this._commandsQueue=new M({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new J,this._lastAvailableFields=[],this.eventLog=new q,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new v}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransitions()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===S(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await U(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view.featuresTilingScheme.tileInfo.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new O(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new O(this.layer);case"subtype-group":return new T(this.layer);case"ogc-feature":return new H(this.layer);case"stream":return new W(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new L(this.layer);case"catalog-footprint":return new Q(this.layer);default:a(this.layer)}return null}get timeExtent(){return E(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="highlight"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return N(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return N(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return N(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return N(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return N(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return N(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=j.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await N(r,{features:[]}),s=j.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await N(r,{features:[]}),s=x.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return N(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return N(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return N(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return N(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return N(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return N(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await N(r,{count:0,extent:null});return{count:i.count,extent:K.fromJSON(i.extent)}}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;const t=this._subscriptionManager.update(e);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new k(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new G({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),d(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())}))]),"stream"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:t=>Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t)))),fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await D(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=V.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=V.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(y):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%Y+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%Y+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n&&this._canEditByFeature(n)){const e=!1,r=!1,i=$(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>b(t,i,e,r))),c=u.map((t=>b(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectId:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every((e=>this.view.spatialReference.equals(e.geometry?.spatialReference)))&&r.every((e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference)))}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await this._updateRequiredFields(),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransitions(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=X(this._lastAvailableFields,e);return this._lastAvailableFields=t,A(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[te(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone}}_addHighlights(e,t){this._highlightCounter.addReason(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteReason(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightReason(i),r=C(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function te(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new F,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new F).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],ee.prototype,"_commandsQueue",void 0),e([w()],ee.prototype,"_sourceRefreshVersion",void 0),e([w()],ee.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],ee.prototype,"_pipelineUpdating",void 0),e([w({readOnly:!0})],ee.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],ee.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],ee.prototype,"hasFullGeometries",null),e([w()],ee.prototype,"featureEffectView",void 0),e([w()],ee.prototype,"labelingCollisionInfos",null),e([w()],ee.prototype,"layerAdapter",null),e([w({readOnly:!0})],ee.prototype,"timeExtent",null),e([w()],ee.prototype,"updating",void 0),ee=e([_("esri.views.2d.layers.FeatureLayerView2D")],ee);const re=ee;export{re 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as r}from"../../../../../layers/graphics/data/projectionSupport.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as a}from"./AAggregateStrategy.js";import{ASendState as o}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as n,FeatureTileUpdateMessage as l}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as c}from"../support/ComputedAttributeStorage.js";import d from"../support/FeatureFilter.js";import{FeatureMetadata as u}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as f}from"../support/FeatureSetReaderJSON.js";import p from"../../../tiling/TileKey.js";import h from"../../../../../geometry/SpatialReference.js";class m extends o{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class g extends a{static async create(e,t,s,a,o){const n=new c({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),u=e.featureFilter?await d.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await r(t,h.WGS84),new g(e,u,o,l,t,s,a)}constructor(e,t,s,r,i,a,o){super(a,o,i,r),this._schema=e,this._featureFilter=t,this._timeZone=s,this._metadata=new u({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:e.fields,globalIdField:null,spatialReference:a.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new m(e,this._attributeStore)}async*applyLocalEdit(e){for(const t of this._sendStates.values()){t.reset();const e=new n(t.subscription,f.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),i=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace()){const{objectId:t,displayId:a}=e,o=r.get(t);if(null!=o){const e=s(a,o,t);i.push(e),r.delete(t)}}return i}getDisplayFeatures(e){const s=new Set(e),r=new Set,i=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace())s.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&i.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:i}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){for(const t of this._sendStates.values())for(const s of t.featuresWorldSpace())e(s)}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,timeZone:this._timeZone,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,timeZone:this._timeZone,scale:s}}}}async*_update(e,t){const{handledChunks:r,subscription:i,bins:a,featureCache:o}=e,n=i.tile;if(e.done)return;for(const s of t.chunks()){if(r.has(s.chunkId))continue;r.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new p(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(a,e.tile.extent,e.tile.resolution)}const c=[],d=i.tile.transform,u=i.tile.key.level;for(const l of a.values()){let e=o.get(l.id);if(
|
|
5
|
+
import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as r}from"../../../../../layers/graphics/data/projectionSupport.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as a}from"./AAggregateStrategy.js";import{ASendState as o}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as n,FeatureTileUpdateMessage as l}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as c}from"../support/ComputedAttributeStorage.js";import d from"../support/FeatureFilter.js";import{FeatureMetadata as u}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as f}from"../support/FeatureSetReaderJSON.js";import p from"../../../tiling/TileKey.js";import h from"../../../../../geometry/SpatialReference.js";class m extends o{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class g extends a{static async create(e,t,s,a,o){const n=new c({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),u=e.featureFilter?await d.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await r(t,h.WGS84),new g(e,u,o,l,t,s,a)}constructor(e,t,s,r,i,a,o){super(a,o,i,r),this._schema=e,this._featureFilter=t,this._timeZone=s,this._metadata=new u({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:e.fields,globalIdField:null,spatialReference:a.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new m(e,this._attributeStore)}async*applyLocalEdit(e){for(const t of this._sendStates.values()){t.reset();const e=new n(t.subscription,f.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),i=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace()){const{objectId:t,displayId:a}=e,o=r.get(t);if(null!=o){const e=s(a,o,t);i.push(e),r.delete(t)}}return i}getDisplayFeatures(e){const s=new Set(e),r=new Set,i=[];for(const a of this._sendStates.values())for(const e of a.featuresWorldSpace())s.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&i.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:i}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){for(const t of this._sendStates.values())for(const s of t.featuresWorldSpace())e(s)}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,timeZone:this._timeZone,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,timeZone:this._timeZone,scale:s}}}}async*_update(e,t){const{handledChunks:r,subscription:i,bins:a,featureCache:o}=e,n=i.tile;if(e.done)return;for(const s of t.chunks()){if(r.has(s.chunkId))continue;r.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new p(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(a,e.tile.extent,e.tile.resolution)}const c=[],d=i.tile.transform,u=i.tile.key.level;for(const l of a.values()){let e=o.get(l.id);if(e)e.attributes=l.getAttributes();else{const t=l.getGeometry(this.spatialReference,d);e=new s(t,l.getAttributes(),null),t||(e.centroid=l.getGeometricCentroid(this.spatialReference,d)),e.objectId=l.id,e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${u}`),o.set(l.id,e)}c.push(e)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const h=f.fromOptimizedFeatures(c,this._metadata,d),m=h.getCursor(),g=e.subscription.tile.createArcadeEvaluationOptions(this._timeZone);for(;m.next();)this._attributeStore.setAttributeData(m.getDisplayId(),m,g);const y=new l(e.subscription,h,[],e.done,{});yield y}}export{m as BinningState,g as BinningStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as w}from"../../../../symbols/support/utils.js";import C from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{SymbolUpdateType as I,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{ApplyRendererDiffResult as A}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as V,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as W,updateFastSymbolUpdatesState as $,evaluateModelTransformScale as q,ConvertOptions as J}from"../support/FastSymbolUpdates.js";import{createTexture as Z,requiresHalfTexelOffset as K,defaultSymbolSizeRatio as Q,defaultTexSize as X}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Y}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as ee}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as te}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as re}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ie}from"../../webgl-engine/materials/HUDMaterial.js";const se=f(0,0,1),oe=16,ae=1.5,ne=Q,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[X*ne,X*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=w(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):oe);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l?.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new M({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=pe("relative",a),i=new re(s,{width:s?.width??1,height:s?.height??1})}else i=new re(new ImageData(1,1),{width:1,height:1});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:pe(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!has("enable-feature:non-occluded-hud"),e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ue(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>Z(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=le;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=_e(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=C(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource?.href?null:this.symbolLayer.resource?.primitive??R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=ue(this._getPrimitive())?ae:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ie(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=W(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ie(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage);const o=window.devicePixelRatio||1;i=[e.parameters.width/o,e.parameters.height/o]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}updateGeometry(e,t){if(this.draped||!this._validateGeometry(t))return!1;const{elevationContext:r,stageObject:i}=e;if(r.mode!==this.getGeometryElevationMode(t))return!1;const s=V(t);if(!s)return!1;const o=H(i,this._context,s,r);if(null==o)return!1;const a=k(this._context,s);return i.geometries[0].localOrigin===a&&(e.alignedSampledElevation=o,B(e,s,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,r,i);if(s!==I.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return A.RecreateSymbol;if(!$(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return A.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return A.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m||null!=de(h))return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=_e(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return fe}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=ee(r,se,null,i,s,ye,null,n,c),m=N(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,j,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),B(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Y;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=ee(r,se,a,i,s,null,null,l,c),m=new te(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=q(ge,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new J({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}function pe(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:I.UPDATE,staysOnTheGround:I.NONE,onTheGroundChanged:I.RECREATE};const fe={mode:"relative-to-ground",offset:0},ye=y(0,0,0,1),ge=_();export{he as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as w}from"../../../../symbols/support/utils.js";import C from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{SymbolUpdateType as I,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{ApplyRendererDiffResult as A}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as V,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as W,updateFastSymbolUpdatesState as $,evaluateModelTransformScale as q,ConvertOptions as J}from"../support/FastSymbolUpdates.js";import{createTexture as Z,requiresHalfTexelOffset as K,defaultSymbolSizeRatio as Q,defaultTexSize as X}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Y}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as ee}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as te}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as re}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ie}from"../../webgl-engine/materials/HUDMaterial.js";const se=f(0,0,1),oe=16,ae=1.5,ne=Q,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[X*ne,X*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=w(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):oe);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l?.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new M({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=pe("relative",a),i=new re(s,{width:s?.width??1,height:s?.height??1,reloadable:!0})}else i=new re(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:pe(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!has("enable-feature:non-occluded-hud"),e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ue(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>Z(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=le;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=_e(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=C(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource?.href?null:this.symbolLayer.resource?.primitive??R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=ue(this._getPrimitive())?ae:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ie(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=W(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ie(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage);const o=window.devicePixelRatio||1;i=[e.parameters.width/o,e.parameters.height/o]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}updateGeometry(e,t){if(this.draped||!this._validateGeometry(t))return!1;const{elevationContext:r,stageObject:i}=e;if(r.mode!==this.getGeometryElevationMode(t))return!1;const s=V(t);if(!s)return!1;const o=H(i,this._context,s,r);if(null==o)return!1;const a=k(this._context,s);return i.geometries[0].localOrigin===a&&(e.alignedSampledElevation=o,B(e,s,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,r,i);if(s!==I.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return A.RecreateSymbol;if(!$(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return A.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return A.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m||null!=de(h))return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=_e(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return fe}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=ee(r,se,null,i,s,ye,null,n,c),m=N(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,j,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),B(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Y;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=ee(r,se,a,i,s,null,null,l,c),m=new te(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=q(ge,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new J({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}function pe(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:I.UPDATE,staysOnTheGround:I.NONE,onTheGroundChanged:I.RECREATE};const fe={mode:"relative-to-ground",offset:0},ye=y(0,0,0,1),ge=_();export{he as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{z as t,s as n,c as o,b as i,n as e}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c,setMin as r,setMax as a}from"../../../../geometry/support/aaBoundingBox.js";import{ContentObjectType as f}from"./ContentObjectType.js";import{assert as u}from"./Util.js";import{VertexAttribute as l}from"./VertexAttribute.js";class m{constructor(t=!1,n=!0){this.isVerticalRay=t,this.normalRequired=n}}const h=c();function p(n,o,i,e,s,c){if(!n.visible)return;const r=t(P,e,i),a=(t,n,o)=>{c(t,o,n,!1)},h=new m(!1,o.options.normalRequired);if(n.boundingInfo){u(n.type===f.Mesh);const t=o.tolerance;b(n.boundingInfo,i,r,t,s,h,a)}else{const t=n.attributes.get(l.POSITION),o=t.indices;V(i,r,0,o.length/3,o,t.data,t.stride,s,h,a)}}const M=s();function b(t,n,o,i,e,s,c){if(null==t)return;const f=C(o,M);if(r(h,t.bbMin),a(h,t.bbMax),null!=e&&e.applyToAabb(h),k(h,n,f,i)){const{primitiveIndices:r,position:a}=t,f=r?r.length:a.indices.length/3;if(f>z){const r=t.getChildren();if(void 0!==r){for(const t of r)b(t,n,o,i,e,s,c);return}}T(n,o,0,f,a.indices,a.data,a.stride,r,e,s,c)}}const d=s();function x(n,o,i,e,s,c,r,a,f){const{data:u,stride:l}=c;V(n,t(P,o,n),i,e,s,u,l,r,a,f)}function g(t,n,o,i,e,s,c,r,a,f=null,u=0){const l=t[0],m=t[1],h=t[2],p=n[0],M=n[1],b=n[2];for(let x=o;x<i;++x){const t=f?f[x]
|
|
5
|
+
import{z as t,s as n,c as o,b as i,n as e}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c,setMin as r,setMax as a}from"../../../../geometry/support/aaBoundingBox.js";import{ContentObjectType as f}from"./ContentObjectType.js";import{assert as u}from"./Util.js";import{VertexAttribute as l}from"./VertexAttribute.js";class m{constructor(t=!1,n=!0){this.isVerticalRay=t,this.normalRequired=n}}const h=c();function p(n,o,i,e,s,c){if(!n.visible)return;const r=t(P,e,i),a=(t,n,o)=>{c(t,o,n,!1)},h=new m(!1,o.options.normalRequired);if(n.boundingInfo){u(n.type===f.Mesh);const t=o.tolerance;b(n.boundingInfo,i,r,t,s,h,a)}else{const t=n.attributes.get(l.POSITION),o=t.indices;V(i,r,0,o.length/3,o,t.data,t.stride,s,h,a)}}const M=s();function b(t,n,o,i,e,s,c){if(null==t)return;const f=C(o,M);if(r(h,t.bbMin),a(h,t.bbMax),null!=e&&e.applyToAabb(h),k(h,n,f,i)){const{primitiveIndices:r,position:a}=t,f=r?r.length:a.indices.length/3;if(f>z){const r=t.getChildren();if(void 0!==r){for(const t of r)b(t,n,o,i,e,s,c);return}}T(n,o,0,f,a.indices,a.data,a.stride,r,e,s,c)}}const d=s();function x(n,o,i,e,s,c,r,a,f){const{data:u,stride:l}=c;V(n,t(P,o,n),i,e,s,u,l,r,a,f)}function g(t,n,o,i,e,s,c,r,a,f=null,u=0){const l=t[0],m=t[1],h=t[2],p=n[0],M=n[1],b=n[2];for(let x=o;x<i;++x){const t=u+(f?f[x]:x),n=3*t,o=c*e[n],i=s[o],g=s[o+1],y=s[o+2],T=c*e[n+1],V=s[T],j=s[T+1],q=s[T+2],v=c*e[n+2],R=V-i,O=j-g,A=q-y,B=s[v]-i,C=s[v+1]-g,k=s[v+2]-y,w=M*k-C*b,z=b*B-k*p,P=p*C-B*M,S=R*w+O*z+A*P;if(Math.abs(S)<=N)continue;const U=l-i,D=m-g,E=h-y,F=U*w+D*z+E*P;if(S>0){if(F<0||F>S)continue}else if(F>0||F<S)continue;const G=D*A-O*E,H=E*R-A*U,J=U*O-R*D,K=p*G+M*H+b*J;if(S>0){if(K<0||F+K>S)continue}else if(K>0||F+K<S)continue;const L=(B*G+C*H+k*J)/S;if(L>=0){a(L,t,r?I(R,O,A,B,C,k,d):null)}}}function y(t,n,o,i,e,s,c,r,a,f,u,l=null,m=0){const h=t[0],p=t[1],M=t[2],b=n[0],x=n[1],g=n[2];for(let y=o;y<i;++y){const t=m+(l?l[y]:y),n=3*t,o=c*e[n],i=s[o],T=s[o+1],V=s[o+2],j=c*e[n+1],q=s[j],v=s[j+1],R=s[j+2],O=c*e[n+2],A=s[O],B=s[O+1],C=s[O+2],k=V-a,w=r/Math.sqrt(i*i+T*T+k*k),z=i+i*w,P=T+T*w,S=V+k*w,U=R-a,D=r/Math.sqrt(q*q+v*v+U*U),E=q+q*D,F=v+v*D,G=R+U*D,H=C-a,J=r/Math.sqrt(A*A+B*B+H*H),K=E-z,L=F-P,Q=G-S,W=A+A*J-z,X=B+B*J-P,Y=C+H*J-S,Z=x*Y-X*g,$=g*W-Y*b,_=b*X-W*x,tt=K*Z+L*$+Q*_;if(Math.abs(tt)<=N)continue;const nt=h-z,ot=p-P,it=M-S,et=nt*Z+ot*$+it*_;if(tt>0){if(et<0||et>tt)continue}else if(et>0||et<tt)continue;const st=ot*Q-L*it,ct=it*K-Q*nt,rt=nt*L-K*ot,at=b*st+x*ct+g*rt;if(tt>0){if(at<0||et+at>tt)continue}else if(at>0||et+at<tt)continue;const ft=(W*st+X*ct+Y*rt)/tt;if(ft>=0){u(ft,t,f?I(K,L,Q,W,X,Y,d):null)}}}function T(t,n,o,i,e,s,c,r,a,f,u){const l=t[0],m=t[1],h=t[2],p=n[0],M=n[1],b=n[2],{normalRequired:x}=f;for(let g=o;g<i;++g){const t=r[g],n=3*t,o=c*e[n];let i=s[o],f=s[o+1],y=s[o+2];const T=c*e[n+1];let V=s[T],j=s[T+1],q=s[T+2];const v=c*e[n+2];let R=s[v],O=s[v+1],A=s[v+2];null!=a&&([i,f,y]=a.applyToVertex(i,f,y,g),[V,j,q]=a.applyToVertex(V,j,q,g),[R,O,A]=a.applyToVertex(R,O,A,g));const B=V-i,C=j-f,k=q-y,w=R-i,z=O-f,P=A-y,S=M*P-z*b,U=b*w-P*p,D=p*z-w*M,E=B*S+C*U+k*D;if(Math.abs(E)<=N)continue;const F=l-i,G=m-f,H=h-y,J=F*S+G*U+H*D;if(E>0){if(J<0||J>E)continue}else if(J>0||J<E)continue;const K=G*k-C*H,L=H*B-k*F,Q=F*C-B*G,W=p*K+M*L+b*Q;if(E>0){if(W<0||J+W>E)continue}else if(W>0||J+W<E)continue;const X=(w*K+z*L+P*Q)/E;if(X>=0){u(X,t,x?I(B,C,k,w,z,P,d):null)}}}function V(i,e,s,c,r,a,f,u,l,m){const h=e,p=S,M=Math.abs(h[0]),b=Math.abs(h[1]),d=Math.abs(h[2]),x=M>=b?M>=d?0:2:b>=d?1:2,g=x,y=h[g]<0?2:1,T=(x+y)%3,V=(x+(3-y))%3,I=h[T]/h[g],O=h[V]/h[g],A=1/h[g],B=j,C=q,k=v,{normalRequired:w}=l;for(let j=s;j<c;++j){const e=3*j,s=f*r[e];n(p[0],a[s+0],a[s+1],a[s+2]);const c=f*r[e+1];n(p[1],a[c+0],a[c+1],a[c+2]);const l=f*r[e+2];n(p[2],a[l+0],a[l+1],a[l+2]),u&&(o(p[0],u.applyToVertex(p[0][0],p[0][1],p[0][2],j)),o(p[1],u.applyToVertex(p[1][0],p[1][1],p[1][2],j)),o(p[2],u.applyToVertex(p[2][0],p[2][1],p[2][2],j))),t(B,p[0],i),t(C,p[1],i),t(k,p[2],i);const h=B[T]-I*B[g],M=B[V]-O*B[g],b=C[T]-I*C[g],d=C[V]-O*C[g],x=k[T]-I*k[g],y=k[V]-O*k[g],q=x*d-y*b,v=h*y-M*x,z=b*M-d*h;if((q<0||v<0||z<0)&&(q>0||v>0||z>0))continue;const N=q+v+z;if(0===N)continue;const P=q*(A*B[g])+v*(A*C[g])+z*(A*k[g]);if(P*Math.sign(N)<0)continue;const S=P/N;if(S>=0){m(S,j,w?R(p):null)}}}const j=s(),q=s(),v=s();function I(t,o,s,c,r,a,f){return n(O,t,o,s),n(A,c,r,a),i(f,O,A),e(f,f),f}function R(n){return t(O,n[1],n[0]),t(A,n[2],n[0]),i(d,O,A),e(d,d),d}const O=s(),A=s();function B(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function C(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function k(t,n,o,i){return w(t,n,o,i,1/0)}function w(t,n,o,i,e){const s=(t[0]-i-n[0])*o[0],c=(t[3]+i-n[0])*o[0];let r=Math.min(s,c),a=Math.max(s,c);const f=(t[1]-i-n[1])*o[1],u=(t[4]+i-n[1])*o[1];if(a=Math.min(a,Math.max(f,u)),a<0)return!1;if(r=Math.max(r,Math.min(f,u)),r>a)return!1;const l=(t[2]-i-n[2])*o[2],m=(t[5]+i-n[2])*o[2];return a=Math.min(a,Math.max(l,m)),!(a<0)&&(r=Math.max(r,Math.min(l,m)),!(r>a)&&r<e)}const z=1e3,N=1e-7,P=s(),S=[s(),s(),s()];export{m as MeshIntersectionOptions,B as computeInvDir,C as computeInvDirFromDirection,I as computeNormalFromBarycentric,k as intersectAabbInvDir,w as intersectAabbInvDirBefore,g as intersectRayTriangles,V as intersectRayTrianglesWithDisplacementWatertight,y as intersectRayTrianglesWithVerticalOffsetENUGlobal,p as intersectTriangleGeometry,x as intersectTriangles,N as triangleRayParallelTolerance};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o=s?.feature??e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>{this.grid?.scrollLeft(0),this.layer?.loaded&&this._generateColumns()})),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o=s?.feature??e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{substitute as i}from"../../intl/substitute.js";import r from"./Grid/Column.js";import{isIFeatureTableSupportedLayerWithRelationships as s}from"./support/tableUtils.js";const l={showRecordsButton:"esri-column__show-related-records-button"};let n=class extends r{constructor(t){super(t),this.flexGrow=1,this.icon="link",this.layer=null,this.relatedLayer=null,this.relationshipId=null,this.renderFunction=({root:t,rowData:e})=>{if(!e)return;const o=e.item,{layer:r,relatedLayer:n}=this;if(!o?.feature||!s(r)||!s(n))return;const{messages:a}=this,{index:p}=e,{feature:c}=o,{collapsed:d,showRelatedTableCallback:h,relationshipId:u}=this,y=o.relatedRecords,b=y?.find((t=>t.relationshipId===u))?.count??0,f=!d&&h&&a?.recordsCount?i(a.recordsCount,{count:b}):`${b}`,m=()
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{substitute as i}from"../../intl/substitute.js";import r from"./Grid/Column.js";import{isIFeatureTableSupportedLayerWithRelationships as s}from"./support/tableUtils.js";const l={showRecordsButton:"esri-column__show-related-records-button"};let n=class extends r{constructor(t){super(t),this.flexGrow=1,this.icon="link",this.layer=null,this.relatedLayer=null,this.relationshipId=null,this.renderFunction=({root:t,rowData:e})=>{if(!e)return;const o=e.item,{layer:r,relatedLayer:n}=this;if(!o?.feature||!s(r)||!s(n))return;const{messages:a}=this,{index:p}=e,{feature:c}=o,{collapsed:d,showRelatedTableCallback:h,relationshipId:u}=this,y=o.relatedRecords,b=y?.find((t=>t.relationshipId===u))?.count??0,f=!d&&h&&a?.recordsCount?i(a.recordsCount,{count:b}):`${b}`,m=t=>{t.preventDefault(),d||this.showRelatedTableCallback?.({feature:c,index:p,layer:r,relatedLayer:n,relationshipId:u})},C=d?"":"chevron-right";if(t.firstChild){const e=t.firstChild;return e.textContent=f,e.onclick=m,void(e.iconEnd=C)}const g=this.createCalciteButton({className:l.showRecordsButton,iconEnd:C,iconFlipRtl:"both",scale:"m",textContent:f,onclick:m});this.removeCellContent(t),t.appendChild(g)},this.resizable=!0,this.showRelatedTableCallback=null,this.textAlign="center",this.width="200px"}get _relationshipLabel(){return this.label||this.originRelationship?.name||this.layer.title||""}get collapsed(){return this._get("collapsed")||!1}set collapsed(t){t?this.set({flexGrow:0,resizable:!1,width:"80px"}):this.set({flexGrow:1,resizable:!0,width:"200px"}),this._set("collapsed",t)}get effectiveLabel(){return this.collapsed?"":this._relationshipLabel}get iconNode(){const{icon:t}=this;return t?this.createCalciteIcon({icon:t,textLabel:this._relationshipLabel}):null}get originRelationship(){const t=this.relationshipId;return this.relatedLayer.relationships?.find((({id:e})=>e===t))}get relationship(){const t=this.relationshipId;return this.layer.relationships?.find((({id:e})=>e===t))}};t([e()],n.prototype,"_relationshipLabel",null),t([e()],n.prototype,"collapsed",null),t([e()],n.prototype,"effectiveLabel",null),t([e()],n.prototype,"flexGrow",void 0),t([e()],n.prototype,"icon",void 0),t([e()],n.prototype,"iconNode",null),t([e()],n.prototype,"layer",void 0),t([e()],n.prototype,"originRelationship",null),t([e()],n.prototype,"relatedLayer",void 0),t([e()],n.prototype,"relationship",null),t([e()],n.prototype,"relationshipId",void 0),t([e()],n.prototype,"renderFunction",void 0),t([e()],n.prototype,"resizable",void 0),t([e()],n.prototype,"showRelatedTableCallback",void 0),t([e()],n.prototype,"textAlign",void 0),t([e()],n.prototype,"width",void 0),n=t([o("esri.widgets.FeatureTable.RelationshipColumn")],n);const a=n;export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/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{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as H,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as q,activeSourcePointSymbol as J,sourcePointSymbol as $}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,isSceneView as Y,isGraphic as Z,calculateSegment as ee,calculateDirection as te}from"./utils.js";import ie from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=/\.(\w+)$/,le=e=>"FA"===e;let he=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i}=this;if(t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(r){g(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new ie,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url;let n=s?e.match(ne)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":if(ae.has(n.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new re(d);let F=s;if(le(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new re({...h(e)?e.toJSON():e,spatialReference:oe.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new re(n,oe.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,T.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e}=this,{imageSize:t,fov:i,imageRenderer:{size:r},pitch:o,yaw:s}=this._panoramicViewer;if(!e||!t)return null;return[i/(r[0]/r[1]),i,s,o]}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?H.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),t>0&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[H[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new re({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new re({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new re(n,oe.WebMercator),symbol:q}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of H)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=ee(t,n),l=te(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=s.find((e=>e.imageID===o[0].attributes.objectId)).clone();n&&!n.contains(o[0].geometry)&&n.addRing([o[0].geometry]);const l=n.extent;let h;if(this.footprintExtent=l,this.view?.supportsGround)try{h=await this.view.map.ground.createElevationSampler(l,i)}catch(p){g(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=h,(h||o[0].attributes.elevationSource)&&l){const e=await k([t],{feature:o[0],footprintExtent:l,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Y(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const c=this._suitabilities.map((e=>e.feature));this.currentBestFeature=c[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:J,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Z);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint.destroy()),this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:void 0))}}};e([_()],he.prototype,"activeLayer",null),e([_({readOnly:!0})],he.prototype,"activeViewer",null),e([_()],he.prototype,"additionalFeatures",void 0),e([_()],he.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],he.prototype,"brightness",null),e([_({type:Number})],he.prototype,"contrast",null),e([_()],he.prototype,"coverageFrustums",void 0),e([_()],he.prototype,"coveragePolygons",void 0),e([_()],he.prototype,"currentBestFeature",void 0),e([_()],he.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([_()],he.prototype,"disabled",void 0),e([_()],he.prototype,"displayMessage",void 0),e([_()],he.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],he.prototype,"featureCount",null),e([_()],he.prototype,"features",void 0),e([_({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],he.prototype,"imageLoaded",null),e([_()],he.prototype,"imagePointsInView",null),e([_()],he.prototype,"isAdditionalCoverageVisible",void 0),e([_()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],he.prototype,"layer",void 0),e([_({type:Number})],he.prototype,"localPort",void 0),e([_()],he.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([_()],he.prototype,"navigatorCurrentBestFeature",void 0),e([_()],he.prototype,"pointSources",void 0),e([_({readOnly:!0})],he.prototype,"popupEnabled",null),e([_()],he.prototype,"previousFeatureAngle",void 0),e([_()],he.prototype,"referencePoint",null),e([_({readOnly:!0})],he.prototype,"sectorData",null),e([_()],he.prototype,"selectedPoint",void 0),e([_({type:Number})],he.prototype,"sharpness",null),e([_()],he.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],he.prototype,"state",null),e([_({readOnly:!0})],he.prototype,"thumbnails",null),e([_()],he.prototype,"updateFootprint",void 0),e([_()],he.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],he.prototype,"view",null),e([_()],he.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalCameraLocations",void 0),e([_()],he.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],he.prototype,"_fetchFeaturesController",void 0),e([_()],he.prototype,"_highlightedFeatureHandle",void 0),e([_()],he.prototype,"_imageViewer",void 0),e([_({type:t})],he.prototype,"bestFeatureFootprint",void 0),e([_()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],he.prototype,"_loading",void 0),e([_()],he.prototype,"_overlays",void 0),e([_({readOnly:!0})],he.prototype,"_overlaysView",null),e([_()],he.prototype,"_panoramicViewer",void 0),e([_()],he.prototype,"_referencePointOnGround",void 0),e([_()],he.prototype,"_referencePointOnImage",void 0),e([_()],he.prototype,"currentBestFeatureLocation",void 0),e([_()],he.prototype,"_sectorData",void 0),e([_()],he.prototype,"footprintExtent",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ce=he;export{ce as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as i,equals as r}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{isSerializable as h}from"../../core/JSONSupport.js";import{equalsShallow as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as m}from"../../core/maybe.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import{watch as F,syncAndInitial as v,initial as w}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{isPolygon as P}from"../../geometry/support/jsonUtils.js";import{geographicToWebMercator as I}from"../../geometry/support/webMercatorUtils.js";import C from"../../layers/GraphicsLayer.js";import{searchImages as V}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as S}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as O,computePolygonForInspection as j,resizePolygon as A,checkIfPolygonContainsSelectedPoint as B}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as k,transformPoints as L}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as G}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import{getInitialAngle as M,convertPixelToHeadingPitch as E,convertHeadingPitchToSphereVertex as R}from"../../layers/orientedImagery/transformations/utils.js";import x from"../../rest/support/AttachmentQuery.js";import{ViewEventPriorities as T}from"../../views/input/InputManager.js";import D from"../PanoramicViewer.js";import{sectorsInOrder as H,sectorsRadii as U}from"./constants.js";import{crossSymbol as N,crossSymbol3D as z,diamondSymbol as W,diamondSymbol3D as q,activeSourcePointSymbol as J,sourcePointSymbol as $}from"./symbols.js";import{getContentType as K,isNoAttachmentError as Q,isTifOrMrf as X,isSceneView as Y,isGraphic as Z,calculateSegment as ee,calculateDirection as te}from"./utils.js";import ie from"./components/ImageViewer.js";import re from"../../geometry/Point.js";import oe from"../../geometry/SpatialReference.js";const se={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles"},ae=new Set(["JPG","JPEG"]),ne=/\.(\w+)$/,le=e=>"FA"===e;let he=class extends l.EventedAccessor{constructor(e){super(e),this.additionalFeatures=new s,this.bestFeatureAngle=0,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=()=>{d(this._featureChangedTask),this._featureChangedTask=o((async e=>{const{currentBestFeature:t,selectedPoint:i,view:r}=this;if(r?.closePopup(),t&&i){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:e}),await this._loadImage({signal:e})}catch(o){g(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}}))},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)},this.features=new s,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.navigatorCurrentBestFeature=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this.additionalFootprints=new s,this.additionalCameraLocations=new s,this.bestFeatureCurrentFootprint=null,this._fetchFeaturesController=null,this._highlightedFeatureHandle=null,this._imageViewer=new ie,this.bestFeatureFootprint=null,this._initialCurrentCoverageUpdate=!0,this._loading=!1,this._overlays=new C({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new D,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadImageFromSource=async(e,t)=>{const{mode:i,imageRotation:r,options:o}=t,s="string"==typeof e,a=s?e:e.url;let n=s?e.match(ne)?.[1]??"":e.datasetFormat;if(!n){const e=await K(a,{...t.options});e&&(n=e.split("/")[1]),n??="UNKNOWN FORMAT"}switch(i){case"default":{this._imageViewer.imageSource={datasetFormat:n.toUpperCase(),url:a};const e=new URL(a);this._imageViewer.customParameters=Object.fromEntries(e.searchParams),this._imageViewer.imageRotation=r??0,await this._imageViewer.loadImage(o);break}case"panoramic":if(ae.has(n.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:r,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=a;let l=r??0;"number"==typeof n?l=n-l:s&&e&&(l=await M(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(o)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:n});break}},this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=o((async e=>{const{currentBestFeature:i,popupEnabled:r,layer:o,view:s}=this;if(s?.closePopup(),!(s&&i&&r&&o))return;const{attributes:a,geometry:n}=i,l=new t({geometry:n,attributes:a.toJSON(),popupTemplate:o.popupTemplate});y(e),await s.openPopup({features:[l],location:a.location.clone()})}))},this._getImageSourceFromAttachment=async(e,t,i)=>{const r=new x({objectIds:[t]}),o=await e.queryAttachments(r,i),s=o[`${t}`]?.[0],a=s?.url;if(!a)throw new n("NoAttachmentError","no attachments found",{[e.objectIdField]:t,layer:e});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:a}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),!i||!t||"none"===r)return;const{attributes:o}=t,{imagePath:s,imageRotation:a,cameraHeading:n,cameraRoll:l,cameraPitch:h,objectId:c,cameraOrientation:p,location:d}=o,m=(l??0)+(a??0),f=d.spatialReference.isWGS84&&4!==p?.type?I(d):new re(d);let F=s;if(le(s))try{F=await this._getImageSourceFromAttachment(i,c,e)}catch(v){if(g(v))return;return Q(v)?(u.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${c}`)):(u.getLogger(this).error(v,{[i.objectIdField]:c,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${c}`))}try{await this.loadImageFromSource(F,{imageRotation:m,options:e,pitch:h,yaw:n,mode:r,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(v){g(v)||this.loadImageError(v)}},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{"mouse"===e.pointerType&&0!==e.button||(e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.loadBestImage(e.mapPoint))},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new re({...h(e)?e.toJSON():e,spatialReference:oe.WebMercator});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,this._crossSymbol=new t({geometry:r,symbol:N}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._crossSymbol=new t({geometry:new re(n,oe.WebMercator),symbol:z}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this),this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([F((()=>this.view),(async e=>{if(e){switch(this._loading=!0,e.type){case"2d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter2D.js");this._adapter=new e(this);break}case"3d":{const{default:e}=await import("./adapters/OrientedImageryViewerViewModelAdapter3D.js");this._adapter=new e(this);break}}this._loading=!1}else this._adapter=null}),v),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),w),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),w),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{if(this.removeHandles(se.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,T.WIDGET),se.click),this.removeHandles(se.imageClick);const{mapImageConversionToolState:t,mode:i}=this;if(t&&"none"!==i)switch(i){case"default":this._imageViewer.clickAction="pixel-location",this.addHandles(this._imageViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature;if(t){const i=(await G([e.toJSON()],{feature:t,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];i&&this.plotReferencePointOnGround(i)}})),se.imageClick);break;case"panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",(async e=>{this.plotReferencePointOnImage(e);const t=this.currentBestFeature,{imageSize:i}=this._panoramicViewer;if(t&&e&&i){const r=(await G([e],{feature:t,imageProperties:{width:i[0],height:i[1]},options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0];r&&this.plotReferencePointOnGround(r)}})),se.imageClick)}}),v),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),v),F((()=>this.currentBestFeature),((e,t)=>{this.determineWorkflowForFeature(e,t)}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(se.interactionHandles),e){case"default":this.addHandles(F((()=>this._imageViewer.imagePointsInView),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=o((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e}=this,{imageSize:t,vfov:i,hfov:r,pitch:o,yaw:s}=this._panoramicViewer;return e&&t?[i,r,s,o]:null}),(e=>{if(!e||"image-loading"===this.state)return;const[t,i,r,s]=e;d(this._updateFootprintTask),this._updateFootprintTask=o((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e})}))}),{...v,equals:(e,t)=>r(e,t,c)}),se.interactionHandles)}}),v),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:o}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=o)}),v)])}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._cancelFetchingFeatures(),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy()}get activeLayer(){return a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){a(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",e>10?10:e<-10?-10:e)}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return X(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){return a(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?H.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get state(){const{mode:e,disabled:t}=this;if(t)return"disabled";if(this._loading)return"image-loading";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const o=e.trim();return X(o)?{url:o,objectId:t,rotation:(i??0)+(r??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}filterByFootprints(e,t){const i=[],r=[],o=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:a}=e;let n;const{polygon:l,frustum:h}=O(a);if(n=l.clone(),a.isInspection&&(n=j(a)),s&&(n=A(n,s)),B(n,t)){o.push(e);const{cameraHeading:t,geometry:s,objectId:n,cameraHeight:c}=a,u=s.clone();u.z=c,u.imageID=n,this.pointSources.push(u),t>0&&(i.push(l),h&&r.push(h))}})),{features:o,polygons:i,frustums:r}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[H[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t];r?.length&&this._updateCurrentBestFeature(r.at(i))}async loadBestImage(e){this._loading=!0,this.view?.closePopup(),this.displayMessage=null,this.selectedPoint=e.spatialReference.isGeographic?I(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),await this._fetchFeaturesWithController(e)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new re({...e.toJSON()}),symbol:W}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),this.mode){case"default":{const i=h(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new re({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:W}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[r,o]=i,{heading:s,pitch:a}=E(e,r,o),n=R(s,a);this._referencePointOnImage=new t({geometry:new re(n,oe.WebMercator),symbol:q}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(e,t){try{const i=await V(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){g(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e,r=this.bestFeatureFootprint?.geometry,o=P(r)&&r.contains(t),s="mesh"===r?.type&&r?.extent.contains(t);if(!o&&!s)return;const a=await this.transformPoint(t,i);return a?(this.plotReferencePointOnImage(a),{x:a.x,y:a.y}):void 0}updateSuitabilities(e){this._suitabilities=e.sort(((e,t)=>e.suitability-t.suitability));const t=this._suitabilities.map((e=>e.feature));this._updateFeatures(t),this._groupFeaturesBySectors(),this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(e){const t=this._fetchFeaturesController;t&&t.abort(e),this._fetchFeaturesController=null}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const r={include:i},o=this.view.toScreen(e);if(!o)return;const s=await this.view.hitTest(o,r);this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:i}=t;this._fetchFeaturesController=t;try{await this._fetchFeatures(e,{signal:i}).finally((()=>{this._fetchFeaturesController=null}))}catch(r){this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",r)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:r}=this;if(!(e&&t&&i&&r))return void(this._sectorData=null);this._sectorData={};for(const l of H)this._sectorData[l]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const a=o.map((({distance:e})=>e)),n=Math.max(...a);o.forEach((e=>{const{distance:t,angle:i,featureIndex:o}=e,s=t/n*U[2],a=ee(t,n),l=te(i);if(!this._sectorData)return;const h=U[3]+s*Math.sin(i*Math.PI/180),c=U[3]+s*Math.cos(i*Math.PI/180);let u;const p=r.at(o),d=p===this.currentBestFeature,m=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(d&&m)u=-90;else{const e=h-U[3],t=c-U[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),u=r}const g=""===a?l:`${a}_${l}`;d&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=m?null:{x:h,y:c,direction:l});const y=this._sectorData[g];y.add({angle:i,featureIndex:o,x:h,y:c,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}async _processFeatureResponse(e,t,i){const{features:r}=e;if(!r?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:o,polygons:s,frustums:a}=this.filterByFootprints(r,t);if(!o.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(a);const n=s.find((e=>e.imageID===o[0].attributes.objectId)).clone();n&&!n.contains(o[0].geometry)&&n.addRing([o[0].geometry]);const l=n.extent;let h;if(this.footprintExtent=l,this.view?.supportsGround)try{h=await this.view.map.ground.createElevationSampler(l,i)}catch(p){g(p)||u.getLogger(this).error(p)}if(o[0].elevationSample=h,(h||o[0].attributes.elevationSource)&&l){const e=await k([t],{feature:o[0],footprintExtent:l,options:i});if(e[0]){const i=e[0];t.elevation=i.z}}o[0].elevationSample&&o.forEach((e=>{e.elevationSample=o[0].elevationSample})),this._suitabilities=S({features:o,selectedPoint:t,camera:Y(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities);const c=this._suitabilities.map((e=>e.feature));this.currentBestFeature=c[0],this._loading=!1}async _processHitTestResults(e,t,i){const{screenPoint:r,results:[o]}=t,s="graphic"===o?.type&&this.shouldShowSelectedImage,a=o?.mapPoint??this.view?.toMap(r);if(!a)return;const n={layerInstanceOrURL:e,point:a,queryParams:{where:e.definitionExpression??"1=1",maximumDistance:e.maximumDistance,objectIds:s?[o.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(n,i)}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.currentBestFeature=e[0],e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll()}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:o,isAdditionalPointSourcesVisible:s}=this;if(r){this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),await(this._adapter?.createFootprints(e)),y(e);for(const e of i)e.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e,symbol:J,visible:o}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e,symbol:$,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-U[3],r=e.y-U[3],o=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(o)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this._loading=!1,this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,selectedPoint:i,state:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r)return;let o;try{o=await this.transformPoint(i,e),y(e),await this.plotSelectedPointOnImage(o,e)}catch(s){g(s)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:s,selectedPoint:i,feature:t})}}async transformPoint(e,t){if("none"===this.mode)return;const i=this.currentBestFeature,r=await L([e],{feature:i,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:t},"3d"===this.view?.type);if(!r.length)return;return r[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:o,currentBestFeatureLocation:s,currentCoverageVisible:a,selectedPoint:n,view:l,_adapter:h}=this,{attributes:{objectId:c},elevationSample:u}=o;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&(e.visible=a,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,this.bestFeatureCurrentFootprint,s].filter(Z);l.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation(e,u),n&&e.push(new t({geometry:n.clone(),symbol:N.clone(),attributes:{imageID:c}})),this._overlays.graphics.addMany(e)}}else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&u&&h?.updateGroundElevation&&h.updateGroundElevation([e],u),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:void 0))}}};e([_()],he.prototype,"activeLayer",null),e([_({readOnly:!0})],he.prototype,"activeViewer",null),e([_()],he.prototype,"additionalFeatures",void 0),e([_()],he.prototype,"bestFeatureAngle",void 0),e([_({type:Number})],he.prototype,"brightness",null),e([_({type:Number})],he.prototype,"contrast",null),e([_()],he.prototype,"coverageFrustums",void 0),e([_()],he.prototype,"coveragePolygons",void 0),e([_()],he.prototype,"currentBestFeature",void 0),e([_()],he.prototype,"currentCoverageVisible",void 0),e([_({json:{write:!1}})],he.prototype,"determineWorkflowForFeature",void 0),e([_()],he.prototype,"disabled",void 0),e([_()],he.prototype,"displayMessage",void 0),e([_()],he.prototype,"drawFootprint",void 0),e([_({readOnly:!0})],he.prototype,"featureCount",null),e([_()],he.prototype,"features",void 0),e([_({readOnly:!0})],he.prototype,"imageGalleryEnabled",null),e([_({readOnly:!0})],he.prototype,"imageLoaded",null),e([_()],he.prototype,"imagePointsInView",null),e([_()],he.prototype,"isAdditionalCoverageVisible",void 0),e([_()],he.prototype,"isAdditionalPointSourcesVisible",void 0),e([_()],he.prototype,"layer",void 0),e([_({type:Number})],he.prototype,"localPort",void 0),e([_()],he.prototype,"mapImageConversionToolState",void 0),e([_({readOnly:!0,value:"none"})],he.prototype,"mode",null),e([_()],he.prototype,"navigatorCurrentBestFeature",void 0),e([_()],he.prototype,"pointSources",void 0),e([_({readOnly:!0})],he.prototype,"popupEnabled",null),e([_()],he.prototype,"previousFeatureAngle",void 0),e([_()],he.prototype,"referencePoint",null),e([_({readOnly:!0})],he.prototype,"sectorData",null),e([_()],he.prototype,"selectedPoint",void 0),e([_({type:Number})],he.prototype,"sharpness",null),e([_()],he.prototype,"shouldShowSelectedImage",void 0),e([_({readOnly:!0})],he.prototype,"state",null),e([_({readOnly:!0})],he.prototype,"thumbnails",null),e([_()],he.prototype,"updateFootprint",void 0),e([_()],he.prototype,"updateFootprintPanorama",void 0),e([_({value:null})],he.prototype,"view",null),e([_()],he.prototype,"_adapter",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalFootprints",void 0),e([_({type:s.ofType(t)})],he.prototype,"additionalCameraLocations",void 0),e([_()],he.prototype,"bestFeatureCurrentFootprint",void 0),e([_()],he.prototype,"_fetchFeaturesController",void 0),e([_()],he.prototype,"_highlightedFeatureHandle",void 0),e([_()],he.prototype,"_imageViewer",void 0),e([_({type:t})],he.prototype,"bestFeatureFootprint",void 0),e([_()],he.prototype,"_initialCurrentCoverageUpdate",void 0),e([_()],he.prototype,"_loading",void 0),e([_()],he.prototype,"_overlays",void 0),e([_({readOnly:!0})],he.prototype,"_overlaysView",null),e([_()],he.prototype,"_panoramicViewer",void 0),e([_()],he.prototype,"_referencePointOnGround",void 0),e([_()],he.prototype,"_referencePointOnImage",void 0),e([_()],he.prototype,"currentBestFeatureLocation",void 0),e([_()],he.prototype,"_sectorData",void 0),e([_()],he.prototype,"footprintExtent",void 0),he=e([b("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],he);const ce=he;export{ce as default};
|