Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
8.7 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../../chunks/tslib.es6 ../../../core/Accessor ../../../core/Evented ../../../core/has ../../../core/promiseUtils ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/Logger ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../geometry/projection ../../../support/elevationInfoUtils ../sketch/normalizedPoint ./Settings ./SnappingDomain ./snappingFactory ./SnappingOptions ./snappingUtils ./candidates/DrapedEdgeSnappingCandidate ./candidates/EdgeSnappingCandidate ./candidates/IntersectionSnappingCandidate ./candidates/LineSnappingCandidate ./candidates/ParallelLineSnappingCandidate ./candidates/RightAngleSnappingCandidate ./candidates/RightAngleTriangleSnappingCandidate ../support/viewUtils".split(" "),
function(m,p,F,G,S,H,t,r,T,U,I,x,y,n,B,v,J,K,C,L,M,w,N,O,D,P,Q){function z(a,b){return!b||null==b.direction&&null==b.distance?!0:a instanceof L.DrapedEdgeSnappingCandidate||a instanceof M.EdgeSnappingCandidate||a instanceof N.LineSnappingCandidate||a instanceof O.ParallelLineSnappingCandidate||a instanceof P.RightAngleTriangleSnappingCandidate||a instanceof D.RightAngleSnappingCandidate&&(null!=b.direction||a.selfSnappingType!==D.SelfSnappingRightAngleType.LastVertex)?!1:!0}function A(a,b){let c=
-1;for(let d=0;d<a.length;++d)if(b.constraint.equals(a[d].constraint)){c=d;break}return c}function R({coordinateHelper:a,elevationInfo:b}){return a.hasZ()?y.absoluteHeightElevationInfo:b}m.SnappingManager=class extends G.EventedMixin(F){constructor(a){super(a);this.options=new K;this.snappingEnginesFactory=J.defaultSnappingEnginesFactory;this._engines=[];this._currentMainCandidate=null;this._currentOtherActiveCandidates=[];this._currentSnappedType=q.MAIN}initialize(){this.addHandles([t.watch(()=>
{const {effectiveFeatureEnabled:a,effectiveSelfEnabled:b,touchSensitivityMultiplier:c,distance:d}=this.options;return{effectiveFeatureEnabled:a,effectiveSelfEnabled:b,touchSensitivityMultiplier:c,distance:d}},()=>{this.doneSnapping();this.emit("changed")},t.sync),t.watch(()=>this.options,a=>{for(const b of this._engines)b.options=a},t.sync),t.watch(()=>({viewReady:this.view.ready,viewSpatialReference:this.view.spatialReference,snappingEnginesFactory:this.snappingEnginesFactory}),({viewReady:a,snappingEnginesFactory:b})=>
this._recreateEngines(a,b),t.syncAndInitial)])}destroy(){this._destroyEngines()}get updating(){return this._engines.some(a=>a.updating)}_recreateEngines(a,b){this._destroyEngines();if(a){var {view:c,options:d}=this;this._engines=b(c,d)}}_destroyEngines(){for(const a of this._engines)a.destroy();this._engines=[]}get _squaredMouseProximityThreshold(){return this.options.distance*this.options.distance}get _squaredTouchProximityThreshold(){const {distance:a,touchSensitivityMultiplier:b}=this.options,
c=a*b;return c*c}snap(a){return null!=a.scenePoint?this._snapMultiPoint(a):this._snapSinglePoint(a)}update(a){const {point:b,context:c}=a;this._removeVisualization();const d=this._currentMainCandidate;if(null==d)return b;var e=this._selectUpdateInput(a);if(null==e)return b;({spatialReference:a}=c);var f=x.project(e,a);if(null==f)return b;({view:e}=this);const {elevationInfo:l,visualizer:k}=c,g=[];f=n.fromPoint(f,e,l);const h=d.constraint.closestTo(f);if(!this._arePointsWithinScreenThreshold(f,h,c)||
!z(d,c.drawConstraints))return this._resetSnappingState(),b;d.targetPoint=n.markAsTarget(h);g.push(...d.hints);for(const u of this._currentOtherActiveCandidates)z(u,c.drawConstraints)&&(u.targetPoint=n.markAsTarget(h),g.push(...u.hints));null!=k&&this.addHandles(k.draw(g,{spatialReference:a,elevationInfo:R(c),view:e,selfSnappingZ:c.selfSnappingZ}),"visualization-handle");return n.toElevationAlignedDehydratedPoint(h,e,b,c)}doneSnapping(){this._removeVisualization();this._resetSnappingState()}_selectUpdateInput({point:a,
scenePoint:b}){switch(this._currentSnappedType){case q.MAIN:return a;case q.SCENE:return b}}_resetSnappingState(){this._currentMainCandidate=null;this._currentOtherActiveCandidates=[];this._currentSnappedType=q.MAIN}_removeVisualization(){this.removeHandles("visualization-handle")}async _snapSinglePoint({point:a,context:b,signal:c}){const {view:d}=this;var {elevationInfo:e}=b;e=n.fromPoint(a,d,e);const f=await this._fetchCandidates(e,v.SnappingDomain.ALL,b,c);return this._createSnapResult(e,q.MAIN,
f,d,a,b,c)}async _snapMultiPoint({point:a,scenePoint:b,context:c,signal:d}){const {view:e}=this,{coordinateHelper:f,elevationInfo:l,spatialReference:k}=c;await x.initializeProjection(b.spatialReference,k);b=x.project(b,k);var g=n.fromPoint(b,e,l);const h=await this._fetchCandidates(g,v.SnappingDomain.FEATURE,c,d);if(0<h.length)return a=await this._fetchCandidates(g,v.SnappingDomain.SELF,c,d),this._createSnapResult(g,q.SCENE,[...h,...a],e,b,c,d);b=n.fromPoint(a,e,l);g=await this._fetchCandidates(b,
v.SnappingDomain.SELF,c,d);return this._createSnapResult(b,q.MAIN,g,e,{z:f.hasZ()&&a.hasZ?a.z??0:void 0,m:f.hasM()&&a.hasM?a.m??0:void 0},c,d)}async _fetchCandidates(a,b,c,d){return(await Promise.all(this._engines.map(e=>e.fetchCandidates(a,b,c,d)))).flat()}_createSnapResult(a,b,c,d,e,f,l){return{get valid(){return!H.isAborted(l)},apply:()=>{const {spatialReference:k}=f,{snappedPoint:g,hints:h}=this._processCandidates(a,b,c,f);this._removeVisualization();null!=f.visualizer&&this.addHandles(f.visualizer.draw(h,
{spatialReference:k,elevationInfo:y.absoluteHeightElevationInfo,view:d,selfSnappingZ:f.selfSnappingZ}),"visualization-handle");return n.toElevationAlignedDehydratedPoint(g,d,e,f)}}}_processCandidates(a,b,c,d){if(1>c.length)return this.doneSnapping(),{snappedPoint:a,hints:[]};this._currentSnappedType!==b&&this._resetSnappingState();C.sortCandidatesInPlace(a,c);const e=this._currentMainCandidate;if(null!=e){var f=e instanceof w.IntersectionSnappingCandidate?0<=A(c,e.first)&&0<=A(c,e.second)?0:-1:A(c,
e);if(0<=f)if(c[f]instanceof w.IntersectionSnappingCandidate){if(this._arePointsWithinScreenThreshold(a,e.targetPoint,d))return this._updateSnappingCandidate(e,b,c,d)}else return this._intersectWithOtherCandidates(f,c,a,b,d)}return this._intersectWithOtherCandidates(0,c,a,b,d)}_intersectWithOtherCandidates(a,b,c,d,e){const {coordinateHelper:f}=e,l=b[a],k=[];for(let g=0;g<b.length;++g){if(g===a)continue;const h=b[g],u=l.constraint.intersect(h.constraint);if(u)for(const E of u.closestPoints(l.targetPoint))k.push([new w.IntersectionSnappingCandidate(n.markAsTarget(E),
l,h,h.isDraped),this._squaredScreenDistance(c,E,f)])}return 0<k.length&&(k.sort((g,h)=>g[1]-h[1]),k[0][1]<this._squaredPointProximityThreshold(e.pointer))?this._updateSnappingCandidate(k[0][0],d,b,e):z(l,e.drawConstraints)?this._updateSnappingCandidate(l,d,b,e):{snappedPoint:c,hints:[]}}_updateSnappingCandidate(a,b,c,d){this.doneSnapping();this._currentMainCandidate=a;this._currentSnappedType=b;b=this._currentMainCandidate.targetPoint;const e=[];e.push(...a.hints);for(const f of c){if(a instanceof
w.IntersectionSnappingCandidate){if(f.constraint.equals(a.first.constraint)||f.constraint.equals(a.second.constraint))continue}else if(f.constraint.equals(a.constraint))continue;c=f.constraint.closestTo(b);this._squaredScreenDistance(c,b,d.coordinateHelper)<B.defaults.satisfiesConstraintScreenThreshold*B.defaults.satisfiesConstraintScreenThreshold&&(f.targetPoint=b,this._currentOtherActiveCandidates.push(f),e.push(...f.hints))}return{snappedPoint:b,hints:e}}_squaredPointProximityThreshold(a){return"touch"===
a?this._squaredTouchProximityThreshold:this._squaredMouseProximityThreshold}_arePointsWithinScreenThreshold(a,b,c){return this._squaredScreenDistance(a,b,c.coordinateHelper)<this._squaredPointProximityThreshold(c.pointer)}_squaredScreenDistance(a,b,c){return C.squaredScreenDistance(this._toScreen(a,c),this._toScreen(b,c))}_toScreen(a,b){return Q.vectorToScreenPoint(a,b.spatialReference,y.absoluteHeightElevationInfo,this.view)}get test(){}};p.__decorate([r.property({constructOnly:!0})],m.SnappingManager.prototype,
"view",void 0);p.__decorate([r.property()],m.SnappingManager.prototype,"options",void 0);p.__decorate([r.property({readOnly:!0})],m.SnappingManager.prototype,"updating",null);p.__decorate([r.property()],m.SnappingManager.prototype,"snappingEnginesFactory",void 0);p.__decorate([r.property()],m.SnappingManager.prototype,"_engines",void 0);p.__decorate([r.property()],m.SnappingManager.prototype,"_squaredMouseProximityThreshold",null);p.__decorate([r.property()],m.SnappingManager.prototype,"_squaredTouchProximityThreshold",
null);m.SnappingManager=p.__decorate([I.subclass("esri.views.interactive.snapping.SnappingManager")],m.SnappingManager);var q;(function(a){a[a.MAIN=0]="MAIN";a[a.SCENE=1]="SCENE"})(q||={});Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});