@arcgis/core 4.27.0-next.20230421 → 4.27.0-next.20230422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/085e9a46ee3a8a1a5e20.js +1 -0
- package/assets/esri/core/workers/chunks/5f3899efbb967c6e8422.js +1 -0
- package/assets/esri/core/workers/chunks/f47046967c3b13996a14.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -0
- package/assets/esri/themes/base/widgets/_FeatureMedia.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Popup/t9n/Popup.json +1 -1
- package/assets/esri/widgets/Popup/t9n/Popup_en.json +1 -1
- package/chunks/Button.js +5 -0
- package/chunks/ColorSet.js +5 -0
- package/chunks/DefaultTheme.js +5 -0
- package/chunks/Theme.js +5 -0
- package/chunks/Tick.js +5 -0
- package/chunks/Tooltip.js +5 -0
- package/interfaces.d.ts +6 -0
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
- package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/FeatureMedia/chartCommon.js +5 -0
- package/widgets/Feature/FeatureMedia/pieChart.js +5 -0
- package/widgets/Feature/FeatureMedia/xyChart.js +5 -0
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/support/chartUtilsAm5.js +5 -0
- package/assets/esri/core/workers/chunks/353e5b283e0f4416684a.js +0 -1
- package/assets/esri/core/workers/chunks/81529aee5e6efa3afc83.js +0 -1
- package/assets/esri/core/workers/chunks/bcd79124744cd3682c78.js +0 -1
- package/widgets/support/am5chartUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as e}from"../../rasterRenderers.js";import r from"../../request.js";import i from"../../core/Error.js";import s from"../../core/Logger.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{ensureClass as o}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as l}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as u}from"../support/arcgisLayerUrl.js";import{url as m}from"../support/commonProperties.js";import c from"../support/DimensionalDefinition.js";import d from"../support/MultidimensionalSubset.js";import h from"../support/RasterFunction.js";import p from"../support/RasterJobHandler.js";import f from"../support/TileInfo.js";import y from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as b,hasExcludedVariableOrDimension as g,getDefaultVariablInfo as F,isMultiSliceOrRangeDefinition as I,getSubsetVariablesFromMdInfo as J}from"../support/rasterDatasets/multidimensionalUtils.js";import{snapToRaster as _,clip as R}from"../support/rasterFunctions/clipUtils.js";import{create as S}from"../support/rasterFunctions/rasterFunctionHelper.js";import{load as x,projectExtent as v,projectPolygon as j}from"../support/rasterFunctions/rasterProjectionHelper.js";import{computeStatisticsHistograms as H}from"../support/rasterFunctions/stretchUtils.js";import{convertVectorFieldData as w}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as D,getVariableRasterInfo as T,getDefaultInterpolation as N,getDefaultBandCombination as O,createDefaultRenderer as z}from"../../renderers/support/rasterRendererHelper.js";import C from"../../renderers/support/RasterSymbolizer.js";import P from"../../rest/support/ImageHistogramParameters.js";import{createFlowMesh as E}from"../../views/2d/engine/flow/dataUtils.js";import A from"../../geometry/SpatialReference.js";import M from"../../geometry/Point.js";const U=s.getLogger("esri.layers.mixins.ImageryTileMixin"),k=s=>{let k=class extends s{constructor(...t){super(...t),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterFunction=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===t[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(t){this._set("multidimensionalDefinition",t),this.updateRenderer()}get tileInfo(){return this.rasterInfo?.storageInfo.tileInfo}set url(t){this._set("url",u(t,U))}set renderer(t){this._set("renderer",t),this.updateRenderer()}async convertVectorFieldData(t,e){if(null==t||!this.rasterInfo)return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:t,dataType:i},e):w(t,i)}async computeStatisticsHistograms(t,e){t=o(P,t).clone();const{rasterInfo:r}=this,{geometry:s}=t;if(null==s)throw new i("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=s;const{spatialReference:a}=r;s.spatialReference.equals(a)||(await x(),n="extent"===s.type?v(s,a):j(s,a));const l=t.pixelSize??new M({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:a}),{extent:u,width:m,height:c}=_(r,n,l),d=await this.fetchPixels(u,m,c,{...e,interpolation:"nearest"});if(null==d.pixelBlock)throw new i("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await R(d.pixelBlock,u,n),p=this._rasterJobHandler.instance;return p?p.computeStatisticsHistograms({pixelBlock:h},e):H(h)}async createFlowMesh(t,e){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(t,e):E(t.meshType,t.simulationSettings,t.flowData,null!=e.signal?e.signal:(new AbortController).signal)}normalizeRasterFetchOptions(t){const{multidimensionalInfo:e}=this.rasterInfo??{};if(null==e)return t;let r=t.multidimensionalDefinition||this.multidimensionalDefinition;null!=r&&r.length||(r=b(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const i=t.timeExtent||this.timeExtent;if(null!=r&&null!=i&&(null!=i.start||null!=i.end)){r=r.map((t=>t.clone()));const s=e.variables.find((({name:t})=>t===r[0].variableName))?.dimensions?.find((({name:t})=>"StdTime"===t)),n=r.find((({dimensionName:t})=>"StdTime"===t));if(!s||!n)return{...t,multidimensionalDefinition:null};const{start:o,end:a}=i,l=null==o?null:o.getTime(),u=null==a?null:a.getTime(),m=l??u,c=u??l;if(null!=s.values){const t=s.values.filter((t=>{if(Array.isArray(t)){if(m===c)return t[0]<=m&&t[1]>=m;const e=t[0]<=m&&t[1]>m||t[0]<c&&t[1]>=c,r=t[0]>=m&&t[1]<=c||t[0]<m&&t[1]>c;return e||r}return m===c?t===m:t>=m&&t<=c}));if(t.length){const e=t.sort(((t,e)=>{const r=Array.isArray(t)?t[0]:t,i=Array.isArray(t)?t[1]:t,s=Array.isArray(e)?e[0]:e,n=Array.isArray(e)?e[1]:e;if(m===c)return r-s;return Math.abs(i-c)-Math.abs(n-c)}))[0];n.values=[e]}else r=null}else if(s.hasRegularIntervals&&s.extent){const[t,e]=s.extent;m>e||c<t?r=null:n.values=m===c?[m]:[Math.max(t,m),Math.min(e,c)]}}return null!=r&&g(r,this.multidimensionalSubset)?{...t,multidimensionalDefinition:null}:{...t,multidimensionalDefinition:r}}async updateRasterFunction(){if("imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const t=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&t&&this._set("rasterFunction",h.fromJSON(t)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let t,e=this.raster,r=!1;"Function"===e.datasetFormat?(t=e.primaryRasters.rasters,e=t[0],r=!0):t=[e];const{rasterFunction:i}=this;if(i){const r={raster:e};t.length>1&&t.forEach((t=>r[t.url]=t));const s=S(i.rasterFunctionDefinition??i.toJSON(),r),n=new y({rasterFunction:s});n.rasterJobHandler=this._rasterJobHandler.instance,await n.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=n}else this.raster=e,this._cachedRasterFunctionJson=null;if(this._cachedRendererJson=null,!r&&!i)return;const{bandIds:s}=this,{bandCount:n}=this.raster.rasterInfo,o=s?.length?s.some((t=>t>=n)):n>=3;s&&(o||"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:t,symbolizer:e}=this;if(!t||!e)return;const{rasterInfo:r}=this.raster,i=F(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=i?.name,n=D({...this.renderer.toJSON(),variableName:s});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(n))return;const o=this._rasterJobHandler.instance;o&&(e.rasterInfo=T(r,s),e.rendererJSON=n,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=n)}async applyRenderer(t,e){const r=t&&t.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const s=this._rasterJobHandler.instance,n=this.bandIds??[];return i=s?await s.symbolize({...t,simpleStretchParams:e,bandIds:n}):this.symbolizer.symbolize({...t,simpleStretchParams:e,bandIds:n}),i}getTileUrl(t,e,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${t}/${e}/${r}`:""}getCompatibleTileInfo(t,e,r=!1){if(!this.loaded||null==e)return null;if(r&&t.equals(this.spatialReference))return this.tileInfo;const i=l(t);return f.create({size:256,spatialReference:t,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:e.xmin,y:e.ymax}})}getCompatibleFullExtent(t){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(t)||(this._compatibleFullExtent=this.raster.computeExtent(t)),this._compatibleFullExtent):null}async fetchTile(t,e,i,s={}){if(q(this),s.requestAsImageElement){const n=this.getTileUrl(t,e,i);return r(n,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s.signal}).then((t=>t.data))}const{rasterInfo:n}=this;if(null!=n.multidimensionalInfo&&null==(s=this.normalizeRasterFetchOptions(s)).multidimensionalDefinition){const r=s.tileInfo||n.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(t,e,i,r),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer.type&&(s={...s,buffer:{cols:1,rows:1}}),this.raster.fetchTile(t,e,i,s)}async fetchPixels(t,e,r,i={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition?{extent:t,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),e=Math.round(e),r=Math.round(r),this.raster.fetchPixels(t,e,r,i))}async identify(t,e={}){const{raster:r,rasterInfo:s}=this;if(null!=s.multidimensionalInfo){if(!(s.hasMultidimensionalTranspose&&!!(I(e.multidimensionalDefinition)||e.transposedVariableName||e.timeExtent))&&null==(e=this.normalizeRasterFetchOptions(e)).multidimensionalDefinition)return{location:t,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(t))throw new i("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return r.identify(t,e)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const t=this.rasterInfo?.multidimensionalInfo;if(null==t||"standard-time"!==this.rasterInfo?.dataType)return!1;const e=this.multidimensionalDefinition,r=e?.[0]?.variableName;return t.variables.some((t=>t.name===r&&(!e?.[0].dimensionName||t.dimensions.some((t=>"StdTime"===t.name)))))}getStandardTimeValue(t){return new Date(24*(t-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(t){const e=t??this.rasterInfo?.multidimensionalInfo;return J(this.multidimensionalSubset,e)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=b(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const t=new p;return this._rasterJobHandler.connectionPromise=t.initialize().then((()=>{q(this),this._rasterJobHandler.instance=t,this.raster.rasterJobHandler=t,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){q(this);const{raster:t}=this,e=N(t.rasterInfo,t.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",e)}}_configDefaultRenderer(t="no"){q(this);const{rasterInfo:e}=this.raster;!this.bandIds&&e.bandCount>1&&(this.bandIds=O(e));const r=F(e,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),i=r?.name;if(!this.renderer||"override"===t){const t=z(e,{bandIds:this.bandIds,variableName:i}),r=e.statistics,s=r&&r.length>0?r[0]:null,n=s?.max??0,o=s?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===t.type&&(n>1e24||o<-1e24)&&(t.dynamicRangeAdjustment=!0,t.statistics=null,"none"===t.stretchType&&(t.stretchType="min-max")),this.renderer=t}const s=D({...this.renderer.toJSON(),variableName:i}),n=T(e,i);this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=n):this.symbolizer=new C({rendererJSON:s,rasterInfo:n});const o=this.symbolizer.bind();if(o.success){if("auto"===t){const{colormap:t}=this.raster.rasterInfo,e=this.renderer;if(null!=t)if("raster-colormap"!==e.type)this._configDefaultRenderer("override");else{const t=z(this.raster.rasterInfo);JSON.stringify(t)!==JSON.stringify(e)&&this._configDefaultRenderer("override")}else if("raster-stretch"===e.type){const t=this.bandIds?.length,r=e.statistics?.length;!e.dynamicRangeAdjustment&&r&&t&&r!==t&&this._configDefaultRenderer("override")}}}else U.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===t&&this._configDefaultRenderer("override")}};function q(t){if(!t.raster||!t.rasterInfo)throw new i("imagery-tile","no raster")}return t([n()],k.prototype,"_cachedRendererJson",void 0),t([n()],k.prototype,"_cachedRasterFunctionJson",void 0),t([n()],k.prototype,"_compatibleFullExtent",void 0),t([n()],k.prototype,"_isConstructedFromFunctionRaster",void 0),t([n()],k.prototype,"_rasterJobHandler",void 0),t([n()],k.prototype,"bandIds",void 0),t([n({json:{origins:{service:{read:{source:"copyrightText"}}}}})],k.prototype,"copyright",void 0),t([n({json:{read:!1}})],k.prototype,"fullExtent",null),t([n()],k.prototype,"interpolation",void 0),t([n()],k.prototype,"ioConfig",void 0),t([n({type:[c],json:{write:!0}})],k.prototype,"multidimensionalDefinition",null),t([n({type:d,json:{write:!0}})],k.prototype,"multidimensionalSubset",void 0),t([n()],k.prototype,"raster",void 0),t([n({type:h})],k.prototype,"rasterFunction",void 0),t([n()],k.prototype,"rasterInfo",void 0),t([n()],k.prototype,"sourceJSON",void 0),t([n({readOnly:!0,type:A,json:{read:!1}})],k.prototype,"spatialReference",void 0),t([n({json:{read:!1}})],k.prototype,"tileInfo",null),t([n(m)],k.prototype,"url",null),t([n({types:e})],k.prototype,"renderer",null),t([n()],k.prototype,"symbolizer",void 0),k=t([a("esri.layers.ImageryTileMixin")],k),k};export{k as ImageryTileMixin};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as t,websceneRasterRendererTypes as r,read as i}from"../../rasterRenderers.js";import n from"../../request.js";import s from"../../core/Error.js";import o from"../../core/Logger.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{ensureClass as l}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as c}from"../support/arcgisLayerUrl.js";import{url as h}from"../support/commonProperties.js";import p from"../support/DimensionalDefinition.js";import f from"../support/MultidimensionalSubset.js";import y from"../support/RasterFunction.js";import b from"../support/RasterJobHandler.js";import g from"../support/TileInfo.js";import F from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as I,hasExcludedVariableOrDimension as _,getDefaultVariablInfo as R,isMultiSliceOrRangeDefinition as J,getSubsetVariablesFromMdInfo as S}from"../support/rasterDatasets/multidimensionalUtils.js";import{snapToRaster as x,clip as v}from"../support/rasterFunctions/clipUtils.js";import{create as w}from"../support/rasterFunctions/rasterFunctionHelper.js";import{load as j,projectExtent as D,projectPolygon as H}from"../support/rasterFunctions/rasterProjectionHelper.js";import{computeStatisticsHistograms as T}from"../support/rasterFunctions/stretchUtils.js";import{convertVectorFieldData as N}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as O,getVariableRasterInfo as z,getDefaultInterpolation as P,getDefaultBandCombination as C,createDefaultRenderer as E}from"../../renderers/support/rasterRendererHelper.js";import A from"../../renderers/support/RasterSymbolizer.js";import M from"../../rest/support/ImageHistogramParameters.js";import{createFlowMesh as U}from"../../views/2d/engine/flow/dataUtils.js";import k from"../../geometry/SpatialReference.js";import q from"../../geometry/Point.js";const B=o.getLogger("esri.layers.mixins.ImageryTileMixin"),V=o=>{let V=class extends o{constructor(...e){super(...e),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===e[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){this._set("rasterFunction",e),this.updateRasterFunction()}get tileInfo(){return this.rasterInfo?.storageInfo.tileInfo}set url(e){this._set("url",c(e,B))}set renderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",e),this.updateRenderer())}readRenderer(e,t,r){const n=t?.layerDefinition?.drawingInfo?.renderer;return i(n,r)||void 0}async convertVectorFieldData(e,t){if(null==e||!this.rasterInfo)return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:e,dataType:i},t):N(e,i)}async computeStatisticsHistograms(e,t){e=l(M,e).clone();const{rasterInfo:r}=this,{geometry:i}=e;if(null==i)throw new s("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=i;const{spatialReference:o}=r;i.spatialReference.equals(o)||(await j(),n="extent"===i.type?D(i,o):H(i,o));const a=e.pixelSize??new q({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:o}),{extent:u,width:d,height:m}=x(r,n,a),c=await this.fetchPixels(u,d,m,{...t,interpolation:"nearest"});if(null==c.pixelBlock)throw new s("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await v(c.pixelBlock,u,n),p=this._rasterJobHandler.instance;return p?p.computeStatisticsHistograms({pixelBlock:h},t):T(h)}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):U(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.rasterInfo??{};if(null==t)return e;let r=e.multidimensionalDefinition||this.multidimensionalDefinition;null!=r&&r.length||(r=I(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const i=e.timeExtent||this.timeExtent;if(null!=r&&null!=i&&(null!=i.start||null!=i.end)){r=r.map((e=>e.clone()));const n=t.variables.find((({name:e})=>e===r[0].variableName))?.dimensions?.find((({name:e})=>"StdTime"===e)),s=r.find((({dimensionName:e})=>"StdTime"===e));if(!n||!s)return{...e,multidimensionalDefinition:null};const{start:o,end:a}=i,l=null==o?null:o.getTime(),u=null==a?null:a.getTime(),d=l??u,m=u??l;if(null!=n.values){const e=n.values.filter((e=>{if(Array.isArray(e)){if(d===m)return e[0]<=d&&e[1]>=d;const t=e[0]<=d&&e[1]>d||e[0]<m&&e[1]>=m,r=e[0]>=d&&e[1]<=m||e[0]<d&&e[1]>m;return t||r}return d===m?e===d:e>=d&&e<=m}));if(e.length){const t=e.sort(((e,t)=>{const r=Array.isArray(e)?e[0]:e,i=Array.isArray(e)?e[1]:e,n=Array.isArray(t)?t[0]:t,s=Array.isArray(t)?t[1]:t;if(d===m)return r-n;return Math.abs(i-m)-Math.abs(s-m)}))[0];s.values=[t]}else r=null}else if(n.hasRegularIntervals&&n.extent){const[e,t]=n.extent;d>t||m<e?r=null:s.values=d===m?[d]:[Math.max(e,d),Math.min(t,m)]}}return null!=r&&_(r,this.multidimensionalSubset)?{...e,multidimensionalDefinition:null}:{...e,multidimensionalDefinition:r}}async updateRasterFunction(){if(!this.loaded||"imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const e=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&e&&this._set("rasterFunction",y.fromJSON(e)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let e,t=this.raster,r=!1;"Function"===t.datasetFormat?(e=t.primaryRasters.rasters,t=e[0],r=!0):e=[t];const{rasterFunction:i}=this;if(i){const r={raster:t};e.length>1&&e.forEach((e=>r[e.url]=e));const n=w(i.rasterFunctionDefinition??i.toJSON(),r),s=new F({rasterFunction:n});s.rasterJobHandler=this._rasterJobHandler.instance,await s.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=s}else this.raster=t,this._cachedRasterFunctionJson=null,await t.when();if(this._cachedRendererJson=null,!r&&!i)return;const{bandIds:n}=this,{bandCount:s}=this.raster.rasterInfo,o=n?.length?n.some((e=>e>=s)):s>=3;n&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:e,symbolizer:t}=this;if(!e||!t||!this.renderer)return;const{rasterInfo:r}=this.raster,i=R(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=i?.name,s=O({...this.renderer.toJSON(),variableName:n});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(s))return;const o=this._rasterJobHandler.instance;o&&(t.rasterInfo=z(r,n),t.rendererJSON=s,t.bind(),await o.updateSymbolizer(t),this._cachedRendererJson=s)}async applyRenderer(e,t){const r=e&&e.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const n=this._rasterJobHandler.instance,s=this.bandIds??[];return i=n?await n.symbolize({...e,simpleStretchParams:t,bandIds:s}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:s}),i}getTileUrl(e,t,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${r}`:""}getCompatibleTileInfo(e,t,r=!1){if(!this.loaded||null==t)return null;if(r&&e.equals(this.spatialReference))return this.tileInfo;const i=m(e);return g.create({size:256,spatialReference:e,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,t,r,i={}){if($(this),i.requestAsImageElement){const s=this.getTileUrl(e,t,r);return n(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:i.signal}).then((e=>e.data))}const{rasterInfo:s}=this;if(null!=s.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition){const n=i.tileInfo||s.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,r,n),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(i={...i,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,t,r,i)}async fetchPixels(e,t,r,i={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition?{extent:e,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),r=Math.round(r),this.raster.fetchPixels(e,t,r,i))}async identify(e,t={}){const{raster:r,rasterInfo:i}=this;if(null!=i.multidimensionalInfo){if(!(i.hasMultidimensionalTranspose&&!!(J(t.multidimensionalDefinition)||t.transposedVariableName||t.timeExtent))&&null==(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition)return{location:e,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(e))throw new s("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return r.identify(e,t)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const e=this.rasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.rasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,r=t?.[0]?.variableName;return e.variables.some((e=>e.name===r&&(!t?.[0].dimensionName||e.dimensions.some((e=>"StdTime"===e.name)))))}getStandardTimeValue(e){return new Date(24*(e-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(e){const t=e??this.rasterInfo?.multidimensionalInfo;return S(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=I(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new b;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{$(this),this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){$(this);const{raster:e}=this,t=P(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){$(this);const{rasterInfo:t}=this.raster;!this.bandIds&&t.bandCount>1&&(this.bandIds=C(t));const r=R(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),i=r?.name;if(!this.renderer||"override"===e){const e=E(t,{bandIds:this.bandIds,variableName:i}),r=t.statistics,n=r&&r.length>0?r[0]:null,s=n?.max??0,o=n?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===e.type&&(s>1e24||o<-1e24)&&(e.dynamicRangeAdjustment=!0,e.statistics=null,"none"===e.stretchType&&(e.stretchType="min-max")),this.renderer=e}const n=O({...this.renderer.toJSON(),variableName:i}),s=z(t,i);this.symbolizer?(this.symbolizer.rendererJSON=n,this.symbolizer.rasterInfo=s):this.symbolizer=new A({rendererJSON:n,rasterInfo:s});const o=this.symbolizer.bind();if(o.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e)if("raster-colormap"!==t.type)this._configDefaultRenderer("override");else{const e=E(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,r=t.statistics?.length;!t.dynamicRangeAdjustment&&r&&e&&r!==e&&this._configDefaultRenderer("override")}}}else B.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}};function $(e){if(!e.raster||!e.rasterInfo)throw new s("imagery-tile","no raster")}return e([a()],V.prototype,"_cachedRendererJson",void 0),e([a()],V.prototype,"_cachedRasterFunctionJson",void 0),e([a()],V.prototype,"_compatibleFullExtent",void 0),e([a()],V.prototype,"_isConstructedFromFunctionRaster",void 0),e([a()],V.prototype,"_rasterJobHandler",void 0),e([a()],V.prototype,"bandIds",void 0),e([a({json:{origins:{service:{read:{source:"copyrightText"}}}}})],V.prototype,"copyright",void 0),e([a({json:{read:!1}})],V.prototype,"fullExtent",null),e([a()],V.prototype,"interpolation",void 0),e([a()],V.prototype,"ioConfig",void 0),e([a({type:[p],json:{write:!0}})],V.prototype,"multidimensionalDefinition",null),e([a({type:f,json:{write:!0}})],V.prototype,"multidimensionalSubset",void 0),e([a()],V.prototype,"raster",void 0),e([a({type:y})],V.prototype,"rasterFunction",null),e([a()],V.prototype,"rasterInfo",void 0),e([a()],V.prototype,"sourceJSON",void 0),e([a({readOnly:!0,type:k,json:{read:!1}})],V.prototype,"spatialReference",void 0),e([a({json:{read:!1}})],V.prototype,"tileInfo",null),e([a(h)],V.prototype,"url",null),e([a({types:t,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],V.prototype,"renderer",null),e([u("renderer")],V.prototype,"readRenderer",null),e([a()],V.prototype,"symbolizer",void 0),V=e([d("esri.layers.ImageryTileMixin")],V),V};export{V as ImageryTileMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import r from"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import i from"../../renderers/Renderer.js";import o from"../../renderers/SimpleRenderer.js";import n from"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import"../../core/has.js";import s from"../../core/Error.js";import{HandleOwnerMixin as l}from"../../core/HandleOwner.js";import{IdentifiableMixin as a}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import d from"../../core/Loadable.js";import u from"../../core/Logger.js";import{MultiOriginJSONMixin as y}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../../core/object.js";import{sqlAnd as m}from"../../core/sql.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import{OriginId as v}from"../../core/accessorSupport/PropertyOrigin.js";import{createTypeReader as j}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import w from"../../form/FormTemplate.js";import{labelsVisible as O,legendEnabled as S,minScale as F,maxScale as I,popupEnabled as T}from"./commonProperties.js";import{createQuery as E}from"./featureLayerUtils.js";import C from"./FeatureTemplate.js";import{defineFieldProperties as A}from"./fieldProperties.js";import{fixRendererFields as x}from"./fieldUtils.js";import R from"./LabelClass.js";import{reader as P}from"./labelingInfo.js";import D from"../../rest/support/Query.js";import{createPopupTemplate as L}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as q,defaultPolylineSymbol2D as U,defaultPointSymbol2D as V}from"../../symbols/support/defaults.js";const G=["charts","editingEnabled","formTemplate","labelsVisible","labelingInfo","legendEnabled","minScale","maxScale","opacity","popupEnabled","popupTemplate","renderer","subtypeCode","templates","title","visible"],N={key:"type",base:i,errorContext:"renderer",typeMap:{simple:o,"unique-value":n,"class-breaks":r}},$=A(),k=j({types:N});let M=0;function _(e){const t=e.json.write;return"object"==typeof t?t.ignoreOrigin=!0:e.json.write={ignoreOrigin:!0},e}function H(e){return new o({symbol:B(e)})}function B(e){switch(e){case"point":case"multipoint":return V.clone();case"polyline":return U.clone();case"polygon":case"multipatch":return q.clone();default:return null}}function Q(e,t){return!!t&&("unique-value"===e?.type&&"string"==typeof e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function z(e,t){return null==e?null:t.subtypes?.find((t=>t.code===e))}function J(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},o=z(e,t);if(null!=o){const{defaultValues:e}=o;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new C({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}const K="esri.layers.support.SubtypeSublayer";let W=class extends(l(y(a(d)))){constructor(e){super(e),this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.id=`${Date.now().toString(16)}-subtype-sublayer-${M++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.templates=null,this.title=null,this.visible=!0}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}writeFieldOverrides(e,t,r){const{fields:i,parent:o}=this;let n;if(i){n=[];let e=0;i.forEach((({name:t,alias:r,editable:i,visible:s})=>{if(!s)return;const l=o?.fields?.find((e=>e.name===t));if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),n.push(a),p&&e++})),0===e&&n.length===i.length&&(n=null)}else n=p(e);n?.length&&c(r,n,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:o,subtypeField:n}=e,s=o?.find((e=>e.code===r)),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,o=t?.find((e=>e.name===i));if(e.visible=!t||!!o,o){const{alias:t,editable:r}=o;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===n?r:s;const u=a?.[i]??null;e.domain=i===n?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get geometryType(){return this.parent?.geometryType}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||u.getLogger(K).error(Y("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){x(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?H(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=k(i,t,r);let s;const{subtypeCode:l}=this;if(null!=l&&Q(n,t.subtypeField)){const e=n.uniqueValueInfos?.find((({value:e})=>(e="number"==typeof e?String(e):e)===String(l)));e&&(s=new o({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(s=n);return s}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(!i)return;const o=i.visualVariables?.some((e=>"rotationInfo"!==e.type));return o?void 0:k(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference}readTemplatesFromService(e,t){return[J(this.subtypeCode,t)]}readTitleFromService(e,t){const r=z(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw Y("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:i}=this;if(!i)throw Y("updateAttachment");if(e.getAttribute(i.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return i.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw Y("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw Y("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:o}=this;if(r){const{displayField:e,editFieldsInfo:n,objectIdField:s}=r;t={displayField:e,editFieldsInfo:n,fields:i,objectIdField:s,title:o}}return L(t,e)}createQuery(){if(!this.parent)throw Y("createQuery");const e=E(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=m(t,this.parent.definitionExpression),e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e){return this._getLayerDomain(e)}hasUserOverrides(){return G.some((e=>this.originIdOf(e)===v.USER))}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw Y("queryAttachments");const i=e.clone();return i.where=X(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(e,t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw Y("queryFeatures");const i=D.from(e)??r.createQuery();return null!=e&&(i.where=X(i.where,r.parent.subtypeField,r.subtypeCode)),r.parent.queryFeatures(i,t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([f({readOnly:!0,json:{read:!1}})],W.prototype,"capabilities",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"effectiveCapabilities",null),e([f({json:{write:{ignoreOrigin:!0}}})],W.prototype,"charts",void 0),e([f({type:Boolean,nonNullable:!0,json:{name:"enableEditing",write:{ignoreOrigin:!0}}})],W.prototype,"editingEnabled",void 0),e([f({type:Boolean,readOnly:!0})],W.prototype,"effectiveEditingEnabled",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"elevationInfo",null),e([f({readOnly:!0,json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],W.prototype,"fieldOverrides",void 0),e([g("fieldOverrides")],W.prototype,"writeFieldOverrides",null),e([f({...$.fields,readOnly:!0,json:{read:!1}})],W.prototype,"fields",null),e([f($.fieldsIndex)],W.prototype,"fieldsIndex",void 0),e([f({type:w,json:{name:"formInfo",write:{ignoreOrigin:!0}}})],W.prototype,"formTemplate",void 0),e([f({type:String,readOnly:!0,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],W.prototype,"id",void 0),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"geometryType",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"type",void 0),e([f(_(p(O)))],W.prototype,"labelsVisible",void 0),e([f({type:[R],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:P},write:{ignoreOrigin:!0}}})],W.prototype,"labelingInfo",void 0),e([f({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0}}})],W.prototype,"layerType",void 0),e([f(_(p(S)))],W.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],W.prototype,"listMode",void 0),e([f((()=>{const e=p(F);return e.json.origins.service.read=!1,_(e)})())],W.prototype,"minScale",void 0),e([f((()=>{const e=p(I);return e.json.origins.service.read=!1,_(e)})())],W.prototype,"maxScale",void 0),e([f({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"objectIdField",null),e([f({type:Number,range:{min:0,max:1},nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],W.prototype,"opacity",void 0),e([f()],W.prototype,"parent",void 0),e([f(_(p(T)))],W.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],W.prototype,"popupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultPopupTemplate",null),e([f({types:N,json:{write:{target:"layerDefinition.drawingInfo.renderer",ignoreOrigin:!0}}})],W.prototype,"renderer",null),e([b("service","renderer",["drawingInfo.renderer","subtypeField","type"])],W.prototype,"readRendererFromService",null),e([b("renderer",["layerDefinition.drawingInfo.renderer"])],W.prototype,"readRenderer",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"spatialReference",null),e([f({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],W.prototype,"subtypeCode",void 0),e([f({type:[C],json:{name:"layerDefinition.templates",write:{ignoreOrigin:!0}}})],W.prototype,"templates",void 0),e([b("service","templates",["geometryType","subtypeField","subtypes","type"])],W.prototype,"readTemplatesFromService",null),e([f({type:String,json:{write:{ignoreOrigin:!0}}})],W.prototype,"title",void 0),e([b("service","title",["subtypes"])],W.prototype,"readTitleFromService",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"url",null),e([f({readOnly:!0})],W.prototype,"userHasUpdateItemPrivileges",null),e([f({type:Boolean,nonNullable:!0,json:{name:"visibility",write:{ignoreOrigin:!0}}})],W.prototype,"visible",void 0),W=e([h(K)],W);const X=(e,t,r)=>{const i=new RegExp(`${t}=[0-9]`),o=`${t}=${r}`,n=e??"";return i.test(n)?n.replace(i,o):m(o,n)},Y=e=>new s(`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`),Z=W;export{Z as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import r from"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import i from"../../renderers/Renderer.js";import o from"../../renderers/SimpleRenderer.js";import n from"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import"../../core/has.js";import s from"../../core/Error.js";import{HandleOwnerMixin as l}from"../../core/HandleOwner.js";import{IdentifiableMixin as a}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import d from"../../core/Loadable.js";import u from"../../core/Logger.js";import{MultiOriginJSONMixin as y}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../../core/object.js";import{sqlAnd as m}from"../../core/sql.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import{OriginId as v}from"../../core/accessorSupport/PropertyOrigin.js";import{createTypeReader as j}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import w from"../../form/FormTemplate.js";import{labelsVisible as O,legendEnabled as S,minScale as F,maxScale as I,popupEnabled as T}from"./commonProperties.js";import{createQuery as E}from"./featureLayerUtils.js";import C from"./FeatureTemplate.js";import{defineFieldProperties as A}from"./fieldProperties.js";import{fixRendererFields as x}from"./fieldUtils.js";import R from"./LabelClass.js";import{reader as P}from"./labelingInfo.js";import D from"../../rest/support/Query.js";import{createPopupTemplate as L}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as q,defaultPolylineSymbol2D as U,defaultPointSymbol2D as V}from"../../symbols/support/defaults.js";const G=["charts","editingEnabled","formTemplate","labelsVisible","labelingInfo","legendEnabled","minScale","maxScale","opacity","popupEnabled","popupTemplate","renderer","subtypeCode","templates","title","visible"],N={key:"type",base:i,errorContext:"renderer",typeMap:{simple:o,"unique-value":n,"class-breaks":r}},$=A(),k=j({types:N});let M=0;function _(e){const t=e.json.write;return"object"==typeof t?t.ignoreOrigin=!0:e.json.write={ignoreOrigin:!0},e}function H(e){return new o({symbol:B(e)})}function B(e){switch(e){case"point":case"multipoint":return V.clone();case"polyline":return U.clone();case"polygon":case"multipatch":return q.clone();default:return null}}function Q(e,t){return!!t&&("unique-value"===e?.type&&"string"==typeof e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function z(e,t){return null==e?null:t.subtypes?.find((t=>t.code===e))}function J(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},o=z(e,t);if(null!=o){const{defaultValues:e}=o;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new C({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}const K="esri.layers.support.SubtypeSublayer";let W=class extends(l(y(a(d)))){constructor(e){super(e),this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.id=`${Date.now().toString(16)}-subtype-sublayer-${M++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.templates=null,this.title=null,this.visible=!0}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}writeFieldOverrides(e,t,r){const{fields:i,parent:o}=this;let n;if(i){n=[];let e=0;i.forEach((({name:t,alias:r,editable:i,visible:s})=>{if(!s)return;const l=o?.fields?.find((e=>e.name===t));if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),n.push(a),p&&e++})),0===e&&n.length===i.length&&(n=null)}else n=p(e);n?.length&&c(r,n,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:o,subtypeField:n}=e,s=o?.find((e=>e.code===r)),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,o=t?.find((e=>e.name===i));if(e.visible=!t||!!o,o){const{alias:t,editable:r}=o;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===n?r:s;const u=a?.[i]??null;e.domain=i===n?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get geometryType(){return this.parent?.geometryType}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||u.getLogger(K).error(Y("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){x(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?H(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=k(i,t,r);let s;const{subtypeCode:l}=this;if(null!=l&&Q(n,t.subtypeField)){const e=n.uniqueValueInfos?.find((({value:e})=>(e="number"==typeof e?String(e):e)===String(l)));e&&(s=new o({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(s=n);return s}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(!i)return;const o=i.visualVariables?.some((e=>"rotationInfo"!==e.type));return o?void 0:k(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference}readTemplatesFromService(e,t){return[J(this.subtypeCode,t)]}readTitleFromService(e,t){const r=z(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw Y("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:i}=this;if(!i)throw Y("updateAttachment");if(e.getAttribute(i.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return i.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw Y("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new s("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw Y("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:o}=this;if(r){const{displayField:e,editFieldsInfo:n,objectIdField:s}=r;t={displayField:e,editFieldsInfo:n,fields:i,objectIdField:s,title:o}}return L(t,e)}createQuery(){if(!this.parent)throw Y("createQuery");const e=E(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=m(t,this.parent.definitionExpression),e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e){return this._getLayerDomain(e)}hasUserOverrides(){return G.some((e=>this.originIdOf(e)===v.USER))}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw Y("queryAttachments");const i=e.clone();return i.where=X(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(e,t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw Y("queryFeatures");const i=D.from(e)??r.createQuery();return null!=e&&(i.where=X(i.where,r.parent.subtypeField,r.subtypeCode)),r.parent.queryFeatures(i,t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([f({readOnly:!0,json:{read:!1}})],W.prototype,"capabilities",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"effectiveCapabilities",null),e([f({json:{write:{ignoreOrigin:!0}}})],W.prototype,"charts",void 0),e([f({type:Boolean,nonNullable:!0,json:{name:"enableEditing",write:{ignoreOrigin:!0}}})],W.prototype,"editingEnabled",void 0),e([f({type:Boolean,readOnly:!0})],W.prototype,"effectiveEditingEnabled",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"elevationInfo",null),e([f({readOnly:!0,json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],W.prototype,"fieldOverrides",void 0),e([g("fieldOverrides")],W.prototype,"writeFieldOverrides",null),e([f({...$.fields,readOnly:!0,json:{read:!1}})],W.prototype,"fields",null),e([f($.fieldsIndex)],W.prototype,"fieldsIndex",void 0),e([f({type:w,json:{name:"formInfo",write:{ignoreOrigin:!0}}})],W.prototype,"formTemplate",void 0),e([f({type:String,readOnly:!0,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],W.prototype,"id",void 0),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"geometryType",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"type",void 0),e([f(_(p(O)))],W.prototype,"labelsVisible",void 0),e([f({type:[R],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:P},write:{ignoreOrigin:!0}}})],W.prototype,"labelingInfo",void 0),e([f({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0}}})],W.prototype,"layerType",void 0),e([f(_(p(S)))],W.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],W.prototype,"listMode",void 0),e([f((()=>{const e=p(F);return e.json.origins.service.read=!1,_(e)})())],W.prototype,"minScale",void 0),e([f((()=>{const e=p(I);return e.json.origins.service.read=!1,_(e)})())],W.prototype,"maxScale",void 0),e([f({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"objectIdField",null),e([f({type:Number,range:{min:0,max:1},nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],W.prototype,"opacity",void 0),e([f()],W.prototype,"parent",void 0),e([f(_(p(T)))],W.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],W.prototype,"popupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultPopupTemplate",null),e([f({types:N,json:{write:{target:"layerDefinition.drawingInfo.renderer",ignoreOrigin:!0}}})],W.prototype,"renderer",null),e([b("service","renderer",["drawingInfo.renderer","subtypeField","type"])],W.prototype,"readRendererFromService",null),e([b("renderer",["layerDefinition.drawingInfo.renderer"])],W.prototype,"readRenderer",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"spatialReference",null),e([f({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],W.prototype,"subtypeCode",void 0),e([f({type:[C],json:{name:"layerDefinition.templates",write:{ignoreOrigin:!0}}})],W.prototype,"templates",void 0),e([b("service","templates",["geometryType","subtypeField","subtypes","type"])],W.prototype,"readTemplatesFromService",null),e([f({type:String,json:{write:{ignoreOrigin:!0}}})],W.prototype,"title",void 0),e([b("service","title",["subtypes"])],W.prototype,"readTitleFromService",null),e([f({readOnly:!0,json:{read:!1}})],W.prototype,"url",null),e([f({readOnly:!0})],W.prototype,"userHasUpdateItemPrivileges",null),e([f({type:Boolean,nonNullable:!0,json:{name:"visibility",write:{ignoreOrigin:!0}}})],W.prototype,"visible",void 0),W=e([h(K)],W);const X=(e,t,r)=>{const i=new RegExp(`${t}=[0-9]`),o=`${t}=${r}`,n=e??"";return i.test(n)?n.replace(i,o):m(o,n)},Y=e=>new s(`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`),Z=W;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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./BandArithmeticFunctionArguments.js";import{calculateBandIndex as n,getBandMatrix3 as a}from"./bandIndexUtils.js";import i from"./BaseRasterFunction.js";const o=new Set(["vari","mtvi2","rtvi-core","evi"]);let c=class extends i{constructor(){super(...arguments),this.functionName="BandArithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0],s=e.clone();s.pixelType=this.outputPixelType,s.statistics=null,s.histograms=null,s.bandCount="sultan"===this.functionArguments.method?e.bandCount:1,this.rasterInfo=s;return{success:!0,supportsGPU:!["custom","gvitm","sultan"].includes(this.functionArguments.method)}}_processPixels(e){const s=e.pixelBlocks?.[0];if(null==s)return s;const{method:t,bandIndexes:r}=this.functionArguments,a=r.split(" ").map((e=>parseFloat(e)));return n(s,{method:t,bandIndexes:a,equation:r})}_getWebGLParameters(){const e=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1));2===e.length&&e.push(0);const s=this.isInputBandIdsSwizzled?[0,1,2]:e;let t,r;const n=new Float32Array(3),{method:i}=this.functionArguments;switch(i){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":t=a([s[0],s[1],0]),r="ndxi";break;case"ndwi":t=a([s[1],s[0],0]),r="ndxi";break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":t=a([s[0],s[1],0]),r="sr";break;case"ci-g":case"ci-re":t=a([s[0],s[1],0]),r="ci";break;case"savi":t=a([s[0],s[1],0]),r="savi",n[0]=e[2]+1;break;case"tsavi":t=a([s[0],s[1],0]),r="tsavi",n[0]=e[2]+1,n[1]=e[3]+1,n[2]=e[4]+1;break;case"msavi":t=a([s[0],s[1],0]),r="msavi";break;case"gemi":t=a([s[0],s[1],0]),r="gemi";break;case"pvi":t=a([s[0],s[1],0]),r="tsavi",n[0]=e[2]+1,n[1]=e[3]+1;break;case"vari":t=a([s[0],s[1],s[2]]),r="vari";break;case"mtvi2":t=a([s[0],s[1],s[2]]),r="mtvi2";break;case"rtvi-core":t=a([s[0],s[1],s[2]]),r="rtvicore";break;case"evi":t=a([s[0],s[1],s[2]]),r="evi";break;case"wndwi":t=a([s[0],s[1],0]),r="wndwi",n[0]=e[3]?e[3]+1:.5;break;case"bai":t=a([s[1],s[0],0]),r="bai";break;default:t=a([0,1,2]),r="custom"}return{bandIndexMat3:t,indexType:r,adjustments:n}}_getInputBandIds(e){if("custom"===this.functionArguments.method)return e;const s=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1)),t=e.length,r=s.map((e=>e>=t?t-1:e)),n=o.has(this.functionArguments.method)?3:2,a=r.slice(0,n).map((s=>e[s]));return 2===a.length&&a.push(0),a}};e([s({json:{write:!0,name:"rasterFunction"}})],c.prototype,"functionName",void 0),e([s({type:r,json:{write:!0,name:"rasterFunctionArguments"}})],c.prototype,"functionArguments",void 0),e([s()],c.prototype,"rasterArgumentNames",void 0),c=e([t("esri.layers.support.rasterFunctions.BandArithmeticFunction")],c);const u=c;export{u as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./BandArithmeticFunctionArguments.js";import{calculateBandIndex as n,getBandMatrix3 as a}from"./bandIndexUtils.js";import i from"./BaseRasterFunction.js";const o=new Set(["vari","mtvi2","rtvi-core","evi"]);let c=class extends i{constructor(){super(...arguments),this.functionName="BandArithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0];if(e.bandCount<2)return{success:!1,supportsGPU:!1,error:"band-arithmetic-function: source raster has insufficient amount of raster bands"};const s=e.clone();s.pixelType=this.outputPixelType,s.statistics=null,s.histograms=null,s.bandCount="sultan"===this.functionArguments.method?e.bandCount:1,this.rasterInfo=s;return{success:!0,supportsGPU:!["custom","gvitm","sultan"].includes(this.functionArguments.method)}}_processPixels(e){const s=e.pixelBlocks?.[0];if(null==s)return s;const{method:t,bandIndexes:r}=this.functionArguments,a=r.split(" ").map((e=>parseFloat(e)));return n(s,{method:t,bandIndexes:a,equation:r})}_getWebGLParameters(){const e=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1));2===e.length&&e.push(0);const s=this.isInputBandIdsSwizzled?[0,1,2]:e;let t,r;const n=new Float32Array(3),{method:i}=this.functionArguments;switch(i){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":t=a([s[0],s[1],0]),r="ndxi";break;case"ndwi":t=a([s[1],s[0],0]),r="ndxi";break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":t=a([s[0],s[1],0]),r="sr";break;case"ci-g":case"ci-re":t=a([s[0],s[1],0]),r="ci";break;case"savi":t=a([s[0],s[1],0]),r="savi",n[0]=e[2]+1;break;case"tsavi":t=a([s[0],s[1],0]),r="tsavi",n[0]=e[2]+1,n[1]=e[3]+1,n[2]=e[4]+1;break;case"msavi":t=a([s[0],s[1],0]),r="msavi";break;case"gemi":t=a([s[0],s[1],0]),r="gemi";break;case"pvi":t=a([s[0],s[1],0]),r="tsavi",n[0]=e[2]+1,n[1]=e[3]+1;break;case"vari":t=a([s[0],s[1],s[2]]),r="vari";break;case"mtvi2":t=a([s[0],s[1],s[2]]),r="mtvi2";break;case"rtvi-core":t=a([s[0],s[1],s[2]]),r="rtvicore";break;case"evi":t=a([s[0],s[1],s[2]]),r="evi";break;case"wndwi":t=a([s[0],s[1],0]),r="wndwi",n[0]=e[3]?e[3]+1:.5;break;case"bai":t=a([s[1],s[0],0]),r="bai";break;default:t=a([0,1,2]),r="custom"}return{bandIndexMat3:t,indexType:r,adjustments:n}}_getInputBandIds(e){if("custom"===this.functionArguments.method)return e;const s=this.functionArguments.bandIndexes.split(" ").map((e=>parseFloat(e)-1)),t=e.length,r=s.map((e=>e>=t?t-1:e)),n=o.has(this.functionArguments.method)?3:2,a=r.slice(0,n).map((s=>e[s]));return 2===a.length&&a.push(0),a}};e([s({json:{write:!0,name:"rasterFunction"}})],c.prototype,"functionName",void 0),e([s({type:r,json:{write:!0,name:"rasterFunctionArguments"}})],c.prototype,"functionArguments",void 0),e([s()],c.prototype,"rasterArgumentNames",void 0),c=e([t("esri.layers.support.rasterFunctions.BandArithmeticFunction")],c);const u=c;export{u as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{calculateNDVI as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{calculateNDVI as n,getBandMatrix3 as e}from"./bandIndexUtils.js";import o from"./BaseRasterFunction.js";import i from"./NDVIFunctionArguments.js";let u=class extends o{constructor(){super(...arguments),this.functionName="NDVI",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{scientificOutput:t,visibleBandID:s,infraredBandID:r}=this.functionArguments;this.outputPixelType=this._getOutputPixelType(t?"f32":"u8");const n=this.sourceRasterInfos[0],e=Math.max(s,r);if(n.bandCount<2||e>=n.bandCount)return{success:!1,supportsGPU:!1,error:"ndvi-function: source raster has insufficient amount of raster bands"};const o=n.clone();o.pixelType=this.outputPixelType,o.colormap=null,o.histograms=null,o.bandCount=1;const[i,u,a,c]=t?[-1,1,0,.1]:[0,200,100,10];return o.statistics=[{min:i,max:u,avg:a,stddev:c}],this.rasterInfo=o,{success:!0,supportsGPU:!0}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return null;const{visibleBandID:r,infraredBandID:e,scientificOutput:o}=this.functionArguments;return n(s,r,e,!o)}_getWebGLParameters(){const{visibleBandID:t,infraredBandID:s,scientificOutput:r}=this.functionArguments,n=this.isInputBandIdsSwizzled?[0,1,2]:[s,t,0];return{bandIndexMat3:e(n),scaled:!r}}_getInputBandIds(t){const{visibleBandID:s,infraredBandID:r}=this.functionArguments;return[r,s,0].map((s=>t[s]))}};t([s({json:{write:!0,name:"rasterFunction"}})],u.prototype,"functionName",void 0),t([s({type:i,json:{write:!0,name:"rasterFunctionArguments"}})],u.prototype,"functionArguments",void 0),t([s()],u.prototype,"rasterArgumentNames",void 0),u=t([r("esri.layers.support.rasterFunctions.NDVIFunction")],u);const a=u;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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{toRGB as t}from"../../../core/colorUtils.js";import r from"../../../core/Error.js";import{clone as e}from"../../../core/lang.js";import n from"./AspectFunction.js";import o from"./BandArithmeticFunction.js";import s from"./ColormapFunction.js";import a from"./CompositeBandFunction.js";import i from"./ConvolutionFunction.js";import u from"./CurvatureFunction.js";import c from"./ExtractBandFunction.js";import m from"./LocalFunction.js";import l from"./MaskFunction.js";import p from"./NDVIFunction.js";import f from"./RemapFunction.js";import d from"./SlopeFunction.js";import g from"./StatisticsHistogramFunction.js";import
|
|
5
|
+
import{toRGB as t}from"../../../core/colorUtils.js";import r from"../../../core/Error.js";import{clone as e}from"../../../core/lang.js";import n from"./AspectFunction.js";import o from"./BandArithmeticFunction.js";import s from"./ColormapFunction.js";import a from"./CompositeBandFunction.js";import i from"./ConvolutionFunction.js";import u from"./CurvatureFunction.js";import c from"./ExtractBandFunction.js";import m from"./LocalFunction.js";import l from"./MaskFunction.js";import p from"./NDVIFunction.js";import f from"./RemapFunction.js";import d from"./SlopeFunction.js";import g from"./StatisticsHistogramFunction.js";import F from"./StretchFunction.js";const A=new Map;function h(t,r,e=["raster"],n=""){A.set(t,{desc:n,ctor:r,rasterArgumentNames:e})}function y(){const t=new Set;return A.forEach(((r,e)=>t.add(e))),t}function C(t,r){const{rasterFunctionArguments:e}=t;if(!e)return;(e.rasters||[e.raster]).forEach((t=>{t&&"number"!=typeof t&&("string"==typeof t?t.startsWith("http")&&(r.includes(t)||r.push(t)):"rasterFunctionArguments"in t&&C(t,r))}))}function N(t,n){if(n=n??{},"function"in(t=e(t))&&"arguments"in t&&t.arguments&&(t=V(t,n)),"rasterFunction"in t)return j(t=v(t),n);throw new r("raster-function-helper","unsupported raster function json.")}function b(t,r){return"rasters"===r[0]&&Array.isArray(t.rasters)?t.rasters:r.map((r=>t[r]))}function S(t){return!!(t&&"object"==typeof t&&t.rasterFunction&&t.rasterFunctionArguments)}function v(t){const{rasterFunction:r,rasterFunctionArguments:e}=t,n={};for(const o in e){let t=e[o];const r=o.toLowerCase();if("rasters"===r&&Array.isArray(t))n.rasters=t.map((t=>S(t)?v(t):t));else switch(S(t)&&(t=v(t)),r){case"dra":n.dra=t;break;case"pspower":n.psPower=t;break;case"pszfactor":n.psZFactor=t;break;case"bandids":n.bandIds=t;break;default:n[o[0].toLowerCase()+o.slice(1)]=t}}return"Local"!==r||n.rasters?.length||(n.rasters=["$$"]),{...t,rasterFunctionArguments:n}}function j(t,e){const{rasterFunction:n,rasterFunctionArguments:o}=t,s=t.outputPixelType?.toLowerCase();if(null==n||!A.has(n))throw new r("raster-function-helper",`unsupported raster function: ${n}`);const a=A.get(n),i=("function"==typeof a.ctor?a.ctor:a.ctor.default).fromJSON({...t,outputPixelType:s}),{rasterArgumentNames:u}=i,c=[],m=b(o,u),l="rasters"===u[0],p=[];for(let r=0;r<m.length;r++){const t=m[r];let n;null==t||"string"==typeof t&&t.startsWith("$")?c.push(e?.raster):"string"==typeof t?e[t]&&c.push(e[t]):"number"!=typeof t&&"rasterFunction"in t&&(n=j(t,e),l||(i.functionArguments[u[r]]=n),c.push(n)),l&&p.push(n??t)}if(l&&(i.functionArguments.rasters=p),e){i.sourceRasters=c;const t=e.raster?.url;t&&(i.mainPrimaryRasterId=t)}return i}function R(t,r){if(!t||!r)return;let e;for(e in t){const n=t[e];n&&"object"==typeof n&&("function"in n&&n.function&&n.arguments?R(n.arguments,r):"type"in n&&"value"in n&&"RasterFunctionVariable"===n.type&&null!=r[n.name]&&(n.value=r[n.name]))}}function w(t){if(!t||"object"!=typeof t)return t;if(Array.isArray(t)&&0===t.length)return 0===t.length?null:["number","string"].includes(typeof t[0])?t:t.map((t=>w(t)));if("value"in t&&["number","string","boolean"].includes(typeof t.value))return t.value;if(!("type"in t))return t;switch(t.type){case"RasterStatistics":case"RecordSet":default:return t;case"Scalar":return t.value;case"AlgorithmicColorRamp":return D(t);case"MultiPartColorRamp":return{type:"multipart",colorRamps:t.ArrayOfColorRamp.map(D)};case"ArgumentArray":{if(!t.elements?.length)return t.elements;if("RasterStatistics"===t.elements[0].type)return t.elements;const e=[];for(let n=0;n<t.elements.length;n++){const o=t.elements[n],{type:s}=o;if(s)if("RasterFunctionTemplate"===s)e.push(V(o));else{if("RasterFunctionVariable"!==s)throw new r("raster-function-helper","unsupported raster function json.");{const t=null==o.value?o.name?.toLowerCase().includes("raster")?"$$":null:w(o.value);e.push(t)}}else e.push(o)}return e}}}function D(r){const e=r.algorithm??"esriHSVAlgorithm";let{FromColor:n,ToColor:o}=r;if(!Array.isArray(n)){const{r,g:e,b:o}=t({h:n.Hue,s:n.Saturation,v:n.Value});n=[r,e,o,n.AlphaValue]}if(!Array.isArray(o)){const{r,g:e,b:n}=t({h:o.Hue,s:o.Saturation,v:o.Value});o=[r,e,n,o.AlphaValue]}return{type:"algorithmic",algorithm:e,fromColor:n,toColor:o}}function V(t,r){r&&R(t,r);const e={};return T(t,e),e}function T(t,r){if(!t||!r)return;const{function:e,arguments:n}=t;if(!e||!n)return;r.rasterFunction=e.type.replace("Function",""),r.outputPixelType=e.pixelType;const o={};r.rasterFunctionArguments=o;for(const s in n){const t=n[s];"object"==typeof t&&("function"in t&&t.function&&t.arguments?(r.rasterFunctionArguments[s]={},T(t,r.rasterFunctionArguments[s])):"value"in t&&(o[s]="RasterFunctionTemplate"===t.type?V(t):w(t.value)))}switch(o.DEM&&!o.Raster&&(o.Raster=o.DEM,delete o.DEM),r.rasterFunction){case"Stretch":k(o);break;case"Colormap":x(o);break;case"Convolution":B(o);break;case"Mask":E(o)}}function k(t){t.Statistics?.length&&"object"==typeof t.Statistics&&(t.Statistics=t.Statistics.map((t=>[t.min,t.max,t.mean,t.standardDeviation]))),null!=t.NumberOfStandardDeviation&&(t.NumberOfStandardDeviations=t.NumberOfStandardDeviation,delete t.NumberOfStandardDeviation)}function x(t){"randomcolorramp"===t.ColorRamp?.type?.toLowerCase()&&(delete t.ColorRamp,t.ColormapName="Random"),0===t.ColorSchemeType&&delete t.ColorRamp}function B(t){null!=t.ConvolutionType&&(t.Type=t.ConvolutionType,delete t.ConvolutionType)}function E(t){t.NoDataValues?.length&&"string"==typeof t.NoDataValues[0]&&(t.NoDataValues=t.NoDataValues.filter((t=>""!==t)).map((t=>Number(t))))}A.set("Aspect",{desc:"Aspect Function",ctor:n,rasterArgumentNames:["raster"]}),A.set("BandArithmetic",{desc:"Band Arithmetic Function",ctor:o,rasterArgumentNames:["raster"]}),A.set("Colormap",{desc:"Colormap Function",ctor:s,rasterArgumentNames:["raster"]}),A.set("CompositeBand",{desc:"CompositeBand Function",ctor:a,rasterArgumentNames:["rasters"]}),A.set("Convolution",{desc:"Convolution Function",ctor:i,rasterArgumentNames:["raster"]}),A.set("ExtractBand",{desc:"ExtractBand Function",ctor:c,rasterArgumentNames:["raster"]}),A.set("Curvature",{desc:"Curvature Function",ctor:u,rasterArgumentNames:["raster"]}),A.set("Local",{desc:"Local Function",ctor:m,rasterArgumentNames:["rasters"]}),A.set("Mask",{desc:"Mask Function",ctor:l,rasterArgumentNames:["raster"]}),A.set("NDVI",{desc:"NDVI Function",ctor:p,rasterArgumentNames:["raster"]}),A.set("Remap",{desc:"Remap Function",ctor:f,rasterArgumentNames:["raster"]}),A.set("Slope",{desc:"Slope Function",ctor:d,rasterArgumentNames:["raster"]}),A.set("StatisticsHistogram",{desc:"Statistics Histogram Function",ctor:g,rasterArgumentNames:["raster"]}),A.set("Stretch",{desc:"Stretch Function",ctor:F,rasterArgumentNames:["raster"]});export{N as create,C as getPrimaryRasterUrls,b as getRasterValues,y as getSupportedFunctions,h as register};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const f="20230422",d="2d4ca22a941794d3ff66f1d2cb2618275f715fda";export{f as buildDate,d as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../Graphic.js";import t from"../../../core/Logger.js";import{isAbortError as i}from"../../../core/promiseUtils.js";import{watch as r,syncAndInitial as o,sync as a,initial as n}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{hasExcludedVariableOrDimension as l}from"../../../layers/support/rasterDatasets/multidimensionalUtils.js";import c from"../engine/flow/FlowView2D.js";import{LayerView2DMixin as d}from"./LayerView2D.js";import p from"./imagery/ImageryTileView2D.js";import m from"./imagery/VectorFieldTileView2D.js";import{canUseMajorityInterpolationOnDataSource as b}from"./support/util.js";import v from"../../layers/ImageryTileLayerView.js";import w from"../../layers/LayerView.js";import y from"../../layers/RefreshableLayerView.js";let g=class extends(v(y(d(w)))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(e){this._useWebGLForProcessing=e,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=e)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(e){this._useProgressiveUpdate=e,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=e)}update(e){this.subview?.update(e),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([r((()=>
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../Graphic.js";import t from"../../../core/Logger.js";import{isAbortError as i}from"../../../core/promiseUtils.js";import{watch as r,syncAndInitial as o,sync as a,initial as n}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{hasExcludedVariableOrDimension as l}from"../../../layers/support/rasterDatasets/multidimensionalUtils.js";import c from"../engine/flow/FlowView2D.js";import{LayerView2DMixin as d}from"./LayerView2D.js";import p from"./imagery/ImageryTileView2D.js";import m from"./imagery/VectorFieldTileView2D.js";import{canUseMajorityInterpolationOnDataSource as b}from"./support/util.js";import v from"../../layers/ImageryTileLayerView.js";import w from"../../layers/LayerView.js";import y from"../../layers/RefreshableLayerView.js";let g=class extends(v(y(d(w)))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(e){this._useWebGLForProcessing=e,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=e)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(e){this._useProgressiveUpdate=e,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=e)}get displayParameters(){const{layer:e}=this,s=this._get("displayParameters");return e.renderer?{bandIds:e.bandIds,renderer:e.renderer,interpolation:e.interpolation,multidimensionalDefinition:e.multidimensionalDefinition,rasterFunction:"imagery-tile"===e.type?e.rasterFunction:null}:s}update(e){this.subview?.update(e),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([r((()=>this.displayParameters),((e,s)=>{const r=e.interpolation!==s?.interpolation&&("majority"===e.interpolation||"majority"===s?.interpolation)&&b(this.layer),o=e.renderer!==s?.renderer&&s?.renderer?.type!==e.renderer?.type;o&&this._updateSubview();const a=e.multidimensionalDefinition!==s?.multidimensionalDefinition,n=e.rasterFunction!==s?.rasterFunction,u=n&&!this._useWebGLForProcessing,h=a||r||o||u;this.subview.redrawOrRefetch({refetch:h,reprocess:n}).catch((e=>{i(e)||t.getLogger(this.declaredClass).error(e)})),this.notifyChange("updating")})),r((()=>this.layer.blendMode??"normal"),(e=>{this.subview.container.blendMode=e}),o),r((()=>this.layer.effect??null),(e=>{this.subview.container.effect=e}),o),r((()=>this.layer.multidimensionalSubset??null),((e,s)=>{const{multidimensionalDefinition:r}=this.layer;null!=r&&l(r,e)!==l(r,s)&&(this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||t.getLogger(this.declaredClass).error(e)})),this.notifyChange("updating"))}),a),r((()=>this.timeExtent),(()=>{this.subview.timeExtent=this.timeExtent,this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||t.getLogger(this.declaredClass).error(e)}))}),n)])}detach(){this.layer.decreaseRasterJobHandlerUsage(),this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.subview.moveEnd()}async hitTest(e,t){return[{type:"graphic",layer:this.layer,mapPoint:e,graphic:new s({attributes:{},geometry:e.clone()})}]}doRefresh(){return this.subview?this.subview.doRefresh():Promise.resolve()}_updateSubview(){const e=this.layer.renderer?.type;if(!e)return;const s="vector-field"===e?"rasterVF":"flow"===e?"flow":"raster";if(this.subview){if(this.subview.type===s)return void this._attachSubview(this.subview);this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}const{layer:t}=this;let i;if(i="rasterVF"===s?new m({layer:t,layerView:this}):"flow"===s?new c({layer:t,layerView:this}):new p({layer:t,layerView:this}),"useWebGLForProcessing"in i&&(i.useWebGLForProcessing=this._useWebGLForProcessing),"useProgressiveUpdate"in i&&(i.useProgressiveUpdate=this._useProgressiveUpdate),"previousLOD"in i){const{subview:e}=this;i.previousLOD=e&&"previousLOD"in e?e.previousLOD:null}this._attachSubview(i),this.subview=i,this.requestUpdate()}_attachSubview(e){e&&!e.attached&&(e.attach(),e.attached=!0,this.container.addChildAt(e.container,0),e.container.blendMode=this.layer.blendMode,e.container.effect=this.layer.effect)}_detachSubview(e){e?.attached&&(this.container.removeChild(e.container),e.detach(),e.attached=!1)}};e([u()],g.prototype,"subview",void 0),e([u()],g.prototype,"useWebGLForProcessing",null),e([u()],g.prototype,"useProgressiveUpdate",null),e([u({readOnly:!0})],g.prototype,"displayParameters",null),g=e([h("esri.views.2d.layers.ImageryTileLayerView2D")],g);const f=g;export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as n}from"../support/util.js";let o=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&n(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:n}=e,o=i.supportsGPU&&(!n||n.rasters.length<=1),a=o?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!o||!a?.functions.length||"raster-stretch"===l
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as n}from"../support/util.js";let o=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&n(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:n}=e,o=i.supportsGPU&&(!n||n.rasters.length<=1),a=o?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!o||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:a;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,r){const t=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:n,globalSymbolizerParams:o,suspended:a,coords:l,resolution:c}=r,u=this.layerView.hasTilingEffects?o:r.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,n&&null!=n&&null!=n.pixelBlock){const e={extent:n.extent,pixelBlock:n.pixelBlock};if(p.rawPixelData=e,i)p.source=n.pixelBlock,p.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===o?.type?o:void 0);p.source=r,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,i?p.transformGrid||(p.transformGrid=n.transformGrid):p.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,r){const{local:t,global:s}=r,i=this._getBandIds(),n=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;o||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=o?this.layerView.hasTilingEffects?s:t:null,a.bandIds=o?i:null,a.interpolation=n,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:r}=this.layer;if(!r)return e;const t=r.type;return"raster-colormap"===t||"unique-value"===t||"class-breaks"===t?"nearest":"raster-stretch"===r.type&&null!=r.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([r()],o.prototype,"container",void 0),e([r()],o.prototype,"layer",void 0),e([r()],o.prototype,"type",void 0),o=e([t("esri.views.2d.layers.imagery.ImageryTileView2D")],o);const a=o;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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as i}from"../../layers/support/commonProperties.js";import{getDefaultDatumTransformationForDataset as a,projectExtent as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as l}from"./support/popupUtils.js";const p=p=>{let u=class extends p{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return this.projectFullExtent(this.view.spatialReference)}get hasTilingEffects(){return
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{combinedViewLayerTimeExtentProperty as i}from"../../layers/support/commonProperties.js";import{getDefaultDatumTransformationForDataset as a,projectExtent as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as l}from"./support/popupUtils.js";const p=p=>{let u=class extends p{constructor(){super(...arguments),this._rasterFieldPrefix="Raster.",this.layer=null,this.view=null,this.tileInfo=null}get fullExtent(){return this._getfullExtent()}_getfullExtent(){return this.projectFullExtent(this.view.spatialReference)}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){return a(this.layer.fullExtent,this.view.spatialReference,!0)}supportsSpatialReference(e){return!!this.projectFullExtent(e)}projectFullExtent(e){const t=this.layer.fullExtent,r=a(t,e,!1);return n(t,e,r)}async fetchPopupFeatures(e,o){const{layer:s}=this;if(!e)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:i}=s,a=l(s,o);if(!i||null==a)throw new r("imageryTileLayerView:fetchPopupFeatures","Missing required popupTemplate or popupEnabled",{popupEnabled:i,popupTemplate:a});const n=[],{value:p,magdirValue:u}=await s.identify(e,{timeExtent:this.timeExtent});let c="";if(p&&p.length){c="imagery-tile"===s.type&&s.hasStandardTime()&&null!=p[0]?p.map((e=>s.getStandardTimeValue(e))).join(", "):p.join(", ");const e={ObjectId:0};e["Raster.ServicePixelValue"]=c;const r=s.rasterInfo.attributeTable;if(null!=r){const{fields:t,features:o}=r,s=t.find((({name:e})=>"value"===e.toLowerCase())),i=s?o.find((e=>String(e.attributes[s.name])===c)):null;if(i)for(const r in i.attributes)if(i.attributes.hasOwnProperty(r)){e[this._rasterFieldPrefix+r]=i.attributes[r]}}const o=s.rasterInfo.dataType;"vector-magdir"!==o&&"vector-uv"!==o||(e["Raster.Magnitude"]=u?.[0],e["Raster.Direction"]=u?.[1]);const i=new t(this.fullExtent.clone(),null,e);i.layer=s,i.sourceLayer=i.layer,n.push(i)}return n}};return e([o()],u.prototype,"layer",void 0),e([o(i)],u.prototype,"timeExtent",void 0),e([o()],u.prototype,"view",void 0),e([o()],u.prototype,"fullExtent",null),e([o()],u.prototype,"tileInfo",void 0),e([o({readOnly:!0})],u.prototype,"hasTilingEffects",null),e([o()],u.prototype,"datumTransformation",null),u=e([s("esri.views.layers.ImageryTileLayerView")],u),u};export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as g}from"./CreateFeaturesWorkflowData.js";import{waitForModelUpload as v}from"./modelUploadUtils.js";import y from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as M,startCreatingNewFeature as _,findLayerInfo as b,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as F,getVisualVariableAttributes as I,startUpdatingFeature as V,createWorkflowSteps as k,avoidFeatureTemplateSelectionWithOnlyOneItem as j,prepareAttachmentsForCreateWorkflow as S,visualVariableInteractiveUpdate as U}from"./workflowUtils.js";var C;const O=Symbol();let E=C=class extends y{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&M(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"===this.stepId&&e)return m(e.layer.geometryType,t.sketchViewModel.createGraphic?.geometry)}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const o=new C({data:new g({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;e.creationInfo=null;const n=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=o._attachmentFileInfos;if(l){const e=H(n,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:n});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,G(n,e,s,c))}}});return o._set("steps",this._createWorkflowSteps(o,a)),o}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{creationInfo:t}=this.data;if(t)return this.createFeatureState="create-new",_(this.data.viewModel.sketchViewModel,t,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:o}=this.data,{featureFormViewModel:n,layerInfos:s,sketchViewModel:l,view:c}=o;if(!c||!a)return;const d=a.layer,u=b(s,d),h=u?.formTemplate,p=c.spatialReference;return n.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),r(this._featureFormHandle),this._featureFormHandle=i([n.on("value-change",(async()=>{e.attributes=n.getValues(),await A(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&F(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=I(e),V(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,i="awaiting-feature-creation-info"){const{data:d,handles:u}=e;let h=null,p=!0;const f=new Map,m=k(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],i,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a}=d;"scene"===a?.layer?.type?(await v({workflow:e,stepId:this.id,handles:u,signal:t}),n(t)):(d.creationInfo=null,u.add(d.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(d.creationInfo=e,d.viewModel.activeWorkflow?.next())})),this.id))},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(u.has(this.id))return;const i=d.viewModel.view;if(!i)return;const n=d.viewModel.sketchViewModel;p=n.updateOnGraphicClick,n.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},S(d.viewModel.attachmentsViewModel);const m="2d"===i.type&&d.creationInfo?e._fadeExistingFeatures(d.creationInfo.layer):null,g=n.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(f);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,f)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,f)})),v=n.on("update",(async t=>{const r=t.graphics[0];if("complete"===t.state){if(r!==h&&(e._lastActiveGraphics.push(r),e._highlight(r)),h=null,"add"!==d.viewModel.attachmentsViewModel.mode&&"edit"!==d.viewModel.attachmentsViewModel.mode||d.viewModel.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);const o=i.cursor;return i.cursor="progress",u.add([a((()=>i.cursor=o)),i.on("click",(e=>e.preventDefault()))],O),s((()=>!d.viewModel.featureFormViewModel.updating)).then((()=>{u.remove(O),e._startCreating(f)}))}if("start"===t.state){e._removeHighlight(r);const t=d.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||d.viewModel.activeWorkflow?.previous(),t.fileInfos.removeAll(),t.graphic=r,t.mode="view";(e._attachmentFileInfos.get(r)||[]).forEach((({file:e,form:a})=>t.addFile(e,a)))}await U(i,r,t,e._visualVariableAttributes,f);const o=r.attributes;if(null!=e._visualVariableAttributes.rotation){const{field:t}=e._visualVariableAttributes.rotation;d.viewModel.featureFormViewModel.setValue(t,o[t])}if(null!=e._visualVariableAttributes.size){const{field:t}=e._visualVariableAttributes.size;d.viewModel.featureFormViewModel.setValue(t,o[t])}})),y=n.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),h=i}));let M=null;const _=l((()=>{const e=n.snappingOptions.featureSources.find((e=>e.layer===d.creationInfo?.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=n.snappingOptions.featureSources;e?(null==M&&(M=new w({layer:n.layer,enabled:t}),a.add(M)),M.enabled=t):(null!=M&&a.remove(M),M=o(M))}),c),b=i.on("immediate-click",(async t=>{const{results:a}=await i.hitTest(t,{include:n.layer}),r=a.find((e=>"graphic"===e.type));if(r){const t=r.graphic;if("transform"===n.activeTool||"reshape"===n.activeTool){if(n.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,f)}}})),A=l((()=>d.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&d.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&d.viewModel.activeWorkflow.go("editing-attachment")}));await e._startCreating(f);const F={remove:()=>{r(e._featureFormHandle),g.remove(),v.remove(),y.remove(),_.remove(),null!=M&&n.snappingOptions.featureSources.remove(M),M=o(M),n.cancel(),b.remove(),A.remove(),r(m)}};u.add(F,this.id)},async tearDown(t){t.cancelled&&(d.viewModel.sketchViewModel.layer.removeAll(),u.remove([this.id,O]),d.viewModel.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),d.viewModel.sketchViewModel.updateOnGraphicClick=p)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}})});return j(d,m)}};function G(e,t,a,i){const r=[];return t.forEach(((t,o)=>{if(!t.error){const n=e[o],s=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function H(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,o)=>{var n;(n=e[o].attributes)[r]??(n[r]=d()),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],E.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],E.prototype,"shouldShowAttachments",null),e([u()],E.prototype,"shouldAllowAttachmentEditing",null),e([u()],E.prototype,"helpMessage",null),E=C=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],E);const D=E;export{D as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as w}from"./CreateFeaturesWorkflowData.js";import{waitForModelUpload as v}from"./modelUploadUtils.js";import y from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as M,startCreatingNewFeature as _,findLayerInfo as b,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as F,getVisualVariableAttributes as I,startUpdatingFeature as V,createWorkflowSteps as k,avoidFeatureTemplateSelectionWithOnlyOneItem as j,prepareAttachmentsForCreateWorkflow as S,visualVariableInteractiveUpdate as U}from"./workflowUtils.js";var C;const E=Symbol();let O=C=class extends y{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"===this.stepId&&e)return m(e.layer.geometryType,t.sketchViewModel.createGraphic?.geometry)}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&M(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const o=new C({data:new w({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;t.geometryToPlace&&(e.creationInfo=null);const n=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=o._attachmentFileInfos;if(l){const e=H(n,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:n});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,G(n,e,s,c))}}});return o._set("steps",this._createWorkflowSteps(o,a)),o}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{creationInfo:t}=this.data;if(t)return this.createFeatureState="create-new",_(this.data.viewModel.sketchViewModel,t,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:o}=this.data,{featureFormViewModel:n,layerInfos:s,sketchViewModel:l,view:c}=o;if(!c||!a)return;const d=a.layer,u=b(s,d),h=u?.formTemplate,p=c.spatialReference;return n.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),r(this._featureFormHandle),this._featureFormHandle=i([n.on("value-change",(async()=>{e.attributes=n.getValues(),await A(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&F(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=I(e),V(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,i="awaiting-feature-creation-info"){const{data:d,handles:u}=e;let h=null,p=!0;const f=new Map,m=k(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],i,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a}=d;"scene"===a?.layer?.type?(await v({workflow:e,stepId:this.id,handles:u,signal:t}),n(t)):(d.creationInfo=null,u.add(d.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(d.creationInfo=e,d.viewModel.activeWorkflow?.next())})),this.id))},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(u.has(this.id))return;const i=d.viewModel.view;if(!i)return;const n=d.viewModel.sketchViewModel;p=n.updateOnGraphicClick,n.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},S(d.viewModel.attachmentsViewModel);const m="2d"===i.type&&d.creationInfo?e._fadeExistingFeatures(d.creationInfo.layer):null,w=n.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(f);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,f)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,f)})),v=n.on("update",(async t=>{const r=t.graphics[0];if("complete"===t.state){if(r!==h&&(e._lastActiveGraphics.push(r),e._highlight(r)),h=null,"add"!==d.viewModel.attachmentsViewModel.mode&&"edit"!==d.viewModel.attachmentsViewModel.mode||d.viewModel.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);const o=i.cursor;return i.cursor="progress",u.add([a((()=>i.cursor=o)),i.on("click",(e=>e.preventDefault()))],E),s((()=>!d.viewModel.featureFormViewModel.updating)).then((()=>{u.remove(E),e._startCreating(f)}))}if("start"===t.state){e._removeHighlight(r);const t=d.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||d.viewModel.activeWorkflow?.previous(),t.fileInfos.removeAll(),t.graphic=r,t.mode="view";(e._attachmentFileInfos.get(r)||[]).forEach((({file:e,form:a})=>t.addFile(e,a)))}await U(i,r,t,e._visualVariableAttributes,f);const o=r.attributes;if(null!=e._visualVariableAttributes.rotation){const{field:t}=e._visualVariableAttributes.rotation;d.viewModel.featureFormViewModel.setValue(t,o[t])}if(null!=e._visualVariableAttributes.size){const{field:t}=e._visualVariableAttributes.size;d.viewModel.featureFormViewModel.setValue(t,o[t])}})),y=n.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),h=i}));let M=null;const _=l((()=>{const e=n.snappingOptions.featureSources.find((e=>e.layer===d.creationInfo?.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=n.snappingOptions.featureSources;e?(null==M&&(M=new g({layer:n.layer,enabled:t}),a.add(M)),M.enabled=t):(null!=M&&a.remove(M),M=o(M))}),c),b=i.on("immediate-click",(async t=>{const{results:a}=await i.hitTest(t,{include:n.layer}),r=a.find((e=>"graphic"===e.type));if(r){const t=r.graphic;if("transform"===n.activeTool||"reshape"===n.activeTool){if(n.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,f)}}})),A=l((()=>d.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&d.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&d.viewModel.activeWorkflow.go("editing-attachment")}));await e._startCreating(f);const F={remove:()=>{r(e._featureFormHandle),w.remove(),v.remove(),y.remove(),_.remove(),null!=M&&n.snappingOptions.featureSources.remove(M),M=o(M),n.cancel(),b.remove(),A.remove(),r(m)}};u.add(F,this.id)},async tearDown(t){t.cancelled&&(d.viewModel.sketchViewModel.layer.removeAll(),u.remove([this.id,E]),d.viewModel.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),d.viewModel.sketchViewModel.updateOnGraphicClick=p)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}})});return j(d,m)}};function G(e,t,a,i){const r=[];return t.forEach(((t,o)=>{if(!t.error){const n=e[o],s=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function H(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,o)=>{var n;(n=e[o].attributes)[r]??(n[r]=d()),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],O.prototype,"hasPendingEdits",null),e([u()],O.prototype,"helpMessage",null),e([u()],O.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],O.prototype,"shouldShowAttachments",null),e([u()],O.prototype,"shouldAllowAttachmentEditing",null),O=C=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],O);const D=O;export{D as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import _ from"./CreateFeaturesWorkflow.js";import W from"./CreateWorkflow.js";import{workflowDeprecation as C}from"./deprecationUtils.js";import F from"./UpdateWorkflow.js";import{whenEditorLayerView as E}from"./workflowUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import O from"../FeatureTemplates/FeatureTemplatesViewModel.js";import U from"../Sketch/SketchViewModel.js";import A from"../Spinner/SpinnerViewModel.js";const V="esri.widgets.Editor.EditorViewModel",j=n.getLogger(V),M=["create","create-features","update"];function T(t,e,a){j.error(new i(t,e,a))}function S(t,e){return t?t.find((t=>t.layer===e)):void 0}let L=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new b({abilities:{editing:!0}}),this.featureFormViewModel=new I,this.featureTemplatesViewModel=new O,this.sketchViewModel=new U({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new A,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...M]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(j,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.pendingFeatures.length?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.pendingFeatures.length){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&(t.numPendingFeatures>0||!!t.data.upload||!!t.data.creationInfo?.geometryToPlace)||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(C(j,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(C(j,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(C(j,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):T("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&T("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return _.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return W.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return F.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await E(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{T("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=S(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],L.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],L.prototype,"_activityQueue",void 0),t([f({value:[...M]})],L.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],L.prototype,"canCreate",null),t([f({readOnly:!0})],L.prototype,"canUpdate",null),t([f()],L.prototype,"editableItems",void 0),t([f({readOnly:!0})],L.prototype,"failures",void 0),t([f()],L.prototype,"attachmentsViewModel",void 0),t([f()],L.prototype,"featureFormViewModel",void 0),t([f()],L.prototype,"featureTemplatesViewModel",void 0),t([f()],L.prototype,"labelOptions",null),t([f()],L.prototype,"layerInfos",null),t([f()],L.prototype,"sketchViewModel",void 0),t([f()],L.prototype,"snappingOptions",null),t([f()],L.prototype,"spinnerViewModel",void 0),t([f()],L.prototype,"state",null),t([f({readOnly:!0})],L.prototype,"syncing",null),t([f()],L.prototype,"updating",null),t([f()],L.prototype,"tooltipOptions",null),t([f()],L.prototype,"view",null),t([f()],L.prototype,"pageStack",void 0),t([f()],L.prototype,"showDiscardPrompt",void 0),t([f()],L.prototype,"_candidateCommitted",void 0),t([f()],L.prototype,"page",null),t([f()],L.prototype,"selectedTemplateItem",null),t([f()],L.prototype,"featureFormDisabled",null),t([f()],L.prototype,"canGoBack",null),t([f()],L.prototype,"shouldShowDeleteButton",null),t([f()],L.prototype,"hasPendingEdits",null),L=t([m(V)],L);const P=L;export{P as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import W from"./CreateFeaturesWorkflow.js";import _ from"./CreateWorkflow.js";import{workflowDeprecation as C}from"./deprecationUtils.js";import F from"./UpdateWorkflow.js";import{whenEditorLayerView as E}from"./workflowUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import U from"../FeatureTemplates/FeatureTemplatesViewModel.js";import O from"../Sketch/SketchViewModel.js";import A from"../Spinner/SpinnerViewModel.js";const V="esri.widgets.Editor.EditorViewModel",M=n.getLogger(V),j=["create","create-features","update"];function T(t,e,a){M.error(new i(t,e,a))}function S(t,e){return t?t.find((t=>t.layer===e)):void 0}let L=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.editableItems=new a,this.failures=[],this.attachmentsViewModel=new b({abilities:{editing:!0}}),this.featureFormViewModel=new I,this.featureTemplatesViewModel=new U,this.sketchViewModel=new O({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new A,this.pageStack=[],this.showDiscardPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.save=()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||this.activeWorkflow?.commit()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this.editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...j]),this._set("allowedWorkflows",t)}get canCreate(){return this.editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this.editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(M,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.hasPendingEdits||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(C(M,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(C(M,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(C(M,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?(await this._delete(t.data.edits.feature),await t.reset()):T("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this.editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this.editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this.editableItems;this.editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&T("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return W.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return _.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return F.create(this,t,((t,e)=>this._applyEdits(t,e)))}async _delete(t){const e=t?.sourceLayer;e&&"applyEdits"in e&&await this._applyEdits(e,{deleteFeatures:[t]})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await E(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{T("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=S(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f({readOnly:!0})],L.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],L.prototype,"_activityQueue",void 0),t([f({value:[...j]})],L.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],L.prototype,"canCreate",null),t([f({readOnly:!0})],L.prototype,"canUpdate",null),t([f()],L.prototype,"editableItems",void 0),t([f({readOnly:!0})],L.prototype,"failures",void 0),t([f()],L.prototype,"attachmentsViewModel",void 0),t([f()],L.prototype,"featureFormViewModel",void 0),t([f()],L.prototype,"featureTemplatesViewModel",void 0),t([f()],L.prototype,"labelOptions",null),t([f()],L.prototype,"layerInfos",null),t([f()],L.prototype,"sketchViewModel",void 0),t([f()],L.prototype,"snappingOptions",null),t([f()],L.prototype,"spinnerViewModel",void 0),t([f()],L.prototype,"state",null),t([f({readOnly:!0})],L.prototype,"syncing",null),t([f()],L.prototype,"updating",null),t([f()],L.prototype,"tooltipOptions",null),t([f()],L.prototype,"view",null),t([f()],L.prototype,"pageStack",void 0),t([f()],L.prototype,"showDiscardPrompt",void 0),t([f()],L.prototype,"_candidateCommitted",void 0),t([f()],L.prototype,"page",null),t([f()],L.prototype,"selectedTemplateItem",null),t([f()],L.prototype,"featureFormDisabled",null),t([f()],L.prototype,"canGoBack",null),t([f()],L.prototype,"shouldShowDeleteButton",null),t([f()],L.prototype,"hasPendingEdits",null),t([f()],L.prototype,"useDeprecatedCreateWorkflow",void 0),L=t([m(V)],L);const P=L;export{P as default};
|