@arcgis/core 4.24.0-next.20220619 → 4.24.0
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/themes/base/widgets/_Editor.scss +12 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/interfaces.d.ts +15 -9
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisResult.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/InputField.js +1 -1
- package/widgets/FeatureForm/InputFieldGroup.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/support/datePickerUtils.js +1 -1
package/config.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const r={apiKey:void 0,applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(r,globalThis.esriConfig,!0),delete r.has),!r.assetsPath){const e="4.24.0";r.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}r.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(r,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),r.request.corsEnabledServers=[],r.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{r as default};
|
package/interfaces.d.ts
CHANGED
|
@@ -64658,23 +64658,29 @@ declare namespace __esri {
|
|
|
64658
64658
|
|
|
64659
64659
|
interface LineOfSightAnalysisResult {
|
|
64660
64660
|
/**
|
|
64661
|
-
*
|
|
64661
|
+
* The first [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) intersected by the line of sight.
|
|
64662
64662
|
*
|
|
64663
64663
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-LineOfSightAnalysisResult.html#intersectedGraphic)
|
|
64664
64664
|
*/
|
|
64665
|
-
intersectedGraphic: Graphic;
|
|
64665
|
+
readonly intersectedGraphic: Graphic;
|
|
64666
64666
|
/**
|
|
64667
|
-
*
|
|
64667
|
+
* A [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) representing the location where the line of sight first intersects the ground or 3D objects in the scene.
|
|
64668
64668
|
*
|
|
64669
64669
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-LineOfSightAnalysisResult.html#intersectedLocation)
|
|
64670
64670
|
*/
|
|
64671
|
-
intersectedLocation: Point;
|
|
64671
|
+
readonly intersectedLocation: Point;
|
|
64672
64672
|
/**
|
|
64673
64673
|
* Represents a target in a [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-LineOfSightAnalysis.html) which is used to calculate the visibility from the [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-LineOfSightAnalysis.html#observer).
|
|
64674
64674
|
*
|
|
64675
64675
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-LineOfSightAnalysisResult.html#target)
|
|
64676
64676
|
*/
|
|
64677
64677
|
target: LineOfSightAnalysisTarget;
|
|
64678
|
+
/**
|
|
64679
|
+
* Whether the target is visible from the observer or not.
|
|
64680
|
+
*
|
|
64681
|
+
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-LineOfSightAnalysisResult.html#visible)
|
|
64682
|
+
*/
|
|
64683
|
+
readonly visible: boolean;
|
|
64678
64684
|
}
|
|
64679
64685
|
|
|
64680
64686
|
interface LineOfSightAnalysisResultConstructor {
|
|
@@ -66448,7 +66454,7 @@ declare namespace __esri {
|
|
|
66448
66454
|
|
|
66449
66455
|
interface SketchLabelOptionsConstructor {
|
|
66450
66456
|
/**
|
|
66451
|
-
* The `SketchLabelOptions` allows users to configure the labels which are shown next to each segment of a graphic while sketching.
|
|
66457
|
+
* The `SketchLabelOptions` allows users to configure the labels which are shown next to each segment of a graphic while sketching and editing.
|
|
66452
66458
|
*
|
|
66453
66459
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-interactive-sketch-SketchLabelOptions.html)
|
|
66454
66460
|
*/
|
|
@@ -82165,10 +82171,9 @@ declare namespace __esri {
|
|
|
82165
82171
|
/**
|
|
82166
82172
|
* The result of `visibilityExpression`.
|
|
82167
82173
|
*
|
|
82168
|
-
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-InputFieldGroup.html#
|
|
82174
|
+
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-InputFieldGroup.html#evaluatedVisibilityExpression)
|
|
82169
82175
|
*/
|
|
82170
|
-
readonly
|
|
82171
|
-
initialState: "expanded" | "collapsed";
|
|
82176
|
+
readonly evaluatedVisibilityExpression: boolean;
|
|
82172
82177
|
/**
|
|
82173
82178
|
* The input fields belonging to this group.
|
|
82174
82179
|
*
|
|
@@ -82181,6 +82186,7 @@ declare namespace __esri {
|
|
|
82181
82186
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-InputFieldGroup.html#label)
|
|
82182
82187
|
*/
|
|
82183
82188
|
readonly label: string;
|
|
82189
|
+
state: "expanded" | "collapsed";
|
|
82184
82190
|
/**
|
|
82185
82191
|
* Arcade expression to determine whether this group is visible or not.
|
|
82186
82192
|
*
|
|
@@ -82216,7 +82222,7 @@ declare namespace __esri {
|
|
|
82216
82222
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-InputFieldGroup.html#description)
|
|
82217
82223
|
*/
|
|
82218
82224
|
description?: string;
|
|
82219
|
-
|
|
82225
|
+
state?: "expanded" | "collapsed";
|
|
82220
82226
|
/**
|
|
82221
82227
|
* Arcade expression to determine whether this group is visible or not.
|
|
82222
82228
|
*
|
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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20220622",a="5920122e73c5174847b703e4af6a3170e28edfa6";export{e as buildDate,a 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{HandleOwner as t}from"../../../../core/HandleOwner.js";import i from"../../../../core/Logger.js";import{isSome as s,unwrap as r}from"../../../../core/maybe.js";import{debounce as l,isAbortError as a,eachAlways as o}from"../../../../core/promiseUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import p from"../../../../layers/support/TileInfo.js";import{update as y,unregister as d,register as g,getRasterId as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{extractBands as _}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{getWorldWidth as f,computeProjectedScales as w}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import"../../tiling/PagedTileQueue.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import P from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{getWebGLCapabilities as C}from"../../../webgl/capabilities.js";import v from"../../../../geometry/Extent.js";const R=[0,0],T=i.getLogger("esri.views.2d.layers.ImageryTileLayerView2D");let V=class extends t{constructor(){super(...arguments),this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=null,this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._globalUpdateRequested=!1,this.attached=!1,this.container=null,this.layer=null,this.timeExtent=null,this.redrawOrRefetch=l(((e,t)=>!this.previousLOD||this.layerView.suspended?Promise.resolve():e?this.updatingHandles.addPromise(this.doRefresh()):this.updatingHandles.addPromise(this._redrawImage(t))))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return null==this._get("useProgressiveUpdate")||this._get("useProgressiveUpdate")}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:v.fromJSON(t);y(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue.updating||this._globalUpdateRequested||!(!this.updatingHandles||!this.updatingHandles.updating)}attach(){C("2d").supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new P({tileInfoView:this._tileInfoView,concurrency:e,process:(e,t)=>this._fetchTile1(e,t)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&s(this._emptyTilePixelBlock))return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,r]=e,l=new u({width:i,height:r,pixels:[new Uint8Array(i*r)],mask:new Uint8Array(i*r),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=l),l}_fetchTile1(e,t){const i=s(t)&&t.signal,l=this.canUseWebGLForProcessing(),{layerView:a}=this,o=!a.tileInfo.isWrappable&&s(f(a.view.spatialReference)),h={allowPartialFill:!0,datumTransformation:a.datumTransformation,interpolation:l?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:l,signal:r(i),srcResolution:this._srcResolutions[e.level],timeExtent:a.timeExtent,tileInfo:a.tileInfo,disableWrapAround:o};return this.fetchTile(e,h)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const e=this.layerView.view.spatialReference,t=new c({x:this.layerView.fullExtent.xmin,y:this.layerView.fullExtent.ymax,spatialReference:e}),{scales:i,srcResolutions:s,isCustomTilingScheme:r}=w(this.layer.rasterInfo,e),l=p.create({spatialReference:e,size:512,scales:i});(0===l.origin.x||l.origin.x>t.x)&&(l.origin=t),this._isCustomTilingScheme=r,this.layerView.set("tileInfo",l),this._srcResolutions=s??[]}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this.updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),{bandIds:s}=this.layer;let r=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){r=!1;try{await this._redrawImage(this._abortController&&this._abortController.signal)}catch(i){a(i)&&T.error(i)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(R,e.key),o=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:r,bandIds:s,coords:l,resolution:o}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(i){a(i)||T.error(i)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await o(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const s=this.layer.symbolizer.generateWebGLParameters({pixelBlock:_(i.pixelBlock,this.layer.bandIds),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:this.previousLOD.resolution,y:this.previousLOD.resolution},bandIds:this.layer.bandIds});!this.canUseWebGLForProcessing()&&s&&"stretch"===s.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(s.factor=s.factor.map((e=>255*e)),s.outMin=Math.round(255*s.outMin),s.outMax=Math.round(255*s.outMax)),this._globalSymbolizerParams=s}_updateSymbolizerParams(){this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:this.previousLOD.resolution,y:this.previousLOD.resolution},bandIds:this.layer.bandIds})}_updateBlockCacheRegistry(e=!1){const{url:t,rasterInfo:i,raster:s}=this.layer,{multidimensionalDefinition:r}=this.layer.normalizeRasterFetchOptions({multidimensionalDefinition:this.layer.multidimensionalDefinition,timeExtent:this.layerView.timeExtent}),l=i?.multidimensionalInfo?s.getSliceIndex(r):null,a=m(t,l);if(a!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=g(a,this.layer.raster.rasterInfo),e){const e=this._tileInfoView.getClosestInfoForScale(this.layerView.view.scale),t=this._srcResolutions[e.level];y(a,this._blockCacheRegistryId,this.layerView.view.extent,this.layerView.view.resolution,t,this.layer.raster.ioConfig.sampling)}this._blockCacheRegistryUrl=a}}async doRefresh(){await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.tiles.forEach((t=>e.push(this._enqueueTileFetch(t)))),await o(e)}};e([h()],V.prototype,"_fetchQueue",void 0),e([h()],V.prototype,"_globalUpdateRequested",void 0),e([h()],V.prototype,"attached",void 0),e([h()],V.prototype,"container",void 0),e([h()],V.prototype,"layer",void 0),e([h()],V.prototype,"layerView",void 0),e([h()],V.prototype,"type",void 0),e([h()],V.prototype,"useWebGLForProcessing",null),e([h()],V.prototype,"useProgressiveUpdate",null),e([h()],V.prototype,"timeExtent",void 0),e([h()],V.prototype,"updating",null),V=e([n("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],V);export{V as BaseImageryTileSubView2D};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import{HandleOwner as t}from"../../../../core/HandleOwner.js";import i from"../../../../core/Logger.js";import{isSome as s,unwrap as r}from"../../../../core/maybe.js";import{debounce as l,isAbortError as a,eachAlways as o}from"../../../../core/promiseUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import p from"../../../../layers/support/TileInfo.js";import{update as y,unregister as d,register as g,getRasterId as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{extractBands as _}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{getWorldWidth as f,computeProjectedScales as w}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import"../../tiling/PagedTileQueue.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import P from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{getWebGLCapabilities as C}from"../../../webgl/capabilities.js";import v from"../../../../geometry/Extent.js";const R=[0,0],T=i.getLogger("esri.views.2d.layers.ImageryTileLayerView2D");let V=class extends t{constructor(){super(...arguments),this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=null,this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._globalUpdateRequested=!1,this.attached=!1,this.container=null,this.layer=null,this.timeExtent=null,this.redrawOrRefetch=l(((e,t)=>!this.previousLOD||this.layerView.suspended?Promise.resolve():e?this.updatingHandles.addPromise(this.doRefresh()):this.updatingHandles.addPromise(this._redrawImage(t))))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return null==this._get("useProgressiveUpdate")||this._get("useProgressiveUpdate")}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:v.fromJSON(t);y(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue?.updating||this._globalUpdateRequested||!(!this.updatingHandles||!this.updatingHandles.updating)}attach(){C("2d").supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new P({tileInfoView:this._tileInfoView,concurrency:e,process:(e,t)=>this._fetchTile1(e,t)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&s(this._emptyTilePixelBlock))return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,r]=e,l=new u({width:i,height:r,pixels:[new Uint8Array(i*r)],mask:new Uint8Array(i*r),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=l),l}_fetchTile1(e,t){const i=s(t)&&t.signal,l=this.canUseWebGLForProcessing(),{layerView:a}=this,o=!a.tileInfo.isWrappable&&s(f(a.view.spatialReference)),h={allowPartialFill:!0,datumTransformation:a.datumTransformation,interpolation:l?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:l,signal:r(i),srcResolution:this._srcResolutions[e.level],timeExtent:a.timeExtent,tileInfo:a.tileInfo,disableWrapAround:o};return this.fetchTile(e,h)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const e=this.layerView.view.spatialReference,t=new c({x:this.layerView.fullExtent.xmin,y:this.layerView.fullExtent.ymax,spatialReference:e}),{scales:i,srcResolutions:s,isCustomTilingScheme:r}=w(this.layer.rasterInfo,e),l=p.create({spatialReference:e,size:512,scales:i});(0===l.origin.x||l.origin.x>t.x)&&(l.origin=t),this._isCustomTilingScheme=r,this.layerView.set("tileInfo",l),this._srcResolutions=s??[]}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this.updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),{bandIds:s}=this.layer;let r=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){r=!1;try{await this._redrawImage(this._abortController&&this._abortController.signal)}catch(i){a(i)&&T.error(i)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(R,e.key),o=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:r,bandIds:s,coords:l,resolution:o}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(i){a(i)||T.error(i)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await o(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const s=this.layer.symbolizer.generateWebGLParameters({pixelBlock:_(i.pixelBlock,this.layer.bandIds),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:this.previousLOD.resolution,y:this.previousLOD.resolution},bandIds:this.layer.bandIds});!this.canUseWebGLForProcessing()&&s&&"stretch"===s.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(s.factor=s.factor.map((e=>255*e)),s.outMin=Math.round(255*s.outMin),s.outMax=Math.round(255*s.outMax)),this._globalSymbolizerParams=s}_updateSymbolizerParams(){this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:this.previousLOD.resolution,y:this.previousLOD.resolution},bandIds:this.layer.bandIds})}_updateBlockCacheRegistry(e=!1){const{url:t,rasterInfo:i,raster:s}=this.layer,{multidimensionalDefinition:r}=this.layer.normalizeRasterFetchOptions({multidimensionalDefinition:this.layer.multidimensionalDefinition,timeExtent:this.layerView.timeExtent}),l=i?.multidimensionalInfo?s.getSliceIndex(r):null,a=m(t,l);if(a!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=g(a,this.layer.raster.rasterInfo),e){const e=this._tileInfoView.getClosestInfoForScale(this.layerView.view.scale),t=this._srcResolutions[e.level];y(a,this._blockCacheRegistryId,this.layerView.view.extent,this.layerView.view.resolution,t,this.layer.raster.ioConfig.sampling)}this._blockCacheRegistryUrl=a}}async doRefresh(){await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.tiles.forEach((t=>e.push(this._enqueueTileFetch(t)))),await o(e)}};e([h()],V.prototype,"_fetchQueue",void 0),e([h()],V.prototype,"_globalUpdateRequested",void 0),e([h()],V.prototype,"attached",void 0),e([h()],V.prototype,"container",void 0),e([h()],V.prototype,"layer",void 0),e([h()],V.prototype,"layerView",void 0),e([h()],V.prototype,"type",void 0),e([h()],V.prototype,"useWebGLForProcessing",null),e([h()],V.prototype,"useProgressiveUpdate",null),e([h()],V.prototype,"timeExtent",void 0),e([h()],V.prototype,"updating",null),V=e([n("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],V);export{V as BaseImageryTileSubView2D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends t{constructor(o){super(o),this.target=null,this.intersectedGraphic=null,this.intersectedLocation=null,this.elevationAlignedTargetLocation=null}};o([e()],s.prototype,"target",void 0),o([e()],s.prototype,"intersectedGraphic",void 0),o([e()],s.prototype,"intersectedLocation",void 0),o([e()],s.prototype,"elevationAlignedTargetLocation",void 0),o([e()],s.prototype,"visible",void 0),s=o([r("esri.views.3d.analysis.LineOfSightAnalysisResult")],s);export{s as LineOfSightAnalysisResult};
|
|
5
|
+
import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends t{constructor(o){super(o),this.target=null,this.intersectedGraphic=null,this.intersectedLocation=null,this.elevationAlignedTargetLocation=null,this.visible=void 0}};o([e()],s.prototype,"target",void 0),o([e()],s.prototype,"intersectedGraphic",void 0),o([e()],s.prototype,"intersectedLocation",void 0),o([e()],s.prototype,"elevationAlignedTargetLocation",void 0),o([e({type:Boolean})],s.prototype,"visible",void 0),s=o([r("esri.views.3d.analysis.LineOfSightAnalysisResult")],s);export{s as LineOfSightAnalysisResult};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Handles.js";import i from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{isSome as a,destroyMaybe as n,isNone as o,unwrap as u}from"../../../../core/maybe.js";import{isAbortError as l,eachAlways as h}from"../../../../core/promiseUtils.js";import{on as c}from"../../../../core/reactiveUtils.js";import{schedule as d}from"../../../../core/scheduling.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as m,equals as g,clone as F,expand as y,toExtent as _}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as T,hasVertices as x}from"../../../../layers/graphics/dehydratedFeatures.js";import E from"../../../../rest/support/QuantizationParameters.js";import C from"../../../../rest/support/Query.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{MultiFeatureReference as b,SingleFeatureReference as v}from"./featureReference.js";import{FAILED_FEATURE_COUNT as M,FetchStatus as D,FeatureTile as w}from"./FeatureTile.js";import{tilesAreRelated as j}from"../../terrain/tileUtils.js";import{ImmediateTask as O,TaskPriority as P}from"../../../support/Scheduler.js";const N=i.getLogger("esri.views.3d.layers.support.FeatureTileFetcher3D");let U=class extends t{constructor(e){super(e),this._useTileCount=!1,this.updating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this.maximumNumberOfFeaturesExceededThrottle=1e3,this._fullRatio=1,this._farRatio=1,this.changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this.handles=new s,this._frameTask=O,this._dirty=!1,this.featureTiles=new Map,this.displayingFeatureReferences=new Map,this.numDisplayingFeatureReferences=0,this.suspended=!0,this.pendingEdits=null}set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this.supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&a(this.context.query.queryFeatureCount)}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get memoryForUnusedFeatures(){let e=0;return this.featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this.featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this.featureTiles.forEach((t=>e+=t.numFeatures)),e}set filterExtent(e){if(e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void N.error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||t&&e&&t.equals(e))return;const s=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}initialize(){this.handles.add(c((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{onListenerAdd:()=>this._setDirty()})),this.objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?b:v;const e=this.context.scheduler;a(e)&&(this._frameTask=e.registerTask(P.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this.handles=n(this.handles),this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this.featureTiles.clear(),this.displayingFeatureReferences.clear(),this.pendingEdits&&(this.pendingEdits.controller.abort(),this.pendingEdits=null)}get paused(){return this.suspended||!!this.pendingEdits}restart(){this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this.suspended||(this.suspended=!0,this._pause(),this._setDirty())}resume(){this.suspended&&(this.suspended=!1,this._unpause())}_pause(){this.paused&&(this.featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this.paused||(this._setDirty(),this._updated())}get availableFields(){let e=null;return this.featureTiles.forEach((t=>{o(t.displayingFeatures)||0===t.displayingFeatures.length||(o(e)?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields.has(s)||u(e).delete(s)})))})),a(e)?e:new Set}applyEdits(e){this.pendingEdits||(this.pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this.pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(l(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this.pendingEdits===t&&(this.pendingEdits=null),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._unpause(),this._updated()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),i=new Set,r=this.objectIdField;e.forEach((({objectId:e,globalId:a})=>{if((!e||e<0)&&t){s||N.errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`);const e=this.features.find((e=>e.attributes&&e.attributes[t]===a));e&&i.add(T(e,r))}else i.add(e)})),this.featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!i.has(T(e,this.objectIdField))));t.length!==e.features.length&&(e.setFeatures(t,0,e.availableFields),this._invalidateCounts())}))}async _applyEditsAddUpdateFeatures(e,t,s){const i=[],r=new Set;if(e.forEach((e=>i.push(e.objectId))),t.forEach((e=>{i.push(e.objectId),r.add(e.objectId)})),0===i.length)return;const a=[];this.featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,i,r,s);t&&a.push(t)})),await h(a)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=t;const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(T(e,this.objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),e.setFeatures(n,0,H(e.availableFields,a.fields)),this._invalidateCounts())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:B})}_setDirty(){this._dirty=!0,this._updated()}get running(){return this.updating}runTask(e){if(this._frameTask.processQueue(e),!this._dirty||!this.constructed)return;this._dirty=!1;const t=this._getListOfTiles();if(this._markTilesNotAlive(t),!e.run((()=>this._addTiles(t,e)))||!e.run((()=>this._filterExtentTiles(t,e)))||!e.run((()=>this._removeTiles(t,e)))||e.done)return void this._setDirty();const s=this._sortTiles(t);e.run((()=>this._displayTiles(s,e)))&&e.run((()=>this._fetchTiles(s,e)))&&e.run((()=>this._updateMemoryEstimates(s,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!this.suspended&&(this.tileDescriptors.forEach((s=>{const i=this.featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_displayTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this.objectIdField)&&this._setDirty(),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this.paused)return!1;let s=!1;for(const i of e){if(!i.needsFetching)continue;const e=a(this.context.memoryCache)?this.context.memoryCache.pop(i.id):null;if(a(e))i.cache=e,this._setDirty(),this._scheduleUpdated(),t.madeProgress();else{if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,(()=>i.numFeatures=M)),s=!0,t.madeProgress()}if(t.done)return!0}}if(s)return t.hasProgressed;for(const i of e)if(i.needsFetching){const e=new AbortController,s=this._fetchTile(i,e.signal);if(this._handleRequest(i,s,e,(e=>{i.setFeatures([],0,null),this._invalidateCounts(),i.featuresMissing=!1,this.context.logFetchError(N,e)})),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.constructed)return;const s=new Array;this.featureTiles.forEach((i=>{o(i.displayingFeatures)||0===i.displayingFeatures.length||(i.intersectionIncludingBorrowed(t,V),i.intersectionIncludingBorrowed(e,z),g(V,z)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this.changes.updates;for(const i of e)if(!o(i.displayingFeatures))for(const e of i.displayingFeatures){const i=T(e,this.objectIdField);if(t.has(i))continue;t.add(i);const{feature:r}=this.displayingFeatureReferences.get(i);s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;this.paused||this.featureTiles.forEach((t=>t.isFetching?++e:0));const t=this._dirty||e>0||!!this.pendingEdits;if(this._set("updating",t),t){let t=0,s=0,i=0,r=0,n=0;const o=this.displayingFeatureReferences.size/this.numDisplayingFeatureReferences;this.featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=a(e.displayingFeatures)?e.displayingFeatures.length*o:0;n+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let u=0,l=0;t?(l=t,u=Math.min(r*t/i,t)):(l=s,u=r),n=Math.min(this.maximumNumberOfFeatures-this.features.length,n),this._set("updatingTotal",l),this._set("updatingRemaining",u),this._set("expectedFeatureDiff",n)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){const e=r(this.featureTiles,(e=>e.perTileMaximumNumberOfFeaturesExceeded));this._set("maximumNumberOfFeaturesExceeded",e)}_updateRatio(e){const t=q(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this.featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===D.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new w(e);return this.featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.descriptor.resolution;this.featureTiles.forEach((s=>{if(!(o(s.displayingFeatures)||e===s||e.descriptor.lij&&s.descriptor.lij&&!j(e.descriptor.lij,s.descriptor.lij))){o(e.displayingFeatures)&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(o(e.extentIncludingBorrowedFeatures)&&(e.extentIncludingBorrowedFeatures=F(e.descriptor.extent)),y(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this.displayingFeatureReferences.get(T(i,this.objectIdField));s.ref(s.feature,t),this.numDisplayingFeatureReferences++}}})),e.featureLimit=a(e.displayingFeatures)?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this.featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=D.DONE):e.fetchStatus=D.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;a(t)&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===D.REFETCHING?D.REFETCH_NEEDED:D.FETCH_NEEDED}async _fetchTile(e,t){const s=this._maximumFeaturesForTile(e);if(s<=0)return L(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(I(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>C.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=Math.ceil(s/i),e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}const{features:n,exceededTransferLimit:o,fields:u}=await this._queryFeatures(a,t),l=o?a.maxRecordCountFactor>=C.MAX_MAX_RECORD_COUNT_FACTOR?D.FULL:D.DONE:D.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=n.length<e.numFeatures||o;const t=this._removeEmptyFeatures(n);e.setFeatures(n,t,Q(u))}),t),this._invalidateCounts(),l}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,n=this._maximumFeaturesForTile(e)-a;const o=this._getMaxRecordCount(e);let l=null;for(;;){const h=this._createQuery(e),c=this._setPagingParameters(h,i,n,o),{features:d,exceededTransferLimit:p,fields:f}=await this._queryFeatures(h,t);if(await this._frameTask.schedule((()=>{c&&(i+=u(h.num)),a+=d.length,r+=this._removeEmptyFeatures(d),e.featuresMissing=i<e.numFeatures||p,s=s?s.concat(d):d,l=H(l,f),e.setFeatures(s,r,l)}),t),this._invalidateCounts(),this._setDirty(),n=this._maximumFeaturesForTile(e)-a,!c||!p||n<=0)return p?D.DONE:D.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery(),s=e.descriptor.extent;if(s){const e=this.context.tilingScheme.spatialReference;t.geometry=_(s,e)}return this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(null==e.descriptor.resolution)return null;const t=this.context.viewingMode===R.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.descriptor.resolution,t)/this.lodFactor}get supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this.supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new E({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];x(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!I(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&a(t)&&t>0&&this.context.capabilities.supportsResultType?t:a(s)&&s>0?s:k}_useTileQuery(e){return(!I(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?D.REFETCHING:D.FETCHING,e.requestController=s;let r=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=D.DONE),l(t)?r=!0:i(t)})).then((()=>{r||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.handles&&!this.handles.has("scheduleUpdated")&&this.handles.add(d((()=>{this.handles.remove("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(a(e.displayingFeatures)&&!e.needsDisplayUpdate)return!1;const t=e.features;if(0===e.featureLimit||!t){const t=a(e.displayingFeatures)&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.descriptor.resolution,i=this.changes.updates,r=this.changes.adds,n=Math.min(e.featureLimit,t.length);e.featureLimit=n;for(let a=0;a<n;++a){const e=t[a],n=T(e,this.objectIdField),o=this.displayingFeatureReferences.get(n);if(o){const t=o.ref(e,s);t.oldVersion!==t.newVersion&&(i.removes.push(t.oldVersion),i.adds.push(t.newVersion))}else this.displayingFeatureReferences.set(n,new this.FeatureReferenceClass(e,s)),r.push(e);this.numDisplayingFeatureReferences++}return this._hideTileFeatures(e),this._applyChanges(),e.displayingFeatures=t.slice(0,n),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(o(e.displayingFeatures))return;const t=this.changes.updates,s=this.changes.removes;for(const i of e.displayingFeatures){const r=T(i,this.objectIdField),a=this.displayingFeatureReferences.get(r);if(!a)continue;const n=a.unref(e.descriptor.resolution);this.numDisplayingFeatureReferences--,n?n.oldVersion!==n.newVersion&&(null==n.newVersion?(this.displayingFeatureReferences.delete(r),s.push(n.oldVersion)):(t.adds.push(n.newVersion),t.removes.push(n.oldVersion))):console.error("Hiding unreferenced feature")}this._applyChanges(),e.displayingFeatures=null}_applyChanges(){const e=this.changes.updates;e.removes.length>0&&(this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this.features.addMany(e.adds),e.adds.length=0);const t=this.changes.adds,s=this.changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+G,i);this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&this.features.addMany(0===r?t:t.slice(r)),s.length>i&&this.features.removeMany(0===r?s:s.slice(r)),t.length=0,s.length=0}_clearTile(e){if(this._hideTile(e),e.features&&a(this.context.memoryCache)){const t=16+e.estimatedSize;this.context.memoryCache.put(e.id,e.cache,t)}e.setFeatures(null,0,null),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this.featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){return{process:e=>this.runTask(e),getFeatureTileById:e=>this.featureTiles.get(e),forEachFeatureTile:e=>this.featureTiles.forEach(e)}}};function I(e){return"dummy-tile-full-extent"===e.id}function q(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function A(e){const t=e.capabilities.query;return{supportsMultipleResolutions:S(e),supportsPagination:!(!t||!t.supportsPagination),supportsResultType:!(!t||!t.supportsResultType),supportsCacheHint:!(!t||!t.supportsCacheHint),supportsQuantization:!(!t||!t.supportsQuantization),supportsQuantizationEditMode:!(!t||!t.supportsQuantizationEditMode),supportsMaxRecordCountFactor:!(!t||!t.supportsMaxRecordCountFactor),supportsFormatPBF:!(!t||!t.supportsFormatPBF)}}function S(e){switch(e.geometryType){case"polyline":return!0;case"polygon":return e.capabilities&&e.capabilities.query&&e.capabilities.query.supportsQuantization;default:return!1}}function L(e){return e.setFeatures([],0,null),e.featuresMissing=!1,D.DONE}function Q(e){return o(e)?new Set:new Set(e.map((e=>e.name)))}function H(e,t){if(o(e)||o(t))return Q(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}e([p({constructOnly:!0})],U.prototype,"features",void 0),e([p()],U.prototype,"tileDescriptors",void 0),e([p({value:1/0})],U.prototype,"maximumNumberOfFeatures",null),e([p({value:1})],U.prototype,"memoryFactor",null),e([p({value:1})],U.prototype,"lodFactor",null),e([p()],U.prototype,"useTileCount",null),e([p({readOnly:!0})],U.prototype,"updating",void 0),e([p({readOnly:!0})],U.prototype,"updatingTotal",void 0),e([p({readOnly:!0})],U.prototype,"updatingRemaining",void 0),e([p({readOnly:!0})],U.prototype,"expectedFeatureDiff",void 0),e([p({readOnly:!0})],U.prototype,"memoryForUnusedFeatures",null),e([p({readOnly:!0})],U.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([p({constructOnly:!0})],U.prototype,"maximumNumberOfFeaturesExceededThrottle",void 0),e([p({readOnly:!0})],U.prototype,"totalVertices",null),e([p({readOnly:!0})],U.prototype,"totalFeatures",null),e([p()],U.prototype,"filterExtent",null),e([p({constructOnly:!0})],U.prototype,"context",void 0),U=e([f("esri.views.3d.layers.support.FeatureTileFetcher3D")],U);const k=2e3,V=m(),z=m(),B=6e5,G=200;export{U as FeatureTileFetcher3D,A as contextCapabilitiesFromLayer};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Handles.js";import i from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{isSome as a,destroyMaybe as n,isNone as o,unwrap as u}from"../../../../core/maybe.js";import{isAbortError as l,eachAlways as h,throwIfAborted as c}from"../../../../core/promiseUtils.js";import{on as d}from"../../../../core/reactiveUtils.js";import{schedule as p}from"../../../../core/scheduling.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as g,equals as F,clone as y,expand as _,toExtent as T}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as x,hasVertices as E}from"../../../../layers/graphics/dehydratedFeatures.js";import C from"../../../../rest/support/QuantizationParameters.js";import R from"../../../../rest/support/Query.js";import{ViewingMode as b}from"../../../ViewingMode.js";import{MultiFeatureReference as v,SingleFeatureReference as M}from"./featureReference.js";import{FAILED_FEATURE_COUNT as D,FetchStatus as w,FeatureTile as j}from"./FeatureTile.js";import{tilesAreRelated as O}from"../../terrain/tileUtils.js";import{ImmediateTask as P,TaskPriority as N}from"../../../support/Scheduler.js";const U=i.getLogger("esri.views.3d.layers.support.FeatureTileFetcher3D");let I=class extends t{constructor(e){super(e),this._useTileCount=!1,this.updating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this.maximumNumberOfFeaturesExceededThrottle=1e3,this._fullRatio=1,this._farRatio=1,this.changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this.handles=new s,this._frameTask=P,this._dirty=!1,this.featureTiles=new Map,this.displayingFeatureReferences=new Map,this.numDisplayingFeatureReferences=0,this.suspended=!0,this.pendingEdits=null}set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this.supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&a(this.context.query.queryFeatureCount)}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get memoryForUnusedFeatures(){let e=0;return this.featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this.featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this.featureTiles.forEach((t=>e+=t.numFeatures)),e}set filterExtent(e){if(e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void U.error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||t&&e&&t.equals(e))return;const s=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}initialize(){this.handles.add(d((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{onListenerAdd:()=>this._setDirty()})),this.objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?v:M;const e=this.context.scheduler;a(e)&&(this._frameTask=e.registerTask(N.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this.handles=n(this.handles),this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this.featureTiles.clear(),this.displayingFeatureReferences.clear(),this.pendingEdits&&(this.pendingEdits.controller.abort(),this.pendingEdits=null)}get paused(){return this.suspended||!!this.pendingEdits}restart(){this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this.featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this.suspended||(this.suspended=!0,this._pause(),this._setDirty())}resume(){this.suspended&&(this.suspended=!1,this._unpause())}_pause(){this.paused&&(this.featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this.paused||(this._setDirty(),this._updated())}get availableFields(){let e=null;return this.featureTiles.forEach((t=>{o(t.displayingFeatures)||0===t.displayingFeatures.length||(o(e)?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields.has(s)||u(e).delete(s)})))})),a(e)?e:new Set}applyEdits(e){this.pendingEdits||(this.pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this.pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(l(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this.pendingEdits===t&&(this.pendingEdits=null),a(this.context.memoryCache)&&this.context.memoryCache.clear(),this._unpause(),this._updated()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),i=new Set,r=this.objectIdField;e.forEach((({objectId:e,globalId:a})=>{if((!e||e<0)&&t){s||U.errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`);const e=this.features.find((e=>e.attributes&&e.attributes[t]===a));e&&i.add(x(e,r))}else i.add(e)})),this.featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!i.has(x(e,this.objectIdField))));t.length!==e.features.length&&(e.setFeatures(t,0,e.availableFields),this._invalidateCounts())}))}async _applyEditsAddUpdateFeatures(e,t,s){const i=[],r=new Set;if(e.forEach((e=>i.push(e.objectId))),t.forEach((e=>{i.push(e.objectId),r.add(e.objectId)})),0===i.length)return;const a=[];this.featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,i,r,s);t&&a.push(t)})),await h(a)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=t;const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(x(e,this.objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),e.setFeatures(n,0,k(e.availableFields,a.fields)),this._invalidateCounts())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:G})}_setDirty(){this._dirty=!0,this._updated()}get running(){return this.updating}runTask(e){if(this._frameTask.processQueue(e),!this._dirty||!this.constructed)return;this._dirty=!1;const t=this._getListOfTiles();if(this._markTilesNotAlive(t),!e.run((()=>this._addTiles(t,e)))||!e.run((()=>this._filterExtentTiles(t,e)))||!e.run((()=>this._removeTiles(t,e)))||e.done)return void this._setDirty();const s=this._sortTiles(t);e.run((()=>this._displayTiles(s,e)))&&e.run((()=>this._fetchTiles(s,e)))&&e.run((()=>this._updateMemoryEstimates(s,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!this.suspended&&(this.tileDescriptors.forEach((s=>{const i=this.featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_displayTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this.objectIdField)&&this._setDirty(),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this.paused)return!1;let s=!1;for(const i of e){if(!i.needsFetching)continue;const e=a(this.context.memoryCache)?this.context.memoryCache.pop(i.id):null;if(a(e))i.cache=e,this._setDirty(),this._scheduleUpdated(),t.madeProgress();else{if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,(()=>i.numFeatures=D)),s=!0,t.madeProgress()}if(t.done)return!0}}if(s)return t.hasProgressed;for(const i of e)if(i.needsFetching){const e=new AbortController,s=this._fetchTile(i,e.signal);if(this._handleRequest(i,s,e,(e=>{i.setFeatures([],0,null),this._invalidateCounts(),i.featuresMissing=!1,this.context.logFetchError(U,e)})),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.constructed)return;const s=new Array;this.featureTiles.forEach((i=>{o(i.displayingFeatures)||0===i.displayingFeatures.length||(i.intersectionIncludingBorrowed(t,z),i.intersectionIncludingBorrowed(e,B),F(z,B)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this.changes.updates;for(const i of e)if(!o(i.displayingFeatures))for(const e of i.displayingFeatures){const i=x(e,this.objectIdField);if(t.has(i))continue;t.add(i);const{feature:r}=this.displayingFeatureReferences.get(i);s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;this.paused||this.featureTiles.forEach((t=>t.isFetching?++e:0));const t=this._dirty||e>0||!!this.pendingEdits;if(this._set("updating",t),t){let t=0,s=0,i=0,r=0,n=0;const o=this.displayingFeatureReferences.size/this.numDisplayingFeatureReferences;this.featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=a(e.displayingFeatures)?e.displayingFeatures.length*o:0;n+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let u=0,l=0;t?(l=t,u=Math.min(r*t/i,t)):(l=s,u=r),n=Math.min(this.maximumNumberOfFeatures-this.features.length,n),this._set("updatingTotal",l),this._set("updatingRemaining",u),this._set("expectedFeatureDiff",n)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){const e=r(this.featureTiles,(e=>e.perTileMaximumNumberOfFeaturesExceeded));this._set("maximumNumberOfFeaturesExceeded",e)}_updateRatio(e){const t=A(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this.featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===w.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new j(e);return this.featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.descriptor.resolution;this.featureTiles.forEach((s=>{if(!(o(s.displayingFeatures)||e===s||e.descriptor.lij&&s.descriptor.lij&&!O(e.descriptor.lij,s.descriptor.lij))){o(e.displayingFeatures)&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(o(e.extentIncludingBorrowedFeatures)&&(e.extentIncludingBorrowedFeatures=y(e.descriptor.extent)),_(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this.displayingFeatureReferences.get(x(i,this.objectIdField));s.ref(s.feature,t),this.numDisplayingFeatureReferences++}}})),e.featureLimit=a(e.displayingFeatures)?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this.featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=w.DONE):e.fetchStatus=w.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;a(t)&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===w.REFETCHING?w.REFETCH_NEEDED:w.FETCH_NEEDED}async _fetchTile(e,t){const s=this._maximumFeaturesForTile(e);if(s<=0)return Q(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(q(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>R.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=Math.ceil(s/i),e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}const{features:n,exceededTransferLimit:o,fields:u}=await this._queryFeatures(a,t),l=o?a.maxRecordCountFactor>=R.MAX_MAX_RECORD_COUNT_FACTOR?w.FULL:w.DONE:w.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=n.length<e.numFeatures||o;const t=this._removeEmptyFeatures(n);e.setFeatures(n,t,H(u))}),t),c(t),this._invalidateCounts(),l}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,n=this._maximumFeaturesForTile(e)-a;const o=this._getMaxRecordCount(e);let l=null;for(;;){const h=this._createQuery(e),d=this._setPagingParameters(h,i,n,o),{features:p,exceededTransferLimit:f,fields:m}=await this._queryFeatures(h,t);if(await this._frameTask.schedule((()=>{d&&(i+=u(h.num)),a+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=i<e.numFeatures||f,s=s?s.concat(p):p,l=k(l,m),e.setFeatures(s,r,l)}),t),c(t),this._invalidateCounts(),this._setDirty(),n=this._maximumFeaturesForTile(e)-a,!d||!f||n<=0)return f?w.DONE:w.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery(),s=e.descriptor.extent;if(s){const e=this.context.tilingScheme.spatialReference;t.geometry=T(s,e)}return this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(null==e.descriptor.resolution)return null;const t=this.context.viewingMode===b.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.descriptor.resolution,t)/this.lodFactor}get supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this.supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new C({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];E(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!q(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&a(t)&&t>0&&this.context.capabilities.supportsResultType?t:a(s)&&s>0?s:V}_useTileQuery(e){return(!q(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?w.REFETCHING:w.FETCHING,e.requestController=s;let r=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=w.DONE),l(t)?r=!0:i(t)})).then((()=>{r||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.handles&&!this.handles.has("scheduleUpdated")&&this.handles.add(p((()=>{this.handles.remove("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(a(e.displayingFeatures)&&!e.needsDisplayUpdate)return!1;const t=e.features;if(0===e.featureLimit||!t){const t=a(e.displayingFeatures)&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.descriptor.resolution,i=this.changes.updates,r=this.changes.adds,n=Math.min(e.featureLimit,t.length);e.featureLimit=n;for(let a=0;a<n;++a){const e=t[a],n=x(e,this.objectIdField),o=this.displayingFeatureReferences.get(n);if(o){const t=o.ref(e,s);t.oldVersion!==t.newVersion&&(i.removes.push(t.oldVersion),i.adds.push(t.newVersion))}else this.displayingFeatureReferences.set(n,new this.FeatureReferenceClass(e,s)),r.push(e);this.numDisplayingFeatureReferences++}return this._hideTileFeatures(e),this._applyChanges(),e.displayingFeatures=t.slice(0,n),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(o(e.displayingFeatures))return;const t=this.changes.updates,s=this.changes.removes;for(const i of e.displayingFeatures){const r=x(i,this.objectIdField),a=this.displayingFeatureReferences.get(r);if(!a)continue;const n=a.unref(e.descriptor.resolution);this.numDisplayingFeatureReferences--,n?n.oldVersion!==n.newVersion&&(null==n.newVersion?(this.displayingFeatureReferences.delete(r),s.push(n.oldVersion)):(t.adds.push(n.newVersion),t.removes.push(n.oldVersion))):console.error("Hiding unreferenced feature")}this._applyChanges(),e.displayingFeatures=null}_applyChanges(){const e=this.changes.updates;e.removes.length>0&&(this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this.features.addMany(e.adds),e.adds.length=0);const t=this.changes.adds,s=this.changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+X,i);this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&this.features.addMany(0===r?t:t.slice(r)),s.length>i&&this.features.removeMany(0===r?s:s.slice(r)),t.length=0,s.length=0}_clearTile(e){if(this._hideTile(e),e.features&&a(this.context.memoryCache)){const t=16+e.estimatedSize;this.context.memoryCache.put(e.id,e.cache,t)}e.setFeatures(null,0,null),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this.featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){return{process:e=>this.runTask(e),getFeatureTileById:e=>this.featureTiles.get(e),forEachFeatureTile:e=>this.featureTiles.forEach(e)}}};function q(e){return"dummy-tile-full-extent"===e.id}function A(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function S(e){const t=e.capabilities.query;return{supportsMultipleResolutions:L(e),supportsPagination:!(!t||!t.supportsPagination),supportsResultType:!(!t||!t.supportsResultType),supportsCacheHint:!(!t||!t.supportsCacheHint),supportsQuantization:!(!t||!t.supportsQuantization),supportsQuantizationEditMode:!(!t||!t.supportsQuantizationEditMode),supportsMaxRecordCountFactor:!(!t||!t.supportsMaxRecordCountFactor),supportsFormatPBF:!(!t||!t.supportsFormatPBF)}}function L(e){switch(e.geometryType){case"polyline":return!0;case"polygon":return e.capabilities&&e.capabilities.query&&e.capabilities.query.supportsQuantization;default:return!1}}function Q(e){return e.setFeatures([],0,null),e.featuresMissing=!1,w.DONE}function H(e){return o(e)?new Set:new Set(e.map((e=>e.name)))}function k(e,t){if(o(e)||o(t))return H(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}e([f({constructOnly:!0})],I.prototype,"features",void 0),e([f()],I.prototype,"tileDescriptors",void 0),e([f({value:1/0})],I.prototype,"maximumNumberOfFeatures",null),e([f({value:1})],I.prototype,"memoryFactor",null),e([f({value:1})],I.prototype,"lodFactor",null),e([f()],I.prototype,"useTileCount",null),e([f({readOnly:!0})],I.prototype,"updating",void 0),e([f({readOnly:!0})],I.prototype,"updatingTotal",void 0),e([f({readOnly:!0})],I.prototype,"updatingRemaining",void 0),e([f({readOnly:!0})],I.prototype,"expectedFeatureDiff",void 0),e([f({readOnly:!0})],I.prototype,"memoryForUnusedFeatures",null),e([f({readOnly:!0})],I.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([f({constructOnly:!0})],I.prototype,"maximumNumberOfFeaturesExceededThrottle",void 0),e([f({readOnly:!0})],I.prototype,"totalVertices",null),e([f({readOnly:!0})],I.prototype,"totalFeatures",null),e([f()],I.prototype,"filterExtent",null),e([f({constructOnly:!0})],I.prototype,"context",void 0),I=e([m("esri.views.3d.layers.support.FeatureTileFetcher3D")],I);const V=2e3,z=g(),B=g(),G=6e5,X=200;export{I as FeatureTileFetcher3D,S as contextCapabilitiesFromLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../../../core/HandleOwner.js";import{isNone as i,isSome as r}from"../../../../../core/maybe.js";import{whenOrAbort as o}from"../../../../../core/promiseUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WorkerHandle as d}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as n}from"../../../../../geometry/support/typeUtils.js";let l=class extends t{constructor(e){super(e),this.availability=0,this.workerHandleUpdating=!0,this.editId=0}get updating(){return this.updatingHandles.updating||this.workerHandleUpdating}destroy(){this.workerHandle.destroy()}initialize(){this.workerHandle=new p(this.schedule),this.handles.add([this.workerHandle.on("notify-updating",(({updating:e})=>this.workerHandleUpdating=e)),this.workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const r=this._serviceInfoFromLayer(e.layer);if(i(r))return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:r,spatialReference:e.spatialReference.toJSON()};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("setup",o,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("configure",i,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("refresh",{},e)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const i={distance:e.distance,point:e.coordinateHelper.vectorToPoint(e.point).toJSON(),types:e.types,filter:r(e.filter)?e.filter.createQuery().toJSON():null};return this.workerHandle.invoke(i,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:r(e.tileInfo)?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("updateTiles",i,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const i=this.editId++,r={id:i};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("beginApplyEdits",r,t))
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{HandleOwner as t}from"../../../../../core/HandleOwner.js";import{isNone as i,isSome as r}from"../../../../../core/maybe.js";import{whenOrAbort as o}from"../../../../../core/promiseUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WorkerHandle as d}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as n}from"../../../../../geometry/support/typeUtils.js";let l=class extends t{constructor(e){super(e),this.availability=0,this.workerHandleUpdating=!0,this.editId=0}get updating(){return this.updatingHandles.updating||this.workerHandleUpdating}destroy(){this.workerHandle.destroy()}initialize(){this.workerHandle=new p(this.schedule),this.handles.add([this.workerHandle.on("notify-updating",(({updating:e})=>this.workerHandleUpdating=e)),this.workerHandle.on("notify-availability",(({availability:e})=>this._set("availability",e)))])}async setup(e,t){const r=this._serviceInfoFromLayer(e.layer);if(i(r))return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:r,spatialReference:e.spatialReference.toJSON()};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("setup",o,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async configure(e,t){const i=this._convertConfiguration(e);await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("configure",i,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async refresh(e){await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("refresh",{},e)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},e))}async fetchCandidates(e,t){const i={distance:e.distance,point:e.coordinateHelper.vectorToPoint(e.point).toJSON(),types:e.types,filter:r(e.filter)?e.filter.createQuery().toJSON():null};return this.workerHandle.invoke(i,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:r(e.tileInfo)?e.tileInfo.toJSON():null,tileSize:e.tileSize};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("updateTiles",i,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}async applyEdits(e,t){const i=this.editId++,r={id:i};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("beginApplyEdits",r,t));const a=await this.updatingHandles.addPromise(o(e.result,t)),s={id:i,edits:{addedFeatures:a.addedFeatures?.map((({objectId:e})=>e))??[],deletedFeatures:a.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:a.updatedFeatures?.map((({objectId:e})=>e))??[]}};await this.updatingHandles.addPromise(this.workerHandle.invokeMethod("endApplyEdits",s,t)),this.updatingHandles.addPromise(this.workerHandle.invokeMethod("whenNotUpdating",{},t))}getDebugInfo(e){return this.workerHandle.invokeMethod("getDebugInfo",{},e)}_convertConfiguration(e){return{filter:r(e.filter)?e.filter.toJSON():null,customParameters:e.customParameters}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl.path,fields:e.fields.map((e=>e.toJSON())),geometryType:n.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([a({constructOnly:!0})],l.prototype,"schedule",void 0),e([a({readOnly:!0})],l.prototype,"updating",null),e([a({readOnly:!0})],l.prototype,"availability",void 0),e([a()],l.prototype,"workerHandleUpdating",void 0),l=e([s("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],l);class p extends d{constructor(e){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated"})}}export{l as FeatureServiceSnappingSourceWorkerHandle};
|
package/widgets/Directions.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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import{on as s,pausable as i}from"../core/events.js";import o from"../core/Handles.js";import r from"../core/Logger.js";import{isNone as n,isSome as a,unwrap as l,unwrapOrValue as c}from"../core/maybe.js";import{watch as d,initial as h,when as u,on as p}from"../core/reactiveUtils.js";import{aliasOf as v}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as m}from"../core/accessorSupport/decorators/cast.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import y from"../rest/support/Stop.js";import S from"../symbols/SimpleMarkerSymbol.js";import w from"./Search.js";import M from"./Widget.js";import b from"./Directions/DirectionsViewModel.js";import{SaveLayer as f}from"./Directions/components/SaveLayer.js";import{formatDistance as C,formatTime as T,isTimeUnits as k}from"./Directions/support/directionsUtils.js";import{DepartureTime as D,CSS as I,getIconPath as L}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import B from"./support/DatePicker.js";import{Heading as A,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as E}from"./support/decorators/accessibleHandler.js";import{messageBundle as H}from"./support/decorators/messageBundle.js";import{tsx as U}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import O from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as $,convertDateFormatToIntlOptions as F}from"../intl/date.js";import{formatNumber as N}from"../intl/number.js";const V={departureTime:!0,layerDetails:!0,printButton:!1,saveAsButton:!0,saveButton:!0,stops:!0,traveMode:!0};function W(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",i=60,o=Math.abs(Math.floor(t/i)),r=Math.abs(Math.floor(t)%i),n={minimumIntegerDigits:2};return`GMT${s}${N(o,n)}${N(r,n)}`}function q(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}const K={awaitingViewClickStop:"awaiting-view-click-stop"},Y=100,G=500,J=r.getLogger("esri.widgets.Directions");let Q=class extends M{constructor(e,t){super(e,t),this._autoStopRemovalDelay=Y,this._departureTime=D.NOW,this._datePicker=new B,this._handles=new o,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._renderSavePopoverFunction=null,this._saveAsButtonNode=null,this._saveLayer=new f,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=I.widgetIcon,this.label=void 0,this.lastRoute=null,this.layer=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.view=null,this.viewModel=new b,this.visibleElements={...V},this._setUpDragAndDropStops=e=>{this._sortable=O.create(e,{draggable:`.${I.validStopRow}`,ghostClass:I.stopRowGhost,handle:`.${I.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:i}=s,o=i[t],r=i[e],n=t-e<0;s.insertBefore(o,n?r.nextElementSibling:r);const a=this.viewModel.layer.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._getDirections()}}initialize(){this.own([d((()=>this.viewModel.layer.routeInfo),(()=>{this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),h),u((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),i=this._prepViewClick();t.pause(),i.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=G)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=Y)),t,i],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=i}}),h),u((()=>n(this.viewModel.serviceDescription)),(()=>{try{this.viewModel.load()}catch{}}),h),d((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))]),this.when((()=>{this.destroyed||(this._renderSavePopoverFunction=this._renderSavePopover.bind(this),this._projector.append(document.body,this._renderSavePopoverFunction))}))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-link.js"),import("@esri/calcite-components/dist/components/calcite-popover.js")])}destroy(){this._datePicker.destroy(),this._timePicker.destroy();for(const e of this._stopsToSearches.values())e.destroy();this._sortable&&this._sortable.destroy(),a(this._renderSavePopoverFunction)&&this._projector.detach(this._renderSavePopoverFunction)}set routeServiceUrl(e){t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url=e}get routeServiceUrl(){return t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url}set routeSymbol(e){t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines}set stopSymbols(e){t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops}castVisibleElements(e){return{...V,...e}}getDirections(){return null}render(){return U("div",{class:this.classes(I.base,I.scroller)},this._renderPanelContent())}save(){return this.viewModel.layer.save()}saveAs(e,t={}){return this.viewModel.layer.saveAs(e,t)}zoomToRoute(){}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,i="error"===t&&!e,o="unauthenticated"===t,r={[I.panelContentLoading]:s,[I.panelContentError]:i,[I.panelContentSignIn]:o},n=s?"presentation":"group",a=o?this._renderSignIn():i?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return U("div",{class:this.classes(I.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return U("div",{key:"sign-in",class:I.signInContent},U(A,{class:I.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),U(A,{level:j(this.headingLevel)},this.messages.signInRequired),U("button",{class:this.classes(I.button,I.buttonSecondary,I.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){if(!this.visibleElements.traveMode)return null;const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=a(e)?e.name:this.messages.travelMode;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.travelMode,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.travelModeSelect,I.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=a(e)&&t.id===e.id;return U("option",{key:`esri-directions__travel-mode-${t.id}`,"data-mode":t,selected:s,value:t.id},t.name)}))))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"],this._getDirections()}_renderStopsContainer(){return this.visibleElements.stops?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.section,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops()):null}_renderDepartureTimeControls(){if(!this.visibleElements.departureTime)return null;const e=this._departureTime,{messages:t}=this,s=t.departureTime;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.departureTime,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.departureTimeSelect,I.select),onchange:this._handleDepartureOptionChange,title:s},U("option",{value:D.NOW,selected:e===D.NOW},t.leaveNow),U("option",{value:D.DEPART_BY,selected:e===D.DEPART_BY},t.departBy),U("option",{value:D.UNSPECIFIED,selected:e===D.UNSPECIFIED},t.timeUnspecified)),e===D.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.layer.stops;let t=0;for(const i of this._stopsToSearches.keys())e.includes(i)||this._disposeSearch(i);for(const i of e){const e=this._acquireSearch(i);"none"!==e.activeMenu&&(t+=1),a(i.name)&&(e.searchTerm=i.name)}const s=e.toArray().map(((s,i)=>{const o=e.length,r=i>1&&n(s.geometry),l={[I.stopsIcon]:i>=0&&i<o-1,[I.lastStopIcon]:i===o-1},c={[I.lastStopIconContainer]:i===o-1},d={[I.validStopRow]:!r},h=e.getItemAt(i+1),u=h&&a(h.geometry),p=i===o-1,v=i===o-2,m=2===o&&0===i||o>2&&!p&&!v||o>2&&v&&u||o>2&&p&&n(s.geometry),_=o<3,g=this._acquireSearch(s),{messages:y}=this,{removeStop:S,reverseStops:w,unlocated:M}=y,b=z(y.stopLabelTemplate,{number:i+1,label:a(s.geometry)?s.name:M}),f=`${this.id}__stop--${i}`,C=!!g.searchTerm&&!!g.selectedResult&&a(s.geometry)&&g.selectedResult.name===s.name,T={zIndex:"none"!==g.activeMenu?""+t--:""};return U("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(I.stopRow,d),id:f,key:i,"data-stop-index":i,styles:T},U("div",{class:I.stopHandle},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.handleIcon,I.stopHandleIcon,I.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),U("div",{bind:this,"aria-labelledby":f,class:this.classes(I.stopIconContainer,c),"data-stop-index":i,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},U("span",{class:this.classes(I.stopIcon,l),tabindex:C?"0":null}))),U("div",{class:I.stopInput},g.render()),U("div",{class:I.stopOptions,role:"group"},U("div",{"aria-label":S,class:I.removeStopButton,bind:this,"data-stop-index":i,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:S},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.removeStop,I.removeStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle")),U("div",{"aria-label":w,class:I.reverseStops,bind:this,hidden:m,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:w},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.reverseStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle"))))}));return U("div",null,U("ol",{class:I.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),U("div",{class:I.toolbarSection},U("div",{class:I.toolbarButtons},this._renderAddStop())))}_renderAddStop(){const e=this.viewModel.layer.stops.length>=this.maxStops;return U("calcite-button",{appearance:"outline",class:I.addStopButton,color:"neutral",disabled:e,"icon-start":"plus",key:I.addStopButton,onclick:()=>{this._addNewPlaceholder()},text:this.messages.addStop,width:"half"},this.messages.addStop)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);s&&a(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],i=this.viewModel.layer.stops.getItemAt(s);if(t===i){const e=this._acquireSearch(i);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this._handles.remove(K.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!!e.selectedResult&&a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle.pause();const s=n(t.geometry)&&n(e.selectedResult?.feature.geometry),i=a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry;if((s||i)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle.pause();e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(a(t.geometry)&&(t.geometry=null,this._getDirections()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(K.awaitingViewClickStop))return;const{view:s,view:{cursor:i}}=this;this._previousCursor=i,this._handles.add(d((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":i)}),h),K.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=i(e,"click",this._handleViewClick.bind(this)),s=i(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=i(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=q(e)?this._activeStop:null})),t=i(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=q(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:i,name:o}=s;this._activeStop.geometry=i.geometry,this._activeStop.name=o,t.searchTerm=o})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new y({symbol:new S});this.viewModel.layer.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.layer.stops.reverse();for(const e of this.viewModel.layer.stops)e.sequence=null;this._getDirections()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);this._removeStop(s),(a(s.geometry)||n(this.viewModel.layer.routeInfo))&&this._getDirections()}_removeStop(e){this.viewModel.layer.stops.length<=2||(this._disposeSearch(e),this.viewModel.layer.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===D.NOW?(this._departureTime=D.NOW,this.viewModel.departureTime=D.NOW,this._handles.remove("departure-time-controls"),this._getDirections()):s.value===D.DEPART_BY?(this._departureTime=D.DEPART_BY,this._handles.add(d((()=>[this._datePicker.value,this._timePicker.value]),(()=>{this._updateDepartureTime(),this._getDirections()}),h),"departure-time-controls")):(this._departureTime=D.UNSPECIFIED,this.viewModel.departureTime=null,this._getDirections())}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return U("div",{class:I.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return U("div",{class:I.sectionSplitter})}_renderSaveContainer(){const{saveButton:e,saveAsButton:t,printButton:s,layerDetails:i}=this.visibleElements;return e||t||s||i?U("div",{class:I.saveSection,key:I.saveSection},this._renderSaveButtons(),this._renderRouteLayerDetailsLink()):null}_renderSaveButtons(){const{saveButton:e,saveAsButton:t,printButton:s}=this.visibleElements;return e||t||s?U("div",{class:I.saveButtons,key:I.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()):null}_renderSaveButton(){if(!this.visibleElements.saveButton)return null;const e=this.viewModel.layer.portalItem?.itemControl,t=a(this.viewModel.layer.routeInfo)&&("admin"===e||"update"===e);return U("calcite-button",{appearance:"outline",class:I.saveButton,color:"neutral",disabled:!t,"icon-start":"save",key:I.saveButton,onclick:()=>{this._handleSaveButtonClick()},text:this.messagesCommon.save,width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){if(!this.visibleElements.saveAsButton)return null;const e=n(this.viewModel.layer.routeInfo);return U("div",{class:I.saveAsButtonPopover,key:I.saveAsButtonPopover},U("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:I.saveAsButton,color:"neutral",disabled:e,"icon-start":"duplicate",key:I.saveAsButton,onclick:()=>this._handleSaveAsButtonClick(),text:this.messagesCommon.saveAs,width:"full"},this.messagesCommon.saveAs))}_renderSavePopover(){return U("calcite-popover",{label:this._saveLayer.label,open:this._saveLayer.opened,"overlay-positioning":"fixed",referenceElement:l(this._saveAsButtonNode)},this._saveLayer.render())}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return this.visibleElements.printButton?U("calcite-button",{appearance:"outline",class:I.printButton,color:"neutral","icon-start":"print",key:I.printButton,text:this.messagesCommon.print}):null}_renderRouteLayerDetailsLink(){if(!this.visibleElements.layerDetails)return null;const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,i=`${s}/home/item.html?id=${t}`;return U("calcite-link",{class:I.layerDetailsLink,href:i,key:I.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return U("div",{class:this.classes(I.directionsSection,I.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return U("div",{class:I.loader,key:"loader"})}_renderWarningCard(){return U("div",{class:I.warningCard,role:"alert"},U("div",{class:I.warningHeader},U("span",{class:I.warningIcon,"aria-hidden":"true"}),U(A,{class:I.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),U("div",{class:I.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{viewModel:{layer:e,state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():a(e.directionLines)?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.summary,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):U("div",{key:"esri-directions__placeholder",class:I.emptyContent},this._renderPlaceholder(),U(A,{class:I.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return U("svg",{class:I.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},U("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return U(A,{level:this.headingLevel},e)}_renderRouteActions(){return U("div",{class:I.routeActions},U("button",{"aria-label":this.messages.clearRoute,class:this.classes(I.clearRouteButton,I.button,I.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){const{directionPoints:e,directionLines:t,stops:s}=this.viewModel.layer;if(n(e)||n(t))return null;const i=[];let o=null;for(const r of e){const{objectId:e,stopId:l}=r;if(a(l)){const e=s.find((e=>e.objectId===l)),t=0===i.length;(n(o)||o.stop!==e)&&(o={stop:e,directions:[],open:t},i.push(o));continue}if(n(o))continue;const c=t.find((t=>t.directionPointId===e));n(c)||o.directions.push({directionPoint:r,directionLine:c})}return i}_renderManeuverSections(){return n(this._sections)?null:U("div",{class:I.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let i;e.directions.length>0&&s&&(i=U("ol",{class:I.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const o=l(this._sections).length>2,r=t===l(this._sections).length-1,n={[I.collapsibleSection]:o},a={[I.openIcon]:!s,[I.closeIcon]:s};let c;if(o&&!r){const t=s?this.messagesCommon.close:this.messagesCommon.open;c=U("header",{class:this.classes(I.maneuverSectionHeader,I.maneuverSectionToggle),key:I.maneuverSectionHeader},U("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:I.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name),U("span",{"aria-hidden":"true",class:this.classes(a)})))}else c=U("header",{class:I.maneuverSectionHeader,key:I.maneuverSectionHeader},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return U("section",{class:this.classes(I.maneuverSection,n),key:t},c,i)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(n(t)||n(e))return null;const s=t.getItemAt(t.length-1).arrivalTime,{primary:i,secondary:o}=e,{eta:r,etaTemplate:l,primaryCosts:c,secondaryCosts:d,zoomToRoute:h}=this.messages,u=F("short-time"),p=a(s)?`<strong>${$(s,u)}</strong>`:null,v=a(s)?`${W(s)}`:null,m=z(l,{time:p,gmt:v});return U("div",{"aria-label":h,bind:this,class:I.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:h},U("div",{class:I.costsDetails,role:"group"},U("div",{class:I.primaryCosts,title:c},i),U("div",{class:I.verticalSplitter}),U("div",{class:I.secondaryCosts,title:d},o)),U("div",{innerHTML:m,title:r}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{lastError:t}}=this;if(a(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??(t.locationType="street"),P(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=R))}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new w({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([p((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._getDirections()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null,this._activeStop=e,this.viewModel.layer.removeResult()}))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.has(e)&&(this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e))}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:i,directionLine:o}=e,{distance:r,duration:n}=o,{messages:l,messagesUnits:d}=this,h=C(l,d,c(r,0),{fromUnits:"meters",toUnits:s}),u=T(c(n,0),"minutes"),p=h&&u?`${h} · ${u}`:`${h}${u}`,v=this._getFormattedManeuverText(i),{objectId:m,directionPointType:_}=i,g=L(_),y=`esri-directions__maneuver-${m}`,S=`esri-directions__cumulative-costs-${m}`,w=`esri-directions__intermediate-costs-${m}`,M={[I.maneuverActive]:this._activeManeuver===o};return U("li",{"aria-labelledby":`${y} ${S} ${w}`,bind:this,class:this.classes(I.maneuver,M),"data-maneuver":o,key:o,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},a(g)&&U("img",{alt:"",class:I.maneuverIcon,src:g}),U("div",{class:I.maneuverCostsContainer},U("span",{id:y,innerHTML:c(v,"")}),U("div",{class:I.maneuverCosts},U("div",{class:I.horizontalSplitter}),U("div",{id:S,class:I.cumulativeCost,innerHTML:t,title:l.cumulativeCosts}),U("div",{id:w,class:I.intermediateCost,innerHTML:p,title:l.intermediateCosts}))))}_handleManeuverClick(e){const t=e.currentTarget["data-maneuver"];if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=e.currentTarget["data-maneuver"];this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=e.currentTarget["data-maneuver"];this._focusedManeuver=t,this.viewModel.highlight(t)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:i}=e;if(n(t))return"";let o=t;return a(s)&&o.includes(s)&&(o=o.replace(s,`<strong>${s}</strong>`)),a(i)&&o.includes(i)&&(o=o.replace(i,`<strong>${i}</strong>`)),o}_getCostSummary(){const{viewModel:{impedanceAttribute:e,layer:{routeInfo:t},routeParameters:s}}=this;if(n(e)||n(t))return null;let{totalDuration:i,totalDistance:o}=t;const{directionsLengthUnits:r}=s;o=a(o)?o:0,i=a(i)?i:0;const l=C(this.messages,this.messagesUnits,o,{fromUnits:"meters",toUnits:r}),c=T(i,"minutes"),[d,h]=k(e.units)?[c,l]:[l,c];return{primary:d,secondary:h}}async _getDirections(){if(!(this.viewModel.layer.stops.filter((e=>a(e.geometry))).length<2))try{await this.viewModel.getDirections()}catch{}}};e([v("viewModel.apiKey")],Q.prototype,"apiKey",void 0),e([v("viewModel.goToOverride")],Q.prototype,"goToOverride",void 0),e([_()],Q.prototype,"headingLevel",void 0),e([_()],Q.prototype,"iconClass",void 0),e([_({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],Q.prototype,"label",void 0),e([v("viewModel.lastRoute")],Q.prototype,"lastRoute",void 0),e([v("viewModel.layer")],Q.prototype,"layer",void 0),e([v("viewModel.maxStops")],Q.prototype,"maxStops",void 0),e([_(),H("esri/widgets/Directions/t9n/Directions")],Q.prototype,"messages",void 0),e([_(),H("esri/t9n/common")],Q.prototype,"messagesCommon",void 0),e([_(),H("esri/core/t9n/Units")],Q.prototype,"messagesUnits",void 0),e([_()],Q.prototype,"routeServiceUrl",null),e([_()],Q.prototype,"routeSymbol",null),e([_()],Q.prototype,"searchProperties",void 0),e([_()],Q.prototype,"stopSymbols",null),e([v("viewModel.view")],Q.prototype,"view",void 0),e([_({type:b})],Q.prototype,"viewModel",void 0),e([_()],Q.prototype,"visibleElements",void 0),e([m("visibleElements")],Q.prototype,"castVisibleElements",null),e([v("viewModel.getDirections")],Q.prototype,"getDirections",null),e([v("viewModel.zoomToRoute")],Q.prototype,"zoomToRoute",null),e([E()],Q.prototype,"_handleStopIconClick",null),e([E()],Q.prototype,"_handleClearRouteClick",null),e([E()],Q.prototype,"_handleReverseStops",null),e([E()],Q.prototype,"_handleRemoveStop",null),e([E()],Q.prototype,"_handleSectionToggle",null),e([E()],Q.prototype,"_handleSummaryInteraction",null),e([E()],Q.prototype,"_handleManeuverClick",null),Q=e([g("esri.widgets.Directions")],Q);const X=Q;export{X as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{deprecatedProperty as t}from"../core/deprecate.js";import{on as s,pausable as i}from"../core/events.js";import o from"../core/Handles.js";import r from"../core/Logger.js";import{isNone as n,isSome as a,unwrap as l,unwrapOrValue as c}from"../core/maybe.js";import{watch as d,initial as h,when as u,on as p}from"../core/reactiveUtils.js";import{aliasOf as v}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as m}from"../core/accessorSupport/decorators/cast.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import y from"../rest/support/Stop.js";import S from"../symbols/SimpleMarkerSymbol.js";import w from"./Search.js";import M from"./Widget.js";import b from"./Directions/DirectionsViewModel.js";import{SaveLayer as f}from"./Directions/components/SaveLayer.js";import{formatDistance as C,formatTime as T,isTimeUnits as k}from"./Directions/support/directionsUtils.js";import{DepartureTime as D,CSS as I,getIconPath as L}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import B from"./support/DatePicker.js";import{Heading as A,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as E}from"./support/decorators/accessibleHandler.js";import{messageBundle as H}from"./support/decorators/messageBundle.js";import{tsx as U}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import O from"sortablejs";import{substitute as z}from"../intl/substitute.js";import{formatDate as $,convertDateFormatToIntlOptions as F}from"../intl/date.js";import{formatNumber as N}from"../intl/number.js";const V={departureTime:!0,layerDetails:!0,printButton:!1,saveAsButton:!0,saveButton:!0,stops:!0,traveMode:!0};function W(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",i=60,o=Math.abs(Math.floor(t/i)),r=Math.abs(Math.floor(t)%i),n={minimumIntegerDigits:2};return`GMT${s}${N(o,n)}${N(r,n)}`}function q(e){return!!e.composedPath?.().find((e=>e.classList?.contains("esri-search__suggestions-list")))}const K={awaitingViewClickStop:"awaiting-view-click-stop"},Y=100,G=500,J=r.getLogger("esri.widgets.Directions");let Q=class extends M{constructor(e,t){super(e,t),this._autoStopRemovalDelay=Y,this._departureTime=D.NOW,this._datePicker=new B,this._handles=new o,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._renderSavePopoverFunction=null,this._saveAsButtonNode=null,this._saveLayer=new f,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=I.widgetIcon,this.label=void 0,this.lastRoute=null,this.layer=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.searchProperties=null,this.view=null,this.viewModel=new b,this.visibleElements={...V},this._setUpDragAndDropStops=e=>{this._sortable=O.create(e,{draggable:`.${I.validStopRow}`,ghostClass:I.stopRowGhost,handle:`.${I.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.layer.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:i}=s,o=i[t],r=i[e],n=t-e<0;s.insertBefore(o,n?r.nextElementSibling:r);const a=this.viewModel.layer.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._getDirections()}}initialize(){this.own([d((()=>this.viewModel.layer.routeInfo),(()=>{this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),h),u((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),i=this._prepViewClick();t.pause(),i.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=G)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=Y)),t,i],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=i}}),h),u((()=>n(this.viewModel.serviceDescription)),(()=>{try{this.viewModel.load()}catch{}}),h),d((()=>this._saveLayer.state),(()=>{this.scheduleRender()}))]),this.when((()=>{this.destroyed||(this._renderSavePopoverFunction=this._renderSavePopover.bind(this),this._projector.append(document.body,this._renderSavePopoverFunction))}))}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-link.js"),import("@esri/calcite-components/dist/components/calcite-popover.js")])}destroy(){this._datePicker.destroy(),this._timePicker.destroy();for(const e of this._stopsToSearches.values())e.destroy();this._sortable&&this._sortable.destroy(),a(this._renderSavePopoverFunction)&&this._projector.detach(this._renderSavePopoverFunction)}set routeServiceUrl(e){t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url=e}get routeServiceUrl(){return t(J,"routeServiceUrl",{replacement:"viewModel.layer.url",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.url}set routeSymbol(e){t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines=e}get routeSymbol(){return t(J,"routeSymbol",{replacement:"viewModel.layer.defaultSymbols.directionLines",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.directionLines}set stopSymbols(e){t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops=e}get stopSymbols(){return t(J,"stopSymbols",{replacement:"viewModel.layer.defaultSymbols.stops",version:"4.24",warnOnce:!0}),this.viewModel.legacyLayer.defaultSymbols.stops}castVisibleElements(e){return{...V,...e}}getDirections(){return null}render(){return U("div",{class:this.classes(I.base,I.scroller)},this._renderPanelContent())}save(){return this.viewModel.layer.save()}saveAs(e,t={}){return this.viewModel.layer.saveAs(e,t)}zoomToRoute(){}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,i="error"===t&&!e,o="unauthenticated"===t,r={[I.panelContentLoading]:s,[I.panelContentError]:i,[I.panelContentSignIn]:o},n=s?"presentation":"group",a=o?this._renderSignIn():i?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return U("div",{class:this.classes(I.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSaveContainer(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return U("div",{key:"sign-in",class:I.signInContent},U(A,{class:I.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),U(A,{level:j(this.headingLevel)},this.messages.signInRequired),U("button",{class:this.classes(I.button,I.buttonSecondary,I.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){if(!this.visibleElements.traveMode)return null;const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=a(e)?e.name:this.messages.travelMode;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.travelMode,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__travel-mode-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.travelModeSelect,I.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=a(e)&&t.id===e.id;return U("option",{key:`esri-directions__travel-mode-${t.id}`,"data-mode":t,selected:s,value:t.id},t.name)}))))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"],this._getDirections()}_renderStopsContainer(){return this.visibleElements.stops?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.section,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__stops-container",role:"group"},this._renderStops()):null}_renderDepartureTimeControls(){if(!this.visibleElements.departureTime)return null;const e=this._departureTime,{messages:t}=this,s=t.departureTime;return U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.departureTime,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__departure-time-controls",role:"group"},U("select",{"aria-label":s,bind:this,class:this.classes(I.departureTimeSelect,I.select),onchange:this._handleDepartureOptionChange,title:s},U("option",{value:D.NOW,selected:e===D.NOW},t.leaveNow),U("option",{value:D.DEPART_BY,selected:e===D.DEPART_BY},t.departBy),U("option",{value:D.UNSPECIFIED,selected:e===D.UNSPECIFIED},t.timeUnspecified)),e===D.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.layer.stops;let t=0;for(const o of this._stopsToSearches.keys())e.includes(o)||this._disposeSearch(o);for(const o of e){const e=this._acquireSearch(o);"none"!==e.activeMenu&&(t+=1),a(o.name)&&(e.searchTerm=o.name)}const s=e.toArray().map(((s,i)=>{const o=e.length,r=i>1&&n(s.geometry),l={[I.stopsIcon]:i>=0&&i<o-1,[I.lastStopIcon]:i===o-1},c={[I.lastStopIconContainer]:i===o-1},d={[I.validStopRow]:!r},h=e.getItemAt(i+1),u=h&&a(h.geometry),p=i===o-1,v=i===o-2,m=2===o&&0===i||o>2&&!p&&!v||o>2&&v&&u||o>2&&p&&n(s.geometry),_=o<3,g=this._acquireSearch(s),{messages:y}=this,{removeStop:S,reverseStops:w,unlocated:M}=y,b=z(y.stopLabelTemplate,{number:i+1,label:a(s.geometry)?s.name:M}),f=`${this.id}__stop--${i}`,C=!!g.searchTerm&&!!g.selectedResult&&a(s.geometry)&&g.selectedResult.name===s.name,T={zIndex:"none"!==g.activeMenu?""+t--:""};return U("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(I.stopRow,d),id:f,key:i,"data-stop-index":i,styles:T},U("div",{class:I.stopHandle},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.handleIcon,I.stopHandleIcon,I.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),U("div",{bind:this,"aria-labelledby":f,class:this.classes(I.stopIconContainer,c),"data-stop-index":i,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},U("span",{class:this.classes(I.stopIcon,l),tabindex:C?"0":null}))),U("div",{class:I.stopInput},g.render()),U("div",{class:I.stopOptions,role:"group"},U("div",{"aria-label":S,class:I.removeStopButton,bind:this,"data-stop-index":i,hidden:_,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:S},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.removeStop,I.removeStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle")),U("div",{"aria-label":w,class:I.reverseStops,bind:this,hidden:m,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:w},U("span",{"aria-hidden":"true",class:this.classes(I.stopIcon,I.reverseStopIcon,I.interactiveStopIcon)}),U("span",{class:I.screenReaderText},"removeStopTitle"))))})),i=this._renderAddStop();return U("div",null,U("ol",{class:I.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),i)}_renderAddStop(){const{stops:e}=this.viewModel.layer,t=e.filter((({geometry:e})=>a(e))),s=e.at(-1);return t.length>1&&t.length<this.maxStops&&a(s)&&a(s.geometry)?U("div",{class:I.toolbarSection},U("div",{class:I.toolbarButtons},U("calcite-button",{appearance:"outline",class:I.addStopButton,color:"neutral","icon-start":"plus",key:I.addStopButton,onclick:()=>{this._addNewPlaceholder()},text:this.messages.addStop,width:"half"},this.messages.addStop))):null}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);s&&a(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],i=this.viewModel.layer.stops.getItemAt(s);if(t===i){const e=this._acquireSearch(i);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){if(this._saveLayer.opened)return;this._handles.remove(K.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!!e.selectedResult&&a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry===e.selectedResult?.feature.geometry)return void this._pointerDownUpHandle.pause();const s=n(t.geometry)&&n(e.selectedResult?.feature.geometry),i=a(t.geometry)&&a(e.selectedResult?.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry;if((s||i)&&"none"===e.activeMenu&&e.searchTerm)return e.search(),void this._pointerDownUpHandle.pause();e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(a(t.geometry)&&(t.geometry=null,this._getDirections()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay))}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(K.awaitingViewClickStop))return;const{view:s,view:{cursor:i}}=this;this._previousCursor=i,this._handles.add(d((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":i)}),h),K.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=i(e,"click",this._handleViewClick.bind(this)),s=i(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=i(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=q(e)?this._activeStop:null})),t=i(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=q(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:i,name:o}=s;this._activeStop.geometry=i.geometry,this._activeStop.name=o,t.searchTerm=o})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new y({symbol:new S});this.viewModel.layer.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.layer.stops.reverse();for(const e of this.viewModel.layer.stops)e.sequence=null;this._getDirections()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.layer.stops.getItemAt(t);this._removeStop(s),(a(s.geometry)||n(this.viewModel.layer.routeInfo))&&this._getDirections()}_removeStop(e){this.viewModel.layer.stops.length<=2||(this._disposeSearch(e),this.viewModel.layer.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===D.NOW?(this._departureTime=D.NOW,this.viewModel.departureTime=D.NOW,this._handles.remove("departure-time-controls"),this._getDirections()):s.value===D.DEPART_BY?(this._departureTime=D.DEPART_BY,this._handles.add(d((()=>[this._datePicker.value,this._timePicker.value]),(()=>{this._updateDepartureTime(),this._getDirections()}),h),"departure-time-controls")):(this._departureTime=D.UNSPECIFIED,this.viewModel.departureTime=null,this._getDirections())}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return U("div",{class:I.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return U("div",{class:I.sectionSplitter})}_renderSaveContainer(){const{saveButton:e,saveAsButton:t,printButton:s,layerDetails:i}=this.visibleElements;return e||t||s||i?U("div",{class:I.saveSection,key:I.saveSection},this._renderSaveButtons(),this._renderRouteLayerDetailsLink()):null}_renderSaveButtons(){const{saveButton:e,saveAsButton:t,printButton:s}=this.visibleElements;return e||t||s?U("div",{class:I.saveButtons,key:I.saveButtons},this._renderSaveButton(),this._renderSaveAsButton(),this._renderPrintButton()):null}_renderSaveButton(){if(!this.visibleElements.saveButton)return null;const e=this.viewModel.layer.portalItem?.itemControl,t=a(this.viewModel.layer.routeInfo)&&("admin"===e||"update"===e);return U("calcite-button",{appearance:"outline",class:I.saveButton,color:"neutral",disabled:!t,"icon-start":"save",key:I.saveButton,onclick:()=>{this._handleSaveButtonClick()},text:this.messagesCommon.save,width:"full"},this.messagesCommon.save)}_renderSaveAsButton(){if(!this.visibleElements.saveAsButton)return null;const e=n(this.viewModel.layer.routeInfo);return U("div",{class:I.saveAsButtonPopover,key:I.saveAsButtonPopover},U("calcite-button",{afterCreate:e=>{this._saveAsButtonNode=e},appearance:"outline",class:I.saveAsButton,color:"neutral",disabled:e,"icon-start":"duplicate",key:I.saveAsButton,onclick:()=>this._handleSaveAsButtonClick(),text:this.messagesCommon.saveAs,width:"full"},this.messagesCommon.saveAs))}_renderSavePopover(){return U("calcite-popover",{label:this._saveLayer.label,open:this._saveLayer.opened,"overlay-positioning":"fixed",referenceElement:l(this._saveAsButtonNode)},this._saveLayer.render())}_handleSaveAsButtonClick(){this._saveLayer.opened?this._saveLayer.close():this._saveLayer.open(this.viewModel.layer)}_renderPrintButton(){return this.visibleElements.printButton?U("calcite-button",{appearance:"outline",class:I.printButton,color:"neutral","icon-start":"print",key:I.printButton,text:this.messagesCommon.print}):null}_renderRouteLayerDetailsLink(){if(!this.visibleElements.layerDetails)return null;const{portalItem:e}=this.viewModel.layer;if(!e)return null;const{id:t,portal:{url:s}}=e,i=`${s}/home/item.html?id=${t}`;return U("calcite-link",{class:I.layerDetailsLink,href:i,key:I.layerDetailsLink,target:"_blank"},this.messages.viewLayerDetails)}_handleSaveButtonClick(){this.viewModel.layer.save()}_renderDirectionsContainer(){return U("div",{class:this.classes(I.directionsSection,I.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return U("div",{class:I.loader,key:"loader"})}_renderWarningCard(){return U("div",{class:I.warningCard,role:"alert"},U("div",{class:I.warningHeader},U("span",{class:I.warningIcon,"aria-hidden":"true"}),U(A,{class:I.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),U("div",{class:I.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{viewModel:{layer:e,state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():a(e.directionLines)?U("div",{"aria-disabled":this._saveLayer.opened.toString(),class:this.classes(I.summary,this._saveLayer.opened&&I.buttonDisabled),key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):U("div",{key:"esri-directions__placeholder",class:I.emptyContent},this._renderPlaceholder(),U(A,{class:I.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return U("svg",{class:I.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},U("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return U(A,{level:this.headingLevel},e)}_renderRouteActions(){return U("div",{class:I.routeActions},U("button",{"aria-label":this.messages.clearRoute,class:this.classes(I.clearRouteButton,I.button,I.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){const{directionPoints:e,directionLines:t,stops:s}=this.viewModel.layer;if(n(e)||n(t))return null;const i=[];let o=null;for(const r of e){const{objectId:e,stopId:l}=r;if(a(l)){const e=s.find((e=>e.objectId===l)),t=0===i.length;(n(o)||o.stop!==e)&&(o={stop:e,directions:[],open:t},i.push(o));continue}if(n(o))continue;const c=t.find((t=>t.directionPointId===e));n(c)||o.directions.push({directionPoint:r,directionLine:c})}return i}_renderManeuverSections(){return n(this._sections)?null:U("div",{class:I.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let i;e.directions.length>0&&s&&(i=U("ol",{class:I.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const o=l(this._sections).length>2,r=t===l(this._sections).length-1,n={[I.collapsibleSection]:o},a={[I.openIcon]:!s,[I.closeIcon]:s};let c;if(o&&!r){const t=s?this.messagesCommon.close:this.messagesCommon.open;c=U("header",{class:this.classes(I.maneuverSectionHeader,I.maneuverSectionToggle),key:I.maneuverSectionHeader},U("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:I.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name),U("span",{"aria-hidden":"true",class:this.classes(a)})))}else c=U("header",{class:I.maneuverSectionHeader,key:I.maneuverSectionHeader},U(A,{class:I.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return U("section",{class:this.classes(I.maneuverSection,n),key:t},c,i)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const e=this._getCostSummary(),{directionPoints:t}=this.viewModel.layer;if(n(t)||n(e))return null;const s=t.getItemAt(t.length-1).arrivalTime,{primary:i,secondary:o}=e,{eta:r,etaTemplate:l,primaryCosts:c,secondaryCosts:d,zoomToRoute:h}=this.messages,u=F("short-time"),p=a(s)?`<strong>${$(s,u)}</strong>`:null,v=a(s)?`${W(s)}`:null,m=z(l,{time:p,gmt:v});return U("div",{"aria-label":h,bind:this,class:I.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:h},U("div",{class:I.costsDetails,role:"group"},U("div",{class:I.primaryCosts,title:c},i),U("div",{class:I.verticalSplitter}),U("div",{class:I.secondaryCosts,title:d},o)),U("div",{innerHTML:m,title:r}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{lastError:t}}=this;if(a(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??(t.locationType="street"),P(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=R))}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new w({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([p((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._getDirections()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e))),s.on("search-clear",(()=>{e.geometry=null,e.name=null,this._activeStop=e,this.viewModel.layer.removeResult()})),d((()=>s.searchTerm),(t=>{e.name=t}))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.has(e)&&(this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e))}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:i,directionLine:o}=e,{distance:r,duration:n}=o,{messages:l,messagesUnits:d}=this,h=C(l,d,c(r,0),{fromUnits:"meters",toUnits:s}),u=T(c(n,0),"minutes"),p=h&&u?`${h} · ${u}`:`${h}${u}`,v=this._getFormattedManeuverText(i),{objectId:m,directionPointType:_}=i,g=L(_),y=`esri-directions__maneuver-${m}`,S=`esri-directions__cumulative-costs-${m}`,w=`esri-directions__intermediate-costs-${m}`,M={[I.maneuverActive]:this._activeManeuver===o};return U("li",{"aria-labelledby":`${y} ${S} ${w}`,bind:this,class:this.classes(I.maneuver,M),"data-maneuver":o,key:o,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},a(g)&&U("img",{alt:"",class:I.maneuverIcon,src:g}),U("div",{class:I.maneuverCostsContainer},U("span",{id:y,innerHTML:c(v,"")}),U("div",{class:I.maneuverCosts},U("div",{class:I.horizontalSplitter}),U("div",{id:S,class:I.cumulativeCost,innerHTML:t,title:l.cumulativeCosts}),U("div",{id:w,class:I.intermediateCost,innerHTML:p,title:l.intermediateCosts}))))}_handleManeuverClick(e){const t=e.currentTarget["data-maneuver"];if(this._activeManeuver===t)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=t;const{geometry:s}=t;this.viewModel.centerAt(s),this.viewModel.highlight(t)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const t=e.currentTarget["data-maneuver"];this.viewModel.highlight(t)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const t=e.currentTarget["data-maneuver"];this._focusedManeuver=t,this.viewModel.highlight(t)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:i}=e;if(n(t))return"";let o=t;return a(s)&&o.includes(s)&&(o=o.replace(s,`<strong>${s}</strong>`)),a(i)&&o.includes(i)&&(o=o.replace(i,`<strong>${i}</strong>`)),o}_getCostSummary(){const{viewModel:{impedanceAttribute:e,layer:{routeInfo:t},routeParameters:s}}=this;if(n(e)||n(t))return null;let{totalDuration:i,totalDistance:o}=t;const{directionsLengthUnits:r}=s;o=a(o)?o:0,i=a(i)?i:0;const l=C(this.messages,this.messagesUnits,o,{fromUnits:"meters",toUnits:r}),c=T(i,"minutes"),[d,h]=k(e.units)?[c,l]:[l,c];return{primary:d,secondary:h}}async _getDirections(){if(!(this.viewModel.layer.stops.filter((e=>a(e.geometry))).length<2))try{await this.viewModel.getDirections()}catch{}}};e([v("viewModel.apiKey")],Q.prototype,"apiKey",void 0),e([v("viewModel.goToOverride")],Q.prototype,"goToOverride",void 0),e([_()],Q.prototype,"headingLevel",void 0),e([_()],Q.prototype,"iconClass",void 0),e([_({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],Q.prototype,"label",void 0),e([v("viewModel.lastRoute")],Q.prototype,"lastRoute",void 0),e([v("viewModel.layer")],Q.prototype,"layer",void 0),e([v("viewModel.maxStops")],Q.prototype,"maxStops",void 0),e([_(),H("esri/widgets/Directions/t9n/Directions")],Q.prototype,"messages",void 0),e([_(),H("esri/t9n/common")],Q.prototype,"messagesCommon",void 0),e([_(),H("esri/core/t9n/Units")],Q.prototype,"messagesUnits",void 0),e([_()],Q.prototype,"routeServiceUrl",null),e([_()],Q.prototype,"routeSymbol",null),e([_()],Q.prototype,"searchProperties",void 0),e([_()],Q.prototype,"stopSymbols",null),e([v("viewModel.view")],Q.prototype,"view",void 0),e([_({type:b})],Q.prototype,"viewModel",void 0),e([_()],Q.prototype,"visibleElements",void 0),e([m("visibleElements")],Q.prototype,"castVisibleElements",null),e([v("viewModel.getDirections")],Q.prototype,"getDirections",null),e([v("viewModel.zoomToRoute")],Q.prototype,"zoomToRoute",null),e([E()],Q.prototype,"_handleStopIconClick",null),e([E()],Q.prototype,"_handleClearRouteClick",null),e([E()],Q.prototype,"_handleReverseStops",null),e([E()],Q.prototype,"_handleRemoveStop",null),e([E()],Q.prototype,"_handleSectionToggle",null),e([E()],Q.prototype,"_handleSummaryInteraction",null),e([E()],Q.prototype,"_handleManeuverClick",null),Q=e([g("esri.widgets.Directions")],Q);const X=Q;export{X 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a}from"../../core/handleUtils.js";import{unwrap as r,removeMaybe as i,isSome as s,isNone as o,destroyMaybe as n}from"../../core/maybe.js";import{watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as p}from"./CreateFeaturesWorkflowData.js";import h from"./Workflow.js";import{startCreatingNewFeature as f,findLayerInfo as m,updateGraphicSymbolWhenRequired as g,getVisualVariableAttributes as v,startUpdatingFeature as w,createWorkflowSteps as y,avoidFeatureTemplateSelectionWithOnlyOneItem as M,visualVariableInteractiveUpdate as b}from"./workflowUtils.js";var V;let F=V=class extends h{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.featureFormHandle=null,this.visualVariableAttributes={rotation:null,size:null},this.highlightHandles=new Map,this.preventDefaultActionOnCancel=!1}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}async updatePendingFeature(e,a){return this.preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this.lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i){const s=new V({data:new p({creationInfo:r(t),viewModel:e}),onCommit:async e=>{await i(e.creationInfo.layer,{addFeatures:e.viewModel.sketchViewModel.layer.graphics.toArray()})}});return s._set("steps",this._createWorkflowSteps(s,a)),s}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t.type&&this.highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){i(this.highlightHandles.get(e)),this.highlightHandles.delete(e)}async _startCreating(e){return this.createFeatureState="create-new",f(this.data.viewModel.sketchViewModel,this.data.creationInfo,e)}async _startUpdating(e,t){const a=this.data.viewModel,r=a.sketchViewModel,s=this.data.creationInfo.layer,o=m(a.layerInfos,s)?.formTemplate;return a.featureFormViewModel.set({feature:e,formTemplate:o}),i(this.featureFormHandle),this.featureFormHandle=a.featureFormViewModel.on("value-change",(async()=>{e.attributes=a.featureFormViewModel.getValues(),await g(e,t)})),this._removeHighlight(e),this.createFeatureState="update-pending",this.visualVariableAttributes=v(e),w(r,e,s,this.visualVariableAttributes,t)}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:r,handles:u}=e;let p=null,h=!0;const f=new Map,m=y(["awaiting-feature-creation-info","creating-features"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){r.creationInfo=null,u.add(r.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{r.creationInfo={layer:e.layer,template:e.template},r.viewModel.activeWorkflow.next()})),this.id)},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){const a=r.viewModel.view,m=r.viewModel.sketchViewModel;h=m.updateOnGraphicClick,m.updateOnGraphicClick=!1,e.lastActiveGraphics=[],e.featureFormHandle=i(e.featureFormHandle),e.visualVariableAttributes={rotation:null,size:null};const g="2d"===a.type?e._fadeExistingFeatures(r.creationInfo.layer):null,v=m.on("create",(async t=>{if("cancel"===t.state){if(e.preventDefaultActionOnCancel)return void(e.preventDefaultActionOnCancel=!1);if(e.lastActiveGraphics.length<1)return e._startCreating(f);const t=e.lastActiveGraphics.pop();return e._startUpdating(t,f)}if("complete"===t.state)return e._startUpdating(t.graphic,f)})),w=m.on("update",(async t=>{const i=t.graphics[0];if("complete"===t.state)return i!==p&&(e.lastActiveGraphics.push(i),e._highlight(i)),p=null,t.aborted&&e.preventDefaultActionOnCancel?void(e.preventDefaultActionOnCancel=!1):e._startCreating(f);"start"===t.state&&e._removeHighlight(i),await b(a,i,t,e.visualVariableAttributes,f);const o=i.attributes;if(s(e.visualVariableAttributes.rotation)){const{field:t}=e.visualVariableAttributes.rotation;r.viewModel.featureFormViewModel.setValue(t,o[t])}if(s(e.visualVariableAttributes.size)){const{field:t}=e.visualVariableAttributes.size;r.viewModel.featureFormViewModel.setValue(t,o[t])}})),y=m.on("delete",(async a=>{const r=a.graphics[0];t(e.lastActiveGraphics,r),p=r}));let M=null;const V=l((()=>{const e=m.snappingOptions.featureSources.find((e=>e.layer===r.creationInfo.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=m.snappingOptions.featureSources;e?(o(M)&&(M=new d({layer:m.layer,enabled:t}),a.add(M)),M.enabled=t):(s(M)&&a.remove(M),M=n(M))}),c),F=a.on("immediate-click",(async t=>{const{results:r}=await a.hitTest(t,{include:m.layer}),i=r.find((e=>"graphic"===e.type));if(i){const t=i.graphic;if("transform"===m.activeTool||"reshape"===m.activeTool){if(m.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,f)}}}));await e._startCreating(f);const A={remove:()=>{i(e.featureFormHandle),v.remove(),w.remove(),y.remove(),V.remove(),s(M)&&m.snappingOptions.featureSources.remove(M),M=n(M),m.cancel(),F.remove(),i(g)}};u.add(A,this.id)},async tearDown(e){e.cancelled&&r.viewModel.sketchViewModel.layer.removeAll(),u.remove(this.id),r.viewModel.sketchViewModel.updateOnGraphicClick=h}})});return M(r,m)}};F=V=e([u("esri.widgets.Editor.CreateFeaturesWorkflow")],F);const A=F;export{A as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a}from"../../core/handleUtils.js";import{unwrap as r,removeMaybe as i,isSome as s,isNone as o,destroyMaybe as n}from"../../core/maybe.js";import{watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as p}from"./CreateFeaturesWorkflowData.js";import h from"./Workflow.js";import{startCreatingNewFeature as f,findLayerInfo as m,updateGraphicSymbolWhenRequired as g,getVisualVariableAttributes as v,startUpdatingFeature as w,createWorkflowSteps as y,avoidFeatureTemplateSelectionWithOnlyOneItem as M,visualVariableInteractiveUpdate as b}from"./workflowUtils.js";var V;let F=V=class extends h{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.featureFormHandle=null,this.visualVariableAttributes={rotation:null,size:null},this.highlightHandles=new Map,this.preventDefaultActionOnCancel=!1}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}async updatePendingFeature(e,a){return this.preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this.lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i){const s=new V({data:new p({creationInfo:r(t),viewModel:e}),onCommit:async e=>{await i(e.creationInfo.layer,{addFeatures:e.viewModel.sketchViewModel.layer.graphics.toArray()})}});return s._set("steps",this._createWorkflowSteps(s,a)),s}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t.type&&this.highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){i(this.highlightHandles.get(e)),this.highlightHandles.delete(e)}async _startCreating(e){return this.createFeatureState="create-new",f(this.data.viewModel.sketchViewModel,this.data.creationInfo,e)}async _startUpdating(e,t){const a=this.data.viewModel,r=a.sketchViewModel,s=this.data.creationInfo.layer,o=m(a.layerInfos,s)?.formTemplate,n=a.view.spatialReference;return a.featureFormViewModel.set({feature:e,formTemplate:o,spatialReference:n}),i(this.featureFormHandle),this.featureFormHandle=a.featureFormViewModel.on("value-change",(async()=>{e.attributes=a.featureFormViewModel.getValues(),await g(e,t)})),this._removeHighlight(e),this.createFeatureState="update-pending",this.visualVariableAttributes=v(e),w(r,e,s,this.visualVariableAttributes,t)}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:r,handles:u}=e;let p=null,h=!0;const f=new Map,m=y(["awaiting-feature-creation-info","creating-features"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){r.creationInfo=null,u.add(r.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{r.creationInfo={layer:e.layer,template:e.template},r.viewModel.activeWorkflow.next()})),this.id)},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){const a=r.viewModel.view,m=r.viewModel.sketchViewModel;h=m.updateOnGraphicClick,m.updateOnGraphicClick=!1,e.lastActiveGraphics=[],e.featureFormHandle=i(e.featureFormHandle),e.visualVariableAttributes={rotation:null,size:null};const g="2d"===a.type?e._fadeExistingFeatures(r.creationInfo.layer):null,v=m.on("create",(async t=>{if("cancel"===t.state){if(e.preventDefaultActionOnCancel)return void(e.preventDefaultActionOnCancel=!1);if(e.lastActiveGraphics.length<1)return e._startCreating(f);const t=e.lastActiveGraphics.pop();return e._startUpdating(t,f)}if("complete"===t.state)return e._startUpdating(t.graphic,f)})),w=m.on("update",(async t=>{const i=t.graphics[0];if("complete"===t.state)return i!==p&&(e.lastActiveGraphics.push(i),e._highlight(i)),p=null,t.aborted&&e.preventDefaultActionOnCancel?void(e.preventDefaultActionOnCancel=!1):e._startCreating(f);"start"===t.state&&e._removeHighlight(i),await b(a,i,t,e.visualVariableAttributes,f);const o=i.attributes;if(s(e.visualVariableAttributes.rotation)){const{field:t}=e.visualVariableAttributes.rotation;r.viewModel.featureFormViewModel.setValue(t,o[t])}if(s(e.visualVariableAttributes.size)){const{field:t}=e.visualVariableAttributes.size;r.viewModel.featureFormViewModel.setValue(t,o[t])}})),y=m.on("delete",(async a=>{const r=a.graphics[0];t(e.lastActiveGraphics,r),p=r}));let M=null;const V=l((()=>{const e=m.snappingOptions.featureSources.find((e=>e.layer===r.creationInfo.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=m.snappingOptions.featureSources;e?(o(M)&&(M=new d({layer:m.layer,enabled:t}),a.add(M)),M.enabled=t):(s(M)&&a.remove(M),M=n(M))}),c),F=a.on("immediate-click",(async t=>{const{results:r}=await a.hitTest(t,{include:m.layer}),i=r.find((e=>"graphic"===e.type));if(i){const t=i.graphic;if("transform"===m.activeTool||"reshape"===m.activeTool){if(m.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,f)}}}));await e._startCreating(f);const A={remove:()=>{i(e.featureFormHandle),v.remove(),w.remove(),y.remove(),V.remove(),s(M)&&m.snappingOptions.featureSources.remove(M),M=n(M),m.cancel(),F.remove(),i(g)}};u.add(A,this.id)},async tearDown(e){e.cancelled&&r.viewModel.sketchViewModel.layer.removeAll(),u.remove(this.id),r.viewModel.sketchViewModel.updateOnGraphicClick=h}})});return M(r,m)}};F=V=e([u("esri.widgets.Editor.CreateFeaturesWorkflow")],F);const A=F;export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/maybe.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import o from"./CreateWorkflowData.js";import{Edits as r}from"./Edits.js";import i from"./Workflow.js";import{createWorkflowSteps as s,avoidFeatureTemplateSelectionWithOnlyOneItem as n,setUpFeatureAdd as l,findLayerInfo as c,getVisualVariableAttributes as d,startUpdatingFeature as f,visualVariableInteractiveUpdate as w,updateGraphicSymbolWhenRequired as u}from"./workflowUtils.js";var
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/maybe.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import o from"./CreateWorkflowData.js";import{Edits as r}from"./Edits.js";import i from"./Workflow.js";import{createWorkflowSteps as s,avoidFeatureTemplateSelectionWithOnlyOneItem as n,setUpFeatureAdd as l,findLayerInfo as c,getVisualVariableAttributes as d,startUpdatingFeature as f,visualVariableInteractiveUpdate as w,updateGraphicSymbolWhenRequired as u}from"./workflowUtils.js";var p;let m=p=class extends i{constructor(e){super(e),this.type="create"}static create(e,t,a){const i=new p({data:new o({edits:new r,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:o,handles:r}=e,i=new Map,p=s(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){o.creationInfo=null,o.edits.feature=null,o.viewModel.featureTemplatesViewModel.select(null),r.add(o.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{o.creationInfo={layer:e.layer,template:e.template},o.viewModel.activeWorkflow.next()})),this.id)},async tearDown(){r.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){r.add(await l(o.viewModel.sketchViewModel,o.creationInfo,(e=>{o.edits.feature=e,o.viewModel.activeWorkflow.next()}),i),this.id)},async tearDown(){r.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=o.edits.feature,a=e.sourceLayer,s=o.viewModel,n=s.sketchViewModel,l=c(s.layerInfos,a)?.formTemplate,{spatialReference:p}=s.view;s.featureFormViewModel.set({feature:e,formTemplate:l,spatialReference:p}),n.allowDeleteKey=!1;const m=d(e);await f(n,e,a,m,i);const v=n.on("update",(async e=>{const o=e.graphics[0];if("complete"===e.state)return f(n,o,a,m,i);await w(n.view,o,e,m,i);const r=o.attributes;if(t(m.rotation)){const{field:e}=m.rotation;s.featureFormViewModel.setValue(e,r[e])}if(t(m.size)){const{field:e}=m.size;s.featureFormViewModel.setValue(e,r[e])}}));r.add([o.viewModel.featureFormViewModel.on("value-change",(async()=>{o.edits.updateAttributes(o.viewModel.featureFormViewModel.getValues()),e.attributes=o.edits.feature.attributes,"3d"===n.view.type&&await u(e,i)})),v],this.id)},async tearDown(e){e.cancelled&&o.viewModel.sketchViewModel.layer.removeAll(),r.remove(this.id)}})});return n(o,p)}};m=p=e([a("esri.widgets.Editor.CreateWorkflow")],m);const v=m;export{v 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.24/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t}from"../../core/handleUtils.js";import{isSome as i}from"../../core/maybe.js";import{onAbort as a,createAbortError as s,throwIfAborted as o,isAborted as r}from"../../core/promiseUtils.js";import{watch as d}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import{Edits as c}from"./Edits.js";import u from"./UpdateWorkflowData.js";import m from"./Workflow.js";import{createWorkflowSteps as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t}from"../../core/handleUtils.js";import{isSome as i}from"../../core/maybe.js";import{onAbort as a,createAbortError as s,throwIfAborted as o,isAborted as r}from"../../core/promiseUtils.js";import{watch as d}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as l}from"../../views/support/layerViewUtils.js";import{Edits as c}from"./Edits.js";import u from"./UpdateWorkflowData.js";import m from"./Workflow.js";import{createWorkflowSteps as w,fetchCandidates as h,fetchFullFeature as f,findLayerInfo as p,getVisualVariableAttributes as g,setUpGeometryUpdate as v}from"./workflowUtils.js";var y;const M="candidate-highlight";let b=y=class extends m{constructor(e){super(e),this.type="update"}static create(e,t,i){const a=new y({data:new u({edits:new c,viewModel:e}),onCommit:async e=>{const t=e.edits.feature,a=t.sourceLayer,s=t.clone();if(!e.edits.attributesModified){const{objectIdField:e}=a;s.attributes={[e]:t.getAttribute(e)}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}highlight(e){const{data:{viewModel:{view:t}}}=this,i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer));l(i)&&this.handles.add(i.highlight(e),M)}unhighlight(){this.handles.remove(M)}static _createWorkflowSteps(e,n="awaiting-feature-to-update"){const{data:l,handles:c}=e,u=new Map;return w(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],n,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e,view:t}=l.viewModel;let i=null;c.add({remove(){i&&(i.abort(),i=null)}},this.id),l.edits.feature=null;const r=t.on("immediate-click",(r=>{e.location=r.mapPoint,e.visible=!0,i&&i.abort();const{editableItems:d}=l.viewModel;i=new AbortController,new Promise(((e,o)=>{a(i.signal,(()=>o(s()))),e(h(d,t,r,i.signal))})).then((e=>{if(o(i),l.candidates=e.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),l.viewModel.spinnerViewModel.visible=1===l.candidates.length,0!==l.candidates.length)if(1===l.candidates.length){const e=l.candidates[0];l.edits.feature=e,l.viewModel.activeWorkflow.go("editing-existing-feature").catch((()=>{})).then((()=>l.viewModel.spinnerViewModel.visible=!1))}else l.viewModel.activeWorkflow.next()}))}));t.focus(),c.add(r,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=l;t.feature=null,c.add(d((()=>t.feature),(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){if(c.has("editing-existing-feature"))return;const a=l.edits.feature,s=l.viewModel;l.editableItem=s.editableItems.find((e=>e.layer===a.layer));const o=new AbortController;c.add({remove:()=>o.abort()},this.id);const n=s.view.whenLayerView(a.layer),m=f(a,s.view,o.signal),w=await n,h=await m;if(r(o))return;l.edits.updateGeometry(h.geometry),l.edits.updateAttributes(h.attributes),l.edits.trackChanges(),s.attachmentsViewModel.set({graphic:h,mode:"view"});const y=h.sourceLayer,M=p(s.layerInfos,y)?.formTemplate,b=s.view.spatialReference;s.featureFormViewModel.set({feature:h,formTemplate:M,spatialReference:b});const V="createInteractiveEditSession"in w?w.createInteractiveEditSession(a):null,j=[s.featureFormViewModel.on("value-change",(e=>{l.edits.updateAttributes(s.featureFormViewModel.getValues()),h.attributes=l.edits.feature.attributes,V&&V.setAttribute(e.fieldName,e.value)})),d((()=>s.attachmentsViewModel.mode),(e=>{"add"===e&&l.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&l.viewModel.activeWorkflow.go("editing-attachment")}))];V&&(j.push(t((()=>V.rollback()))),c.add(t((()=>V.commit())),e._handleKeys.afterCommit));const{supportsGeometryUpdate:k}=y.capabilities.editing;if(k){s.sketchViewModel.allowDeleteKey=!1;const t=g(h),{interactive:a,visual:o}=await v(h,t,s.sketchViewModel,s.view,(({geometry:e,attributes:a})=>{if(i(t.rotation)){const{field:e}=t.rotation;s.featureFormViewModel.setValue(e,a[e])}if(i(t.size)){const{field:e}=t.size;s.featureFormViewModel.setValue(e,a[e])}l.edits.updateAttributes(a),l.edits.updateGeometry(e)}),u);j.push(a,o),c.add(a,e._handleKeys.beforeCommit),c.add(o,e._handleKeys.afterCommit)}else e.highlight(h);c.add(j,this.id)},async tearDown({cancelled:t}){t&&(e.unhighlight(),c.remove(this.id))}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){l.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){l.viewModel.attachmentsViewModel.mode="view"}})})}};b=y=e([n("esri.widgets.Editor.UpdateWorkflow")],b);const V=b;export{V as default};
|