@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.46 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{G as t}from"./SimpleGeometryCursor.js";import{G as e,c as s,g as r}from"./Geometry.js";import{P as n,a as o,E as m,n as i}from"./QuadraticBezier.js";import{g as u,a as c}from"./Envelope.js";import{T as a,s as h,k as l,l as d,m as y,C as p}from"./ProjectionTransformation.js";var _=p;function g(t,e){return{m_geometry:t,m_side:e}}function f(t,e,s,r,n,o){if(e.isEmpty()){const t=g(e,0);return void n.push(t)}if(s.isEmpty()){const t=g(e,0);return void n.push(t)}const i=[],u=new m;{const m=u.createGeometryUserIndex(),c=u.addGeometry(e),p=u.addGeometry(s),f=new a(o);let C=0,E=null;if(u.hasCurves()){E=new _;const t=u.getEnvelope2D(o);C=h(r.total());const e=l(r.total(),t);d(u,e,r.total(),12e3,E,null,o)}u.dbgVerifyCurves(),f.setEditShapeCrackAndCluster(u,r),f.cut(t,m,c,p,i);for(const t of i){null!==E&&E.stitchCurves(u,t,C,!1);const e=g(u.getGeometry(t),y(u.getGeometryUserIndex(t,m)));n.push(e)}null!==E&&E.clearStitcher(u)}}function C(t,e,s,r,n,u){if(e.isEmpty()){const t=g(e,0);return void n.push(t)}if(s.isEmpty()){const t=g(e,0);return void n.push(t)}const c=[],y=new m;{const t=y.createGeometryUserIndex(),p=y.addGeometry(e),f=y.addGeometry(s),C=new a(u);let E=0,G=null;if(y.hasCurves()){G=new _;const t=y.getEnvelope2D(u);E=h(r.total());const e=l(r.total(),t);d(y,e,r.total(),12e3,G,null,u)}y.dbgVerifyCurves(),C.setEditShapeCrackAndCluster(y,r),C.cut(!1,t,p,f,c),null!==G&&G.stitchCurves(y,i,E,!0);let v=y.getGeometry(p);const w=new o,x=new o,k=[];for(let e=0;e<c.length;e++){let s=null;{const n=new m,o=n.addGeometry(v),a=n.addGeometry(y.getGeometry(c[e]));if(n.hasCurves()){const t=n.getEnvelope2D(u);E=h(r.total());const e=l(r.total(),t);d(n,e,r.total(),12e3,G,null,u)}C.setEditShapeCrackAndCluster(n,r);const p=C.intersection(o,a);if(null!==G&&G.stitchCurves(n,i,E,!0),s=n.getGeometry(p),s.isEmpty())continue;const _=y.getGeometryUserIndex(c[e],t);2===_?w.add(s,!1):1===_?x.add(s,!1):k.push(s)}{const t=new m,s=t.addGeometry(v),n=t.addGeometry(y.getGeometry(c[e]));if(t.hasCurves()){const e=t.getEnvelope2D(u);E=h(r.total());const s=l(r.total(),e);d(t,s,r.total(),12e3,G,null,u)}C.setEditShapeCrackAndCluster(t,r);const o=C.difference(s,n);null!==G&&G.stitchCurves(t,i,E,!0);v=t.getGeometry(o)}}if(!v.isEmpty()&&c.length>0&&k.push(v),w.isEmpty()&&x.isEmpty())return;if(!w.isEmpty()){const t=g(w,1);n.push(t)}if(!x.isEmpty()){const t=g(x,2);n.push(t)}for(let e=0,s=k.length;e<s;++e){const t=g(k[e],3);n.push(t)}}}class E{getOperatorType(){return 10005}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}execute(t,e,s,r,n){return new G(t,e,s,r,n)}}class G extends t{constructor(t,e,s,r,o){super(),this.m_cutIndex=-1,this.m_cuts=[],this.m_progressTracker=o,this.m_cuttee=e.clone(),this.m_cutter=new n({copy:s}),this.m_bConsiderTouch=t;const m=u(e,s);this.m_tolerance=c(r,m,!0)}next(){return-1===this.m_cutIndex&&this.generateCuts(),++this.m_cutIndex<this.m_cuts.length?this.m_cuts[this.m_cutIndex]:null}getGeometryID(){return this.m_cutIndex}tock(){return!0}getRank(){return 1}generateCuts(){switch(this.m_cuttee.getGeometryType()){case e.enumPolyline:this.generatePolylineCuts();break;case e.enumPolygon:this.generatePolygonCuts()}}generatePolylineCuts(){const t=new n,e=new n,r=new n;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const o=[];f(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,o,this.m_progressTracker);for(let n=0;n<o.length;n++){const m=o[n];1===m.m_side?t.add(m.m_geometry,!1):2===m.m_side||4===m.m_side?e.add(m.m_geometry,!1):3===m.m_side?this.m_cuts.push(m.m_geometry):0===m.m_side?r.add(m.m_geometry,!1):s("")}r.isEmpty()||t.isEmpty()&&e.isEmpty()&&!(this.m_cuts.length>=3)||this.m_cuts.push(r),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}generatePolygonCuts(){const t=new o,e=new o,n=new o;this.m_cuts.length=0,this.m_cuts.push(t),this.m_cuts.push(e);const m=[];C(this.m_bConsiderTouch,this.m_cuttee,this.m_cutter,this.m_tolerance,m,this.m_progressTracker);for(let r=0;r<m.length;r++){const o=m[r];1===o.m_side?t.add(o.m_geometry,!1):2===o.m_side?e.add(o.m_geometry,!1):3===o.m_side?this.m_cuts.push(o.m_geometry):0===o.m_side?n.add(o.m_geometry,!1):s("")}r(n.isEmpty()||1===m.length),t.isEmpty()&&e.isEmpty()&&this.m_cuts.length<3&&(this.m_cuts.length=0)}}export{E as O};