@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{remove as e}from"../../../../core/arrayUtils.js";import{LineSegment as t}from"../EditGeometry.js";class r{constructor(e,t){this._editGeometry=e,this._part=t,this._createdSegment=null}apply(){let e="redo";const{_part:r}=this;if(null==this._createdSegment){e="apply";const n=r.getFirstVertex(),i=r.getLastVertex();if(r.isClosed()||r.vertices.length<2||null==n||null==i)return;if(2===r.vertices.length&&"line"===i.leftSegment?.type)return;this._createdSegment=new t(this._part,i,n)}this._createdSegment.leftVertex.rightSegment=this._createdSegment,this._createdSegment.rightVertex.leftSegment=this._createdSegment,r.segments.push(this._createdSegment),this._editGeometry.notifyChanges({operation:e})}undo(){const{_part:t,_createdSegment:r,_editGeometry:n}=this;null!=r&&(e(t.segments,r),r.leftVertex.rightSegment=null,r.rightVertex.leftSegment=null,n.notifyChanges({operation:"undo"}))}accumulate(){return!1}}export{r as ClosePart};