@arcgis/core 4.34.0-next.55 → 4.34.0-next.56
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/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0a4586e596413ef7a4b5.js +1 -0
- package/assets/esri/core/workers/chunks/{62ade6f18b375795ddfd.js → 10b46438885916d18425.js} +1 -1
- package/assets/esri/core/workers/chunks/1166ed298cf5ca7ad444.js +1 -0
- package/assets/esri/core/workers/chunks/13797036850dcc3671c3.js +1 -0
- package/assets/esri/core/workers/chunks/{c9c109d43a1e5160955d.js → 3490d47cac7c8dec70cd.js} +2 -2
- package/assets/esri/core/workers/chunks/43a56c8fa4e5be18c12a.js +1 -0
- package/assets/esri/core/workers/chunks/4b58da6cb91f7bf6af8b.js +1 -0
- package/assets/esri/core/workers/chunks/{cac060a187f3a27a19ba.js → 4d5abcf57a6ded4750ba.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0bf1fc6e3c198bc565d.js → 57486b18421a3c9690d0.js} +1 -1
- package/assets/esri/core/workers/chunks/5f518931a660b3c4f519.js +1 -0
- package/assets/esri/core/workers/chunks/66f3659ba18f92cd623e.js +1 -0
- package/assets/esri/core/workers/chunks/67355372ac5fd8a15d18.js +1 -0
- package/assets/esri/core/workers/chunks/{5691d504ffe5592bc40f.js → 6dc0009889f2b7cc8cff.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d2473e680324dc17cfa.js → 853b9f29b4d62fa621b9.js} +1 -1
- package/assets/esri/core/workers/chunks/855f25ce748aaef44b1a.js +1 -0
- package/assets/esri/core/workers/chunks/{71acded1b3c0057917a1.js → 862fe2f96d4b777ff5b8.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe5c37c69da3ec1e56ac.js → 8fa50cac57b6e1ecec76.js} +1 -1
- package/assets/esri/core/workers/chunks/9307108821d82c131654.js +1 -0
- package/assets/esri/core/workers/chunks/9b10e70f28873cff44f5.js +1 -0
- package/assets/esri/core/workers/chunks/{3b51b61a7b8a1ef87c9b.js → adf11d31f95481f89a55.js} +1 -1
- package/assets/esri/core/workers/chunks/af4412e79275c5a87539.js +1 -0
- package/assets/esri/core/workers/chunks/{7a8d740d1226719a578a.js → b457b7dd907f06278bee.js} +1 -1
- package/assets/esri/core/workers/chunks/{81e518dd62bd95611d00.js → b47688e3263099540873.js} +1 -1
- package/assets/esri/core/workers/chunks/c91217d977a6baaee74a.js +1 -0
- package/assets/esri/core/workers/chunks/{e1b25b1ce3bd4f0f2cda.js → cb57cdff976d2d4b0b41.js} +1 -1
- package/assets/esri/core/workers/chunks/{9fef330b241f958b55df.js → d0124b0dd62b331afe58.js} +1 -1
- package/assets/esri/core/workers/chunks/d3a7747f23e91d1f1b5e.js +1 -0
- package/assets/esri/core/workers/chunks/d3ae88fcde2d7fb3e2e2.js +1 -0
- package/assets/esri/core/workers/chunks/{b6a201e86f9caef45ff0.js → d42fd0effc560eefb14b.js} +1 -1
- package/assets/esri/core/workers/chunks/{4f8dab492331c9a2d67a.js → d87fdc64a5cc6be4bd69.js} +1 -1
- package/assets/esri/core/workers/chunks/db5d3feeb61ccb5ede98.js +1 -0
- package/assets/esri/core/workers/chunks/{aab349d4624b78ef429f.js → e6bf4f3f6868dc9028e3.js} +1 -1
- package/assets/esri/core/workers/chunks/f74b0cdc1c2b56bac5f0.js +1 -0
- package/assets/esri/core/workers/chunks/f807e7fc90e0e7ce6b67.js +1 -0
- package/assets/esri/core/workers/chunks/{fae6030a81cb91a91b69.js → faf4002f9547a0cc4e33.js} +1 -1
- package/assets/esri/core/workers/chunks/{fe55833c80cf59df9c2b.js → ff42b24b48019a03d841.js} +1 -1
- package/assets/esri/core/workers/chunks/{e10c5405f956b2cc59e4.js → ff4e15a872de94d2b438.js} +1 -1
- package/assets/esri/core/workers/chunks/{ff7962063d132c1ec814.js → ff8a4bf1bceb362d67ab.js} +1 -1
- package/config.js +1 -1
- package/core/has.js +1 -1
- package/geometry/Multipoint.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/extentUtils.js +1 -1
- package/graphic/KMLGraphicOrigin.js +5 -0
- package/graphic/isKMLGraphicOrigin.js +5 -0
- package/interfaces.d.ts +6 -3
- package/kernel.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/KMLSublayer.js +1 -1
- package/layers/support/featureReductionUtils.js +1 -1
- package/layers/support/kmlUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/support/requestUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/KMLLayerView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/Viewshed/{ArrowManipulator.js → ViewshedArrowManipulator.js} +1 -1
- package/views/3d/analysis/Viewshed/{FieldOfViewManipulation.js → ViewshedFieldOfViewManipulation.js} +1 -1
- package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedShapeVisualElement.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +5 -0
- package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/MultipointDrawAction.js +1 -1
- package/views/draw/PointDrawAction.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/drawUtils.js +1 -1
- package/views/draw/support/reshapeTooltipUtils.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/AppendVertex.js +1 -1
- package/views/interactive/tooltip/infos/SelectedVertexTooltipInfo.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/widgets/ElevationProfile/support/profileUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/sketchUtils.js +1 -1
- package/assets/esri/core/workers/chunks/02902303e5585a16ebea.js +0 -1
- package/assets/esri/core/workers/chunks/0445de3a8968c0734c91.js +0 -1
- package/assets/esri/core/workers/chunks/09268dc856c3d5ce178f.js +0 -1
- package/assets/esri/core/workers/chunks/0f51e51db83f303ce5a6.js +0 -1
- package/assets/esri/core/workers/chunks/17776d9d3558d45ea7b5.js +0 -1
- package/assets/esri/core/workers/chunks/1cbd59918c60a1a21494.js +0 -1
- package/assets/esri/core/workers/chunks/252ee00fd6c4ae0ee7fa.js +0 -1
- package/assets/esri/core/workers/chunks/3800764932a1c32cb29f.js +0 -1
- package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +0 -1
- package/assets/esri/core/workers/chunks/772e81e9162e2240a7a6.js +0 -1
- package/assets/esri/core/workers/chunks/8c81156b1605a16acc29.js +0 -1
- package/assets/esri/core/workers/chunks/8f6ff09e7d2f01b79faf.js +0 -1
- package/assets/esri/core/workers/chunks/998c38974372720b1c52.js +0 -1
- package/assets/esri/core/workers/chunks/a7530dcb08b43e37bbb2.js +0 -1
- package/assets/esri/core/workers/chunks/c51e2a048df152abd901.js +0 -1
- package/assets/esri/core/workers/chunks/d1842745a7699879a1e1.js +0 -1
- package/assets/esri/core/workers/chunks/d578c3880eaf2dd62324.js +0 -1
- package/assets/esri/core/workers/chunks/de499e33035b56b6697d.js +0 -1
- package/assets/esri/core/workers/chunks/e04951ee32f041faaeca.js +0 -1
- package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +0 -5
- package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +0 -5
- package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +0 -5
- /package/assets/esri/core/workers/chunks/{c9c109d43a1e5160955d.js.LICENSE.txt → 3490d47cac7c8dec70cd.js.LICENSE.txt} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as R}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as P}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";const Z=j.reshapeGraphics,X={vertices:{default:new b({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}},Y=Symbol();let q=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,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=new s,this.snappingManager=null,this.symbols=X,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}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(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_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&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_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 u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=P.fromGeometry(t,2)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_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=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_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()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=K(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}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_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 E({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)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),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,o=this._connectedReshapeManager,r=o?Q(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.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),r&&o?.startVertexMove(r,W(n)),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=K(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=$(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),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._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=B(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=B(e);let p=G(r);const c=p[a].length-1,l=n.pointToArray(t);p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),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=G(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,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.removeHandles(Y),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,p=G(e.geometry),c=0===h?a+1:h,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=J(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=J(e);for(const a of n){const{x:e,y:t}=a.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[a,h]=s[n];e===a&&t===h&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.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)}),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_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){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),Y)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,R(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),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."))}};function K(e){const t=G(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}function B({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function J(e){return e instanceof t?[e]:[...e]}function Q(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function W(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function $(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],q.prototype,"_activeOperationInfo",void 0),e([y()],q.prototype,"_connectedReshapeManager",void 0),e([y()],q.prototype,"_coordinateHelper",null),e([y()],q.prototype,"_editGeometryOperations",void 0),e([y()],q.prototype,"tooltip",void 0),e([y()],q.prototype,"tooltipInfos",void 0),e([y()],q.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],q.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],q.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],q.prototype,"_selectedVertex",null),e([y()],q.prototype,"_tooltipsContext",null),e([y()],q.prototype,"callbacks",void 0),e([y()],q.prototype,"connectedReshapeProviders",void 0),e([y()],q.prototype,"enableMidpoints",void 0),e([y()],q.prototype,"enableMovement",void 0),e([y()],q.prototype,"enableVertices",void 0),e([y()],q.prototype,"graphic",void 0),e([y()],q.prototype,"highlightName",void 0),e([y()],q.prototype,"highlightsEnabled",void 0),e([y()],q.prototype,"layer",void 0),e([y({readOnly:!0})],q.prototype,"midpointGraphics",void 0),e([y()],q.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],q.prototype,"selectedVertices",void 0),e([y()],q.prototype,"snappingManager",void 0),e([y({readOnly:!0})],q.prototype,"state",null),e([y()],q.prototype,"symbols",void 0),e([y({type:z})],q.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],q.prototype,"type",void 0),e([y({readOnly:!0})],q.prototype,"vertexGraphics",void 0),e([y()],q.prototype,"view",void 0),q=e([_("esri.views.draw.support.Reshape")],q);const ee=q;export{ee as default};
|
|
5
|
+
import{__decorate as e}from"tslib";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{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import{closeRingsAndFixWinding as u,getMidpoint as f,geometryToCoordinates as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as b}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as V}from"./ConnectedReshapeManager.js";import{cloneMove as S}from"./drawUtils.js";import w from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as I,isConnectedReshapeSupportedLayer as O}from"./layerUtils.js";import{createTooltipInfos as C,connectTooltip as k,updateTranslateTooltipInfo as T,updateTranslateVertexTooltipInfo as H}from"./reshapeTooltipUtils.js";import{settings as R}from"./settings.js";import{ViewEventPriorities as j}from"../../input/InputManager.js";import{createCoordinateHelper as A}from"../../interactive/coordinateHelper.js";import{sketchKeys as U}from"../../interactive/keybindings.js";import{EditGeometryOperations as L}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as P}from"../../interactive/tooltip/tooltipCommonUtils.js";const N=R.reshapeGraphics,Z={vertices:{default:new M({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:N.selected.size,color:N.selected.color,outline:{color:N.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:N.midpoint.size,color:N.midpoint.color,outline:{color:N.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:N.midpoint.size,color:N.midpoint.color,outline:{color:N.midpoint.outlineColor,width:1}})}},X=Symbol();let Y=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=Z,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=C(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;I(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),j.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),k(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??A(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}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(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_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._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;null!=e&&"mesh"!==e.type&&"extent"!==e.type?this._editGeometryOperations=L.fromGeometry(e,2):this._logGeometryTypeError()}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new b(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(X)}_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=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_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()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type||"multipoint"===e.type)){const t=q(e);this.enableMidpoints&&"multipoint"!==e.type&&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}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_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&&"multipoint"!==t.geometry?.type&&r.push(t),this._mover=new w({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)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new V({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),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,o=this._connectedReshapeManager,r=o?J(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.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),r&&o?.startVertexMove(r,Q(n)),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=q(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=W(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),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._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=f(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=K(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=K(e);let p=x(r);const c=p[a].length-1,l=n.pointToArray(t);if(p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),"multipoint"===r.type&&r.points)for(let e=0;e<p.length;e++)r.points[e]=p[e][0];this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),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=S(r.geometry,i,s,this.view),p=x(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,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.removeHandles(X),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,p=x(e.geometry),c=0===h?a+1:h,l=x(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=B(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&P(e,this.tooltip)||U.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry,i=this.vertexGraphics.length;if(null==t||"polygon"!==t.type&&"polyline"!==t.type&&"multipoint"!==t.type)return;if("polygon"===t.type&&i<4||"multipoint"===t.type&&i<2||"polyline"===t.type&&i<3)return;const s=this.graphic.clone(),o=t.clone();let r=x(o);const n=[],a=B(e);for(const h of a){const{x:e,y:t}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&t===h&&(n.push({coordinates:r[i][o],componentIndex:i,vertexIndex:o}),r[i].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 if("polyline"===o.type){for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}else o.points=r.flat();this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,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){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),X)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,T(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,H(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),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."))}};function q(e){const t=x(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}function K({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function B(e){return e instanceof t?[e]:[...e]}function J(e){const t=e.sourceLayer??e.layer;return O(t)?{graphic:e,layer:t}:null}function Q(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function W(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],Y.prototype,"_activeOperationInfo",void 0),e([y()],Y.prototype,"_connectedReshapeManager",void 0),e([y()],Y.prototype,"_coordinateHelper",null),e([y()],Y.prototype,"_editGeometryOperations",void 0),e([y()],Y.prototype,"tooltip",void 0),e([y()],Y.prototype,"tooltipInfos",void 0),e([y()],Y.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],Y.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],Y.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],Y.prototype,"_selectedVertex",null),e([y()],Y.prototype,"_tooltipsContext",null),e([y()],Y.prototype,"callbacks",void 0),e([y()],Y.prototype,"connectedReshapeProviders",void 0),e([y()],Y.prototype,"enableMidpoints",void 0),e([y()],Y.prototype,"enableMovement",void 0),e([y()],Y.prototype,"enableVertices",void 0),e([y()],Y.prototype,"graphic",void 0),e([y()],Y.prototype,"highlightName",void 0),e([y()],Y.prototype,"highlightsEnabled",void 0),e([y()],Y.prototype,"layer",void 0),e([y({readOnly:!0})],Y.prototype,"midpointGraphics",void 0),e([y()],Y.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],Y.prototype,"selectedVertices",void 0),e([y()],Y.prototype,"snappingManager",void 0),e([y({readOnly:!0})],Y.prototype,"state",null),e([y()],Y.prototype,"symbols",void 0),e([y({type:z})],Y.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],Y.prototype,"type",void 0),e([y({readOnly:!0})],Y.prototype,"vertexGraphics",void 0),e([y()],Y.prototype,"view",void 0),Y=e([_("esri.views.draw.support.Reshape")],Y);const $=Y;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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t}from"../../../core/mathUtils.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as e}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as o}from"../../../geometry/support/coordsUtils.js";function
|
|
5
|
+
import{rad2deg as t}from"../../../core/mathUtils.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as e}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as o}from"../../../geometry/support/coordsUtils.js";function s(t,n,e,s){if(null==s||t.hasZ||(s=void 0),"point"===t.type)return t.x+=n,t.y+=e,t.hasZ&&null!=s&&(t.z+=s),t;if("multipoint"===t.type){const o=t.points;for(let t=0;t<o.length;t++)o[t]=l(o[t],n,e,s);return t}if("extent"===t.type)return t.xmin+=n,t.xmax+=n,t.ymin+=e,t.ymax+=e,null!=s&&(t.zmin??=0,t.zmin+=s,t.zmax??=0,t.zmax+=s),t;const i=o(t),r="polyline"===t.type?t.paths:t.rings;for(let o=0;o<i.length;o++){const t=i[o];for(let o=0;o<t.length;o++)t[o]=l(t[o],n,e,s)}return"paths"in t?t.paths=r:t.rings=r,t}function i(t,n,e,i,r){const a=t.clone(),m=i.resolution;if("point"===a.type){if(r)s(a,n*m,-e*m);else{const t=i.state.transform,o=i.state.inverseTransform,s=t[0]*a.x+t[2]*a.y+t[4],r=t[1]*a.x+t[3]*a.y+t[5];a.x=o[0]*(s+n)+o[2]*(r+e)+o[4],a.y=o[1]*(s+n)+o[3]*(r+e)+o[5]}return a}if("multipoint"===a.type){if(r)s(a,n*m,-e*m);else{const t=a.points,o=i.state.transform,s=i.state.inverseTransform;for(let i=0;i<t.length;i++){const r=t[i],a=o[0]*r[0]+o[2]*r[1]+o[4],m=o[1]*r[0]+o[3]*r[1]+o[5],l=s[0]*(a+n)+s[2]*(m+e)+s[4],p=s[1]*(a+n)+s[3]*(m+e)+s[5];t[i]=x(r,l,p,void 0)}}return a}if("extent"===a.type){if(r)s(a,n*m,-e*m);else{const t=i.state.transform,o=i.state.inverseTransform,s=t[0]*a.xmin+t[2]*a.ymin+t[4],r=t[1]*a.xmin+t[3]*a.ymin+t[5],m=t[0]*a.xmax+t[2]*a.ymax+t[4],l=t[1]*a.xmax+t[3]*a.ymax+t[5];a.xmin=o[0]*(s+n)+o[2]*(r+e)+o[4],a.ymin=o[1]*(s+n)+o[3]*(r+e)+o[5],a.xmax=o[0]*(m+n)+o[2]*(l+e)+o[4],a.ymax=o[1]*(m+n)+o[3]*(l+e)+o[5]}return a}if(r)s(a,n*m,-e*m);else{const t=o(a),s="polyline"===a.type?a.paths:a.rings,r=i.state.transform,m=i.state.inverseTransform;for(let o=0;o<t.length;o++){const s=t[o];for(let t=0;t<s.length;t++){const o=s[t],i=r[0]*o[0]+r[2]*o[1]+r[4],a=r[1]*o[0]+r[3]*o[1]+r[5],l=m[0]*(i+n)+m[2]*(a+e)+m[4],p=m[1]*(i+n)+m[3]*(a+e)+m[5];s[t]=x(o,l,p,void 0)}}"paths"in a?a.paths=s:a.rings=s}return a}function r(t,s,i,r){if("point"===t.type){const{x:n,y:e}=t,o=r?r[0]:n,a=r?r[1]:e,m=t.clone(),l=(n-o)*s+o,x=(e-a)*i+a;return m.x=l,m.y=x,m}if("extent"===t.type){const{xmin:n,xmax:e,ymin:o,ymax:a}=t,m=r?r[0]:(n+e)/2,l=r?r[1]:(a+o)/2,x=t.clone();if(x.xmin=(n-m)*s+m,x.ymax=(a-l)*i+l,x.xmax=(e-m)*s+m,x.ymin=(o-l)*i+l,x.xmin>x.xmax){const t=x.xmin,n=x.xmax;x.xmin=n,x.xmax=t}if(x.ymin>x.ymax){const t=x.ymin,n=x.ymax;x.ymin=n,x.ymax=t}return x}let a=null;if(!r){a=o(t);const s=n(),[i,m,l,x]=e(s,a);r=[(i+l)/2,(m+x)/2]}const[m,l]=r;if("multipoint"===t.type){const n=t.clone(),e=n.points;for(let t=0;t<e.length;t++){const n=e[t],[o,r]=n,a=(o-m)*s+m,p=(r-l)*i+l;e[t]=x(n,a,p,void 0)}return n.points=e,n}const p=t.clone(),y="polyline"===p.type?p.paths:p.rings;a??=o(t);for(let n=0;n<a.length;n++){const t=a[n];for(let e=0;e<t.length;e++){const o=t[e],[r,a]=o,p=(r-m)*s+m,f=(a-l)*i+l;y[n][e]=x(o,p,f,void 0)}}return"paths"in p?p.paths=y:p.rings=y,p}function a(t,n,e,o,s,i){const r=Math.sqrt((e-t)*(e-t)+(o-n)*(o-n));return Math.sqrt((s-t)*(s-t)+(i-n)*(i-n))/r}function m(n,e,o,s=!1){const i=Math.atan2(e.y-o.y,e.x-o.x)-Math.atan2(n.y-o.y,n.x-o.x),r=Math.atan2(Math.sin(i),Math.cos(i));return s?r:t(r)}function l(t,n,e,o){return x(t,t[0]+n,t[1]+e,null!=t[2]&&null!=o?t[2]+o:void 0)}function x(t,n,e,o){const s=[n,e];return t.length>2&&s.push(null!=o?o:t[2]),t.length>3&&s.push(t[3]),s}export{i as cloneMove,m as getRotationAngle,a as getScaleRatio,s as move,r as scale};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{handlesGroup as t}from"../../../core/handleUtils.js";import{zeroMeters as e}from"../../../core/quantityUtils.js";import{watch as o,syncAndInitial as n,sync as i}from"../../../core/reactiveUtils.js";import{createScreenPoint as r}from"../../../core/screenUtils.js";import a from"../../../geometry/Point.js";import{connectPasteEvent as
|
|
5
|
+
import{handlesGroup as t}from"../../../core/handleUtils.js";import{zeroMeters as e}from"../../../core/quantityUtils.js";import{watch as o,syncAndInitial as n,sync as i}from"../../../core/reactiveUtils.js";import{createScreenPoint as r}from"../../../core/screenUtils.js";import a from"../../../geometry/Point.js";import{connectPasteEvent as s,getXYZDeltasFromTooltipInfo as c}from"../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as l}from"../../interactive/tooltip/infos/MovePointTooltipInfo.js";import{SelectedVertexTooltipInfo as p}from"../../interactive/tooltip/infos/SelectedVertexTooltipInfo.js";import{TranslateTooltipInfo as m}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{TranslateVertexTooltipInfo as u}from"../../interactive/tooltip/infos/TranslateVertexTooltipInfo.js";import{elevationFromPoint as f}from"../../support/euclideanLengthMeasurementUtils.js";function y(t){const e={sketchOptions:t,viewType:"2d"};return{movePoint:new l(e),selectedVertex:new p(e),translateGraphic:new m(e),translateVertices:new u(e)}}function v(e,r){function a(){const t=r(),e=t.sketchOptions.tooltips.effectiveEnabled?t.activeTooltipInfo:null;return{...t,activeTooltipInfo:e}}let c=!1;function l(t){c||(c=!0,t(),c=!1)}return t([o(()=>{const t=a();return{context:t,geometry:t.graphic?.geometry,vertexGeometry:t.selectedVertex?.geometry}},({context:t})=>{l(()=>{g(t),e.info=t.activeTooltipInfo})},n),o(()=>{const t=a(),{activeTooltipInfo:e}=t;if(e&&"key"in e)return{context:t,key:e.key}},(t,e)=>{t&&e&&t.key!==e.key&&l(()=>T(t.context))},i),s(e,{onBeforePaste:()=>{c=!0},onAfterPaste:()=>{T(a()),c=!1}})])}function g(t){const e=t.activeTooltipInfo;if(e){switch(e?.type){case"move-point":return h(e,t);case"selected-vertex":return d(e,t)}e.sketchOptions=t.sketchOptions}}function h(t,{graphic:e}){x(t,e,e?.geometry)}function d(t,{graphic:e,selectedVertex:o,automaticAreaMeasurementUtils:n,automaticLengthMeasurementUtils:i}){x(t,e,o?.geometry);const r=e?.geometry;switch(r?.type){case"polygon":t.geometryType="polygon",t.totalLength.visible=!1,t.area.actual=n.autoArea2D(r);break;case"polyline":t.geometryType="polyline",t.totalLength.actual=i.autoLength2D(r),t.area.visible=!1;break;case"multipoint":t.geometryType="multipoint",t.area.visible=!1,t.totalLength.visible=!1}}function x(t,e,o){e&&"point"===o?.type&&(t.setLocationFromPoint(o),t.elevation.actual=f(o),t.elevation.visible=!!e.geometry?.hasZ,t.elevation.readOnly=!1,t.elevation.showAsZ=!0)}function T(t){function e(e,o){const n=o?.geometry;if(!n||"point"!==n.type)return;const{dx:i,dy:r,dz:s}=c(e,n);if(0===i&&0===r&&0===s)return;const{x:l,y:p,z:m,m:u,spatialReference:f}=n,y=new a({x:l+i,y:p+r,z:null!=m?m+s:void 0,m:u,spatialReference:f});t.updateGeometry(o,y,n,i,r)}const{activeTooltipInfo:o,graphic:n,selectedVertex:i}=t;switch(o?.type){case"move-point":return e(o,n);case"selected-vertex":return e(o,i)}}function j(t,e,o,n){t.clear(),w(t,e,n,o)}function k(t,e,o,n,i){t.clear();const{automaticAreaMeasurementUtils:r,automaticLengthMeasurementUtils:a}=n;"polygon"===o?.type?t.area=r.autoArea2D(o):"polyline"===o?.type&&(t.totalLength=a.autoLength2D(o)),w(t,e,i,n)}function w(t,o,n,{automaticLengthMeasurementUtils:i}){if(!n)return;const{x:a,y:s}=n.origin,c=o.toMap(n),l=o.toMap(r(a,s)),p=i.autoDistanceBetweenPoints2D(l,c);t.distance=null!=p?p:e}export{v as connectTooltip,y as createTooltipInfos,j as updateTranslateTooltipInfo,k as updateTranslateVertexTooltipInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as t}from"../../../core/arrayUtils.js";import{neverReached as e}from"../../../core/compilerUtils.js";import{Evented as r}from"../../../core/Evented.js";import i from"../../../geometry/
|
|
5
|
+
import{equals as t}from"../../../core/arrayUtils.js";import{neverReached as e}from"../../../core/compilerUtils.js";import{Evented as r}from"../../../core/Evented.js";import i from"../../../geometry/Multipoint.js";import s from"../../../geometry/Polygon.js";import n from"../../../geometry/Polyline.js";import{getEndpoint as o,isCoordinate as h,isBezierCurve as c,isCircularArc as a,isEllipticArc4 as l}from"../../../geometry/support/curves/curveUtils.js";import{createCoordinateHelper as p}from"../coordinateHelper.js";import{unnormalize as u,getUnnormalizationInfo as g}from"./unnormalizationHelper.js";class f{constructor(t){this.part=t,this.leftSegment=null,this.rightSegment=null,this.type="vertex",this.index=null}get pos(){return this._pos}set pos(t){this._pos=t,this.part.unnormalizeVertexPositions()}}class m{constructor(t,e,r){this.part=t,this.leftVertex=e,this.rightVertex=r,this.type="line",e.rightSegment=this,r.leftSegment=this}toCurveOrCoordinate(){return[...this.rightVertex.pos]}}class d{constructor(t,e,r,i){this.part=t,this.leftVertex=e,this.rightVertex=r,this.curveDefinition=i,this.type="bezier",e.rightSegment=this,r.leftSegment=this}toCurveOrCoordinate(){return{b:[[...this.rightVertex.pos],[...this.curveDefinition.controlPoint1],[...this.curveDefinition.controlPoint2]]}}}class y{constructor(t,e,r,i){this.part=t,this.leftVertex=e,this.rightVertex=r,this.curveDefinition=i,this.type="circular-arc",e.rightSegment=this,r.leftSegment=this}toCurveOrCoordinate(){const t=this.rightVertex.pos,{interiorPoint:e}=this.curveDefinition;return{c:[[...t],[...e]]}}}class v{constructor(t,e,r,i){this.part=t,this.leftVertex=e,this.rightVertex=r,this.curveDefinition=i,this.type="elliptic-arc-4",e.rightSegment=this,r.leftSegment=this}toCurveOrCoordinate(){const t=this.rightVertex.pos,{centerPoint:e,sweep:r,orientation:i}=this.curveDefinition;return{a:[[...t],[...e],r,i]}}}class x{constructor(t,e,r,i){this.part=t,this.leftVertex=e,this.rightVertex=r,this.curveDefinition=i,this.type="elliptic-arc-7",e.rightSegment=this,r.leftSegment=this}toCurveOrCoordinate(){const t=this.rightVertex.pos,{centerPoint:e,sweep:r,orientation:i,rotation:s,semiMajorAxisLength:n,minorMajorAxisRatio:o}=this.curveDefinition;return{a:[[...t],e,r,i,s,n,o]}}}class V{constructor(t,e){this._spatialReference=t,this._viewingMode=e,this.vertices=[],this.segments=[],this.index=null}unnormalizeVertexPositions(){this.vertices.length<=1||u(this.vertices,g(this._spatialReference,this._viewingMode))}updateVertexIndex(t,e){const{vertices:r}=this;if(0===r.length)return;const i=r[0];let s=null,n=t,o=e;do{s=n,s.index=o++,n=s.rightSegment?s.rightSegment.rightVertex:null}while(null!=n&&n!==i);s.leftSegment&&s!==r[r.length-1]&&this.swapVertices(r.indexOf(s),r.length-1)}getFirstVertex(){return this.vertices.at(0)}getLastVertex(){return this.vertices.at(-1)}isClosed(){return null!==this.getFirstVertex()?.leftSegment}swapVertices(t,e){const{vertices:r}=this,i=r[t];r[t]=r[e],r[e]=i}*iterateVertices(){const t=this.getFirstVertex();let e=t;if(e)do{yield e,e=e.rightSegment?.rightVertex}while(e!==t&&null!=e)}}class w extends r{constructor(t,e){super(),this.type=t,this.coordinateHelper=e,this._geometry=null,this._dirty=!0,this.parts=[]}get geometry(){if(this._dirty){switch(this.type){case"point":this._geometry=this._toPoint();break;case"multipoint":this._geometry=this._toMultipoint();break;case"polyline":this._geometry=this._toPolyline();break;case"polygon":this._geometry=this._toPolygon();break;case"mesh":break;default:e(this.type)}this._dirty=!1}return this._geometry}get spatialReference(){return this.coordinateHelper.spatialReference}get allVerticesUnordered(){return Array.from(this.iterateVerticesUnordered())}*iterateVerticesUnordered(){for(const t of this.parts)for(const e of t.vertices)yield e}get allVertices(){return Array.from(this.iterateVertices())}*iterateVertices(){for(const t of this.parts)yield*t.iterateVertices()}notifyChanges(t){this._dirty=!0,this.emit("change",t)}_toPoint(){const{parts:t,coordinateHelper:e}=this;return t.at(0)?.vertices.length?e.vectorToPoint(t[0].vertices[0].pos):null}_toMultipoint(){const t=[],{coordinateHelper:e,parts:r,spatialReference:s}=this;for(const i of r){const r=i.getFirstVertex();r&&t.push(e.arrayToVector(r.pos))}return new i({hasM:e.hasM(),hasZ:e.hasZ(),spatialReference:s,points:t})}_toPolyline(){const t=[];let e=!1;for(const r of this.parts){if(r.vertices.length<1)continue;const i=r.vertices[0],s=[];s.push(i.pos);let n=i.rightSegment;for(;n;)e||="line"!==n.type,s.push(n.toCurveOrCoordinate()),n=n.rightVertex.rightSegment;t.push(s)}return new n({paths:e?void 0:t,curvePaths:e?t:void 0,spatialReference:this.spatialReference,hasZ:this.coordinateHelper.hasZ(),hasM:this.coordinateHelper.hasM()})}_toPolygon(){const t=[];let e=!1;for(const r of this.parts){if(r.vertices.length<1)continue;const i=r.vertices[0],s=[];s.push(i.pos);let n=i.rightSegment;for(;n&&(e||="line"!==n.type,s.push(n.toCurveOrCoordinate()),n=n.rightVertex.rightSegment,n?.leftVertex!==i););t.push(s)}return new s({rings:e?void 0:t,curveRings:e?t:void 0,spatialReference:this.spatialReference,hasZ:this.coordinateHelper.hasZ(),hasM:this.coordinateHelper.hasM()})}static fromGeometry(t,e,r){const i=t.spatialReference,s=p(t.hasZ,t.hasM,i),n=new w(t.type,s);switch(t.type){case"polygon":S(n,t,e,r?.allowCurves??!1);break;case"polyline":R(n,t,e,r?.allowCurves??!1);break;case"point":C(n,t,e);break;case"multipoint":M(n,t,e);break;case"mesh":C(n,t.origin,e),n._geometry=t,n._dirty=!1}return n}}function _(t,e,r,i){const s=new f(t);t.vertices.push(s);const n=o(i);return s.pos=e.arrayToVector(n),s.index=t.vertices.length-1,r&&t.segments.push(P(t,r,s,i)),s}function P(t,e,r,i){if(h(i))return new m(t,e,r);if(c(i)){const[,s,n]=i.b;return new d(t,e,r,{controlPoint1:[...s],controlPoint2:[...n]})}if(a(i)){const[,s]=i.c;return new y(t,e,r,{interiorPoint:[...s]})}if(l(i)){const[,s,n,o]=i.a;return new v(t,e,r,{centerPoint:[...s],sweep:n,orientation:o})}const[,s,n,o,p,u,g]=i.a;return new x(t,e,r,{centerPoint:[...s],sweep:n,orientation:o,rotation:p,semiMajorAxisLength:u,minorMajorAxisRatio:g})}function S(e,r,i,s){const n=r.spatialReference,h=e.coordinateHelper,{rings:c,curveRings:a}=r,l=a&&s?a:c;for(let p=0;p<l.length;++p){const r=l[p],s=new V(n,i);if(s.index=p,e.parts.push(s),r.length<1)continue;let c=null,a=null;for(let t=0;t<r.length-1;++t)a=_(s,h,a,r[t]),c??=a;r.length>1&&t(o(r[r.length-1]),c?.pos)?a&&c&&s.segments.push(P(s,a,c,r[r.length-1])):a=_(s,h,a,r[r.length-1])}}function R(t,e,r,i){const s=e.spatialReference,n=t.coordinateHelper,{curvePaths:o,paths:h}=e,c=o&&i?o:h;for(let a=0;a<c.length;++a){const e=c[a],i=new V(s,r);if(i.index=a,t.parts.push(i),e.length<1)continue;let o=null;for(let t=0;t<e.length;++t)o=_(i,n,o,e[t])}}function C(t,e,r){const i=e.spatialReference,s=t.coordinateHelper,n=new V(i,r);n.index=0;const o=new f(n);o.index=0,o.pos=s.pointToVector(e),n.vertices.push(o),t.parts.push(n)}function M(t,e,r){const i=e.spatialReference,{coordinateHelper:s,parts:n}=t,o=e.points.map(t=>s.arrayToVector(t));for(let h=0;h<o.length;h++){const t=new V(i,r);t.index=h,n.push(t);const e=new f(t);e.pos=o[h],e.index=0,t.vertices.push(e)}}function H(t){return"mesh"===t.type}export{d as BezierSegment,y as CircularArcSegment,w as EditGeometry,v as EllipticArc4Segment,x as EllipticArc7Segment,m as LineSegment,V as Part,f as Vertex,P as createConnectingSegment,H as isMeshEditGeometry};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{Evented as e}from"../../../core/Evented.js";import{makeHandle as t}from"../../../core/handleUtils.js";import{clone as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{hasCompatibleTopology as s}from"../../../geometry/support/coordsUtils.js";import{isMeshEditGeometry as i,EditGeometry as
|
|
5
|
+
import{Evented as e}from"../../../core/Evented.js";import{makeHandle as t}from"../../../core/handleUtils.js";import{clone as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{hasCompatibleTopology as s}from"../../../geometry/support/coordsUtils.js";import{isMeshEditGeometry as i,Part as o,EditGeometry as a}from"./EditGeometry.js";import{AppendVertex as n}from"./operations/AppendVertex.js";import{UpdateVertices as p}from"./operations/UpdateVertices.js";import{RemoveVertices as d}from"./operations/RemoveVertices.js";import{SplitSegment as h}from"./operations/SplitSegment.js";import{SetVertexPosition as c}from"./operations/SetVertexPosition.js";import{ClosePart as u}from"./operations/ClosePart.js";import{MoveMesh as l}from"./operations/MoveMesh.js";import{MoveVertex as m}from"./operations/MoveVertex.js";import{OffsetEdgeVertex as V}from"./operations/OffsetEdgeVertex.js";import{RotateVertex as y}from"./operations/RotateVertex.js";import{ScaleVertex as f}from"./operations/ScaleVertex.js";import{SetAllVertexPositions as v}from"./operations/SetAllVertexPositions.js";import{UndoGroup as _}from"./operations/UndoGroup.js";class g extends e{constructor(e,t,r=!1){super(),this.data=e,this.viewingMode=t,this.allowCurves=r,this._undoStack=[],this._redoStack=[],this._listener=this.data.on("change",e=>{e.addedVertices&&this.emit("vertex-add",{type:"vertex-add",vertices:e.addedVertices,operation:e.operation}),e.removedVertices&&this.emit("vertex-remove",{type:"vertex-remove",vertices:e.removedVertices,operation:e.operation}),e.updatedVertices&&this.emit("vertex-update",{type:"vertex-update",vertices:e.updatedVertices,operation:e.operation})})}destroy(){super.destroy(),this._listener.remove()}splitSegment(e,t){return this._apply(new h(this.data,e,t))}updateVertices(e,t,r=1){return this._apply(new p(this.data,e,t),r)}move(e,t,r,s=1){return i(this.data)?this._apply(new l(this.data,e,t,r),s):this.moveVertices(this.data.allVerticesUnordered,e,t,r,s)}moveVertices(e,t,r,s,o=1){return i(this.data)?this._apply(new l(this.data,t,r,s),o):this.updateVertices(e,new m(this.data.coordinateHelper,t,r,s),o)}scale(e,t,r,s,i=1,o=0){return this.scaleVertices(this.data.allVerticesUnordered,e,t,r,s,i,o)}scaleVertices(e,t,r,s,i,o=1,a=0){return this.updateVertices(e,new f(t,r,s,i,a),o)}rotate(e,t,r=1,s=0){return this.rotateVertices(this.data.allVerticesUnordered,e,t,r,s)}rotateVertices(e,t,r,s=1,i=0){return this.updateVertices(e,new y(t,r,i),s)}removeVertices(e){return this._apply(new d(this.data,e,this._minNumVerticesPerType))}appendVertex(e,t){return t??=new o(this.data.spatialReference,this.viewingMode),this._apply(new n(this.data,t,e))}appendVertexToFirstPart(e){const t=this.data.parts.at(0);return t?this._apply(new n(this.data,t,e)):null}setVertexPosition(e,t){return this._apply(new c(this.data,e,t))}offsetEdge(e,t,r,s=1){return this.updateVertices([t.leftVertex,t.rightVertex],new V(this.data.coordinateHelper,e,t,r),s)}trySetGeometry(e,t=1){const{data:r}=this,{coordinateHelper:o}=r;if(r.type!==e.type||!r.spatialReference.equals(e.spatialReference)||o.hasZ()!==e.hasZ||o.hasM()!==e.hasM||!s(r.geometry,e)||i(r))return;const n=Array.from(a.fromGeometry(e,this.viewingMode,{allowCurves:this.allowCurves}).iterateVerticesUnordered(),e=>e.pos);return this.setVertexPositions(n,t)}setVertexPositions(e,t=1){return this._apply(new v(this.data,e),t)}createResetState(){if(i(this.data))return this._createResetStateMesh();const e=this.data.geometry.clone();return t(()=>this.trySetGeometry(e))}closePart(e){return this.data.parts.includes(e)?this._apply(new u(this.data,e)):null}canRemoveVertex(e){return e.vertices.length>this._minNumVerticesPerType}createUndoGroup(){const e=new _;return this._apply(e),t(()=>e.close())}undo(){if(this._undoStack.length>0){const e=this._undoStack.pop();return e.undo(),this._redoStack.push(e),e}return null}redo(){if(this._redoStack.length>0){const e=this._redoStack.pop();return e.apply(),this._undoStack.push(e),e}return null}get canUndo(){return this._undoStack.length>0}get canRedo(){return this._redoStack.length>0}get lastOperation(){return this._undoStack.length>0?this._undoStack[this._undoStack.length-1]:null}get _minNumVerticesPerType(){switch(this.data.type){case"point":return 1;case"polyline":return 2;case"polygon":return 3;default:return 0}}_apply(e,t=1){return 0!==t&&null!=this.lastOperation&&this.lastOperation.accumulate(e)||(e.apply(),this._undoStack.push(e),this._redoStack=[]),e}_createResetStateMesh(){if(!i(this.data))return t();const e=this.data.geometry,{vertexSpace:s}=e;if(s.origin){const i=r(s.origin);return t(()=>{e.vertexSpace.origin=i})}const o=e.vertexAttributes.clonePositional();return t(()=>{e.vertexAttributes=o,e.vertexAttributesChanged()})}static fromGeometry(e,t,r){return new g(a.fromGeometry(e,t,r),t,!!r?.allowCurves)}}export{g as EditGeometryOperations};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getEndpoint as e}from"../../../../geometry/support/curves/curveUtils.js";import{Vertex as t,createConnectingSegment as i,LineSegment as s}from"../EditGeometry.js";class r{constructor(e,t,i){this._editGeometry=e,this._part=t,this._posOrCurveDef=i,this._addedVertex=null,this._originalSegment=null,this._left=null,this._right=null}apply(){let r="redo";const{_part:
|
|
5
|
+
import{getEndpoint as e}from"../../../../geometry/support/curves/curveUtils.js";import{Vertex as t,createConnectingSegment as i,LineSegment as s}from"../EditGeometry.js";class r{constructor(e,t,i){this._editGeometry=e,this._part=t,this._posOrCurveDef=i,this._addedVertex=null,this._originalSegment=null,this._left=null,this._right=null,this._partAdded=!1}apply(){let r="redo";const{_part:d,_editGeometry:n,_posOrCurveDef:l}=this;if(null==this._addedVertex&&(r="apply",this._addedVertex=new t(d)),!n.parts.includes(d)){this._partAdded=!0;const e=n.parts.at(-1)?.index??-1;d.index=e+1,n.parts.push(d)}const h=d.getLastVertex(),a=n.coordinateHelper.arrayToVector(e(l));if(null==h)d.vertices.push(this._addedVertex),this._addedVertex.pos=a,this._addedVertex.index=0;else{let e=null;h.rightSegment&&(this._originalSegment=h.rightSegment,e=this._originalSegment.rightVertex,d.segments.splice(d.segments.indexOf(this._originalSegment),1)),d.vertices.push(this._addedVertex),this._addedVertex.pos=a,this._left??=i(d,h,this._addedVertex,l),d.segments.push(this._left),h.rightSegment=this._left,null!=this._originalSegment&&null!=e&&(this._right??=new s(this._part,this._addedVertex,e),d.segments.push(this._right),e.leftSegment=this._right),d.updateVertexIndex(this._addedVertex,h.index+1)}this._editGeometry.notifyChanges({operation:r,addedVertices:[this._addedVertex]})}undo(){const{_addedVertex:e,_part:t,_left:i,_right:s,_originalSegment:r}=this;null!=e&&(t.vertices.splice(t.vertices.indexOf(e),1),null!=i&&(t.segments.splice(t.segments.indexOf(i),1),i.leftVertex.rightSegment=null),null!=s&&(t.segments.splice(t.segments.indexOf(s),1),s.rightVertex.leftSegment=null),null!=r&&(t.segments.push(r),r.leftVertex.rightSegment=r,r.rightVertex.leftSegment=r),null!=i?t.updateVertexIndex(i.leftVertex,i.leftVertex.index):t.updateVertexIndex(e,0),this._partAdded&&this._editGeometry.parts.splice(this._editGeometry.parts.indexOf(this._part)),this._editGeometry.notifyChanges({operation:"undo",removedVertices:[e]}))}accumulate(){return!1}}export{r as AppendVertex};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as
|
|
5
|
+
import{__decorate as o}from"tslib";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{makeAreaField as r,makeTotalLengthField as s}from"../fields/fields.js";import{SketchTooltipInfo as i}from"./SketchTooltipInfo.js";import{TooltipInfoWithCoordinates as l}from"./TooltipInfoWithCoordinates.js";let p=class extends(l(i)){constructor(o){super(o),this.type="selected-vertex",this.area=r(),this.totalLength=s(),this.geometryType="polyline",this.allFields.forEach(o=>{o.lockable=!1,o.setActual(null)})}get allFields(){const{longitude:o,latitude:t,x:e,y:r,elevation:s,area:i,totalLength:l,geometryType:p}=this;return[o,t,e,r,s,..."multipoint"===p?[]:["polygon"===p?i:l]]}};o([t()],p.prototype,"geometryType",void 0),o([t()],p.prototype,"allFields",null),p=o([e("esri.views.interactive.tooltip.infos.SelectedVertexTooltipInfo")],p);export{p as SelectedVertexTooltipInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../Basemap.js";import n from"../../Ground.js";import a from"../../WebScene.js";import"../../core/has.js";import{isLongFormType as s,Null as
|
|
5
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../Basemap.js";import n from"../../Ground.js";import a from"../../WebScene.js";import"../../core/has.js";import{isLongFormType as s,Null as l,Integer as y}from"../../core/accessorSupport/ensureType.js";import{isCollection as i}from"../../core/accessorSupport/extensions/serializableProperty/type.js";import o from"../../layers/GroupLayer.js";import p from"../../layers/KMLLayer.js";import{typeModuleMap as u}from"../../layers/mixins/operationalLayerModuleMap.js";import{supportedTypes as c}from"../../layers/mixins/operationalLayers.js";import f from"../../layers/support/Sublayer.js";import{JoinTableDataSource as m,DataLayerSource as d}from"../../layers/support/source/DataLayerSource.js";import{MapLayerSource as b}from"../../layers/support/source/MapLayerSource.js";import w from"../InitialViewProperties.js";import{ScanContext as j,sorted as N}from"./utils.js";import{webSceneAnalysisRegistry as v}from"../support/analysisUtils.js";import g from"../support/SlideElements.js";async function T(r){const n={stack:[],error:void 0,hasError:!1};try{const t=e(n,new j,!1);return await L(null,{typeName:"json",type:r},void 0,t)}catch(a){n.error=a,n.hasError=!0}finally{t(n)}}async function q(e,t,r,n){switch(t.typeName){case"array":await R(e,t,r,n);break;case"union":await M(e,t,r,n);break;case"json":await L(e,t,r,n);break;case"native":await h(e,t,r,n);break;case"enum":await k(e,t,r,n)}}async function h(e,t,r,n){const a=r??t;n.addProperty({name:e,type:O(n,t),default:a.default,required:a.isRequired,nullable:a.nullable})}async function k(e,t,r,n){const a=r??t;n.currentClass?.typeValue&&"type"===e?n.addProperty({name:e,type:"string",enum:`"${n.currentClass.typeValue}"`,default:a.default,required:a.isRequired,nullable:a.nullable}):n.addProperty({name:e,type:O(n,t),enum:N(t.values).map(e=>"string"==typeof e?`"${e}"`:`${e}`).join("|"),default:a.default,required:a.isRequired,nullable:a.nullable})}async function R(e,t,r,n){t.elementType.isRequired=t.isRequired,await q(`${e}[]`,t.elementType,r??t.elementType,n)}function S(e,t){if("json"===e.typeName){const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;if(s&&Array.isArray(s)&&1===s.length&&"string"==typeof s[0])return a?s[0]:D(r,s[0])}return t}async function M(e,t,r,n){const a=[],s=r??t;for(const l of t.types)if("native"!==l.type.typeName&&t.key){const a=`${e}<${S(l.type,l.value)}>`;await q(a,l.type,r??t,n)}else a.push(l.type);if(a.length){const t=N(a.map(e=>O(n,e)));n.addProperty({type:t.join("|"),name:e,default:s.default,required:s.isRequired,nullable:s.nullable})}}async function C(e,t){return e.type===a&&"layers"===t?_("web-scene/operational-layers","operational-layers"):e.type===a&&"tables"===t?_("web-scene/tables","tables"):e.type!==r||"baseLayers"!==t&&"baseMapLayers"!==t?e.type===r&&"elevationLayers"===t||e.type===n&&"layers"===t?_("web-scene/ground","ground"):e.type===o&&"layers"===t?_("web-scene/operational-layers","operational-layers",e=>e!==o):e.type!==g&&e.type!==w||"analyses"!==t?e.type!==m||"leftTableSource"!==t&&"rightTableSource"!==t?null:V({},{key:"type",base:null,typeMap:{"data-layer":d,"map-layer":b}}):{typeName:"array",elementType:{typeName:"union",key:"type",types:await Promise.all(Object.entries(v).map(async([e,t])=>({type:{typeName:"json",type:await t()},value:e})))}}:_("web-scene/basemap","basemap")}async function P(e,t,r){const n=I(r),a=await C(e,t);return a?(a.isRequired=n.isRequired,a.nullable=n.nullable,a.default=n.default,a):n}async function L(e,t,r,n){const a=t.type.__accessorMetadata__,s=n.getDeclaredClass(t.type);if(!a)return e&&n.addProperty({name:e,type:"unknown"}),null;let l=s,y=null;t.layerContainerType&&(l+=`--${t.layerContainerType}`);const i=e?.match(/<([^>]+)>$/);i&&(l+=`--${i[1]}`,y=i[1]);const o=r??t;t.type===f&&(l+=`--${n.currentClass?.name}`,y=n.currentClass?.name);const p=n.seen.get(l);if(p&&e)return n.addProperty({name:e,type:p,required:o.isRequired,default:o.default,nullable:o.nullable}),p;const u={type:t.type,name:s,id:l,properties:[]};e&&(n.addProperty({name:e,type:u,required:o.isRequired,default:o.default,nullable:o.nullable}),u.typeValue=y),n.push(e,u);for(const c in a){const e=a[c],r=F(e);if(!r?.enabled)continue;if(r.layerContainerTypes&&t.layerContainerType&&!r.layerContainerTypes.includes(t.layerContainerType))continue;if(t.type===f){const e="esri/layers/TileLayer"===n.stack[n.stack.length-2].klass.name;if(e&&f.test.isMapImageLayerOverridePolicy(r.overridePolicy)||!e&&f.test.isTileImageLayerOverridePolicy(r.overridePolicy))continue}const s=r.target;if("string"==typeof s||null==s){const r=await P(t,c,e);if(!r)continue;await q("string"==typeof s?s:c,r,void 0,n)}else await $(t,s,n)}return n.pop()}async function $(e,t,r){for(const n in t){let a=await C(e,n);if(!a){const e=t[n];a=e.types?V({default:e.default,write:e},e.types):J(e.type),a.default=e.default,a.isRequired=e.isRequired,a.nullable=e.allowNull,a=E(a)}await q(n,a,void 0,r)}}async function _(e,t,r){const n={typeName:"union",key:"layerType",types:[]};for(const a in c[e]){if("web-scene/operational-layers"===e&&"ArcGISTiledElevationServiceLayer"===a)continue;const s=await u[a]();s&&(r&&!r(s)||s!==p&&n.types.push({type:{typeName:"json",layerContainerType:t,type:s},value:a}))}if(0===n.types.length)return null;return{typeName:"array",elementType:1===n.types.length?n.types[0].type:n}}function O(e,t){switch(t.typeName){case"array":return`${O(e,t.elementType)}[]`;case"union":return`${N(t.types.map(t=>O(e,t.type))).join(" | ")}`;case"native":switch(t.type){case Number:return"number";case y:return"integer";case String:return"string";case Boolean:return"boolean";case Object:return"object";default:return"unknown"}case"json":return e.getDeclaredClass(t.type);case"enum":return"string"}}function A(e){const t=e.prototype.itemType?.Type;if(!t)return{typeName:"array",elementType:{typeName:"native",type:null}};if("function"==typeof t)return{typeName:"array",elementType:J(t)};if(t.typeMap){const e=[];for(const r in t.typeMap){const n=t.typeMap[r];e.push({type:J(n),value:K(n)?null:r})}return{typeName:"array",elementType:{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:e}}}}function x(e){if("json"!==e.typeName)return null;const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;return s&&Array.isArray(s)&&"string"==typeof s[0]?a||r.type.map(e=>D(r,e)):null}function E(e){if("array"===e.typeName)return e.elementType=E(e.elementType),e;const t=x(e);return t?{typeName:"union",key:"type",nullable:e.nullable,isRequired:e.isRequired,types:t.map(t=>({value:t,type:e}))}:e}function I(e){const t=U(e);return t?.types?V(t,t.types):!t?.type&&e.types?V(t,e.types):E(G(e))}function V(e,t){if(Array.isArray(t))return{typeName:"array",elementType:V(e,t[0])};const r=[];for(const n in t.typeMap){const e=t.typeMap[n];r.push({type:J(e),value:K(e)?null:n})}return{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:r,nullable:e?.write?.allowNull,isRequired:e?.write?.isRequired,default:e?.default}}function B(e){return null!=e&&e.isJSONMapWriter}function D(e,t){const r=F(e);if(r&&B(r.writer)){const e={value:""};return r.writer?.(t,e,"value"),e.value}return t}function G(e){const t=U(e),r=F(e),n=t?.type,a=J(n||e.type);return t&&void 0!==t.default&&"function"!=typeof t.default&&(a.default=D(e,t.default)),r?.allowNull&&(a.nullable=!0),r?.isRequired&&(a.isRequired=!0),a}function J(e){if(!e)return{typeName:"native",type:null};if(s(e))return W(e);if(Array.isArray(e)){if("string"==typeof e[0]||"number"==typeof e[0])return{typeName:"enum",values:e};if(e.length>1){const t=[];let r;for(const n of e)n!==l?t.push({type:J(n),value:null}):r=!0;return 1===t.length?{...t[0].type,nullable:r}:{typeName:"union",key:null,types:t,nullable:r}}return{typeName:"array",elementType:J(e[0])}}return i(e)?A(e):K(e)?{typeName:"native",type:e}:z(e)?{typeName:"json",type:e}:{typeName:"native",type:null}}function W(e){switch(e.type){case"native":return{typeName:"native",type:e.value};case"array":return{typeName:"array",elementType:J(e.value)};case"one-of":return{typeName:"union",key:null,types:e.values.map(e=>({type:W(e),value:null}))}}}function z(e){let t=e;for(;t;){if(t.prototype&&("esri.core.JSONSupport"===t.prototype.declaredClass||"esri.core.MultiOriginJSONSupport"===t.prototype.declaredClass))return!0;t=Object.getPrototypeOf(t)}return!1}function K(e){return e===String||e===Boolean||e===Number||e===y||e===Object||e===l}function U(e){if(!e.json)return null;const t=e.json.origins,r=e.json,n=t?.["web-scene"],a=t?.["web-document"];return n||a||r||null}function F(e){if(!e.json)return null;const t=e.json.origins,r=e.json.write,n=t?.["web-scene"]?.write,a=t?.["web-document"]?.write;return n||a||r||null}export{T as scan};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{collectClassPaths as e}from"./utils.js";function t(e){const t=r(e),n=[],i=
|
|
5
|
+
import{collectClassPaths as e}from"./utils.js";function t(e){const t=r(e),n=[],i=p(t),s=new Map;a("api","",e.api,t,i.api,s);const c=new Map;a("spec","",e.spec,t,i.spec,c);const u=o(t);for(const[a,p]of s){if("esri/rest/support/AlgorithmicColorRamp (colorRamp_algorithmic_part_schema.json) <algorithmic>"===a)continue;const e=c.get(a),t=u.get(p.container.id),o=`${p.container.name} (${e.container.name})${p.container.typeValue?` <${p.container.typeValue}>`:""}`;n.push({name:o,api:p,spec:e,indent:t})}return n}function n(e,t,p,o,r,s,c,u,l){if(c.has(o))return l;for(const f of o.properties){const m=t?`${t}.${f.name}`:f.name,d=p?`${p}.${f.name}`:f.name,g=r.get(d);if(g){const t=s.get(g[e].id);l.push({name:m,type:"ref",ref:g,refName:t,required:f.required,nullable:f.nullable}),a(e,d,g[e],r,s,u)}else"string"==typeof f.type?l.push(i(m,f)):(c.add(o),n(e,m,d,f.type,r,s,c,u,l))}return c.delete(o),l}function a(e,t,a,p,o,r){if(r.has(a.id))return r;const i={container:a,text:null,props:[]};return o.get(a.id).forEach(e=>r.set(e,i)),n(e,"",t,a,p,o,new Set,r,i.props),i.props.sort(s),r}function p(e){const t={api:new Map,spec:new Map};for(const n of e.values()){const e=`${n.api.name} (${n.spec.name})${n.api.typeValue?` <${n.api.typeValue}>`:""}`;let a=t.api.get(n.api.id);a||(a=new Set,t.api.set(n.api.id,a)),a.add(e);let p=t.spec.get(n.spec.id);p||(p=new Set,t.spec.set(n.spec.id,p)),p.add(e)}return t}function o(e){const t=new Map;for(const n of e.keys()){const a=n?n.split(".").length:0,p=e.get(n).api.id;t.has("id")?t.set(p,Math.min(a,t.get(p))):t.set(p,a)}return t}function r(t){const n=e(t.api),a=e(t.spec),p=new Map;p.set("",{api:t.api,spec:t.spec});for(const[e,o]of n){const t=a.get(e);t&&p.set(e,{api:o,spec:t})}return p}function i(e,t){return{name:e,type:t.enum||("string"==typeof t.type?t.type:""),default:JSON.stringify(t.default),required:t.required,nullable:t.nullable}}function s(e,t){const n=e.name.localeCompare(t.name);if(0!==n)return n;const a=(e.type||"").localeCompare(t.type||"");return 0!==a?a:(e.default||"").localeCompare(t.default||"")}export{t as collect};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{json as t}from"../../portal/schemas/webScene.js";import{ScanContext as r,sorted as n}from"./utils.js";function s(e,t){if(t.properties){if("layerType"in t.properties)return t.properties.layerType.enum[0];if("type"in t.properties&&t.properties.type.enum)return t.properties.type.enum[0]}switch(e){case"multipoint_geometry_schema.json":return"multipoint";case"point_geometry_schema.json":return"point";case"polyline_geometry_schema.json":return"polyline";case"polygon_geometry_schema.json":return"polygon";case"extent_schema.json":return"extent"}}function i(e){return"array"===e.type?`${i(e.items)}[]`:e.type}function a(e){const t={count:e.length,refsCount:0,typesCount:0,distinctTypes:[],type:null},r=new Set;for(const n in e){const s=e[n];s.$ref?t.refsCount++:s.type&&(t.typesCount++,r.add(i(s)))}return r.forEach(e=>t.distinctTypes.push(e)),t.distinctTypes.sort(),t.refsCount===t.count?t.type="refs":2===t.count&&t.refsCount>0&&1===t.distinctTypes.length&&"null"===t.distinctTypes[0]?t.type="refsAndNull":t.typesCount===t.count?(t.type="types",t.distinctTypes=t.distinctTypes):t.type="mix",t}function o(e,t){const r=t.stack[t.stack.length-1],n=t.definitions[r.klass.name];return n?.required&&n.required.includes(e.replace("[]",""))}function c(e){return"array"===e.type||!("properties"in e)}function l(e,t,r){if(!r.hasFilteredProperties)return`${e}--${t}`;return`${e}--${t}--${r.filteredPropertiesArray.join("/")}`}async function u(e,t,r,n,i){i.schemaStack.push(e);const
|
|
5
|
+
import e from"../../core/Error.js";import{json as t}from"../../portal/schemas/webScene.js";import{ScanContext as r,sorted as n}from"./utils.js";function s(e,t){if(t.properties){if("layerType"in t.properties)return t.properties.layerType.enum[0];if("type"in t.properties&&t.properties.type.enum)return t.properties.type.enum[0]}switch(e){case"multipoint_geometry_schema.json":return"multipoint";case"point_geometry_schema.json":return"point";case"polyline_geometry_schema.json":return"polyline";case"polygon_geometry_schema.json":return"polygon";case"extent_schema.json":return"extent"}}function i(e){return"array"===e.type?`${i(e.items)}[]`:e.type}function a(e){const t={count:e.length,refsCount:0,typesCount:0,distinctTypes:[],type:null},r=new Set;for(const n in e){const s=e[n];s.$ref?t.refsCount++:s.type&&(t.typesCount++,r.add(i(s)))}return r.forEach(e=>t.distinctTypes.push(e)),t.distinctTypes.sort(),t.refsCount===t.count?t.type="refs":2===t.count&&t.refsCount>0&&1===t.distinctTypes.length&&"null"===t.distinctTypes[0]?t.type="refsAndNull":t.typesCount===t.count?(t.type="types",t.distinctTypes=t.distinctTypes):t.type="mix",t}function o(e,t){const r=t.stack[t.stack.length-1],n=1===t.stack.length?t.schemaRoot:t.definitions[r.klass.name];return n?.required&&n.required.includes(e.replace("[]",""))}function c(e){return"array"===e.type||!("properties"in e)}function l(e,t,r){if(!r.hasFilteredProperties)return`${e}--${t}`;return`${e}--${t}--${r.filteredPropertiesArray.join("/")}`}async function u(e,t,r,n,i,a){i.schemaStack.push(e);const u=s(e,r),p=n?n.replace("<?TYPE?>",u?`<${u}>`:""):"";if(c(r)){const n=i.currentClass?null:{type:e,name:e,id:`${e}--${t}`,typeValue:t,properties:[]};return n&&i.push(null,n),await T(r,p,i,a),i.schemaStack.pop(),n}const f=l(e,t,i),h="drawingInfo_schema.json"!==e&&"layer_schema.json"!==e&&i.seen.get(f);if(h&&p)return i.addProperty({name:p,type:h,required:o(p,i),nullable:a?.nullable}),i.schemaStack.pop(),h;const m={type:e,name:e,id:f,typeValue:t,properties:[]};return p&&i.addProperty({name:p,type:m,required:o(p,i),nullable:a?.nullable}),i.push(p,m),await T(r,"",i),i.schemaStack.pop(),i.pop()}async function p(e,t,r,n){const s=await r.requestSchema(e.$ref),i=L(s.schema);if(i){for(const e of i){const i={...s.schema};i.properties={...i.properties,type:{type:"string",enum:[e]}};const a=t&&!t.includes("<?TYPE?>")?`${t}<?TYPE?>`:t;await u(s.schemaId,e,i,a,r,n)}return}const a="layer_schema.json"===s.schemaId&&r.schemaStack.length?r.schemaStack[r.schemaStack.length-1].replace(/_schema\.json/,""):null;await u(s.schemaId,a,s.schema,t,r,n)}function f(e,t){if(!m(e))return!1;const r=e.stack.map(e=>e.klass.type).join("/");return/.*pointCloudLayer_schema\.json\/layerDefinition_schema\.json\/drawingInfo_schema\.json$/.test(r)&&"renderer"===t}function h(e,t){if(!y(e)&&!d(e))return!1;const r=e.stack.map(e=>e.klass.type).join("/");return(/.*(imageServiceLayer|tiledImageServiceLayer|wcsLayer)_schema\.json\/(layerDefinition|rasterLayerDefinition)_schema\.json\/rasterDrawingInfo_schema\.json$/.test(r)||/.*rasterPresetRenderer_schema\.json$/.test(r))&&"renderer"===t}function m(e){return!!e.currentClass&&"drawingInfo_schema.json"===e.currentClass.name}function y(e){return!!e.currentClass&&"rasterDrawingInfo_schema.json"===e.currentClass.name}function d(e){return!!e.currentClass&&"rasterPresetRenderer_schema.json"===e.currentClass.name}function _(e){switch(e.schemaStack[e.schemaStack.length-1]){case"operationalLayers_schema.json":case"elevationLayers_schema.json":case"baseMapLayer_schema.json":return!0}return!1}const w=/raster.*Renderer|vectorFieldRenderer/,j=/(uniqueValueRenderer|classBreaksRenderer|raster.*Renderer|vectorFieldRenderer)/,$=/(rasterUniqueValueRenderer|rasterClassBreaksRenderer)/;function g(e,t,r){if(m(r)||y(r)||d(r)){const n=f(r,t),s=h(r,t);return e.filter(e=>{if(e.$ref.endsWith("uniqueValueFromStyleRenderer_schema.json"))return!1;if(s)return j.test(e.$ref)&&!$.test(e.$ref);if(w.test(e.$ref))return!1;const t=/pointCloud.*Renderer/.test(e.$ref);return n===t})}if(_(r)){const t=["kmlLayer","rasterDataElevationLayer","rasterDataLayer","object3DTilesLayer"];return e.filter(e=>!t.some(t=>e.$ref.replace(/.*\//,"")===`${t}_schema.json`))}return e}async function P(e,t,r){await T(e.items,`${t}[]`,r)}async function S(e,t,r){for(const n in e.properties)if(!("webscene_schema.json"===r.currentClass?.name&&"mapRangeInfo"===n||"baseMap_schema.json"===r.currentClass?.name&&"elevationLayers"===n)){if(m(r)){const e=r.stack.map(e=>e.klass.type).join("/");if(/imageServiceLayer|tiledImageServiceLayer/.test(e)&&"transparency"===n)continue}await r.withFilter(n,async()=>{const s=t?`${t}.${n}`:n;await T(e.properties[n],s,r)})}}function k(e,t="",r=new Set){for(const n of e)if("properties"in n)for(const e in n.properties){const s=n.properties[e],i=t?`${t}.${e}`:e,a=Object.keys(s);if(0===a.length||1===a.length&&"$ref"===a[0])r.add(i);else{if(1!==a.length||"allOf"!==a[0])throw new Error(`unexpected allOf filter construct: ${JSON.stringify(s)}`);r.add(i),k(s.allOf,i,r)}}return r}async function R(e,t,r){let n=null;for(const i of e.allOf)if("$ref"in i){if(n)throw new Error("Cannot process more than 1 ref in an allOf construct");n=i}else if(!("properties"in i))throw new Error("allOf construct only allows simple top-level property filters");const s=k(e.allOf);await r.addFilter(s,()=>p(n,t,r))}async function b(e,t,r){const s=a(e.oneOf),i="refsAndNull"===s.type;if("refs"===s.type||i){const n=g(e.oneOf,t,r);for(const e of n)if(i&&"null"===e.type);else{const s=`${t||""}`+(1!==n.length?"<?TYPE?>":"");await T(e,s,r,{nullable:i})}return}if("types"===s.type){const{types:e,nullable:i}=C(s.distinctTypes);return void r.addProperty({name:t,type:n(e).join("|"),required:o(t,r),nullable:i})}for(const n in e.oneOf){const s=`.oneOf[${n}]`;await T(e.oneOf[n],`${t}${s}`,r)}}function C(e){const t=e.indexOf("null");if(-1===t)return{types:e};const r=e.slice();return r.splice(t,1),{types:r,nullable:!0}}function L(e){if("layerDefinition"===e.title)return null;const t=e.properties?.type;return t?.enum?t.enum:null}async function q(e,t,r,n){await p(e,t,r,n)}async function O(e,t,r){let s,i="unknown";if(e.type){const{types:t,nullable:r}=C(Array.isArray(e.type)?e.type:e.type.replaceAll(" ","").split(","));i=n(t).join("|"),s=r}const a={name:t,type:i,default:e.default,required:o(t,r),nullable:s};e.enum&&(a.enum=n(e.enum).map(e=>"string"==typeof e?`"${e}"`:`${e}`).join("|")),r.addProperty(a)}async function T(e,t,r,n){return"array"===e.type?P(e,t,r):"properties"in e?S(e,t,r):"allOf"in e?R(e,t,r):"oneOf"in e?b(e,t,r):"$ref"in e?q(e,t,r,n):O(e,t,r)}const E="#/definitions/";function v(e){return e.startsWith(E)?e.slice(E.length):e}async function I(e,t){const r=await F.create(e,t);return u(`${e||"webscene"}_schema.json`,null,r.schemaRoot,null,r)}class F extends r{constructor(e,t,r){super(),this.definitions=e,this.schemaRoot=t,this.requestSchema=r,this._filteredProperties=null,this.schemaStack=[],this.requestSchema.bind(this)}get hasFilteredProperties(){return(this._filteredProperties?.size??0)>0}get filteredPropertiesArray(){const e=[];return this._filteredProperties?.forEach(t=>e.push(t)),e}async withFilter(e,t){if(!this.hasFilteredProperties)return t();if(!this._filteredProperties?.has(e))return;const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r.forEach(t=>{const r=t.split(".",2);r.length>1&&r[0]===e&&n(r[1])}),await t(),this._filteredProperties=r}async addFilter(e,t){const r=this._filteredProperties;this._filteredProperties=null;const n=e=>{this._filteredProperties||(this._filteredProperties=new Set),this._filteredProperties.add(e)};r&&r.forEach(n),e&&e.forEach(n);const s=await t();return this._filteredProperties=r,s}static async create(e,t){return t?.useRemoteSchema?F.createRemote(e,t?.baseUrl):F.createLocal(e)}static createLocal(e){const r=e&&"webscene"!==e?t.definitions[`${e}_schema.json`]:t;return new F(t.definitions,r,F._getLocalSchemaRequest())}static async createRemote(e,t){const r=await F._getRemoteSchemaRequest(t),n=new F({},null,r),s=(await n.requestSchema(`${e||"webscene"}_schema.json`)).schema;return new F(n.definitions,s,r)}static _getLocalSchemaRequest(){return function(t){const r=v(t),n=this.definitions[r];return n?Promise.resolve({schemaId:r,schema:n}):Promise.reject(new e("spec-certification:spec-invalid-local-schema","Schema reference is not a local reference"))}}static async _getRemoteSchemaRequest(t){if(!t)return Promise.reject(new e("spec-certification:spec-missing-base-url","The base url of the remote schema directory must be specified when using a remote schema"));const r=F._getLocalSchemaRequest(),n=(await import("../../request.js")).default;return function(e){return r.call(this,e).catch(()=>n(`${t}/${e}`,{responseType:"json"}).then(t=>(this.definitions[v(e)]=t.data,{schemaId:e,schema:t.data})))}}}const D=Object.keys(t.definitions).map(e=>e.replace(/_schema\.json$/,""));export{I as scan,D as schemaDefinitions};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{splitIntoChunks as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as r,after as o,isAbortError as n,throwIfNotAbortError as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Multipoint.js";import{unnormalizedCoordinate as l}from"../../../geometry/support/coordsUtils.js";import{getInfo as a}from"../../../geometry/support/spatialReferenceUtils.js";import{ScheduledQueueProcessor as c}from"../../../views/support/ScheduledQueueProcessor.js";import{TaskPriority as u}from"../../../views/support/Scheduler.js";import{getConfig as p,errorResult as f}from"./constants.js";import{isValidInputPath as m,countPoints as d,densifyPath as h}from"./geometryUtils.js";import{ProfileGenerationError as y}from"./ProfileGenerationError.js";import{getStatistics as w}from"./statisticsUtils.js";import{breadthFirstBinaryPartitioning as g}from"../../support/traversalUtils.js";async function*v(e,t){const{view:n,geometry:s,elevationInfo:i,providers:l,options:a}=e,c=n.spatialReference;if(!c||null==s||!m(s))throw new y("invalid-geometry");const u=l.length;if(0===u)return null;const f=Math.round(a.maxTotalSamples/u);if(d(s)>f)throw new y("too-complex");const w=await h(s,i,n,c,a,f,t);let g=0;const v=new Array(u),j=new Array(u);for(let r=0;r<u;r++){const o=S(w);v[r]=o,g+=o.samples.length;const n={...e,provider:l[r],result:o,densificationResult:w};j[r]=P(n,t)[Symbol.iterator]()}if(g>a.maxTotalSamples)throw new y("too-complex");const R=await Promise.all(j.map(e=>{const t=e.next();return!0===t.done?Promise.resolve(null):t.value}));r(t);for(let r=0;r<u;r++)v[r]=R[r];yield v,await o(e.delayAfterPreview??p().delayAfterPreviewMillis,null,t.signal);const Z=[];try{let e;do{e=!1;for(let t=0;t<u;t++){const r=j[t].next();!1===r.done&&(Z.push({resultPromise:r.value,index:t}),e=!0)}}while(e)}finally{j.forEach(e=>e.return?.())}for(const{resultPromise:o,index:p}of Z)v[p]=await o,r(t),yield v;for(const r of v)null!=r&&(r.progress=1);yield v}function*P(t,r){const{densificationResult:o}=t,n={...t,abortOptions:r,densificationResult:o},s=g(0,n.result.samples.length),i=s.slice(0,n.provider.numSamplesForPreview);yield j(n,i,!0);const l=e(s,n.provider.numSamplesPerChunk);for(const e of l)yield j(n,e,!1)}async function j({densificationResult:e,result:t,provider:r,queue:o,abortOptions:s,cache:l},a,c){const{densifiedPath:u,pathLength:m}=e,d=t.spatialReference,{samples:h}=t,y=[];for(let n=0;n<a.length;n++){const e=h[a[n]];y[n]=e.coordinate}try{return await o.push({geometry:new i({spatialReference:d,points:y,hasZ:u.hasZ}),provider:r,indices:a,preview:c,result:t,queryOptions:{...p().defaultQueryOptions(),minDemResolution:c?Math.round(m/r.numSamplesForPreview):Math.round(m/h.length),cache:l}},s),{...t}}catch(w){return n(w)?null:f}}function R(e){return new c({priority:u.ELEVATION_PROFILE,concurrency:1,scheduler:e,process:async e=>{r(e.queryOptions);try{await Z(e)}catch(t){s(t)}}})}async function Z({geometry:e,provider:t,indices:r,preview:o,result:n,queryOptions:s}){if(0===r.length)return;const i=(await M(t,e,s)).geometry,{hasZ:l,points:a}=i,c=s.noDataValue,{samples:u}=n;for(let p=0;p<r.length;p++){const e=u[r[p]];if(e.isHole)continue;const t=l?a[p][2]:null;null===t||t===c?e.sampledZ=null:(n.hasZ=!0,e.sampledZ=t),e.sampled=!0}x(u),n.progress=o?0:n.progress+r.length/u.length,n.statistics=w(n.samples,n.spatialReference)}function x(e){const t=e.length-1;let r=0;for(let o=1;o<=t;o++){(e[o].sampled||o===t)&&(O(e,r,o),r=o)}}function O(e,r,o){if(o-r===1)return;const n=e[r],s=n.sampledZ,i=e[o],l=i.sampledZ;if(null==s||null==l){for(let t=r+1;t<o;t++)e[t].sampledZ=null;return}const a=n.distance,c=i.distance-a;for(let u=r+1;u<o;u++){const r=e[u],o=(r.distance-a)/c;r.sampledZ=t(s,l,o)}}function S({densifiedPath:e,distances:t}){const r=e.spatialReference,o=a(r),n=e.paths,s=n.length,i=[];let c=null,u=0;for(let a=0;a<s;a++){const e=n[a],r=e.length,s=t[a];for(let t=0;t<r;t++){const r=e[t],n=s[t];o&&(r[0]=l(r[0],o.valid[0],o.valid[1])),c&&0===t&&U(i,c,r,u,n),i.push(q(r,n)),c=r,u=n}}return{progress:0,samples:i,hasZ:!1,statistics:null,spatialReference:r}}function U(e,t,r,o,n){e.push(E(t,o)),e.push(E(r,n))}function q(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!1,isHole:!1}}function E(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!0,isHole:!0}}async function M(e,t,r){try{return await e.queryElevation(t,r)}catch(o){throw new y("elevation-query-error")}}function A(e,t,r){if(!e||0===e.length)return;const o=e.length-1,n=e[0];if(t<=r(n))return n;const s=e[o];if(t>=r(s))return s;let i=0,l=0,a=o;for(;i<a;){l=i+Math.floor((a-i)/2);const n=e[l],s=r(n);if(s===t)return n;if(t<s){if(l>0){const o=e[l-1],i=r(o);if(t>i)return t-i>=s-t?n:o}a=l}else{if(l<o){const o=e[l+1],i=r(o);if(t<i)return t-s>=i-t?o:n}i=l+1}}return e[l]}export{A as binaryFindClosest,R as createProfileQueue,P as generateProfile,v as generateProfiles,x as interpolateElevations};
|
|
5
|
+
import{splitIntoChunks as e}from"../../../core/arrayUtils.js";import{lerp as t}from"../../../core/mathUtils.js";import{throwIfAborted as r,after as o,isAbortError as n,throwIfNotAbortError as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Multipoint.js";import{unnormalizedCoordinate as l}from"../../../geometry/support/coordsUtils.js";import{getInfo as a}from"../../../geometry/support/spatialReferenceUtils.js";import{ScheduledQueueProcessor as c}from"../../../views/support/ScheduledQueueProcessor.js";import{TaskPriority as u}from"../../../views/support/Scheduler.js";import{getConfig as p,errorResult as f}from"./constants.js";import{isValidInputPath as m,countPoints as d,densifyPath as h}from"./geometryUtils.js";import{ProfileGenerationError as y}from"./ProfileGenerationError.js";import{getStatistics as w}from"./statisticsUtils.js";import{breadthFirstBinaryPartitioning as g}from"../../support/traversalUtils.js";async function*v(e,t){const{view:n,geometry:s,elevationInfo:i,providers:l,options:a}=e,c=n.spatialReference;if(!c||null==s||!m(s))throw new y("invalid-geometry");const u=l.length;if(0===u)return null;const f=Math.round(a.maxTotalSamples/u);if(d(s)>f)throw new y("too-complex");const w=await h(s,i,n,c,a,f,t);let g=0;const v=new Array(u),j=new Array(u);for(let r=0;r<u;r++){const o=S(w);v[r]=o,g+=o.samples.length;const n={...e,provider:l[r],result:o,densificationResult:w};j[r]=P(n,t)[Symbol.iterator]()}if(g>a.maxTotalSamples)throw new y("too-complex");const R=await Promise.all(j.map(e=>{const t=e.next();return!0===t.done?Promise.resolve(null):t.value}));r(t);for(let r=0;r<u;r++)v[r]=R[r];yield v,await o(e.delayAfterPreview??p().delayAfterPreviewMillis,null,t.signal);const Z=[];try{let e;do{e=!1;for(let t=0;t<u;t++){const r=j[t].next();!1===r.done&&(Z.push({resultPromise:r.value,index:t}),e=!0)}}while(e)}finally{j.forEach(e=>e.return?.())}for(const{resultPromise:o,index:p}of Z)v[p]=await o,r(t),yield v;for(const r of v)null!=r&&(r.progress=1);yield v}function*P(t,r){const{densificationResult:o}=t,n={...t,abortOptions:r,densificationResult:o},s=g(0,n.result.samples.length),i=s.slice(0,n.provider.numSamplesForPreview);yield j(n,i,!0);const l=e(s,n.provider.numSamplesPerChunk);for(const e of l)yield j(n,e,!1)}async function j({densificationResult:e,result:t,provider:r,queue:o,abortOptions:s,cache:l},a,c){const{densifiedPath:u,pathLength:m}=e,d=t.spatialReference,{samples:h}=t,y=[];for(let n=0;n<a.length;n++){const e=h[a[n]];y[n]=[...e.coordinate]}try{return await o.push({geometry:new i({spatialReference:d,points:y,hasZ:u.hasZ}),provider:r,indices:a,preview:c,result:t,queryOptions:{...p().defaultQueryOptions(),minDemResolution:c?Math.round(m/r.numSamplesForPreview):Math.round(m/h.length),cache:l}},s),{...t}}catch(w){return n(w)?null:f}}function R(e){return new c({priority:u.ELEVATION_PROFILE,concurrency:1,scheduler:e,process:async e=>{r(e.queryOptions);try{await Z(e)}catch(t){s(t)}}})}async function Z({geometry:e,provider:t,indices:r,preview:o,result:n,queryOptions:s}){if(0===r.length)return;const i=(await M(t,e,s)).geometry,{hasZ:l,points:a}=i,c=s.noDataValue,{samples:u}=n;for(let p=0;p<r.length;p++){const e=u[r[p]];if(e.isHole)continue;const t=l?a[p][2]:null;null===t||t===c?e.sampledZ=null:(n.hasZ=!0,e.sampledZ=t),e.sampled=!0}x(u),n.progress=o?0:n.progress+r.length/u.length,n.statistics=w(n.samples,n.spatialReference)}function x(e){const t=e.length-1;let r=0;for(let o=1;o<=t;o++){(e[o].sampled||o===t)&&(O(e,r,o),r=o)}}function O(e,r,o){if(o-r===1)return;const n=e[r],s=n.sampledZ,i=e[o],l=i.sampledZ;if(null==s||null==l){for(let t=r+1;t<o;t++)e[t].sampledZ=null;return}const a=n.distance,c=i.distance-a;for(let u=r+1;u<o;u++){const r=e[u],o=(r.distance-a)/c;r.sampledZ=t(s,l,o)}}function S({densifiedPath:e,distances:t}){const r=e.spatialReference,o=a(r),n=e.paths,s=n.length,i=[];let c=null,u=0;for(let a=0;a<s;a++){const e=n[a],r=e.length,s=t[a];for(let t=0;t<r;t++){const r=e[t],n=s[t];o&&(r[0]=l(r[0],o.valid[0],o.valid[1])),c&&0===t&&U(i,c,r,u,n),i.push(q(r,n)),c=r,u=n}}return{progress:0,samples:i,hasZ:!1,statistics:null,spatialReference:r}}function U(e,t,r,o,n){e.push(E(t,o)),e.push(E(r,n))}function q(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!1,isHole:!1}}function E(e,t){return{coordinate:e,distance:t,sampledZ:null,sampled:!0,isHole:!0}}async function M(e,t,r){try{return await e.queryElevation(t,r)}catch(o){throw new y("elevation-query-error")}}function A(e,t,r){if(!e||0===e.length)return;const o=e.length-1,n=e[0];if(t<=r(n))return n;const s=e[o];if(t>=r(s))return s;let i=0,l=0,a=o;for(;i<a;){l=i+Math.floor((a-i)/2);const n=e[l],s=r(n);if(s===t)return n;if(t<s){if(l>0){const o=e[l-1],i=r(o);if(t>i)return t-i>=s-t?n:o}a=l}else{if(l<o){const o=e[l+1],i=r(o);if(t<i)return t-s>=i-t?o:n}i=l+1}}return e[l]}export{A as binaryFindClosest,R as createProfileQueue,P as generateProfile,v as generateProfiles,x as interpolateElevations};
|