removeVertex_() {
    const dragSegments = this.dragSegments_;
    const segmentsByFeature = {};
    let deleted = false;
    let component, coordinates, dragSegment, geometry, i, index, left;
    let newIndex, right, segmentData, uid;
    for (i = dragSegments.length - 1; i >= 0; --i) {
      dragSegment = dragSegments[i];
      segmentData = dragSegment[0];
      uid = getUid(segmentData.feature);
      if (segmentData.depth) {
        // separate feature components
        uid += '-' + segmentData.depth.join('-');
      }
      if (!(uid in segmentsByFeature)) {
        segmentsByFeature[uid] = {};
      }
      if (dragSegment[1] === 0) {
        segmentsByFeature[uid].right = segmentData;
        segmentsByFeature[uid].index = segmentData.index;
      } else if (dragSegment[1] == 1) {
        segmentsByFeature[uid].left = segmentData;
        segmentsByFeature[uid].index = segmentData.index + 1;
      }
    }
    for (uid in segmentsByFeature) {
      right = segmentsByFeature[uid].right;
      left = segmentsByFeature[uid].left;
      index = segmentsByFeature[uid].index;
      newIndex = index - 1;
      if (left !== undefined) {
        segmentData = left;
      } else {
        segmentData = right;
      }
      if (newIndex < 0) {
        newIndex = 0;
      }
      geometry = segmentData.geometry;
      coordinates = geometry.getCoordinates();
      component = coordinates;
      deleted = false;
      switch (geometry.getType()) {
        case GeometryType.MULTI_LINE_STRING:
          if (coordinates[segmentData.depth[0]].length > 2) {
            coordinates[segmentData.depth[0]].splice(index, 1);
            deleted = true;
          }
          break;
        case GeometryType.LINE_STRING:
          if (coordinates.length > 2) {
            coordinates.splice(index, 1);
            deleted = true;
          }
          break;
        case GeometryType.MULTI_POLYGON:
          component = component[segmentData.depth[1]];
        /* falls through */
        case GeometryType.POLYGON:
          component = component[segmentData.depth[0]];
          if (component.length > 4) {
            if (index == component.length - 1) {
              index = 0;
            }
            component.splice(index, 1);
            deleted = true;
            if (index === 0) {
              // close the ring again
              component.pop();
              component.push(component[0]);
              newIndex = component.length - 1;
            }
          }
          break;
        default:
        // pass
      }

      if (deleted) {
        this.setGeometryCoordinates_(geometry, coordinates);
        const segments = [];
        if (left !== undefined) {
          this.rBush_.remove(left);
          segments.push(left.segment[0]);
        }
        if (right !== undefined) {
          this.rBush_.remove(right);
          segments.push(right.segment[1]);
        }
        if (left !== undefined && right !== undefined) {
          /** @type {SegmentData} */
          const newSegmentData = {
            depth: segmentData.depth,
            feature: segmentData.feature,
            geometry: segmentData.geometry,
            index: newIndex,
            segment: segments,
          };

          this.rBush_.insert(
            boundingExtent(newSegmentData.segment),
            newSegmentData
          );
        }
        this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
        if (this.vertexFeature_) {
          this.overlay_.getSource().removeFeature(this.vertexFeature_);
          this.vertexFeature_ = null;
        }
        dragSegments.length = 0;
      }
    }
    return deleted;
  }
/**
   * Removes a vertex from all matching features.
   * @return {boolean} True when a vertex was removed.
   * @private
   */
Removes a vertex from all matching features.
@return {boolean} True when a vertex was removed.
@private
Removes a vertex from all matching features . @return { boolean } True when a vertex was removed . @private
removeVertex_() {
    const dragSegments = this.dragSegments_;
    const segmentsByFeature = {};
    let deleted = false;
    let component, coordinates, dragSegment, geometry, i, index, left;
    let newIndex, right, segmentData, uid;
    for (i = dragSegments.length - 1; i >= 0; --i) {
      dragSegment = dragSegments[i];
      segmentData = dragSegment[0];
      uid = getUid(segmentData.feature);
      if (segmentData.depth) {
        uid += '-' + segmentData.depth.join('-');
      }
      if (!(uid in segmentsByFeature)) {
        segmentsByFeature[uid] = {};
      }
      if (dragSegment[1] === 0) {
        segmentsByFeature[uid].right = segmentData;
        segmentsByFeature[uid].index = segmentData.index;
      } else if (dragSegment[1] == 1) {
        segmentsByFeature[uid].left = segmentData;
        segmentsByFeature[uid].index = segmentData.index + 1;
      }
    }
    for (uid in segmentsByFeature) {
      right = segmentsByFeature[uid].right;
      left = segmentsByFeature[uid].left;
      index = segmentsByFeature[uid].index;
      newIndex = index - 1;
      if (left !== undefined) {
        segmentData = left;
      } else {
        segmentData = right;
      }
      if (newIndex < 0) {
        newIndex = 0;
      }
      geometry = segmentData.geometry;
      coordinates = geometry.getCoordinates();
      component = coordinates;
      deleted = false;
      switch (geometry.getType()) {
        case GeometryType.MULTI_LINE_STRING:
          if (coordinates[segmentData.depth[0]].length > 2) {
            coordinates[segmentData.depth[0]].splice(index, 1);
            deleted = true;
          }
          break;
        case GeometryType.LINE_STRING:
          if (coordinates.length > 2) {
            coordinates.splice(index, 1);
            deleted = true;
          }
          break;
        case GeometryType.MULTI_POLYGON:
          component = component[segmentData.depth[1]];
        case GeometryType.POLYGON:
          component = component[segmentData.depth[0]];
          if (component.length > 4) {
            if (index == component.length - 1) {
              index = 0;
            }
            component.splice(index, 1);
            deleted = true;
            if (index === 0) {
              component.pop();
              component.push(component[0]);
              newIndex = component.length - 1;
            }
          }
          break;
        default:
      }
      if (deleted) {
        this.setGeometryCoordinates_(geometry, coordinates);
        const segments = [];
        if (left !== undefined) {
          this.rBush_.remove(left);
          segments.push(left.segment[0]);
        }
        if (right !== undefined) {
          this.rBush_.remove(right);
          segments.push(right.segment[1]);
        }
        if (left !== undefined && right !== undefined) {
          const newSegmentData = {
            depth: segmentData.depth,
            feature: segmentData.feature,
            geometry: segmentData.geometry,
            index: newIndex,
            segment: segments,
          };
          this.rBush_.insert(
            boundingExtent(newSegmentData.segment),
            newSegmentData
          );
        }
        this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
        if (this.vertexFeature_) {
          this.overlay_.getSource().removeFeature(this.vertexFeature_);
          this.vertexFeature_ = null;
        }
        dragSegments.length = 0;
      }
    }
    return deleted;
  }
removeVertex_ ( ) { const dragSegments = this . dragSegments_ ; const segmentsByFeature = { } ; let deleted = false ; let component , coordinates , dragSegment , geometry , i , index , left ; let newIndex , right , segmentData , uid ; for ( i = dragSegments . length - 1 ; i >= 0 ; -- i ) { dragSegment = dragSegments [ i ] ; segmentData = dragSegment [ 0 ] ; uid = getUid ( segmentData . feature ) ; if ( segmentData . depth ) { uid += '-' + segmentData . depth . join ( '-' ) ; } if ( ! ( uid in segmentsByFeature ) ) { segmentsByFeature [ uid ] = { } ; } if ( dragSegment [ 1 ] === 0 ) { segmentsByFeature [ uid ] . right = segmentData ; segmentsByFeature [ uid ] . index = segmentData . index ; } else if ( dragSegment [ 1 ] == 1 ) { segmentsByFeature [ uid ] . left = segmentData ; segmentsByFeature [ uid ] . index = segmentData . index + 1 ; } } for ( uid in segmentsByFeature ) { right = segmentsByFeature [ uid ] . right ; left = segmentsByFeature [ uid ] . left ; index = segmentsByFeature [ uid ] . index ; newIndex = index - 1 ; if ( left !== undefined ) { segmentData = left ; } else { segmentData = right ; } if ( newIndex < 0 ) { newIndex = 0 ; } geometry = segmentData . geometry ; coordinates = geometry . getCoordinates ( ) ; component = coordinates ; deleted = false ; switch ( geometry . getType ( ) ) { case GeometryType . MULTI_LINE_STRING : if ( coordinates [ segmentData . depth [ 0 ] ] . length > 2 ) { coordinates [ segmentData . depth [ 0 ] ] . splice ( index , 1 ) ; deleted = true ; } break ; case GeometryType . LINE_STRING : if ( coordinates . length > 2 ) { coordinates . splice ( index , 1 ) ; deleted = true ; } break ; case GeometryType . MULTI_POLYGON : component = component [ segmentData . depth [ 1 ] ] ; case GeometryType . POLYGON : component = component [ segmentData . depth [ 0 ] ] ; if ( component . length > 4 ) { if ( index == component . length - 1 ) { index = 0 ; } component . splice ( index , 1 ) ; deleted = true ; if ( index === 0 ) { component . pop ( ) ; component . push ( component [ 0 ] ) ; newIndex = component . length - 1 ; } } break ; default : } if ( deleted ) { this . setGeometryCoordinates_ ( geometry , coordinates ) ; const segments = [ ] ; if ( left !== undefined ) { this . rBush_ . remove ( left ) ; segments . push ( left . segment [ 0 ] ) ; } if ( right !== undefined ) { this . rBush_ . remove ( right ) ; segments . push ( right . segment [ 1 ] ) ; } if ( left !== undefined && right !== undefined ) { const newSegmentData = { depth : segmentData . depth , feature : segmentData . feature , geometry : segmentData . geometry , index : newIndex , segment : segments , } ; this . rBush_ . insert ( boundingExtent ( newSegmentData . segment ) , newSegmentData ) ; } this . updateSegmentIndices_ ( geometry , index , segmentData . depth , - 1 ) ; if ( this . vertexFeature_ ) { this . overlay_ . getSource ( ) . removeFeature ( this . vertexFeature_ ) ; this . vertexFeature_ = null ; } dragSegments . length = 0 ; } } return deleted ; }
Removes a vertex from all matching features.
Removes a vertex from all matching features .
// separate feature components /* falls through */ // close the ring again // pass /** @type {SegmentData} */