wasm-spatial-core
    Preparing search index...

    Class SpatialIndex

    A high-performance spatial index using an R-Tree.

    Index
    • Build a spatial index from a flat Float64Array of coordinates [lng0, lat0, lng1, lat1, ...]. Each coordinate pair is assigned an ID equal to its index (i.e. 0 for the first pair, 1 for the second).

      Parameters

      • coords: Float64Array

      Returns SpatialIndex

    • Find the K nearest neighbors to a given query coordinate. Returns a Uint32Array containing the IDs, ordered by distance (nearest first). If k is greater than the number of points, returns all points.

      Parameters

      • query_x: number
      • query_y: number
      • k: number

      Returns Uint32Array

    • Find the nearest point to a given query coordinate. Returns the ID of the nearest point, or null if the index is empty.

      Parameters

      • query_x: number
      • query_y: number

      Returns number | undefined

    • Search for all points within a given bounding box. Returns a Uint32Array containing the IDs of the points.

      Parameters

      • min_x: number
      • min_y: number
      • max_x: number
      • max_y: number

      Returns Uint32Array