code: function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
    let layout = GeometryLayout.XY;
    let stride = 2;
    if (layoutOptions.hasZ && layoutOptions.hasM) {
      layout = GeometryLayout.XYZM;
      stride = 4;
    } else if (layoutOptions.hasZ) {
      layout = GeometryLayout.XYZ;
      stride = 3;
    } else if (layoutOptions.hasM) {
      layout = GeometryLayout.XYM;
      stride = 3;
    }
    if (stride !== 4) {
      for (let i = 0, ii = flatCoordinates.length / 4; i < ii; i++) {
        flatCoordinates[i * stride] = flatCoordinates[i * 4];
        flatCoordinates[i * stride + 1] = flatCoordinates[i * 4 + 1];
        if (layoutOptions.hasZ) {
          flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 2];
        }
        if (layoutOptions.hasM) {
          flatCoordinates[i * stride + 2] = flatCoordinates[i * 4 + 3];
        }
      }
      flatCoordinates.length = flatCoordinates.length / 4 * stride;
      if (ends) {
        for (let i = 0, ii = ends.length; i < ii; i++) {
          ends[i] = ends[i] / 4 * stride;
        }
      }
    }
    return layout;
  }
docs: Choose GeometryLayout based on flags in layoutOptions and adjust flatCoordinates
  and ends arrays by shrinking them accordingly (removing unused zero entries).
  
  @param {LayoutOptions} layoutOptions Layout options.
  @param {Array<number>} flatCoordinates Flat coordinates.
  @param {Array<number>=} ends Ends.
  @return {GeometryLayout} Layout.