import { BinaryFeatureCollection } from '@loaders.gl/schema'; import type { GeometryCollection } from '@geoda/common'; import { BinaryGeometryType } from '../geometry/binary-geometry'; import { WeightsMeta } from './weights-stats'; import { SpatialGeometry } from '../geometry/utils'; /** * Interface for the arguments used in calculating contiguity neighbors from binary geometries. */ export type ContiguityNeighborsFromBinaryGeometriesProps = { /** * The type of binary geometry */ binaryGeometryType: BinaryGeometryType; /** * The array of binary geometry features */ binaryGeometries: BinaryFeatureCollection[]; /** * Whether to use centroids for neighbor calculations */ useCentroids?: boolean; /** * Whether to use queen contiguity (true) or rook contiguity (false) */ isQueen: boolean; /** * Threshold for considering points as neighbors */ precisionThreshold?: number; /** * The order of contiguity to calculate */ orderOfContiguity?: number; /** * Whether to include lower orders in the results */ includeLowerOrder?: boolean; }; /** * Interface for the arguments used in calculating contiguity neighbors from a geometry collection. */ export type ContiguityNeighborsFromGeomCollectionProps = { /** * The geometry collection to calculate the neighbors for */ geomCollection: GeometryCollection; /** * Whether to use queen contiguity (true) or rook contiguity (false) */ isQueen: boolean; /** * Whether to use centroids for neighbor calculations */ useCentroids?: boolean; /** * Threshold for considering points as neighbors */ precisionThreshold?: number; /** * The order of contiguity to calculate */ orderOfContiguity?: number; /** * Whether to include lower orders in the results */ includeLowerOrder?: boolean; }; /** * Calculates contiguity-based neighbors for a set of geometries. * * This function processes geometries to determine spatial relationships * between them based on their contiguity (shared boundaries or vertices). * * @param {ContiguityNeighborsFromGeomCollectionProps} input - Configuration object for neighbor calculation See {@link ContiguityNeighborsFromGeomCollectionProps} for more information. * @returns {Promise} Array where each element contains indices of neighboring geometries */ export declare function getContiguityNeighborsFromGeomCollection({ geomCollection, isQueen, useCentroids, precisionThreshold, orderOfContiguity, includeLowerOrder, }: ContiguityNeighborsFromGeomCollectionProps): Promise; /** * Calculates contiguity-based neighbors for a set of binary geometries. * * This function processes binary geometry features to determine spatial relationships * between geometries based on their contiguity (shared boundaries or vertices). * * @param {ContiguityNeighborsFromBinaryGeometriesProps} input - Configuration object for neighbor calculation * @returns {Promise} Array where each element contains indices of neighboring geometries */ export declare function getContiguityNeighborsFromBinaryGeometries({ binaryGeometryType, binaryGeometries, isQueen, useCentroids, precisionThreshold, orderOfContiguity, includeLowerOrder, }: ContiguityNeighborsFromBinaryGeometriesProps): Promise; /** * ## Description * Create Queen contiguity weights for GeoJSON features. * * Queen contiguity defines neighbors as spatial units that share either: * - A common edge (border) * - A common vertex (corner) * * This is in contrast to Rook contiguity, which only considers shared edges. * * ## Example * ```ts * import { queenWeights } from '@geoda/core'; * * const geometries = [ * { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 0] } }, * { type: 'Feature', geometry: { type: 'Point', coordinates: [1, 0] } }, * { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 1] } }, * ]; * * const weights = await queenWeights(geometries); * * console.log(weights); * ``` * * @param {SpatialGeometry} geometries - The geometries used to create the queen contiguity weights. See {@link SpatialGeometry} for more information. * @param {boolean} [useCentroids=false] - If true, uses geometry centroids for calculations * @param {number} [precisionThreshold=0.0] - Distance threshold for determining neighbors. * Useful when geometries don't perfectly align * @param {number} [orderOfContiguity=1] - Number of steps to consider for neighbor relationships. * 1 means immediate neighbors only * @param {boolean} [includeLowerOrder=false] - If true, includes all neighbors from order 1 * up to the specified order * @returns {Promise} Spatial weights metadata including neighbor relationships */ export declare function queenWeights(geometries: SpatialGeometry, useCentroids?: boolean, precisionThreshold?: number, orderOfContiguity?: number, includeLowerOrder?: boolean): Promise; /** * ## Description * Create Rook contiguity weights for GeoJSON features. * * Rook contiguity defines neighbors as spatial units that only share common edge (border) * * This is in contrast to Queen contiguity, which considers shared edges and vertices. * * ## Example * ```ts * import { rookWeights } from '@geoda/core'; * * const geometries = [ * { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 0] } }, * { type: 'Feature', geometry: { type: 'Point', coordinates: [1, 0] } }, * { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 1] } }, * ]; * * const weights = await rookWeights(geometries); * * console.log(weights); * ``` * * @param {SpatialGeometry} geometries - The geometries used to create the rook contiguity weights. See {@link SpatialGeometry} for more information. * @param {boolean} [useCentroids=false] - If true, uses geometry centroids for calculations * @param {number} [precisionThreshold=0.0] - Distance threshold for determining neighbors. * Useful when geometries don't perfectly align * @param {number} [orderOfContiguity=1] - Number of steps to consider for neighbor relationships. * 1 means immediate neighbors only * @param {boolean} [includeLowerOrder=false] - If true, includes all neighbors from order 1 * up to the specified order * @returns {Promise} Spatial weights metadata including neighbor relationships */ export declare function rookWeights(geometries: SpatialGeometry, useCentroids?: boolean, precisionThreshold?: number, orderOfContiguity?: number, includeLowerOrder?: boolean): Promise;