@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.34 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Graphic.js";import r from"../../../../request.js";import i from"../../../../core/Accessor.js";import s from"../../../../core/Logger.js";import{isAbortError as a}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Extent.js";import{srToRESTValue as p}from"../../../../geometry/support/spatialReferenceUtils.js";import{projectExtent as h}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{snapImageToSymbolTile as y,convertVectorFieldData as u}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFContainer as x}from"../../engine/imagery/RasterVFContainer.js";import d from"./ImageryVFStrategy.js";let f=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new x,this.type="imageryVF",this._dataParameters={exportParametersVersion:0,bbox:"",symbolTileSize:0,time:""},this._fetchpixels=async(t,e,r,i)=>{const s=await this._projectFullExtentPromise,{symbolTileSize:a}=this.layer.renderer,{extent:o,width:n,height:l}=y(t,e,r,a,s);if(null!=s&&!s.intersects(t))return{extent:o,pixelBlock:null};const m={bbox:`${o.xmin}, ${o.ymin}, ${o.xmax}, ${o.ymax}`,exportParametersVersion:this.layer.exportImageServiceParameters.version,symbolTileSize:a,time:JSON.stringify(this.timeExtent||"")};if(this._canReuseVectorFieldData(m)){const t=this.getPixelData();if(null!=t){if(`${t.extent.xmin}, ${t.extent.ymin}, ${t.extent.xmax}, ${t.extent.ymax}`===m.bbox)return t}}const{pixelData:c}=await this.layer.fetchImage(o,n,l,{timeExtent:this.timeExtent,requestAsImageElement:!1,signal:i});this._dataParameters=m;const p=c?.pixelBlock;if(null==p)return{extent:o,pixelBlock:null};return{extent:o,pixelBlock:"vector-uv"===this.layer.rasterInfo.dataType?u(p,"vector-uv"):p}}}get updating(){return!this.attached||this._strategy.updating}attach(){this._projectFullExtentPromise=this._getProjectedFullExtent(this.view.spatialReference),this._strategy=new d({container:this.container,fetchPixels:this._fetchpixels}),this.addHandles(o((()=>this.layer.renderer),(t=>this._updateSymbolizerParams(t)),n),"attach")}detach(){this._strategy.destroy(),this.container.children.forEach((t=>t.destroy())),this.container.removeAllChildren(),this.removeHandles("attach"),this._strategy=this.container=this._projectFullExtentPromise=null}getPixelData(){const t=this.container.children[0]?.rawPixelData;if(this.updating||!t)return null;const{extent:e,pixelBlock:r}=t;return{extent:e,pixelBlock:r}}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}update(t){this._strategy.update(t,this._symbolizerParams).catch((t=>{a(t)||s.getLogger(this).error(t)}))}redraw(){const{renderer:t}=this.layer;t&&(this._updateSymbolizerParams(t),this._strategy.redraw(this._symbolizerParams))}_canReuseVectorFieldData(t){const e=this._dataParameters.exportParametersVersion===t.exportParametersVersion,r=this._dataParameters.time===t.time,i=this._dataParameters.symbolTileSize===t.symbolTileSize,s=this._dataParameters.bbox===t.bbox;return e&&r&&i&&s}async _getProjectedFullExtent(t){try{return h(this.layer.fullExtent,t)}catch(e){try{const e=(await r(this.layer.url,{query:{option:"footprints",outSR:p(t),f:"json"}})).data.featureCollection.layers[0].layerDefinition.extent;return e?c.fromJSON(e):null}catch{return null}}}_updateSymbolizerParams(t){"vector-field"===t?.type&&(this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null}))}};t([l()],f.prototype,"attached",void 0),t([l()],f.prototype,"container",void 0),t([l()],f.prototype,"layer",void 0),t([l()],f.prototype,"timeExtent",void 0),t([l()],f.prototype,"type",void 0),t([l()],f.prototype,"view",void 0),t([l()],f.prototype,"updating",null),f=t([m("esri.views.2d.layers.imagery.VectorFieldView2D")],f);const g=f;export{g as default};