Skip to main content

strTreeIndex

Constructs a 2D R-tree spatial index using Sort-Tile-Recursive (STR) packing algorithm.

The index is query-only; once constructed, geometries cannot be added or removed from the index.

The tree indexes the bounding boxes of each geometry. Geometries of any type can be indexed, types can mix within one index. Empty geometries are ignored during indexing and will never be returned by queries.

Type Parameters

  • G - The type of indexed geometry

Parameters

NameTypeDefaultDescription
geometriesG[]The array of geometries to be indexed
options?objectOptional options object
options.nodeCapacity?number10The maximum number of child nodes that a tree node may have.
The minimum recommended capacity value is 4.

Returns

STRTreeRef<G>

A new STRTreeRef instance

Throws

  • GEOSError when options.nodeCapacity is less than 2

Examples