/** * Copyright 2014-present Palantir Technologies * @license MIT */ import { Bounds, IEntityBounds, Point } from "../core/interfaces"; export interface IPositionedEntity { position: Point; } /** * EntityStore stores entities and makes them searchable. Valid entities must be * positioned in Cartesian space. */ export interface IEntityStore { /** * Adds all of the supplied entities to the store. * * If the optional bounds argument is provided, only entities within the * bounds will be available to `entityNearest` queries. Regardless, all * entities will be available with the `entities` method. * * @param {T[]} [entities] Entity array to add to the store. Entities must be * positionable * @param [entityBoundsFactory] A factory method for producing {IEntityBounds} * for each entity. * @param {Bounds} [bounds] Optionally add bounds filter for entityNearest * queries */ addAll(entities: T[], entityBoundsFactory: (entity: T) => IEntityBounds, bounds?: Bounds): void; /** * Returns the entity closest to a given {Point} * * Note that if a {Bounds} was provided to the `addAll` method, entities * outside those bounds will not be returned by this method. * * @param {Point} [point] Point around which to search for a closest entity * @returns {T} Will return the nearest entity or undefined if none are found */ entityNearest(point: Point): T; /** * Returns the entity closest to a given {Point} in the x-dimension. Ties are * broken with a sort in the y-dimension. * * @param {Point} [point] Point around which to search for a closest entity * @returns {T} Will return the nearest entity or undefined if none are found */ entityNearestX(point: Point): T; /** * Returns the entity closest to a given {Point} in the y-dimension. Ties are * broken with a sort in the x-dimension. * * @param {Point} [point] Point around which to search for a closest entity * @returns {T} Will return the nearest entity or undefined if none are found */ entityNearestY(point: Point): T; /** * Returns the entites whose bounding boxes overlap the parameter. * * @param {IEntityBounds} [bounds] The query bounding box. */ entitiesInBounds(bounds: IEntityBounds): T[]; /** * Returns the entites whose bounding boxes overlap the parameter on the * x-axis. * * @param {IEntityBounds} [bounds] The query bounding box. */ entitiesInXBounds(bounds: IEntityBounds): T[]; /** * Returns the entites whose bounding boxes overlap the parameter on the * y-axis. * * @param {IEntityBounds} [bounds] The query bounding box. */ entitiesInYBounds(bounds: IEntityBounds): T[]; /** * Returns the current internal array of all entities. * * @returns {T[]} the current internal array of entities. */ entities(): T[]; } /** * Implementation of {IEntityStore} that uses an array for easy iteration as * well as a quad tree for fast nearest-point queries. * * Note that if the position of your entities changes, you MUST rebuild the * entity store for the `entityNearest` method to work since the quadtree does * not know that its nodes have moved. */ export declare class EntityStore implements IEntityStore { private _entities; private _rtree; constructor(); addAll(entities: T[], entityBoundsFactory: (entity: T) => IEntityBounds, bounds?: Bounds): void; entityNearest(queryPoint: Point): T; entityNearestX(queryPoint: Point): T; entityNearestY(queryPoint: Point): T; entitiesInBounds(bounds: IEntityBounds): T[]; entitiesInXBounds(bounds: IEntityBounds): T[]; entitiesInYBounds(bounds: IEntityBounds): T[]; entities(): T[]; }