@arcgis/core 4.34.3 → 4.34.5
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/{0638a36eaacb56cf89fa.js → 262851e9feb1e55ad09d.js} +1 -1
- package/assets/esri/core/workers/chunks/ce961c602c51637b3e1c.js +1 -0
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/parquetUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/support/flow/constants.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/support/forms/expressions/FormExpressionArcadeExecutor.js +1 -1
- package/assets/esri/core/workers/chunks/c91ce5fcdd4d0a6514d3.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Collection.js";import t from"../../core/Error.js";import{JSONMap as o}from"../../core/jsonMap.js";import n from"../../geometry/SpatialReference.js";import i from"./Field.js";import{inferLocationInfo as r}from"./locationUtils.js";import l from"./ParquetEncodingLocation.js";import s from"./ParquetEncodingWkb.js";import{createParquetFile as a,readGeoMetadata as m,readEsriMetadata as u}from"../../libs/parquet/parquet.js";const c=new o({esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint"});function p(e){return c.toJSON(e)}function f(e){return c.fromJSON(e)}function d(t,o={}){return y({urls:new e(t)},o)}async function y(e,o={}){if(e.geometryType&&e.spatialReference&&e.encoding&&e.fields)return e;if(e.urls.length<1)throw new t("parquet:bad-input","At least one url must be specified",e);const r=await a(e.urls.getItemAt(0),{getCustomParameters:()=>o.customParameters}),l=m(r),s={...e,file:r};null==s.fields&&(s.fields=r.fields().map(e=>i.fromJSON({name:e.name,type:e.type}))),null==s.encoding&&(s.encoding=g(l,s.fields));const c=u(r);if(c)switch(c.mode){case"z":s.displayOptimization={mode:"z"};break;case"xz":{const e=c.multiscale;if(!e)throw new t("bad-format","XZ display optimization requires multiscale geometries");s.displayOptimization={mode:"xz",multiscale:e};break}}if(!s.encoding)return s;switch(s.encoding.type){case"location":null==s.spatialReference&&(s.spatialReference=n.WGS84),null==s.geometryType&&(s.geometryType="point");break;case"wkb":{if(!l)return s;const e=l.primary_column,t=l.columns[e];if(s.geometryType||(s.geometryType=P(t)),s.spatialReference||(s.spatialReference=b(t)),s.fields)for(const o of Object.keys(l.columns))s.fields=s.fields.filter(e=>e.name!==o)}}return s}function g(e,t){if(null!=e){const t=e.primary_column,o=e.columns[t];return new s({primaryFieldName:t,orientation:o.orientation??null})}const o=r(t.map(e=>e.name));return o.latitudeFieldName&&o.
|
|
5
|
+
import e from"../../core/Collection.js";import t from"../../core/Error.js";import{JSONMap as o}from"../../core/jsonMap.js";import n from"../../geometry/SpatialReference.js";import i from"./Field.js";import{inferLocationInfo as r}from"./locationUtils.js";import l from"./ParquetEncodingLocation.js";import s from"./ParquetEncodingWkb.js";import{createParquetFile as a,readGeoMetadata as m,readEsriMetadata as u}from"../../libs/parquet/parquet.js";const c=new o({esriGeometryPoint:"point",esriGeometryPolygon:"polygon",esriGeometryPolyline:"polyline",esriGeometryMultipoint:"multipoint"});function p(e){return c.toJSON(e)}function f(e){return c.fromJSON(e)}function d(t,o={}){return y({urls:new e(t)},o)}async function y(e,o={}){if(e.geometryType&&e.spatialReference&&e.encoding&&e.fields)return e;if(e.urls.length<1)throw new t("parquet:bad-input","At least one url must be specified",e);const r=await a(e.urls.getItemAt(0),{getCustomParameters:()=>o.customParameters}),l=m(r),s={...e,file:r};null==s.fields&&(s.fields=r.fields().map(e=>i.fromJSON({name:e.name,type:e.type}))),null==s.encoding&&(s.encoding=g(l,s.fields));const c=u(r);if(c)switch(c.mode){case"z":s.displayOptimization={mode:"z"};break;case"xz":{const e=c.multiscale;if(!e)throw new t("bad-format","XZ display optimization requires multiscale geometries");s.displayOptimization={mode:"xz",multiscale:e};break}}if(!s.encoding)return s;switch(s.encoding.type){case"location":null==s.spatialReference&&(s.spatialReference=n.WGS84),null==s.geometryType&&(s.geometryType="point");break;case"wkb":{if(!l)return s;const e=l.primary_column,t=l.columns[e];if(s.geometryType||(s.geometryType=P(t)),s.spatialReference||(s.spatialReference=b(t)),s.fields)for(const o of Object.keys(l.columns))s.fields=s.fields.filter(e=>e.name!==o)}}return s}function g(e,t){if(null!=e){const t=e.primary_column,o=e.columns[t];return new s({primaryFieldName:t,orientation:o.orientation??null})}const o=r(t.map(e=>e.name));return o.latitudeFieldName&&o.longitudeFieldName?new l({latitudeFieldName:o.latitudeFieldName,longitudeFieldName:o.longitudeFieldName}):null}function w(e){switch(e){case"Point":return"point";case"Polygon":case"MultiPolygon":return"polygon";case"LineString":return"polyline";case"MultiPoint":return"multipoint";default:return null}}function P(e){const{geometry_types:o}=e,n=new Set;for(const t of o){const e=w(t);e&&n.add(e)}if(n.size>1)throw new t("unsupported","Parquet mixed geometry types are not support",{geometryTypes:n});return 1===n.size?n.values().next().value:void 0}function b(e){const t=e.crs?.id?.code;return t&&"number"==typeof t?new n({wkid:t}):void 0}export{y as completeParquetLayerInfo,f as fromParquetJSONGeometryType,d as getParquetLayerInfo,c as parquetGeometryTypeKebabDict,p as toParquetJSONGeometryType};
|
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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const c="20251028",e="724e4a60c50767f78dca62e1f2ec7596dc807515";export{c as buildDate,e 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as s}from"./processor/textureUtils.js";import{RasterColorizerLUTShader as o}from"../shaders/raster/RasterColorizerLUTShader.js";import{RasterColorizerShadedReliefShader as r}from"../shaders/raster/RasterColorizerShadedReliefShader.js";import{RasterColorizerStretchShader as n}from"../shaders/raster/RasterColorizerStretchShader.js";import{SizedPixelFormat as a,PixelType as u}from"../../../../../../webgl/enums.js";import{FramebufferObject as c}from"../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../../../../webgl/TextureDescriptor.js";
|
|
5
|
+
import has from"../../../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{TextureStatisticsTechnique as i}from"../TextureStatisticsTechnique.js";import{getInterpolationDefines as s}from"./processor/textureUtils.js";import{RasterColorizerLUTShader as o}from"../shaders/raster/RasterColorizerLUTShader.js";import{RasterColorizerShadedReliefShader as r}from"../shaders/raster/RasterColorizerShadedReliefShader.js";import{RasterColorizerStretchShader as n}from"../shaders/raster/RasterColorizerStretchShader.js";import{SizedPixelFormat as a,PixelType as u}from"../../../../../../webgl/enums.js";import{FramebufferObject as c}from"../../../../../../webgl/FramebufferObject.js";import{Texture as m}from"../../../../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../../../../webgl/TextureDescriptor.js";const h=160,p=new Set(["f32","f64","u16","s16","u32","s32"]);class f extends t{constructor(){super(...arguments),this.name="BrushRasterColorizer",this.type=0,this.shaders={lut:new o,stretch:new n,shadedRelief:new r},this._mosaicFbo=null,this._statisticsTechnique=null,this._draTimer=0}shutdown(t){super.shutdown(t),this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique)}render(t,i){const s=i.bitmaps.some(g);s||(this._mosaicFbo=e(this._mosaicFbo),this._statisticsTechnique=e(this._statisticsTechnique));const o=s?this._computeStatisticsTextures(t,i):void 0;for(const e of i.bitmaps){if(!e.source||e.suspended)continue;t.timeline.begin(this.name);const{painter:i}=t;i.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}}),e.updateTexture(t),e.updateProcessedTexture();const{type:s}=e.symbolizerParameters,r="stretch"===s?this._getStretchOptions(e,o):"lut"===s?this._getLutOptions(e):this._getShadedReliefOptions(e);"bilinear"!==e.interpolation||t.context.capabilities.textureFloatLinear||(r.defines.bilinear=!0),i.submitDrawMesh(t.context,r,i.quadMesh,e),t.timeline.end(this.name)}}_computeStatisticsTextures(e,t){this._statisticsTechnique??=new i;const s=this._statisticsTechnique;let o=has("esri-2d-dra-delay");if(null==o){const e=t.bitmaps.find(g),{stretchType:i,bandCount:s}=e.symbolizerParameters,{pixelType:r}=e.source;"minMax"===i&&s>=3&&p.has(r)&&(o=h)}if(o){const i=performance.now();(i-this._draTimer>=o||e.stationary||!s.minValuesTexture)&&(this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo}),this._draTimer=i)}else this._mosaic(e,t),s.render(e,{fbo:this._mosaicFbo});return{minTexture:s.minValuesTexture,maxTexture:s.maxValuesTexture,meanTexture:s.meanValuesTexture,stddevTexture:s.stdDevValuesTexture}}_mosaic(e,t){const{context:i,painter:s}=e,o=i.getBoundFramebufferObject();if(this._mosaicFbo)this._mosaicFbo.resize(o.width,o.height);else{const e=d(i,o.width,o.height);this._mosaicFbo=new c(i,e)}i.bindFramebuffer(this._mosaicFbo);const r="RasterColorizerMosaic";for(const n of t.bitmaps){if(!g(n))continue;e.timeline.begin(r),s.setPipelineState({depth:!1,stencil:{test:{mask:255,compare:514,op:{fail:7680,zFail:7680,zPass:7680}},write:!1},color:{write:[!0,!0,!0,!0],blendMode:"composite"}});const t=n.interpolation;n.interpolation="nearest",n.updateTexture(e),n.updateProcessedTexture();const i=this._getStretchOptions(n);i.defines.noOp=!0,s.submitDrawMesh(e.context,i,s.quadMesh,n),n.interpolation=t,e.timeline.end(r)}i.bindFramebuffer(o)}_getLutOptions(e){const{config:t,projectionConfig:i,colormapConfig:o,pixelMaskConfig:r,highlightConfig:n,projectionDefines:a}=this._getCommonConfig(e),u=s(e);return{shader:this.shaders.lut,uniforms:{projectionConfig:i,config:t,colormapConfig:o,pixelMaskConfig:r,highlightConfig:n},defines:{...a,...u,applyPixelMask:!!r,applyPixelHighlights:!!n},optionalAttributes:null,useComputeBuffer:!1}}_getStretchOptions(e,t){const i=e.symbolizerParameters,{config:o,projectionConfig:r,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,projectionDefines:c,textureUnit:m}=this._getCommonConfig(e),l=s(e),h=t?{minTexture:{texture:t.minTexture,unit:m},maxTexture:{texture:t.maxTexture,unit:m+1},meanTexture:{texture:t.meanTexture,unit:m+2},stddevTexture:{texture:t.stddevTexture,unit:m+3},numberOfStandardDeviations:i.numberOfStandardDeviations||2}:void 0,p=t?"standardDeviation"===i.stretchType?2:1:0;return{shader:this.shaders.stretch,uniforms:{projectionConfig:r,config:o,stretchConfig:i,colormapConfig:n,pixelMaskConfig:a,highlightConfig:u,statisticsConfig:h},defines:{...c,...l,isMultiband:i.bandCount>1,applyColormap:!!n,useGamma:i.useGamma,noOp:e.isRendereredSource&&!e.processed,applyPixelMask:!!a,applyPixelHighlights:!!u,draStretchType:p},optionalAttributes:null,useComputeBuffer:!1}}_getShadedReliefOptions(e){const t=e.symbolizerParameters,{config:i,projectionConfig:o,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a,projectionDefines:u}=this._getCommonConfig(e),c=s(e);return{shader:this.shaders.shadedRelief,uniforms:{projectionConfig:o,config:i,hillshadeConfig:t,colormapConfig:r,pixelMaskConfig:n,highlightConfig:a},defines:{...u,...c,isMultidirectional:t.hillshadeType>0,applyColormap:!!r,applyPixelMask:!!n,applyPixelHighlights:!!a},optionalAttributes:null,useComputeBuffer:!1}}_getCommonConfig(e){const{coordScale:t,computedOpacity:i,transforms:s}=e,{names:o,textures:r}=e.getTextures({useProcessedTexture:e.processed}),n=r[o.indexOf("u_image")],a=e.getRasterTextureSize();let u=0;const c={texture:{texture:n,unit:u++},dvsMat3:s.displayViewScreenMat3,coordScale:t,srcImageSize:a,opacity:i},m=r[o.indexOf("u_transformGrid")],{transformGrid:l}=e,h=!(!m||!l),p=h?{transformTexture:{texture:m,unit:u++},targetImageSize:[e.width,e.height],transformSpacing:l.spacing,transformGridSize:l.size}:void 0,f=r[o.indexOf("u_colormap")],{colormap:d,colormapOffset:g}=e.symbolizerParameters,x=f&&d?{colormapTexture:{texture:f,unit:u++},colormapOffset:g??0,colormapMaxIndex:d.length/4-1}:void 0,T=r[o.indexOf("u_mask")],b=T?{maskTexture:{texture:T,unit:u++}}:void 0,{highlightTexture:C}=e;return{config:c,projectionConfig:p,colormapConfig:x,pixelMaskConfig:b,highlightConfig:C?{highlightTexture:{texture:C,unit:u++}}:void 0,projectionDefines:{applyProjection:h,lookupProjection:h&&1===l.spacing[0]},textureUnit:u}}}function d(e,t,i){const s=new l(t,i);return s.internalFormat=a.RGBA32F,s.samplingMode=9728,s.dataType=u.FLOAT,s.wrapMode=33071,new m(e,s)}function g(e){return!e.suspended&&null!=e.source&&!e.isRendereredSource&&"stretch"===e.symbolizerParameters.type&&!!e.symbolizerParameters.dynamicRangeAdjustment}export{f as RasterColorizerTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as r}from"../../../core/maybe.js";import{debounce as s,ignoreAbortErrors as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as l,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{getMetersPerVerticalUnitForSR as m}from"../../../core/unitUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import{projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{fromExtent as v,intersection as w,toExtent as T,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as j}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as L,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import U from"./SubView3D.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{tileFilterDistance as E,thresholdForLoadingAllTiles as I,fadeOutTime as q,fadeInTime as F,defaultTransitionDuration as V,transitionDurationFactor as k,seamlessTransitionEnabled as C,averageLoadingTimeSmoothingFactor as D,minimumTracingResolution as B}from"../support/flow/constants.js";import{wrappedWidth as W,isFullExtent as z,FlowQuery3D as G}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as O,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{tilesAreRelated as X}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as Y}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as Z}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as $,hasLayerBasedScaleVisibility as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";let ie=class extends U{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=s(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*r(r){for(let s=0;s<e.length;++s){const n=e.at(s);t(n)&&i.add(n),r.madeProgress(),r.done&&(r=yield)}}await this.frameTask.scheduleGenerator(r),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(P(i)),this.frameTask=i.scheduler.registerTask(te.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([l(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),l(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),l(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()}),t.enableFeatureTiles(),l(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),l(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],r=e?.visualVariables??[];r.length===i.length&&r.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=r(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=y(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=y(this.layer.fullExtent,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get _ellipsoidRadius(){return f(this.view.spatialReference).radius}get extent(){const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<E&&e.add(t)}),t=e}const r=Q(t,this.spatialReferenceInfo);return null==r?null:(w(r,this._clippingArea,r),T(r,e))}get loadAllTiles(){const{position:e}=this.view.camera,t=e.z;if(null==t)return!1;return t*m(e.spatialReference)/this._ellipsoidRadius>=I}get loadByTileTreesAllowed(){return!this.loadAllTiles||!this.loadRequirementsMet}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=y(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...O(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:F,fadeOutTime:q,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&Y(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?V:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:C}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=W(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,r]=this.view.size;let s,n;i<r?(s=i,n=i/t):(s=r*t,n=r);const o=B,l=this.view.qualitySettings.flow3D.maxTracingResolution,a=Math.max(1,o/Math.min(s,n)),u=a*Math.min(1,l/Math.max(s*a,n*a));return[Math.round(s*u),Math.round(n*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density,s=null==e?null:v(e);if(null==s)return 0;let n=0;for(const a of i)S(s,a.extent)&&(n+=b(a.extent));const o=b(s),l=0===o?0:n/o;return 2*Math.round(r*l)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:r}=this.view;if(null==t)return 0;const s=i.flow3D.maxTotalNumberOfStreamlines,n=e>=s?s/e:1,o=t.density*n*r;return t.lineSpacing/Math.sqrt(o)<t.lineCollisionWidth?4*t.lineSpacing:o}get elevationInfo(){return this.layer.elevationInfo??re}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:L(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return j(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&this.renderedTiles.size>0}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ee()||$(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const r="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:r,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const r=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const r=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(r)};this.updatingHandles.addPromise(n(r())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=D;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const r=new G(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const s=this._abortController,n=await this._loadStreamlines(r,s.signal);if(o(s.signal),this._visible&&null!=n){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=n;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await n.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:r,material:s}=await this._createGeometry(e,i);return this._draped?new J(e,i,s,r,this.layerView):new K(e,i,s,r,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new Z(this._materialParameters,this.view.state.isGlobal),r=new Array,{elevationInfo:s,_draped:n,view:o}=this;function*l(l){for(let a=0;a<t.length;++a)r.push(N(o,e,t[a],s,i,n)),l.madeProgress(),l.done&&(l=yield)}return await this.frameTask.scheduleGenerator(l),{geometries:r,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(n(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:r}=this;if(this.loadAllTiles)return t=>t.leaf&&se(e,t.extent);const s=t=>t.rendered&&t.visible&&se(e,t.extent),{featureTiles:n}=i;if(!n)return s;const o=n.tiles.filter(e=>e.measures.visible);return e=>s(e)&&se(r,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||X(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+q?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ie.prototype,"type",void 0),e([g()],ie.prototype,"renderedTiles",void 0),e([g()],ie.prototype,"_resources",void 0),e([g()],ie.prototype,"_lastResources",void 0),e([g()],ie.prototype,"requireLoad",void 0),e([g()],ie.prototype,"_averageLoadingTime",void 0),e([g()],ie.prototype,"_loadingState",void 0),e([g()],ie.prototype,"emissiveStrength",void 0),e([g()],ie.prototype,"_clippingArea",null),e([g()],ie.prototype,"_dataBounds",null),e([g()],ie.prototype,"_draped",null),e([g()],ie.prototype,"_ellipsoidRadius",null),e([g()],ie.prototype,"extent",null),e([g()],ie.prototype,"loadAllTiles",null),e([g()],ie.prototype,"_featureTilesBounds",null),e([g()],ie.prototype,"_flowRenderer",null),e([g()],ie.prototype,"_materialParameters",null),e([g()],ie.prototype,"_opacity",null),e([g()],ie.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ie.prototype,"_seamlessTransitionEnabled",null),e([g()],ie.prototype,"_tracingResolution",null),e([g()],ie.prototype,"_visible",null),e([g()],ie.prototype,"_estimatedStreamlines",null),e([g()],ie.prototype,"_effectiveDensity",null),e([g()],ie.prototype,"elevationInfo",null),e([g()],ie.prototype,"needsMagnitude",null),e([g()],ie.prototype,"spatialReferenceInfo",null),e([g()],ie.prototype,"layer",null),e([g()],ie.prototype,"loadingState",null),e([g()],ie.prototype,"updating",null),e([g()],ie.prototype,"visibleAtCurrentScale",null),e([g()],ie.prototype,"_overrideMaterialParameters",void 0),e([g()],ie.prototype,"_overrideSimulationSettings",void 0),e([g()],ie.prototype,"_overrideTransitionEnabled",void 0),e([g()],ie.prototype,"_simulationSettings",null),e([g()],ie.prototype,"surface",null),ie=e([_("esri.views.3d.layers.FlowSubView3D")],ie);const re=new x({mode:"on-the-ground"});function se(e,t){return null==e||null==t||R(e,t)}export{ie as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as l,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{getMetersPerVerticalUnitForSR as m}from"../../../core/unitUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as f}from"../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as _}from"../../../geometry/ellipsoidUtils.js";import{projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{fromExtent as v,intersection as w,toExtent as T,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as x}from"../../../geometry/support/spatialReferenceUtils.js";import j from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as L,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import U from"./SubView3D.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{tileFilterDistance as E,thresholdForLoadingAllTiles as I,fadeOutTime as q,fadeInTime as D,defaultTransitionDuration as C,transitionDurationFactor as F,seamlessTransitionEnabled as V,densityFactor as k,loadAllTilesDensityFactor as B,averageLoadingTimeSmoothingFactor as W,minimumTracingResolution as G}from"../support/flow/constants.js";import{isFullExtent as z,wrappedWidth as H,FlowQuery3D as O}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as N}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as Q,createStreamlineGeometry as J}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as K}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as X}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as Y}from"../support/flow/StreamlineResources3DShape.js";import{tilesAreRelated as Z}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as $}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as ee}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as te,hasLayerBasedScaleVisibility as ie}from"../../support/layerViewUtils.js";import{TaskPriority as se}from"../../support/Scheduler.js";let re=class extends U{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const n=e.at(r);t(n)&&i.add(n),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new N(P(i)),this.frameTask=i.scheduler.registerTask(se.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([l(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),l(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),l(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()}),t.enableFeatureTiles(),l(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),l(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=y(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=y(this.layer.fullExtent,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get _ellipsoidRadius(){return _(this.view.spatialReference).radius}get extent(){const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<E&&e.add(t)}),t=e}const s=K(t,this.spatialReferenceInfo);return null==s?null:(w(s,this._clippingArea,s),T(s,e))}get loadAllTiles(){const{position:e}=this.view.camera,t=e.z;if(null==t)return!1;return t*m(e.spatialReference)/this._ellipsoidRadius>=I}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&z(e.xmin,e.xmax,t)}get loadByTileTreesAllowed(){return!this.loadAllTiles||!this.loadRequirementsMet}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=y(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...Q(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:D,fadeOutTime:q,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&$(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?C:this._averageLoadingTime*F)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:V}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=H(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,n;i<s?(r=i,n=i/t):(r=s*t,n=s);const o=G,l=this.view.qualitySettings.flow3D.maxTracingResolution,a=Math.max(1,o/Math.min(r,n)),u=a*Math.min(1,l/Math.max(r*a,n*a));return[Math.round(r*u),Math.round(n*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i}=this;if(null==t||null==i)return 0;const s=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density,r=null==e?null:v(e);if(null==r)return 0;let n=0;for(const a of i)S(r,a.extent)&&(n+=b(a.extent));const o=b(r),l=0===o?0:n/o;return 2*Math.round(s*l)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow3D.maxTotalNumberOfStreamlines,n=e>=r?r/e:1,o=t.density*n*s;return t.lineSpacing/Math.sqrt(o)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:o}get elevationInfo(){return this.layer.elevationInfo??ne}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:L(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return x(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&this.renderedTiles.size>0}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ie()||te(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=k,this.loadAllTiles&&this.isDataGlobal&&(i.density*=B),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const s=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const s=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(n(s())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=W;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const s=new O(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,n=await this._loadStreamlines(s,r.signal);if(o(r.signal),this._visible&&null!=n){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=n;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await n.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new X(e,i,r,s,this.layerView):new Y(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new ee(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:n,view:o}=this;function*l(l){for(let a=0;a<t.length;++a)s.push(J(o,e,t[a],r,i,n)),l.madeProgress(),l.done&&(l=yield)}return await this.frameTask.scheduleGenerator(l),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(n(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s}=this;if(this.loadAllTiles)return t=>t.leaf&&oe(e,t.extent);const r=t=>t.rendered&&t.visible&&oe(e,t.extent),{featureTiles:n}=i;if(!n)return r;const o=n.tiles.filter(e=>e.measures.visible);return e=>r(e)&&oe(s,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||Z(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+q?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],re.prototype,"type",void 0),e([g()],re.prototype,"renderedTiles",void 0),e([g()],re.prototype,"_resources",void 0),e([g()],re.prototype,"_lastResources",void 0),e([g()],re.prototype,"requireLoad",void 0),e([g()],re.prototype,"_averageLoadingTime",void 0),e([g()],re.prototype,"_loadingState",void 0),e([g()],re.prototype,"emissiveStrength",void 0),e([g()],re.prototype,"_clippingArea",null),e([g()],re.prototype,"_dataBounds",null),e([g()],re.prototype,"_draped",null),e([g()],re.prototype,"_ellipsoidRadius",null),e([g()],re.prototype,"extent",null),e([g()],re.prototype,"loadAllTiles",null),e([g()],re.prototype,"isDataGlobal",null),e([g()],re.prototype,"_featureTilesBounds",null),e([g()],re.prototype,"_flowRenderer",null),e([g()],re.prototype,"_materialParameters",null),e([g()],re.prototype,"_opacity",null),e([g()],re.prototype,"_seamlessTransitionWaitingTime",null),e([g()],re.prototype,"_seamlessTransitionEnabled",null),e([g()],re.prototype,"_tracingResolution",null),e([g()],re.prototype,"_visible",null),e([g()],re.prototype,"_estimatedStreamlines",null),e([g()],re.prototype,"_effectiveDensity",null),e([g()],re.prototype,"elevationInfo",null),e([g()],re.prototype,"needsMagnitude",null),e([g()],re.prototype,"spatialReferenceInfo",null),e([g()],re.prototype,"layer",null),e([g()],re.prototype,"loadingState",null),e([g()],re.prototype,"updating",null),e([g()],re.prototype,"visibleAtCurrentScale",null),e([g()],re.prototype,"_overrideMaterialParameters",void 0),e([g()],re.prototype,"_overrideSimulationSettings",void 0),e([g()],re.prototype,"_overrideTransitionEnabled",void 0),e([g()],re.prototype,"_simulationSettings",null),e([g()],re.prototype,"surface",null),re=e([f("esri.views.3d.layers.FlowSubView3D")],re);const ne=new j({mode:"on-the-ground"});function oe(e,t){return null==e||null==t||R(e,t)}export{re as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=1.
|
|
5
|
+
const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=1.5,x=501,a=256,b=!0,d=3,f=2,g=2;export{e as averageLoadingTimeSmoothingFactor,r as defaultTransitionDuration,f as densityFactor,t as fadeInTime,o as fadeOutTime,g as loadAllTilesDensityFactor,a as minimumTracingResolution,n as seamlessTransitionEnabled,x as streamlinGeometryBatchSize,s as thresholdForLoadingAllTiles,d as tileFilterDistance,b as tileFilteringByDistanceEnabled,c as tilesWaitingTime,p as transitionDurationFactor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../../../../../core/Logger.js";import{disposeMaybe as
|
|
5
|
+
import{__decorate as e}from"tslib";import r from"../../../../../core/Logger.js";import{abortMaybe as t,disposeMaybe as s}from"../../../../../core/maybe.js";import{throwIfAborted as i,isAbortError as o}from"../../../../../core/promiseUtils.js";import{watch as a,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as c}from"../../../../../support/requestImageUtils.js";import{RenderCategory as u,InternalRenderCategory as m}from"../../../webgl.js";import d from"../../../webgl/RenderNode.js";import{SMAABlendWeightsTechnique as p}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as b}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as f}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as T}from"./SMAAPassParameters.js";import{Texture as x}from"../../../../webgl/Texture.js";import{TextureDescriptor as _}from"../../../../webgl/TextureDescriptor.js";let g=class extends d{constructor(e){super(e),this.produces="disabled",this.consumes={required:[m.ANTIALIASING],optional:[u.COMPOSITE]},this._areaTexture=null,this._searchTexture=null,this._smaaParameters=new T}initialize(){this.addHandles([a(()=>this.isEnabled(),e=>e?this.enable():this.disable(),n)])}async enable(){if(this.destroyed)return;if(this.produces=m.ANTIALIASING,this.requestRender(1),this._abortController||this._areaTexture&&this._searchTexture)return;this._abortController=new AbortController;const e=this._abortController.signal;try{const r=await import("./SMAAData.js");i(e),await this._loadTextures(r,e),i(e),this.requestRender(1)}catch(t){o(t)||r.getLogger(this).errorOnce(t)}this._abortController=null}async _loadTextures(e,r){i(r);const[t,s]=await Promise.allSettled([c(e.areaTexture,{signal:r}),c(e.searchTexure,{signal:r})]);if(i(r),"fulfilled"!==t.status||"fulfilled"!==s.status)return;const o=this.renderingContext;this._areaTexture=w(o,9729,6407,t.value),this._searchTexture=w(o,9728,6409,s.value)}disable(){this.produces="disabled",this.requestRender(1)}destroy(){this._abortController=t(this._abortController),this._searchTexture=s(this._searchTexture),this._areaTexture=s(this._areaTexture)}precompile(){this.techniques.precompile(f),this.techniques.precompile(p),this.techniques.precompile(b)}render(e){const r=e.find(({name:e})=>e===m.ANTIALIASING),t=e.find(({name:e})=>e===u.COMPOSITE);if(!t)return r;if(!this._areaTexture||!this._searchTexture)return this.view.stage.renderer.blitFBO(t,r,!1),this.requestRender(1),r;const s=this.techniques.get(f),i=this.techniques.get(p),o=this.techniques.get(b);if(!s.compiled||!i.compiled||!o.compiled)return this.view.stage.renderer.blitFBO(t,r,!1),this.requestRender(1),r;const a=t.fbo.width,n=t.fbo.height,h=this.renderingContext;h.setViewport(0,0,a,n);const l=this.fboCache.acquire(a,n,"smaa edges",2);h.bindFramebuffer(l.fbo),h.setClearColor(0,0,0,1),h.clear(16384),this._smaaParameters.color=t.getTexture();const c=this.bindParameters;h.bindTechnique(s,c,this._smaaParameters),h.screen.draw();const d=this.fboCache.acquire(a,n,"smaa blend");return h.bindFramebuffer(d.fbo),h.setClearColor(0,0,1,1),h.clear(16384),this._smaaParameters.inputTexture=l.getTexture(),this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,h.bindTechnique(i,c,this._smaaParameters),h.screen.draw(),l.release(),h.bindFramebuffer(r.fbo),h.setClearColor(0,1,0,1),h.clear(16384),this._smaaParameters.inputTexture=d.getTexture(),h.bindTechnique(o,c,this._smaaParameters),h.screen.draw(),d.release(),r}};function w(e,r,t,s){const i=new _(s.width,s.height);return i.pixelFormat=t,i.wrapMode=33071,i.samplingMode=r,new x(e,i,s)}e([h()],g.prototype,"produces",void 0),e([h()],g.prototype,"consumes",void 0),e([h({constructOnly:!0})],g.prototype,"isEnabled",void 0),e([h()],g.prototype,"_abortController",void 0),g=e([l("esri.views.3d.webgl-engine.effects.smaa.SMAA")],g);export{g as SMAA};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as _,isStandardFeatureTemplate as F}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import L from"./Workflow.js";import{createToolFromGeometryType as U,findEditorItemForLayer as j,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const oe=Symbol(),ne=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends L{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:o}=a;return k("rectangle"===o||"circle"===o?o:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=U(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{formViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?j(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=_(c)&&u;if(n){if(fe(s),h){let t=ge(u,l);const a=await(O(o,d.view)?.load());a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,me(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ne);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,oe,ne,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){n&&p.push(e._fadeExistingFeatures(n.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,o,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,n?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(ne)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:o}).then(t=>e.addHandles(t,ne)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ne),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const _=r(p);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,d=l(e.geometry,"completion"),u=c(d)?await d:d;n.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=G(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=j(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(o.layer),{template:_}=o,b=!_||F(_)||v(_)&&"feature"===_.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=Q(e.fullTemplate,o.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"allowSave",null),e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"formViewModel",null),e([g()],ue.prototype,"hasInvalidFormTemplate",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"saveActionLabel",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as _,isStandardFeatureTemplate as F}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import L from"./Workflow.js";import{createToolFromGeometryType as U,findEditorItemForLayer as j,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const oe=Symbol(),ne=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends L{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:o}=a;return k("rectangle"===o||"circle"===o?o:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=U(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{formViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?j(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=_(c)&&u;if(n){if(fe(s),h){let t=ge(u,l);const a=await(O(o,d.view)?.load());a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,me(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ne);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,oe,ne,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){n&&p.push(e._fadeExistingFeatures(n.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,o,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,n?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(ne)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:o}).then(t=>e.addHandles(t,ne)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ne),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const _=r(p);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,d=l(e.geometry,"completion"),u=c(d)?await d:d;n.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=G(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.updateAttributes(s.getValues()),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=j(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(o.layer),{template:_}=o,b=!_||F(_)||v(_)&&"feature"===_.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=Q(e.fullTemplate,o.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"allowSave",null),e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"formViewModel",null),e([g()],ue.prototype,"hasInvalidFormTemplate",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"saveActionLabel",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{isSome as e,unique as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as o}from"../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{EsriPromise as a}from"../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as d}from"../../layers/support/layerUtils.js";import c from"./Edits.js";import{fetchFullFeaturesByObjectId as m}from"./workflowUtils.js";let h=class extends a{constructor(t){super(t),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const t=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(t.signal).then(e=>{l(t.signal),this._initializeEdits(e)}).catch(t=>{if(n(t))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw t})),this.addHandles(o(t)),this._initializeEditorItemsByLayer()}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(t=>t.initialFeature).filter(e)}get layers(){const{featureInfos:t,features:s}=this;return t?.length?t.map(t=>t.layer):s.length?r(s.map(t=>t.sourceLayer).filter(e)):[]}set timeZone(t){this._set("timeZone",t),this._pendingEdits.forEach(e=>{e.timeZone=t})}getEditorItemForLayer(t){return this._editorItemsByLayer.get(t)}getFeatureTitle(t){return this._pendingEdits.get(t)?.displayTitle}getPendingEditsForFeature(t){const e=t.getObjectId();if(null!=e)return this._pendingEdits.get(this._fullFeatures.get(e)??t)}isSubmittable(t){const e=this._pendingEdits.get(t);return!!e&&(e.submittable||e.isAssociation)}stageDelete(){for(const t of this._pendingEdits.values())t.stageDelete()}_initializeEditorItemsByLayer(){for(const t of this.editorItems)this._editorItemsByLayer.set(t.layer,t)}_initializeEdits(t){const{timeZone:e}=this;for(const r of t){const t=new c({feature:r,timeZone:e});t.trackChanges(),this._pendingEdits.set(r,t)}}async _initializeFullFeatures(t){const{_fullFeatures:e,featureInfos:r,features:o,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:i}of r)n.set(d(s)?s.parent:s,i);else if(o.length)for(const s of o){const t=s.getObjectId();if(null!=t){const e=s.sourceLayer??s.layer,r=d(e)?e.parent:e;i(n,r,()=>[]).push(t)}}const u=Array.from(n.entries()).map(async([r,o])=>{const i=await m(o,r,l,t);if(i.length!==o.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(t,e)=>t.attributes[a]>e.attributes[a]?1:-1,u=o.sort(),p=i.sort(n);for(let t=0;t<u.length;t++)e.set(u[t],p[t]);return i});return(await Promise.all(u)).flat()}};t([p({constructOnly:!0})],h.prototype,"editorItems",void 0),t([p({constructOnly:!0})],h.prototype,"featureInfos",void 0),t([p()],h.prototype,"features",null),t([p()],h.prototype,"fullFeatures",null),t([p()],h.prototype,"initialFeatures",null),t([p()],h.prototype,"layers",null),t([p()],h.prototype,"parent",void 0),t([p()],h.prototype,"selectedFeature",void 0),t([p({constructOnly:!0})],h.prototype,"sketchOptions",void 0),t([p()],h.prototype,"snappingManager",void 0),t([p()],h.prototype,"timeZone",null),t([p()],h.prototype,"viewModel",void 0),t([p()],h.prototype,"_fullFeatures",void 0),h=t([f("esri.widgets.Editor.UpdateFeaturesWorkflowData")],h);const y=h;export{y as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import{isSome as e,unique as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as o}from"../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{EsriPromise as a}from"../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as d}from"../../layers/support/layerUtils.js";import c from"./Edits.js";import{fetchFullFeaturesByObjectId as m}from"./workflowUtils.js";let h=class extends a{constructor(t){super(t),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const t=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(t.signal).then(e=>{l(t.signal),this._initializeEdits(e)}).catch(t=>{if(n(t))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw t})),this.addHandles(o(t)),this._initializeEditorItemsByLayer()}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(t=>t.initialFeature).filter(e)}get layers(){const{featureInfos:t,features:s}=this;return t?.length?t.map(t=>t.layer):s.length?r(s.map(t=>t.sourceLayer).filter(e)):[]}set timeZone(t){this._set("timeZone",t),this._pendingEdits.forEach(e=>{e.timeZone=t})}getEditorItemForLayer(t){return this._editorItemsByLayer.get(t)}getFeatureTitle(t){return this._pendingEdits.get(t)?.displayTitle}getPendingEditsForFeature(t){const e=t.getObjectId();if(null!=e)return this._pendingEdits.get(this._fullFeatures.get(e)??t)}isSubmittable(t){const e=this._pendingEdits.get(t);return!!e&&(e.submittable||e.isAssociation)}stageDelete(){for(const t of this._pendingEdits.values())t.stageDelete()}_initializeEditorItemsByLayer(){for(const t of this.editorItems)this._editorItemsByLayer.set(t.layer,t)}_initializeEdits(t){const{timeZone:e}=this;for(const r of t){const t=new c({feature:r,timeZone:e});t.trackChanges(),this._pendingEdits.set(r,t)}}async _initializeFullFeatures(t){const{_fullFeatures:e,featureInfos:r,features:o,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:i}of r)n.set(d(s)?s.parent:s,i);else if(o.length)for(const s of o){const t=s.getObjectId();if(null!=t){const e=s.sourceLayer??s.layer,r=d(e)?e.parent:e;i(n,r,()=>[]).push(t)}}const u=Array.from(n.entries()).map(async([r,o])=>{const i=await m(o,r,l,t);if(i.length!==o.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(t,e)=>t.attributes[a]>e.attributes[a]?1:-1,u=o.sort((t,e)=>t-e),p=i.sort(n);for(let t=0;t<u.length;t++)e.set(u[t],p[t]);return i});return(await Promise.all(u)).flat()}};t([p({constructOnly:!0})],h.prototype,"editorItems",void 0),t([p({constructOnly:!0})],h.prototype,"featureInfos",void 0),t([p()],h.prototype,"features",null),t([p()],h.prototype,"fullFeatures",null),t([p()],h.prototype,"initialFeatures",null),t([p()],h.prototype,"layers",null),t([p()],h.prototype,"parent",void 0),t([p()],h.prototype,"selectedFeature",void 0),t([p({constructOnly:!0})],h.prototype,"sketchOptions",void 0),t([p()],h.prototype,"snappingManager",void 0),t([p()],h.prototype,"timeZone",null),t([p()],h.prototype,"viewModel",void 0),t([p()],h.prototype,"_fullFeatures",void 0),h=t([f("esri.widgets.Editor.UpdateFeaturesWorkflowData")],h);const y=h;export{y as default};
|