import type PointCloudFilter from "./PointCloudFilter.js";
import type { PointCloudFilterProperties } from "./PointCloudFilter.js";

export interface PointCloudBitfieldFilterProperties extends PointCloudFilterProperties, Partial<Pick<PointCloudBitfieldFilter, "requiredClearBits" | "requiredSetBits">> {}

/**
 * Points can be classified using flags that indicate special characteristics associated with the point like
 * the direction of the flight or the method used to create the point. The flags are stored as a bit encoded field
 * and the PointCloudBitfieldFilter can be used to filter points that have certain flags set. Each flag is defined
 * by its bit position and value. If the flag is set its value is `1`, otherwise its value is `0`.
 *
 * The data format of the points determines the bit position of each flag. You can read more about
 * this in the [LAS specification v1.4](https://www.asprs.org/wp-content/uploads/2010/12/LAS_1_4_r13.pdf).
 *
 * For example for the [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) used in the
 * [Filter points in a PointCloudLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-pointcloud-filters/) the only available flag
 * is the Scan direction, which is stored on bit position 6. The Scan direction flag has the value `1` only when the point was collected when the direction of the scan
 * was positive (which means from the left to the right side of the in-track direction). To only show points with
 * a positive scan direction we can set the requiredSetBit to `[6]` in the PointCloudBitfieldFilter:
 *
 * ```js
 * const pointCloudLayer = new PointCloudLayer({
 *  url: "https://tiles.arcgis.com/tiles/Imiq6naek6ZWdour/arcgis/rest/services/PointCloud_urban/SceneServer/",
 *  filters: [{
 *    type: "bitfield",
 *    field: "FLAGS",
 *    requiredSetBits: [6]
 *  }]
 * });
 * ```
 *
 * The field for the PointCloudBitfieldFilter should be set to the field where the flags are stored. For most
 * datasets this is the `FLAGS` field.
 *
 * @since 4.10
 * @see [Sample - Filter points in a PointCloudLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-pointcloud-filters/)
 */
export default class PointCloudBitfieldFilter extends PointCloudFilter {
  constructor(properties?: PointCloudBitfieldFilterProperties);
  /**
   * An array of bit positions where the bit value must be `0`, otherwise the point will not be displayed.
   * Use this property to filter points based on the classification flag stored at that bit position.
   */
  accessor requiredClearBits: number[] | null | undefined;
  /**
   * An array of bit positions where the bit value must be `1`, otherwise the point will not be displayed.
   * Use this property to filter points based on the classification flag stored at that bit position.
   */
  accessor requiredSetBits: number[] | null | undefined;
  /** For PointCloudBitfieldFilter the type is always `bitfield`. */
  get type(): "bitfield";
}