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.
 
 

19 lines
8.8 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("require exports ../../../chunks/tslib.es6 ../../../core/Accessor ../../../core/arrayUtils ../../../core/handleUtils ../../../core/has ../../../core/promiseUtils ../../../core/reactiveUtils ../../../core/unitUtils ../../../core/accessorSupport/decorators/property ../../../core/Logger ../../../core/accessorSupport/decorators/subclass ../../../core/libs/gl-matrix-2/math/vec2 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../core/libs/gl-matrix-2/math/common ../../../core/support/UpdatingHandles ../../../support/elevationInfoUtils ../sketch/constraints ../sketch/normalizedPoint ./FeatureSnappingSourceInfo ./SnappingDomain ./snappingUtils ./candidates/DrapedEdgeSnappingCandidate ./candidates/EdgeSnappingCandidate ./candidates/FeatureSnappingCandidate ./candidates/RightAngleSnappingCandidate ../support/viewUtils".split(" "),
function(q,k,n,I,J,K,U,t,u,y,r,V,L,v,z,A,M,N,B,O,l,C,D,E,P,Q,R,F,G){function S({constraint:{start:a,end:c}}){const b=z.squaredDistance(a,c);a=v.squaredDistance(l.asVec2(a),l.asVec2(c));return b<M.getEpsilon()||1E-4>a/b}function w(a,c,b,d,g,e,{spatialReference:f}){c=z.copy(T,c);c[0]+=b;c[1]+=d;c[2]+=g;return(b=G.vectorToScreenPoint(c,f,B.absoluteHeightElevationInfo,e))?E.screenDistance(b,a):Infinity}k.FeatureSnappingEngine=class extends I{get updating(){return this._snappingSources.some(a=>null==a?.valid||
!0===a.valid&&!0===a.snappingSource?.updating)||this._updatingHandles.updating}constructor(a){super(a);this.options=null;this._domain=D.SnappingDomain.FEATURE;this._updatingHandles=new N.UpdatingHandles;this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){const a=u.mapCollectionAsync(()=>this.options?._effectiveFeatureSources,(c,b)=>
this._createSourceInfo(c,b));this._snappingSources=a;this.addHandles([K.destroyHandle(a),u.watch(()=>({rulesEnabled:!!this.options?.attributeRulesEnabled,sources:this._snappingSources.filter(J.isSome)}),({rulesEnabled:c,sources:b})=>{for(const d of b)d.attributeRulesEnabled=c},u.sync)])}destroy(){this._set("options",null);this._updatingHandles.destroy()}async fetchCandidates(a,c,b,d){if(!(c&this._domain&&null!=this.options&&this.options.effectiveFeatureEnabled))return[];const g=[];c=this._computeScreenSizeDistanceParameters(a,
b);for(const f of this._snappingSources){if(!f?.valid||!f.snappingSource?.layerSource?.enabled||f.layerView?.suspended)continue;const h=f.getFetchCandidatesParameters(a,b,c);for(var e of h)g.push(f.snappingSource.fetchCandidates(e,d).then(m=>m.filter(x=>!this._candidateIsExcluded(f.snappingSource,x,b.excludeFeature))))}e=(await t.allSettledValues(g)).flat();this._addRightAngleCandidates(e,a,c,b);t.throwIfAborted(d);E.sortCandidatesInPlace(a,e);return e}_addRightAngleCandidates(a,c,b,d){var g=null!=
d.vertexHandle?d.vertexHandle.rightEdge?.rightVertex?.pos:null!=d.editGeometryOperations&&"polygon"===d.editGeometryOperations.data.type?d.editGeometryOperations.data.components[0]?.getFirstVertex()?.pos:null,e=null!=d.vertexHandle?d.vertexHandle.leftEdge?.leftVertex?.pos:null!=d.editGeometryOperations?d.editGeometryOperations.data.components[0]?.getLastVertex()?.pos:null,{view:f}=this;g=l.fromAnyMapPoint(g,f,d);d=l.fromAnyMapPoint(e,f,d);e=a.length;for(f=0;f<e;f++)this._addRightAngleCandidate(a[f],
d,c,b,a),this._addRightAngleCandidate(a[f],g,c,b,a)}_addRightAngleCandidate(a,c,b,d,g){var e;(e=null==c)||(e=!((a instanceof Q.EdgeSnappingCandidate||a instanceof P.DrapedEdgeSnappingCandidate)&&!S(a)));if(!e){e=a.constraint.closestTo(c);var f=(e[0]-b[0])/d.x;b=(e[1]-b[1])/d.y;var {start:h,end:m}=a.constraint;1>=f*f+b*b&&(b=v.squaredDistance(l.asVec2(e),l.asVec2(h))>v.squaredDistance(l.asVec2(e),l.asVec2(m))?h:m,a=new F.RightAngleSnappingCandidate({targetPoint:l.markAsTarget(e),otherVertex:c,otherVertexType:F.OtherVertexType.NEXT,
previousVertex:b,constraint:new O.VerticalHalfPlaneConstraint(c,e),objectId:a.objectId,isDraped:a.isDraped,domain:D.SnappingDomain.FEATURE}),g.push(a))}}_computeScreenSizeDistanceParameters(a,c){let b=null!=this.options?this.options.distance*("touch"===c.pointer?this.options.touchSensitivityMultiplier:1):0;return null==this.view?{x:b,y:b,z:b,distance:b}:"2d"===this.view.type?(b*=this.view.resolution,{x:b,y:b,z:b,distance:b}):this._computeScreenSizeDistanceParameters3D(a,b,this.view,c)}_computeScreenSizeDistanceParameters3D(a,
c,b,d){var {spatialReference:g}=d;b.renderCoordsHelper.toRenderCoords(a,g,H);const e=b.state.camera.computeScreenPixelSizeAt(H);var f=e*b.renderCoordsHelper.unitInMeters,h=f/y.getMetersPerUnitForSR(g);const m=f/y.getMetersPerVerticalUnitForSR(g);f=c*h;const x=c*m,p=G.vectorToScreenPoint(a,g,B.absoluteHeightElevationInfo,b);g=p?w(p,a,h,0,0,b,d):0;h=p?w(p,a,0,h,0,b,d):0;a=p?w(p,a,0,0,m,b,d):0;return{x:0===g?0:f/g,y:0===h?0:f/h,z:0===a?0:x/a,distance:e*c}}_candidateIsExcluded(a,c,b){if(null==b)return!1;
c=this._getCandidateObjectId(c);if(null==c)return!1;a=a.layerSource.layer;return"graphics"===a.type?b.uid===c:b.sourceLayer===a&&b.attributes&&"objectIdField"in a?b.attributes[a.objectIdField]===c:!1}_getCandidateObjectId(a){return a instanceof R.FeatureSnappingCandidate?a.objectId:null}async _createSourceInfo(a,c){const b=a.layer;b.loaded||(await b.load(),t.throwIfAborted(c));const {view:d}=this;a=await this._createFeatureSnappingSourceType(a);t.throwIfAborted(c);return null==a?new C.FeatureSnappingSourceInfo({}):
new C.FeatureSnappingSourceInfo({snappingSource:a,view:d,layer:b})}async _createFeatureSnappingSourceType(a){switch(a.layer.type){case "feature":case "geojson":case "csv":case "oriented-imagery":case "subtype-group":case "wfs":return this._createFeatureSnappingSourceFeatureLayer(a);case "graphics":return this._createFeatureSnappingSourceGraphicsLayer(a);case "map-notes":return this._createFeatureSnappingSourceMapNotesLayer(a);case "scene":case "building-scene":return this._createFeatureSnappingSourceSceneLayer(a)}return null}async _createFeatureSnappingSourceSceneLayer(a){const {view:c}=
this;return null==c||"3d"!==c.type?null:new ((await this._getSourceModule("scene")).SceneLayerSnappingSource)({layerSource:a,view:c})}async _createFeatureSnappingSourceFeatureLayer(a){switch(a.layer.source?.type){case "feature-layer":case "oriented-imagery":return new ((await this._getSourceModule("featureService")).FeatureServiceSnappingSource)({spatialReference:this.spatialReference,view:this.view,layerSource:a});case "memory":case "csv":case "geojson":case "wfs":if("mesh"!==a.layer.geometryType)return new ((await this._getSourceModule("featureCollection")).FeatureCollectionSnappingSource)({layerSource:a,
view:this.view})}return null}async _createFeatureSnappingSourceGraphicsLayer(a){return new ((await this._getSourceModule("graphics")).GraphicsSnappingSource)({getGraphicsLayers:()=>[a.layer],spatialReference:this.spatialReference,view:this.view,layerSource:a})}async _createFeatureSnappingSourceMapNotesLayer(a){return new ((await this._getSourceModule("notes")).GraphicsSnappingSource)({getGraphicsLayers:()=>a.layer.sublayers?.toArray()??[],spatialReference:this.spatialReference,view:this.view,layerSource:a})}async _getSourceModule(a){var c=
this._sourceModules[a];if(null==c.loader){c=this._loadSourceModule(a);this._sourceModules[a]={module:null,loader:c};const b=await c;this._sourceModules[a]={module:b,loader:c};return b}return null==c.module?c.loader:c.module}_loadSourceModule(a){const c=this._updatingHandles;switch(a){case "featureService":return c.addPromise(new Promise((b,d)=>q(["./featureSources/FeatureServiceSnappingSource"],b,d)));case "featureCollection":return c.addPromise(new Promise((b,d)=>q(["./featureSources/FeatureCollectionSnappingSource"],
b,d)));case "graphics":return c.addPromise(new Promise((b,d)=>q(["./featureSources/GraphicsSnappingSource"],b,d)));case "notes":return c.addPromise(new Promise((b,d)=>q(["./featureSources/GraphicsSnappingSource"],b,d)));case "scene":return c.addPromise(new Promise((b,d)=>q(["./featureSources/SceneLayerSnappingSource"],b,d)))}}get test(){}};n.__decorate([r.property({constructOnly:!0})],k.FeatureSnappingEngine.prototype,"spatialReference",void 0);n.__decorate([r.property({constructOnly:!0})],k.FeatureSnappingEngine.prototype,
"view",void 0);n.__decorate([r.property()],k.FeatureSnappingEngine.prototype,"options",void 0);n.__decorate([r.property({readOnly:!0})],k.FeatureSnappingEngine.prototype,"updating",null);n.__decorate([r.property()],k.FeatureSnappingEngine.prototype,"_snappingSources",void 0);k.FeatureSnappingEngine=n.__decorate([L.subclass("esri.views.interactive.snapping.FeatureSnappingEngine")],k.FeatureSnappingEngine);const H=A.create(),T=A.create();Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});