@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
- package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
- package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
- package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
- package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
- package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
- package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
- package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
- package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
- package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 78e2fa121760383b08ec.js} +9 -6
- package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
- package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
- package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
- package/assets/esri/core/workers/chunks/969a82b674eda9f8720f.js +1 -0
- package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
- package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
- package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
- package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
- package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
- package/assets/esri/themes/base/widgets/_BasemapGallery.scss +3 -9
- package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
- package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +3 -3
- 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/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +1254 -262
- package/kernel.js +1 -1
- package/layers/GroupLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/queryValidationUtils.js +1 -1
- package/layers/mixins/ArcGISMapService.js +1 -1
- package/layers/save/groupLayerUtils.js +1 -1
- package/layers/save/utils.js +1 -1
- package/layers/support/ImageElement.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/Subtype.d.ts +4 -0
- package/layers/support/Subtype.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/networks/Network.js +1 -1
- package/package.json +1 -1
- package/portal/support/jsonContext.js +1 -1
- package/portal/support/layersLoader.js +1 -1
- package/rest/featureService/FeatureService.d.ts +4 -0
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/featureService/utils.d.ts +4 -0
- package/rest/query/operations/query.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/versionManagement/VersionManagementService.d.ts +4 -0
- package/versionManagement/VersionManagementService.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/input/handlers/KeyPan.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/PBFDecoder.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOPool.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
- package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/DirectionalPad.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/TimeZoneLabel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
- package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
- package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
- package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
- package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
- package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
- package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
- package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
- package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
- package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
- package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
- package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
- package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
- package/widgets/DirectionalPad.d.ts +0 -4
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as h}from"../../../core/maybe.js";import{zeroMeters as p}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m,initial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import j from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as F}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as L,autoLength2D as D}from"../../support/automaticLengthMeasurementUtils.js";import z from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.symbols=ee,this.tooltipOptions=new j,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),T.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):a(this._tooltip)}),m),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new z({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=h(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p]=e;r.push(new t({geometry:new P({x:h,y:p,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c]=a,l=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==l){const[a,d]=e[l],[m,v]=x([p,c],[a,d]);r.push(new t({geometry:new P({x:m,y:v,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:l}}))}}))})),r}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n]=e[s][o];i.geometry=new P({x:r,y:n,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n]=e[i][s],[a,h]=e[i][o],[p,c]=x([r,n],[a,h]);t.geometry=new P({x:p,y:c,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){h(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,p="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!p){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r(),this._snappingTask=i((async i=>{const h=await o.snap({point:a,context:n,signal:i});h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,p),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a}=t,[h,p]=this._getIndicesForVertexGraphic(e);let c=f(r);const l=c[h].length-1;c[h][p]=[n,a],"polygon"===r.type&&(0===p?c[h][l]=[n,a]:p===l&&(c[h][0]=[n,a])),this._isVertex(e)&&(c=this._moveRelatedCoordinates(c,e,n,a),c=this._moveSelectedHandleCoordinates(c,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(c)),this.graphic.geometry=r.clone();const d=this._getVertexFromEditGeometry(e),m=n-d.pos[0],v=a-d.pos[1];this._editGeometryOperations.moveVertices([d],m,v,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i,s){const{relatedGraphicIndices:o}=t.attributes;for(const r of o){const o=this.vertexGraphics.at(r),{pathIndex:n,pointIndex:a}=o.attributes;e[n][a]=[i,s],o.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c}=e.geometry,l=0===h?a+1:h,d=f(o);return d[n].splice(l,0,[p,c]),e.attributes={...t,pathIndex:n,pointIndex:l,relatedGraphicIndices:[]},r.push({coordinates:d[n][l],componentIndex:n,vertexIndex:l}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new U({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=L(n,r);o.distance=null!=a?a:p}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new A({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=F(i):"polyline"===i?.type&&(r.totalLength=D(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=L(n,s);r.distance=null!=a?a:p}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"_translateGraphicTooltipInfo",void 0),e([_()],te.prototype,"_translateVertexTooltipInfo",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_()],te.prototype,"symbols",void 0),e([_({type:j})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as h}from"../../../core/maybe.js";import{zeroMeters as p}from"../../../core/quantityUtils.js";import{when as c,pausable as l,watch as d,syncAndInitial as m,initial as v}from"../../../core/reactiveUtils.js";import{createScreenPoint as y}from"../../../core/screenUtils.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as g}from"../../../core/accessorSupport/decorators/subclass.js";import{closeRingsAndFixWinding as u,geometryToCoordinates as f,getMidpoint as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as M}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import S from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as k}from"./layerUtils.js";import{settings as I}from"./settings.js";import{ViewEventPriorities as T}from"../../input/InputManager.js";import{sketchKeys as O}from"../../interactive/keybindings.js";import{EditGeometryOperations as C}from"../../interactive/editGeometry/EditGeometryOperations.js";import j from"../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as R}from"../../interactive/snapping/SnappingContext.js";import{Tooltip as H}from"../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as U,TranslateVertexTooltipInfo as A}from"../../interactive/tooltip/TranslateTooltipInfos.js";import{autoArea2D as z}from"../../support/automaticAreaMeasurementUtils.js";import{autoDistanceBetweenPoints2D as F,autoLength2D as L}from"../../support/automaticLengthMeasurementUtils.js";import D from"../../../geometry/Polyline.js";import P from"../../../geometry/Point.js";class q{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class Q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class W{constructor(e){this.added=e,this.type="vertex-select"}}class X{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Y{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class Z{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=I.reshapeGraphics,ee={vertices:{default:new b({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this._tooltip=null,this._translateGraphicTooltipInfo=null,this._translateVertexTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=[],this.snappingManager=null,this.symbols=ee,this.tooltipOptions=new j,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this.addHandles([c((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),T.TOOL))}),{once:!0,initial:!0}),l((()=>this.graphic),(()=>this.refresh())),l((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),l((()=>this.enableMidpoints),(()=>this.refresh())),d((()=>this.tooltipOptions.enabled),(e=>{this._tooltip=e?new H({view:this.view}):a(this._tooltip)}),m),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),v)])}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._tooltip=a(this._tooltip)}set highlightsEnabled(e){this._highlightHelper?.removeAll(),this._set("highlightsEnabled",e),this._setUpHighlights()}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new D({paths:e.points,spatialReference:e.spatialReference}):e;this._editGeometryOperations=C.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer),this._snappingContext=new R({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new M(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=h(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this._set("selectedVertices",[])}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_getCoordinatesForUI(e){const t=f(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=this._getCoordinatesForUI(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((e,a)=>{const[h,p,c]=e;r.push(new t({geometry:new P({x:h,y:p,z:c,spatialReference:o}),symbol:s?.vertices?.default,attributes:{...i,pathIndex:n,pointIndex:a}}))}))})),r}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s,view:{spatialReference:o}}=this,r=[];return e?.forEach(((e,n)=>{e.forEach(((a,h)=>{const[p,c,l]=a,d=e[h+1]?h+1:0;if("polygon"===this.graphic.geometry?.type||0!==d){const[a,m,v]=e[d],[y,_,g]=x([p,c,l],[a,m,v]);r.push(new t({geometry:new P({x:y,y:_,z:g,spatialReference:o}),symbol:s.midpoints.default,attributes:{...i,pathIndex:n,pointIndexStart:h,pointIndexEnd:d}}))}}))})),r}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new S({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=this._getCoordinatesForUI(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const t=this.view.spatialReference;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes,[r,n,a]=e[s][o];i.geometry=new P({x:r,y:n,z:a,spatialReference:t})}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,[r,n,a]=e[i][s],[h,p,c]=e[i][o],[l,d,m]=x([r,n,a],[h,p,c]);t.geometry=new P({x:l,y:d,z:m,spatialReference:this.view.spatialReference})}}_getIndicesForVertexGraphic({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}_getVertexFromEditGeometry(e){const[t,i]=this._getIndicesForVertexGraphic(e);return this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){h(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,p="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!p){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r(),this._snappingTask=i((async i=>{const h=await o.snap({point:a,context:n,signal:i});h.valid&&(this._stagedVertex=h.apply(),this._syncGeometryAfterVertexMove(e,new P(this._stagedVertex),t,s,p),r())}))}else{const i=null!=this._stagedVertex?new P(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,p),r()}}async _syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations.data.geometry;if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t),e.notifyGeometryChanged();else{const{x:n,y:a,z:h}=t,[p,c]=this._getIndicesForVertexGraphic(e);let l=f(r);const d=l[p].length-1,m=null!=h?[n,a,h]:[n,a];l[p][c]=m,"polygon"===r.type&&(0===c?l[p][d]=m:c===d&&(l[p][0]=m)),this._isVertex(e)&&(l=this._moveRelatedCoordinates(l,e,m),l=this._moveSelectedHandleCoordinates(l,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(l)),this.graphic.geometry=r.clone();const v=this._getVertexFromEditGeometry(e),y=n-v.pos[0],_=a-v.pos[1];this._editGeometryOperations.moveVertices([v],y,_,0),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=e[t].length-1;e[t][n]=[h.x,h.y],r.geometry=h,o&&(0===n?e[t][p]=[h.x,h.y]:n===p&&(e[t][0]=[h.x,h.y]));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=[h.x,h.y],t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,{x:p,y:c,z:l}=e.geometry,d=0===h?a+1:h,m=f(o);return m[n].splice(d,0,null!=l?[p,c,l]:[p,c]),e.attributes={...t,pathIndex:n,pointIndex:d,relatedGraphicIndices:[]},r.push({coordinates:m[n][d],componentIndex:n,vertexIndex:d}),this.graphic.geometry=o,r}_addToSelection(e){e instanceof t&&(e=[e]);for(const t of e)t.symbol=this.symbols.vertices.selected;this._set("selectedVertices",this.selectedVertices.concat(e)),this._emitSelectEvent(e)}_removeFromSelection(e,i){const{vertices:s}=this.symbols,o=i?s.hover:s.default;e instanceof t&&(e=[e]);for(const t of e)this.selectedVertices.splice(this.selectedVertices.indexOf(t),1),this._set("selectedVertices",this.selectedVertices),t.set("symbol",o);this._emitDeselectEvent(e)}_clearSelection(){if(this.selectedVertices.length){const e=this.selectedVertices;for(const t of this.selectedVertices)t.set("symbol",this.symbols.vertices.default);this._set("selectedVertices",[]),this._emitDeselectEvent(e)}}_keyDownHandler(e){O.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const i=this.graphic.geometry;if(null==i||"polygon"!==i.type&&"polyline"!==i.type)return;if("polygon"===i.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;e instanceof t&&(e=[e]);const s=this.graphic.clone(),o=i.clone();let r=f(o);const n=[];e instanceof t&&(e=[e]);for(const t of e){const{x:e,y:i}=t.geometry;for(let t=0;t<r.length;t++){const s=r[t];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&i===h&&(n.push({coordinates:r[t][o],componentIndex:t,vertexIndex:o}),r[t].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),o.rings=r;else{for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}this.graphic.geometry=o,this.refresh(),this._emitVertexRemoveEvent(e,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){null!=this._tooltip&&(e?e===this.graphic?this._updateMoveGraphicTooltip(t):this._updateMoveVertexTooltip(t):this._tooltip.clear())}_updateMoveGraphicTooltip(e){const{_tooltip:t,tooltipOptions:i,view:s}=this;if(null==t)return;const o=this._translateGraphicTooltipInfo??=new U({tooltipOptions:i});if(o.clear(),o.tooltipOptions=i,e){const{x:t,y:i}=e.origin,r=s.toMap(e),n=s.toMap(y(t,i)),a=F(n,r);o.distance=null!=a?a:p}t.info=o}_updateMoveVertexTooltip(e){const{_tooltip:t,graphic:{geometry:i},tooltipOptions:s,view:o}=this;if(null==t)return;const r=this._translateVertexTooltipInfo??=new A({tooltipOptions:s});if(r.clear(),r.tooltipOptions=s,"polygon"===i?.type?r.area=z(i):"polyline"===i?.type&&(r.totalLength=L(i)),e){const{x:t,y:i}=e.origin,s=o.toMap(e),n=o.toMap(y(t,i)),a=F(n,s);r.distance=null!=a?a:p}t.info=r}_emitMoveStartEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart&&this.callbacks.onMoveStart(i)}_emitMoveEvent(e,t){const i=new J(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove&&this.callbacks.onMove(i)}_emitMoveStopEvent(){const e=this._activeOperationInfo;if(!e)return;const{totalDx:t,totalDy:i}=e,s=new Q(this.graphic,t,i);this.emit("move-stop",s),this.callbacks.onMoveStop&&this.callbacks.onMoveStop(s)}_emitReshapeStartEvent(e){const t=new q(this.graphic,e,this.selectedVertices);this.emit("reshape-start",t),this.callbacks.onReshapeStart&&this.callbacks.onReshapeStart(t)}_emitReshapeEvent(e){const t=new K(this.graphic,e,this.selectedVertices);this.emit("reshape",t),this.callbacks.onReshape&&this.callbacks.onReshape(t)}_emitReshapeStopEvent(e){const t=new N(this.graphic,e,this.selectedVertices);this.emit("reshape-stop",t),this.callbacks.onReshapeStop&&this.callbacks.onReshapeStop(t)}_emitSelectEvent(e){const t=new W(e);this.emit("select",t),this.callbacks.onVertexSelect&&this.callbacks.onVertexSelect(t)}_emitDeselectEvent(e){const t=new X(e);this.emit("deselect",t),this.callbacks.onVertexDeselect&&this.callbacks.onVertexDeselect(t)}_emitVertexAddEvent(e,t,i){const s=new Y(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd&&this.callbacks.onVertexAdd(s)}_emitVertexRemoveEvent(e,t,i){const s=new Z(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove&&this.callbacks.onVertexRemove(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};e([_()],te.prototype,"_tooltip",void 0),e([_()],te.prototype,"_translateGraphicTooltipInfo",void 0),e([_()],te.prototype,"_translateVertexTooltipInfo",void 0),e([_()],te.prototype,"callbacks",void 0),e([_()],te.prototype,"enableMidpoints",void 0),e([_()],te.prototype,"enableMovement",void 0),e([_()],te.prototype,"enableVertices",void 0),e([_()],te.prototype,"graphic",void 0),e([_({value:!0})],te.prototype,"highlightsEnabled",null),e([_()],te.prototype,"layer",void 0),e([_({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([_()],te.prototype,"midpointSymbol",void 0),e([_({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([_()],te.prototype,"snappingManager",void 0),e([_({readOnly:!0})],te.prototype,"state",null),e([_()],te.prototype,"symbols",void 0),e([_({type:j})],te.prototype,"tooltipOptions",void 0),e([_({readOnly:!0})],te.prototype,"type",void 0),e([_({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([_()],te.prototype,"view",void 0),te=e([g("esri.views.draw.support.Reshape")],te);const ie=te;export{ie 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import{allSettledValues as n,throwIfAborted as a}from"../../../core/promiseUtils.js";import{mapCollectionAsync as s}from"../../../core/reactiveUtils.js";import{
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import{allSettledValues as n,throwIfAborted as a}from"../../../core/promiseUtils.js";import{mapCollectionAsync as s}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as o,getMetersPerVerticalUnitForSR as i}from"../../../core/unitUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{k as p}from"../../../chunks/vec2.js";import{a as l,c as d}from"../../../chunks/vec3.js";import{c as S}from"../../../chunks/vec3f64.js";import{g as m}from"../../../chunks/common.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as g}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as f}from"../sketch/constraints.js";import{fromAnyMapPoint as y}from"../sketch/normalizedPoint.js";import{FeatureSnappingSourceInfo as _}from"./FeatureSnappingSourceInfo.js";import{SnappingDomain as v}from"./SnappingDomain.js";import{sortCandidatesInPlace as w,screenDistance as j}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as F}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as C}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as x}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as R,OtherVertexType as b}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as M}from"../support/viewUtils.js";let I=class extends t{get updating(){return this._snappingSources.some((e=>null==e||e.valid&&e.snappingSource.updating))||this._updatingHandles.updating}constructor(e){super(e),this.options=null,this._domain=v.FEATURE,this._updatingHandles=new h,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){const e=s((()=>this.options?.featureSources),((e,t)=>this._createSourceInfo(e,t)));this._snappingSources=e,this.addHandles(r(e))}destroy(){this._set("options",null),this._updatingHandles.destroy()}async fetchCandidates(e,t,r,s){if(!(t&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const o=[],i=this._computeScreenSizeDistanceParameters(e,r);for(const n of this._snappingSources){if(null==n||!n.valid||!n.snappingSource.layerSource.enabled||n.layerView?.suspended)continue;const t=n.getFetchCandidatesParameters(e,r,i);for(const e of t)o.push(n.snappingSource.fetchCandidates(e,s).then((e=>e.filter((e=>!this._candidateIsExcluded(n.snappingSource,e,r.excludeFeature))))))}const c=(await n(o)).flat();return this._addRightAngleCandidates(c,e,i,r),a(s),w(e,c),c}_addRightAngleCandidates(e,t,r,n){const a=null!=n.vertexHandle?n.vertexHandle.rightEdge?.rightVertex?.pos:null!=n.editGeometryOperations&&"polygon"===n.editGeometryOperations.data.type?n.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,s=null!=n.vertexHandle?n.vertexHandle.leftEdge?.leftVertex?.pos:null!=n.editGeometryOperations?n.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:o}=this,i=y(a,o,n),c=y(s,o,n),u=e.length;for(let p=0;p<u;p++)this._addRightAngleCandidate(e[p],c,t,r,e),this._addRightAngleCandidate(e[p],i,t,r,e)}_addRightAngleCandidate(e,t,r,n,a){if(null==t||!L(e))return;const s=e.constraint.closestTo(t),o=(s[0]-r[0])/n.x,i=(s[1]-r[1])/n.y,{start:c,end:u}=e.constraint;if(o*o+i*i<=1){const r=new R({targetPoint:s,otherVertex:t,otherVertexType:b.NEXT,previousVertex:p(s,c)>p(s,u)?c:u,constraint:new f(t,s),objectId:e.objectId,isDraped:e.isDraped});a.push(r)}}_computeScreenSizeDistanceParameters(e,t){let r=null!=this.options?this.options.distance*("touch"===t.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:r,y:r,z:r,distance:r}:"2d"===this.view.type?(r*=this.view.resolution,{x:r,y:r,z:r,distance:r}):this._computeScreenSizeDistanceParameters3D(e,r,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,r,n){const{spatialReference:a}=n;r.renderCoordsHelper.toRenderCoords(e,a,P);const s=r.state.camera.computeScreenPixelSizeAt(P),c=s*r.renderCoordsHelper.unitInMeters,u=c/o(a),p=c/i(a),l=t*u,d=t*p,S=M(e,a,g,r),m=S?H(S,e,u,0,0,r,n):0,h=S?H(S,e,0,u,0,r,n):0,f=S?H(S,e,0,0,p,r,n):0;return{x:0===m?0:l/m,y:0===h?0:l/h,z:0===f?0:d/f,distance:s*t}}_candidateIsExcluded(e,t,r){if(null==r)return!1;const n=this._getCandidateObjectId(t);if(null==n)return!1;const a=e.layerSource.layer;return"graphics"===a.type?r.uid===n:r.sourceLayer===a&&(!(!r.attributes||!("objectIdField"in a))&&r.attributes[a.objectIdField]===n)}_getCandidateObjectId(e){return e instanceof x?e.objectId:null}async _createSourceInfo(e,t){const r=e.layer;r.loaded||(await r.load(),a(t));const{view:n}=this,s=await this._createFeatureSnappingSourceType(e);return a(t),new _(null==s?{}:{snappingSource:s,view:n,layer:r})}async _createFeatureSnappingSourceType(e){switch(e.layer.type){case"feature":case"geojson":case"csv":case"oriented-imagery":case"subtype-group":case"wfs":return this._createFeatureSnappingSourceFeatureLayer(e);case"graphics":return this._createFeatureSnappingSourceGraphicsLayer(e);case"map-notes":return this._createFeatureSnappingSourceMapNotesLayer(e);case"scene":case"building-scene":return this._createFeatureSnappingSourceSceneLayer(e)}return null}async _createFeatureSnappingSourceSceneLayer(e){const{view:t}=this;if(null==t||"3d"!==t.type)return null;return new((await this._getSourceModule("scene")).SceneLayerSnappingSource)({layerSource:e,view:t})}async _createFeatureSnappingSourceFeatureLayer(e){switch(e.layer.source?.type){case"feature-layer":case"oriented-imagery":return new((await this._getSourceModule("featureService")).FeatureServiceSnappingSource)({spatialReference:this.spatialReference,view:this.view,layerSource:e});case"memory":case"csv":case"geojson":case"wfs":if("mesh"===e.layer.geometryType)return null;return new((await this._getSourceModule("featureCollection")).FeatureCollectionSnappingSource)({layerSource:e,view:this.view})}return null}async _createFeatureSnappingSourceGraphicsLayer(e){return new((await this._getSourceModule("graphics")).GraphicsSnappingSource)({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _createFeatureSnappingSourceMapNotesLayer(e){return new((await this._getSourceModule("notes")).GraphicsSnappingSource)({getGraphicsLayers:()=>e.layer.sublayers?.toArray()??[],spatialReference:this.spatialReference,view:this.view,layerSource:e})}async _getSourceModule(e){const t=this._sourceModules[e];if(null==t.loader){const t=this._loadSourceModule(e),r={module:null,loader:t};this._sourceModules[e]=r;const n=await t,a={module:n,loader:t};return this._sourceModules[e]=a,n}return null==t.module?t.loader:t.module}_loadSourceModule(e){const t=this._updatingHandles;switch(e){case"featureService":return t.addPromise(import("./featureSources/FeatureServiceSnappingSource.js"));case"featureCollection":return t.addPromise(import("./featureSources/FeatureCollectionSnappingSource.js"));case"graphics":case"notes":return t.addPromise(import("./featureSources/GraphicsSnappingSource.js"));case"scene":return t.addPromise(import("./featureSources/SceneLayerSnappingSource.js"))}}get test(){return{snappingSources:this._snappingSources}}};function L(e){return(e instanceof C||e instanceof F)&&!G(e)}function G({constraint:{start:e,end:t}}){const r=l(e,t),n=p(e,t);return r<m()||n/r<z}function H(e,t,r,n,a,s,{spatialReference:o}){const i=d(E,t);i[0]+=r,i[1]+=n,i[2]+=a;const c=M(i,o,g,s);return c?j(c,e):1/0}e([c({constructOnly:!0})],I.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],I.prototype,"view",void 0),e([c()],I.prototype,"options",void 0),e([c({readOnly:!0})],I.prototype,"updating",null),e([c()],I.prototype,"_snappingSources",void 0),I=e([u("esri.views.interactive.snapping.FeatureSnappingEngine")],I);const P=S(),E=S(),z=1e-4;export{I as FeatureSnappingEngine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{throwIfAborted as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{throwIfAborted as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,initial as r,on as a}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as l}from"../../../../support/elevationInfoUtils.js";import{makeFilter as y,makeSnappingQuery as c}from"../snappingUtils.js";import{convertSnappingCandidate as u,makeGetGroundElevation as g}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as h}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as m}from"./symbologySnappingCandidates.js";let v=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return h();const o=async(i,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(i,o);return h(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?m(this._symbologySnappingSupported,(async(n,o)=>{const r=await e.whenLayerView(t);return i(o),r.queryForSymbologySnapping({candidates:n,spatialReference:e.spatialReference},o)})):m()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;l(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),o((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),r),o((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),r),a((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:n}=this.layerSource,o=n.source;if(!o?.querySnapping)return[];const r=y(n),a=c(e,this.view?.type??"2d",r),s=await o.querySnapping(a,{signal:t});i(t);const p=await this._snappingElevationAligner.alignCandidates(s.candidates,e.coordinateHelper.spatialReference,t);i(t);const l=await this._symbologySnappingFetcher.fetch(p,t);i(t);const g=0===l.length?p:[...p,...l],h=this._snappingElevationFilter.filter(a,g),d=this._getGroundElevation;return h.map((e=>u(e,d)))}get _getGroundElevation(){return g(this.view)}};e([s({constructOnly:!0})],v.prototype,"layerSource",void 0),e([s({constructOnly:!0})],v.prototype,"view",void 0),e([s()],v.prototype,"_snappingElevationAligner",null),e([s()],v.prototype,"_snappingElevationFilter",null),e([s()],v.prototype,"_symbologySnappingFetcher",null),e([s()],v.prototype,"_layerView3D",void 0),e([s()],v.prototype,"_symbologySnappingSupported",null),e([s()],v.prototype,"_getGroundElevation",null),v=e([p("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],v);export{v as FeatureCollectionSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{throwIfAborted as r,allSettledValues as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{initial as a,watch as p,on as l}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Polygon.js";import{initializeProjection as y,canProjectWithoutEngine as m,project as g}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as f}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as _}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as S}from"../../../../layers/graphics/OptimizedFeature.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as j}from"../../../../layers/graphics/data/QueryEngine.js";import b from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as E}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as k}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as C}from"../snappingUtils.js";import{convertSnappingCandidate as A,makeGetGroundElevation as I}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as P}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as G}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as H}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const O="graphics-collections";let R=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return P();const o=async(s,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return P(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return G(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?H(o,(async(s,o)=>{const i=await e.whenLayerView(t);return r(o),i.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):H()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new u}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(O);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],O)}),a);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{E(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),p((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),l((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s}=e,o=await i(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));r(t);const n=this._getGroundElevation,a=o.flat().map((e=>A(e,n)));return F(s,a),a}get _getGroundElevation(){return I(this.view)}async _fetchCandidatesForSource(e,t,s){const o=C(t,this.view?.type??"2d"),i=await e.queryEngine.executeQueryForSnapping(o,s);r(s);const n=await this._snappingElevationAligner.alignCandidates(i.candidates,t.coordinateHelper.spatialReference,s);r(s);const a=await this._symbologySnappingFetcher.fetch(n,s);r(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await y(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=h.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),k(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!m(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=g(f(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new S(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=_.toJSON(e),s=this._hasZ,o=new w({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new j({featureStore:o,fieldsIndex:b.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),k(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([d()],R.prototype,"getGraphicsLayers",void 0),e([d({constructOnly:!0})],R.prototype,"layerSource",void 0),e([d({constructOnly:!0})],R.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],R.prototype,"view",void 0),e([d({readOnly:!0})],R.prototype,"updating",null),e([d({readOnly:!0})],R.prototype,"availability",void 0),e([d()],R.prototype,"_hasZ",null),e([d()],R.prototype,"_snappingElevationAligner",null),e([d()],R.prototype,"_snappingElevationFilter",null),e([d()],R.prototype,"_symbologySnappingFetcher",null),e([d()],R.prototype,"_extrudedPolygonSymbolsCount",void 0),e([d()],R.prototype,"_getGroundElevation",null),R=e([c("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],R);const U="OBJECTID";export{R as GraphicsSnappingSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Evented.js";import{createResolver as i,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{watch as r,whenOnce as n,sync as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/SpatialReference.js";import u from"../../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as c}from"../../../../../layers/graphics/data/QueryEngine.js";import h from"../../../../../layers/support/TileInfo.js";import f from"../../../../../rest/support/Query.js";import g from"../../../../../symbols/support/ElevationInfo.js";import{getSnappingCandidateElevationAligner as m}from"../snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as y}from"../snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as _}from"../symbologySnappingCandidates.js";import{FeatureServiceTiledFetcher as S}from"./FeatureServiceTiledFetcher.js";import{FeatureServiceTileStore as F}from"./FeatureServiceTileStore.js";import{fromJSON as v}from"../../../../../geometry/support/jsonUtils.js";let w=class extends t.EventedAccessor{constructor(){super(...arguments),this._isInitializing=!0,this.remoteClient=null,this._whenSetup=i(),this._elevationAligner=m(),this._elevationFilter=y(),this._symbologyCandidatesFetcher=_(),this._updatingHandles=new d,this._editsUpdatingHandles=new d,this._pendingApplyEdits=new Map,this._alignPointsInFeatures=async(e,t)=>{const i={query:e},r=await this.remoteClient.invoke("alignElevation",i,{signal:t});return s(t),r},this._getSymbologyCandidates=async(e,t)=>{const i={candidates:e,spatialReference:this._spatialReference.toJSON()},r=await this.remoteClient.invoke("getSymbologyCandidates",i,{signal:t});return s(t),r}}get updating(){return this.updatingExcludingEdits||this._editsUpdatingHandles.updating||this._featureFetcher.updating}get updatingExcludingEdits(){return this._featureFetcher.updatingExcludingEdits||this._isInitializing||this._updatingHandles.updating}destroy(){this._featureFetcher?.destroy(),this._queryEngine?.destroy(),this._featureStore?.clear()}async setup(e){if(this.destroyed)return{result:{}};const{geometryType:t,objectIdField:i,timeInfo:s,fieldsIndex:n}=e.serviceInfo,{hasZ:o}=e,l=p.fromJSON(e.spatialReference);this._spatialReference=l,this._featureStore=new u({...e.serviceInfo,hasZ:o,hasM:!1}),this._queryEngine=new c({spatialReference:e.spatialReference,featureStore:this._featureStore,geometryType:t,fieldsIndex:n,hasZ:o,hasM:!1,objectIdField:i,timeInfo:s}),this._featureFetcher=new S({store:new F({featureStore:this._featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:l,sourceSpatialReference:p.fromJSON(e.serviceInfo.spatialReference)});const d="3d"===e.configuration.viewType;return this._elevationAligner=m(d,{elevationInfo:null!=e.elevationInfo?g.fromJSON(e.elevationInfo):null,alignPointsInFeatures:this._alignPointsInFeatures}),this._elevationFilter=y(d),this.addHandles([r((()=>this._featureFetcher.availability),(e=>this.emit("notify-availability",{availability:e})),a),r((()=>this.updating),(()=>this._notifyUpdating()))]),this._whenSetup.resolve(),this._isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this._updatingHandles.addPromise(this._whenSetup.promise),this._updateFeatureFetcherConfiguration(e),j}async setSuspended(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.suspended=e,j}async updateOutFields(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.outFields=new Set(e??[]),j}async fetchCandidates(e,t){await this._whenSetup.promise,s(t);const i=b(e),r=t?.signal,n=await this._queryEngine.executeQueryForSnapping(i,r);s(r);const a=await this._elevationAligner.alignCandidates(n.candidates,e.point.spatialReference??p.WGS84,r);s(r);const o=await this._symbologyCandidatesFetcher.fetch(a,r);s(r);const l=0===o.length?a:a.concat(o);return{result:{candidates:this._elevationFilter.filter(i,l)}}}async updateTiles(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.tileSize=e.tileSize,this._featureFetcher.tilesOfInterest=e.tiles,this._featureFetcher.tileInfo=null!=e.tileInfo?h.fromJSON(e.tileInfo):null,j}async refresh(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),this._featureFetcher.refresh(),j}async whenNotUpdating(e,t){return await this._updatingHandles.addPromise(this._whenSetup.promise),s(t),await n((()=>!this.updatingExcludingEdits),t),s(t),j}async getDebugInfo(e,t){return s(t),{result:this._featureFetcher.debugInfo}}async beginApplyEdits(e,t){this._updatingHandles.addPromise(this._whenSetup.promise),s(t);const r=i();return this._pendingApplyEdits.set(e.id,r),this._featureFetcher.applyEdits(r.promise),this._editsUpdatingHandles.addPromise(r.promise),j}async endApplyEdits(e,t){const i=this._pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),s(t),j}async notifyElevationSourceChange(e,t){return this._elevationAligner.notifyElevationSourceChange(),j}async notifySymbologyChange(e,t){return this._symbologyCandidatesFetcher.notifySymbologyChange(),j}async setSymbologySnappingSupported(e){return this._symbologyCandidatesFetcher=_(e,this._getSymbologyCandidates),j}_updateFeatureFetcherConfiguration(e){this._featureFetcher.filter=null!=e.filter?f.fromJSON(e.filter):null,this._featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};e([o({readOnly:!0})],w.prototype,"updating",null),e([o({readOnly:!0})],w.prototype,"updatingExcludingEdits",null),e([o()],w.prototype,"_isInitializing",void 0),w=e([l("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],w);const I=w;function b(e){if(!e.filter)return{...e,query:{where:"1=1"}};const{distance:t,units:i,spatialRel:s,where:r,timeExtent:n,objectIds:a}=e.filter,o={geometry:e.filter.geometry?v(e.filter.geometry):void 0,distance:t,units:i,spatialRel:s,timeExtent:n,objectIds:a,where:r??"1=1"};return{...e,query:o}}const j={result:{}};export{I 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{abortMaybe as o}from"../../../../../core/maybe.js";import{debounce as n,whenOrAbort as a}from"../../../../../core/promiseUtils.js";import{property as
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{isSome as i}from"../../../../../core/arrayUtils.js";import{abortMaybe as o}from"../../../../../core/maybe.js";import{debounce as n,whenOrAbort as a}from"../../../../../core/promiseUtils.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../../core/support/UpdatingHandles.js";import{WorkerHandle as l}from"../../../../../core/workers/WorkerHandle.js";import{featureGeometryTypeKebabDictionary as p}from"../../../../../geometry/support/typeUtils.js";import{makeDehydratedPoint as u}from"../../../../../layers/graphics/dehydratedPoint.js";let h=class extends t{get updating(){return this._updatingHandles.updating||this._workerHandleUpdating}constructor(e){super(e),this._updatingHandles=new d,this._suspendController=null,this.schedule=null,this.hasZ=!1,this.elevationAlignPointsInFeatures=async e=>{const t=[];for(const{points:i}of e.pointsInFeatures)for(const{z:e}of i)t.push(e);return{elevations:t,drapedObjectIds:new Set,failedObjectIds:new Set}},this.queryForSymbologySnapping=async()=>({candidates:[],sourceCandidateIndices:[]}),this.availability=0,this._workerHandleUpdating=!0,this._editId=0,this.updateOutFields=n((async(e,t)=>{await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("updateOutFields",[...e],t)),this._updatingHandles.addPromise(this._workerHandle.invokeMethod("whenNotUpdating",{},t))}))}destroy(){this._suspendController=o(this._suspendController),this._workerHandle.destroy(),this._updatingHandles.destroy()}initialize(){this._workerHandle=new c(this.schedule,{alignElevation:async(e,{signal:t})=>({result:await this.elevationAlignPointsInFeatures(e.query,t)}),getSymbologyCandidates:async(e,{signal:t})=>({result:await this.queryForSymbologySnapping(e,t)})}),this.addHandles([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 i=this._serviceInfoFromLayer(e.layer);if(null==i)return;const o={configuration:this._convertConfiguration(e.configuration),serviceInfo:i,spatialReference:e.spatialReference.toJSON(),hasZ:this.hasZ,elevationInfo:e.layer.elevationInfo?.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{point:i,filter:o,coordinateHelper:n}=e,a={...e,point:u(i[0],i[1],i[2],n.spatialReference.toJSON()),filter:o?.toJSON()};return this._workerHandle.invoke(a,t)}async updateTiles(e,t){const i={tiles:e.tiles,tileInfo:null!=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 o=this._editId++,n={id:o};await this._updatingHandles.addPromise(this._workerHandle.invokeMethod("beginApplyEdits",n,t));const r=await this._updatingHandles.addPromise(a(e.result,t)),s={id:o,edits:{addedFeatures:r.addedFeatures?.map((({objectId:e})=>e)).filter(i)??[],deletedFeatures:r.deletedFeatures?.map((({objectId:e,globalId:t})=>({objectId:e,globalId:t})))??[],updatedFeatures:r.updatedFeatures?.map((({objectId:e})=>e)).filter(i)??[]}};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)}async notifyElevationSourceChange(){await this._workerHandle.invokeMethod("notifyElevationSourceChange",{})}async notifySymbologyChange(){await this._workerHandle.invokeMethod("notifySymbologyChange",{})}async setSymbologySnappingSupported(e){await this._workerHandle.invokeMethod("setSymbologySnappingSupported",e)}async setSuspended(e){this._suspendController?.abort(),this._suspendController=new AbortController,await this._workerHandle.invokeMethod("setSuspended",e,this._suspendController.signal)}_convertConfiguration(e){return{filter:null!=e.filter?e.filter.toJSON():null,customParameters:e.customParameters,viewType:e.viewType}}_serviceInfoFromLayer(e){return"multipatch"===e.geometryType||"mesh"===e.geometryType?null:{url:e.parsedUrl?.path??"",fieldsIndex:e.fieldsIndex.toJSON(),geometryType:p.toJSON(e.geometryType),capabilities:e.capabilities,objectIdField:e.objectIdField,globalIdField:e.globalIdField,spatialReference:e.spatialReference.toJSON(),timeInfo:e.timeInfo?.toJSON()}}};e([r({constructOnly:!0})],h.prototype,"schedule",void 0),e([r({constructOnly:!0})],h.prototype,"hasZ",void 0),e([r({constructOnly:!0})],h.prototype,"elevationAlignPointsInFeatures",void 0),e([r({constructOnly:!0})],h.prototype,"queryForSymbologySnapping",void 0),e([r({readOnly:!0})],h.prototype,"updating",null),e([r({readOnly:!0})],h.prototype,"availability",void 0),e([r()],h.prototype,"_workerHandleUpdating",void 0),h=e([s("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorkerHandle")],h);class c extends l{constructor(e,t){super("FeatureServiceSnappingSourceWorker","fetchCandidates",{},e,{strategy:"dedicated",client:t})}}export{h as FeatureServiceSnappingSourceWorkerHandle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s
|
|
5
|
+
import"../../../../core/has.js";import{LRUCache as e}from"../../../../core/LRUCache.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{getMetersPerUnit as o}from"../../../../symbols/support/unitConversionUtils.js";function i(e=!1,t){if(e){const{elevationInfo:e,alignPointsInFeatures:s}=t;return new c(e,s)}return new a}class a{async alignCandidates(e,t,s){return e}notifyElevationSourceChange(){}}const r=1024;class c{constructor(t,s){this._elevationInfo=t,this._alignPointsInFeatures=s,this._alignmentsCache=new e(r),this._cacheVersion=0}async alignCandidates(e,t,s){const n=this._elevationInfo;return null==n||"absolute-height"!==n.mode||n.featureExpressionInfo?this._alignComputedElevationCandidates(e,t,s):(this._alignAbsoluteElevationCandidates(e,t,n),e)}notifyElevationSourceChange(){this._alignmentsCache.clear(),this._cacheVersion++}_alignAbsoluteElevationCandidates(e,t,s){const{offset:i,unit:a}=s;if(null==i)return;const r=n(t),c=i*(o(a??"meters")/r);for(const n of e)switch(n.type){case"edge":n.start.z+=c,n.end.z+=c;continue;case"vertex":n.target.z+=c;continue}}async _alignComputedElevationCandidates(e,n,o){const i=new Map;for(const s of e)t(i,s.objectId,d).push(s);const[a,r,c]=this._prepareQuery(i,n),l=await this._alignPointsInFeatures(a,o);s(o);if(c!==this._cacheVersion)return this._alignComputedElevationCandidates(e,n,o);this._applyCacheAndResponse(a,l,r);const{drapedObjectIds:h,failedObjectIds:u}=l,p=[];for(const t of e){const{objectId:e}=t;h.has(e)&&"edge"===t.type&&(t.draped=!0),u.has(e)||p.push(t)}return p}_prepareQuery(e,t){const s=[],n=[];for(const[o,i]of e){const e=[];for(const t of i)this._addToQueriesOrCachedResult(o,t.target,e,n),"edge"===t.type&&(this._addToQueriesOrCachedResult(o,t.start,e,n),this._addToQueriesOrCachedResult(o,t.end,e,n));0!==e.length&&s.push({objectId:o,points:e})}return[{spatialReference:t,pointsInFeatures:s},n,this._cacheVersion]}_addToQueriesOrCachedResult(e,t,s,n){const o=h(e,t),i=this._alignmentsCache.get(o);null==i?s.push(t):n.push(new l(t,i))}_applyCacheAndResponse(e,{elevations:t,drapedObjectIds:s,failedObjectIds:n},o){for(const r of o)r.apply();let i=0;const a=this._alignmentsCache;for(const{objectId:r,points:c}of e.pointsInFeatures){if(n.has(r)){i+=c.length;continue}const e=!s.has(r);for(const s of c){const n=h(r,s),o=t[i++];s.z=o,e&&a.put(n,o,1)}}}}class l{constructor(e,t){this.point=e,this.z=t}apply(){this.point.z=this.z}}function h(e,{x:t,y:s,z:n,spatialReference:o}){return`${e}-${t}-${s}-${n??0}}-wkid:${o?.wkid}`}function d(){return[]}export{i as getSnappingCandidateElevationAligner};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import{getAssetUrl as t}from"../assets.js";import{when as s}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{getBasemapThumbnailUrl as r,isBasemap3D as o}from"../support/basemapUtils.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{getAssetUrl as t}from"../assets.js";import{when as s}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{getBasemapThumbnailUrl as r,isBasemap3D as o,isBasemapInBeta as l}from"../support/basemapUtils.js";import n from"./Widget.js";import d from"./BasemapGallery/BasemapGalleryViewModel.js";import{css as p}from"./BasemapGallery/css.js";import{loadCalciteComponents as c}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{Heading as h}from"./support/Heading.js";import{accessibleHandler as u}from"./support/decorators/accessibleHandler.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{onResize as y}from"./support/widgetUtils.js";const w={small:200,default:280,wide:420};let b=class extends n{constructor(e,t){super(e,t),this.disabled=!1,this.headingLevel=2,this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.viewModel=new d,this._focusBasemapItemEnabled=!1,this._container=null,this._width=0,this._onContainerCreated=e=>{this._container=e}}initialize(){this.addHandles([y((()=>this._container),(({contentRect:e})=>{this._width=e.width})),s((()=>this.source),(()=>this.viewModel.load()),{sync:!0,initial:!0,once:!0})])}loadDependencies(){return c({scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip.js")})}get activeBasemap(){return this.viewModel.activeBasemap}set activeBasemap(e){this.viewModel.activeBasemap=e}get includeCurrentBasemap(){return this.viewModel.includeCurrentBasemap}set includeCurrentBasemap(e){this.viewModel.includeCurrentBasemap=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get source(){return this.viewModel.source}set source(e){this.viewModel.source=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const e="loading"===this.source.state,t=this.disabled||"disabled"===this.viewModel.state,s=this.viewModel.items,a={[p.sourceLoading]:e,[m.disabled]:t},i=this._width;i<=w.small||i>=w.wide?a[p.layoutGrid]=!0:i<w.default&&(a[p.narrowItems]=!0);const r=e?v("div",{class:p.loader,key:"loader"}):null,o=e?null:s.length>0?v("ul",{"aria-disabled":this.disabled,"aria-label":this.label,bind:this,class:p.itemContainer,key:"item-container",onkeydown:this._handleKeyDown,role:"radiogroup"},s.map(((e,t)=>this._renderBasemapGalleryItem(e,t))).toArray()):v("div",{class:m.empty,key:"empty-message"},v(h,{level:this.headingLevel},this.messages.noBasemaps));return v("div",{afterCreate:this._onContainerCreated,class:this.classes(p.base,m.widget,m.panelHeightOnly,a),key:"container"},0===this._width?null:[r,o])}_getRoundRobinIndex(e,t){return(e+t)%t}_handleKeyDown(e){const{key:t}=e;if(!["ArrowUp","ArrowDown","ArrowRight","ArrowLeft"].includes(t))return;e.preventDefault();const{items:s,activeBasemapIndex:a}=this.viewModel,i="ArrowUp"===t||"ArrowLeft"===t?this._getRoundRobinIndex(Math.max(a-1,-1),s.length):this._getRoundRobinIndex(a+1,s.length),r=s.at(i);"ready"===r?.state&&(this.viewModel.activeBasemap=r.basemap),this._focusBasemapItemEnabled=!0}_focusBasemapItem(e){this._focusBasemapItemEnabled&&0===e.tabIndex&&(e.focus(),this._focusBasemapItemEnabled=!1)}_handleClick(e){const t=e.currentTarget["data-item"];"ready"===t.state&&(this.viewModel.activeBasemap=t.basemap)}_renderBasemapGalleryItem(e,s){const a=r(e.basemap)||t("esri/themes/base/images/basemap-toggle-64.svg"),i=e.basemap.title,l=e.basemap.portalItem?.snippet,n=e.error?.message||l||i,{viewModel:{state:d,activeBasemapIndex:c}}=this,h=this.disabled||"disabled"===d,u=c===s,g=u||-1===c&&0===s?0:-1,y="loading"===d,w={[p.selectedItem]:u,[p.itemError]:"error"===e.state},b=`basemapgallery-item-${e.uid}`;return v("li",{afterUpdate:this._focusBasemapItem,"aria-checked":u.toString(),"aria-disabled":h.toString(),"aria-labelledby":b,bind:this,class:this.classes(p.item,w),"data-item":e,key:e.uid,onclick:this._handleClick,onkeydown:this._handleClick,role:"radio",tabIndex:g,title:n},v("img",{alt:"",class:p.itemThumbnail,src:a}),v("div",{class:p.itemContent,key:"content"},v("div",{class:p.itemTitle,key:"title"},v("span",{id:b},i)),o(e.basemap)?this._renderTags(e.basemap):null),"loading"===e.state||u&&y?v("calcite-scrim",null,v("span",{"aria-hidden":"true",class:m.loaderAnimation,key:"loader",role:"presentation"})):null)}_renderTags(e){return v("div",{class:p.itemTagsContainer,key:"tag"},this._render3DTag(),l(e)?this._renderBetaTag():null)}_render3DTag(){const{messages:e}=this;return v("calcite-chip",{key:"tag-3d",scale:"s",value:e.tag3D},this.messages.tag3D)}_renderBetaTag(){const{messages:e}=this;return v("calcite-chip",{appearance:"outline-fill",key:"tag-beta",scale:"s",value:e.tagBeta},this.messages.tagBeta)}};e([a()],b.prototype,"activeBasemap",null),e([a()],b.prototype,"disabled",void 0),e([a()],b.prototype,"headingLevel",void 0),e([a()],b.prototype,"iconClass",void 0),e([a()],b.prototype,"icon",void 0),e([a()],b.prototype,"label",null),e([a(),g("esri/widgets/BasemapGallery/t9n/BasemapGallery")],b.prototype,"messages",void 0),e([a()],b.prototype,"source",null),e([a()],b.prototype,"view",null),e([a()],b.prototype,"viewModel",void 0),e([a()],b.prototype,"_focusBasemapItemEnabled",void 0),e([a()],b.prototype,"_container",void 0),e([a()],b.prototype,"_width",void 0),e([u()],b.prototype,"_handleClick",null),b=e([i("esri.widgets.BasemapGallery")],b);const _=b;export{_ 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import{watch as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{canShowNorth as r}from"./Compass/utils.js";import{directionalPadAngles as a,directionalPadArrows as l}from"./DirectionalPad/constants.js";import{css as c}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as p}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const g="esri.widgets.DirectionalPad";let w=class extends n{constructor(t,i){super(t,i),this._buttonsContainer=null,this._buttons={},this.iconClass=c.widgetIcon,this.icon=null,this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=p(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,i)=>{const o=e(i);v(o)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(i((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(c.base,m.widget,e?m.disabled:null);return _("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage)}_renderUnsupportedMessage(){return _("section",{class:c.error,key:"unsupported"},_("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return _("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},_("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:c.buttonsContainer},a.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),a.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=l[t];return _("calcite-action",{active:this.viewModel.angle===t,afterCreate:this._afterButtonCreate.bind(this,t),afterRemoved:this._afterButtonRemoved.bind(this,t),alignment:"center",class:c.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:this.messages[e]},_("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||r(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation;return _("calcite-action",{alignment:"center",class:c.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:this.messages.resetHeading},!e&&_("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return _("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},_("calcite-action-group",{class:c.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){return _("calcite-action",{alignment:"center",class:c.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:this.messages.resetHeading},_("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return _("div",{class:c.rotationSliderContainer},_("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([o()],w.prototype,"_buttonsContainer",void 0),t([o()],w.prototype,"_buttons",void 0),t([o()],w.prototype,"disabled",null),t([o()],w.prototype,"iconClass",void 0),t([o()],w.prototype,"icon",void 0),t([o()],w.prototype,"label",null),t([o(),b("esri/widgets/DirectionalPad/t9n/DirectionalPad")],w.prototype,"messages",void 0),t([o({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),t([o()],w.prototype,"view",null),t([o()],w.prototype,"viewModel",void 0),t([o()],w.prototype,"visualScale",void 0),t([o()],w.prototype,"speed",null),t([o({readOnly:!0})],w.prototype,"_rotationEnabled",null),w=t([s(g)],w);const f=w;export{f as default};
|
|
5
|
+
import{_ as t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import{watch as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{canShowNorth as r}from"./Compass/utils.js";import{directionalPadAngles as a,directionalPadArrows as l}from"./DirectionalPad/constants.js";import{css as c}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as p}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const g="esri.widgets.DirectionalPad";let w=class extends n{constructor(t,i){super(t,i),this._buttonsContainer=null,this._buttons={},this.iconClass=c.widgetIcon,this.icon=null,this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=p(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,i)=>{const o=e(i);v(o)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(i((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(c.base,m.widget,e?m.disabled:null);return _("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage())}_renderUnsupportedMessage(){return _("section",{class:c.error,key:"unsupported"},_("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return _("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},_("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:c.buttonsContainer},a.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),a.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=l[t];return _("calcite-action",{active:this.viewModel.angle===t,afterCreate:this._afterButtonCreate.bind(this,t),afterRemoved:this._afterButtonRemoved.bind(this,t),alignment:"center",class:c.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:this.messages[e]},_("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||r(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation;return _("calcite-action",{alignment:"center",class:c.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:this.messages.resetHeading},!e&&_("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return _("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},_("calcite-action-group",{class:c.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){return _("calcite-action",{alignment:"center",class:c.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:this.messages.resetHeading},_("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return _("div",{class:c.rotationSliderContainer},_("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([o()],w.prototype,"_buttonsContainer",void 0),t([o()],w.prototype,"_buttons",void 0),t([o()],w.prototype,"disabled",null),t([o()],w.prototype,"iconClass",void 0),t([o()],w.prototype,"icon",void 0),t([o()],w.prototype,"label",null),t([o(),b("esri/widgets/DirectionalPad/t9n/DirectionalPad")],w.prototype,"messages",void 0),t([o({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),t([o()],w.prototype,"view",null),t([o()],w.prototype,"viewModel",void 0),t([o()],w.prototype,"visualScale",void 0),t([o()],w.prototype,"speed",null),t([o({readOnly:!0})],w.prototype,"_rotationEnabled",null),w=t([s(g)],w);const f=w;export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as u}from"../../core/reactiveUtils.js";import{generateBracedUUID as h}from"../../core/uuid.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as F}from"./modelUploadUtils.js";import M from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends M{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||"pending"!==t.state&&"success"!==t.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:u,sketchViewModel:h,view:p}=r;if(!p||!i)return;const f=i.layer,m=k(u,f),g=m?.formTemplate,y=p.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:p.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===p.type?p.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===p.type){const a=c((()=>p.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===p.type?p.scale:null)})),h.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:h,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await F({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const u=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const h=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&u.push(e._fadeExistingFeatures(i.creationInfo.layer)),u.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const u=e._visualVariableAttributes;await E(o,l,a,u,t);const h=l.attributes,{rotation:p,size:f}=u;if(null!=p){const{field:e}=p;n.setValue(e,h[e])}if(null!=f){const{field:e}=f;n.setValue(e,h[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(u),afterCommit:r((()=>{l.updateOnGraphicClick=h}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],u=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const h=D(o);d.push(h);const p=w(e?.layer);try{if(b(e)&&u.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),p){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),u.push(t.afterCommit),e?.initialFeature&&(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)),await this._startCreating(l)}}finally{h.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...u,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),u),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=h(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:h(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([p({constructOnly:!0})],N.prototype,"isNested",void 0),e([p()],N.prototype,"hasPendingEdits",null),e([p()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([p()],N.prototype,"helpMessage",null),e([p()],N.prototype,"parent",null),e([p()],N.prototype,"keyboardCancellationEnabled",null),e([p()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([p()],N.prototype,"shouldShowAttachments",null),e([p()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{remove as a,isSome as i}from"../../core/arrayUtils.js";import{makeHandle as r,handlesGroup as s}from"../../core/handleUtils.js";import{removeMaybe as n,destroyMaybe as o}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as c,whenOnce as d,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as u}from"../../core/uuid.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as m,getEffectiveEditingEnabled as g,isTable as w}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as y}from"../../views/draw/support/helpMessageUtils.js";import v from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as _}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as b,handleModelUpload as M}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as I,startCreatingNewFeature as A,findLayerInfo as k,updateGraphicSymbolWhenRequired as C,isTerminalUpdateEventType as H,getVisualVariableAttributes as V,startUpdatingFeature as S,createWorkflowSteps as U,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as D,visualVariableInteractiveUpdate as E,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var O;const T=Symbol(),P=Symbol(),W=Symbol(),x=Symbol();let N=O=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[],this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>C(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1)}get hasPendingEdits(){if(this.numPendingFeatures>0)return!0;const{data:e}=this,{sketchViewModel:t}=e.viewModel,{activeComponent:a}=t,i=t.createGraphic?.geometry;if(("polyline"===i?.type||"polygon"===i?.type||"multipoint"===i?.type)&&("draw-2d"===a?.type||"draw-3d"===a?.type)&&a.drawOperation.committedVertices.length>0)return!0;const{upload:r}=e;return!(!r||"pending"!==r.state&&"success"!==r.state)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}return y(a,i?.geometry)}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=m(t)?.operations.supportsAdd;return g(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!(!this.data.creationInfo||!this.data.viewModel)&&I(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){this._isActive=!0;const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks=null,this.addHandles(r((()=>{e.relatedRecordCallbacks=t})),P),"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([P,x])}async updatePendingFeature(e,t){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),a(this._lastActiveGraphics,e),this._startUpdating(e,t)}async start(){return await super.start(),w(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{}}}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,startAt:n,viewModel:o}=e,l=new O({data:new _({creationInfo:r,parent:s,viewModel:o}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;const r=e.pendingFeatures.toArray(),{layer:s}=i,n=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,o=l._attachmentFileInfos;if(n){const e=z(r,s,o);return void await a(s,e,{globalIdUsed:!0})}const c=await a(s,{addFeatures:r});if(o.size>0){const e=c?.addFeatureResults??[];await t(s,L(r,e,s,o))}}});return l._set("steps",this._createWorkflowSteps(l,n)),l}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",r((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,r((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){n(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){this.removeHandles(W);const{data:t}=this,{creationInfo:a}=t;if(!a)return;this.createFeatureState="create-new";const i=await A(t.viewModel.sketchViewModel,a,e);this.addHandles(i,W)}async _startUpdating(e,t){const{pendingFeatures:a}=this;a.includes(e)||a.add(e);const{creationInfo:i,viewModel:r}=this.data,{attachmentsViewModel:o,editableItems:l,featureFormViewModel:d,layerInfos:p,sketchViewModel:u,view:h}=r;if(!h||!i)return;const f=i.layer,m=k(p,f),g=m?.formTemplate,y=h.spatialReference;this.data.editableItem=l.find((e=>e.layer===f)),d.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:h.map}),"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),o.graphic=e,o.fileInfos.removeAll(),o.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>o.addFile(e,t))),this._removeHighlight(e),await C(e,t,"2d"===h.type?h.scale:null),this.removeHandles(W),n(this._featureFormHandle),"2d"===h.type){const a=c((()=>h.scale),(a=>this._updateGraphicDebounced(e,t,a)));this.addHandles(a,W)}return this._featureFormHandle=s([d.on("value-change",(async()=>{e.attributes=d.getValues(),await C(e,t,"2d"===h.type?h.scale:null)})),u.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&H(e.toolEventInfo.type))&&d.notifyFeatureGeometryChanged()}))]),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),w(f)?void 0:S({graphic:e,sketchViewModel:u,sourceLayer:f,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=U(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(b(t)?e.addHandles(await M({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,W])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([x,T,W]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return j(a,i)}static _configureSketchViewModel(e,t){const{data:i}=e,{viewModel:n}=i,{view:o}=n,l=n.sketchViewModel;let c=null;const p=[];if(!o)return{beforeCommit:r(),afterCommit:r()};const u=l.updateOnGraphicClick;return l.updateOnGraphicClick=!1,"2d"===o.type&&i.creationInfo&&p.push(e._fadeExistingFeatures(i.creationInfo.layer)),p.push(l.on("create",(async a=>{if("cancel"===a.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(t);const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("complete"===a.state&&a.graphic)return e._startUpdating(a.graphic,t)})),l.on("update",(async a=>{const{viewModel:r}=i,{attachmentsViewModel:s,featureFormViewModel:n}=r,l=a.graphics[0];if("complete"===a.state){if(l!==c&&(e._lastActiveGraphics.push(l),e._highlight(l)),c=null,e.numPendingFeatures===i.creationInfo?.maxFeatures){const a=e._lastActiveGraphics.pop();return e._startUpdating(a,t)}if("add"!==s.mode&&"edit"!==s.mode||r.activeWorkflow?.previous(),a.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);e.addHandles([D(o),o.on("click",(e=>e.preventDefault()))],T),await d((()=>!n.updating)),e.removeHandles(T),e._startCreating(t)}"start"===a.state&&e._removeHighlight(l);const p=e._visualVariableAttributes;await E(o,l,a,p,t);const u=l.attributes,{rotation:h,size:f}=p;if(null!=h){const{field:e}=h;n.setValue(e,u[e])}if(null!=f){const{field:e}=f;n.setValue(e,u[e])}})),l.on("delete",(async t=>{const i=t.graphics[0];e.pendingFeatures.remove(i),a(e._lastActiveGraphics,i),c=i})),o.on("immediate-click",(async a=>{if(b(i.creationInfo))return;const{results:r}=await o.hitTest(a,{include:l.layer}),s=r.find((e=>"graphic"===e.type&&e.graphic.sourceLayer===i.creationInfo?.layer));if(!s)return;const n=s.graphic;if("transform"===l.activeTool||"reshape"===l.activeTool){if(l.updateGraphics.at(0)===n)return;await e.updatePendingFeature(n,t)}})),r((()=>{e._preventDefaultActionOnCancel=!0,l.cancel()})),R(l,i)),{beforeCommit:s(p),afterCommit:r((()=>{l.updateOnGraphicClick=u}))}}async _setUpCreatingFeaturesStep(){if(this.hasHandles(x))return;const{creationInfo:e,viewModel:a}=this.data,{attachmentsViewModel:s,view:o}=a;if(!o)return;const l=new Map,d=[],p=[];this._lastActiveGraphics=[],this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},G(s),d.push(c((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const u=D(o);d.push(u);const h=w(e?.layer);try{if(b(e)&&p.push(r((()=>a.cancelWorkflow({warnIfNoWorkflow:!1})))),h){const a=e?.initialFeature??new t({attributes:{...e?.template?.prototype.attributes,...e?.attributeOverrides},sourceLayer:e?.layer});await this._startUpdating(a,l)}else{const t=O._configureSketchViewModel(this,l);d.push(t.beforeCommit),p.push(t.afterCommit),e?.initialFeature&&(a.sketchViewModel.layer.add(e.initialFeature),await this._startUpdating(e.initialFeature,l)),await this._startCreating(l)}}finally{u.remove()}const f=r((()=>this.pendingFeatures.drain((e=>a.sketchViewModel.layer.remove(e)))));d.push(this._featureFormHandle),this.addHandles(d.filter(i),this._handleKeys.beforeCommit),this.addHandles([r((()=>s.fileInfos.removeAll())),...d,...p,f].filter(i),x)}};function R(e,t){let a=null;const i=()=>e.snappingOptions.featureSources,n=()=>(a=new v({layer:e.layer}),i().add(a),a),l=()=>{null!=a&&(i().remove(a),a=o(a))};return s([c((()=>{const e=t.creationInfo?.layer,a=i().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=n(),a.enabled=t}),p),r(l)])}function L(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const n=e[s],o=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,o.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function z(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=u(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:u(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([h({constructOnly:!0})],N.prototype,"isNested",void 0),e([h()],N.prototype,"hasPendingEdits",null),e([h()],N.prototype,"_getDrawMeshHelpMessage",void 0),e([h()],N.prototype,"helpMessage",null),e([h()],N.prototype,"parent",null),e([h()],N.prototype,"keyboardCancellationEnabled",null),e([h()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],N.prototype,"shouldShowAttachments",null),e([h()],N.prototype,"shouldAllowAttachmentEditing",null),N=O=e([f("esri.widgets.Editor.CreateFeaturesWorkflow")],N);const K=N;export{K as default};
|