@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 972 B
JavaScript
import{remove as e}from"../../../../core/arrayUtils.js";import{isNone as t}from"../../../../core/maybe.js";import{Edge as r}from"../EditGeometry.js";class i{constructor(e,t){this._editGeometry=e,this._component=t,this._createdEdge=null}apply(){let e="redo";if(t(this._createdEdge)){e="apply";const i=this._component.getFirstVertex(),o=this._component.getLastVertex();if(this._component.isClosed()||this._component.vertices.length<3||t(i)||t(o))return;this._createdEdge=new r(this._component,o,i)}this._createdEdge.leftVertex.rightEdge=this._createdEdge,this._createdEdge.rightVertex.leftEdge=this._createdEdge,this._component.edges.push(this._createdEdge),this._editGeometry.notifyChanges({operation:e})}undo(){t(this._createdEdge)||(e(this._component.edges,this._createdEdge),this._createdEdge.leftVertex.rightEdge=null,this._createdEdge.rightVertex.leftEdge=null,this._editGeometry.notifyChanges({operation:"undo"}))}accumulate(){return!1}}export{i as CloseComponent};