import type { OsmPbfRelation } from "@osmix/pbf"; import type { ContentHasher } from "@osmix/shared/content-hasher"; import type { GeoBbox2D, LonLat, OsmEntityType, OsmRelation, OsmRelationMember, OsmTags } from "@osmix/types"; import Flatbush from "flatbush"; import { Entities, type EntitiesTransferables } from "./entities.ts"; import { type IdOrIndex } from "./ids.ts"; import type { Nodes } from "./nodes.ts"; import type StringTable from "./stringtable.ts"; import { type BufferType } from "./typed-arrays.ts"; import type { Ways } from "./ways.ts"; export interface RelationsTransferables extends EntitiesTransferables { memberStart: T; memberCount: T; memberRefs: T; memberTypes: T; memberRoles: T; bbox: T; /** Optional - can be rebuilt via buildSpatialIndex() */ spatialIndex?: T; } export declare class Relations extends Entities { private stringTable; private memberStart; private memberCount; private memberRefs; private memberTypes; private memberRoles; private spatialIndex; private spatialIndexBuilt; private bbox; private nodes; private ways; private wayMemberIdsCache; /** * Create a new Relations index. */ constructor(stringTable: StringTable, nodes: Nodes, ways: Ways, transferables?: RelationsTransferables); /** * Add a single relation to the index. */ addRelation(relation: OsmRelation): number; /** * Bulk add relations directly from a PBF PrimitiveBlock. */ addRelations(relations: OsmPbfRelation[], blockStringIndexMap: Uint32Array, filter?: (relation: OsmRelation) => OsmRelation | null): number; /** * Compact the internal arrays to free up memory. */ buildEntityIndex(): void; /** * Build the spatial index for relations. * Handles nested relations by resolving all descendant nodes and ways. * If bbox data already exists (e.g., loaded from storage), reuses it. */ buildSpatialIndex(): Flatbush; /** * Check if the spatial index has been built. */ hasSpatialIndex(): boolean; /** * Collect all coordinates from a relation, including nested relations. * Used for building bounding boxes and spatial indexes. */ private collectRelationCoordinates; /** * Get the bounding box of a relation. */ getEntityBbox(i: IdOrIndex): GeoBbox2D; /** * Get the full relation entity. */ getFullEntity(index: number, id: number, tags?: OsmTags): OsmRelation; /** * Get the members of a relation. */ getMembersByIndex(index: number, relationMemberTypes?: OsmEntityType[]): OsmRelationMember[]; /** * Check if a relation includes a specific member. */ includesMember(index: number, memberRef: number, memberType: OsmEntityType, memberRole?: string): boolean; /** * Get all way IDs that are members of relations, including nested relations. * Used to exclude these ways from individual rendering. */ getWayMemberIds(): ReadonlySet; /** * Get relation geometry based on its kind. * Returns coordinates suitable for rendering based on relation type. * @param index - Relation index * @returns Object with geometry data based on relation kind */ getRelationGeometry(index: number): { points?: LonLat[]; lineStrings?: LonLat[][]; rings?: LonLat[][][]; }; /** * Find relations that intersect a bounding box. */ intersects(bbox: GeoBbox2D, filterFn?: (index: number) => boolean): number[]; /** * Find relation indexes near a point using great-circle distance. * @param lon - Longitude in degrees. * @param lat - Latitude in degrees. * @param maxResults - Maximum number of results to return. * @param maxDistanceKm - Maximum distance in kilometers. * @returns Array of relation indexes sorted by distance. */ neighbors(lon: number, lat: number, maxResults?: number, maxDistanceKm?: number): number[]; /** * Get transferable objects for passing to another thread. * Only includes spatialIndex if it has been built. */ transferables(): RelationsTransferables; /** * Get the approximate memory requirements for a given number of relations in bytes. */ static getBytesRequired(count: number): number; /** * Update a ContentHasher with relation-specific data (members). */ updateHash(hasher: ContentHasher): ContentHasher; } //# sourceMappingURL=relations.d.ts.map