wasm-spatial-core
    Preparing search index...

    Class SpatialEdgeIndex

    A spatial index for 2D line segments using an R-Tree.

    Indexes individual edges (line segments) from LineString geometries. Supports bounding box queries to find all edges that intersect with a given rectangular area. Useful for viewport-based progressive loading of road networks, pipelines, and other linear features.

    Index
    • Build a spatial edge index from line segments.

      Input format: a flat Float64Array of line segment endpoints [x0, y0, x1, y1, x2, y2, x3, y3, ...] where each consecutive pair of 2D points forms an edge (line segment).

      Each edge is assigned an ID equal to its sequential index (0 for the first edge, 1 for the second, etc.).

      Parameters

      • segments: Float64Array

      Returns SpatialEdgeIndex

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

      Distance is measured as the minimum Euclidean distance from the query point to any point on the edge.

      Parameters

      • query_x: number
      • query_y: number

      Returns number | undefined

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

      An edge matches if its bounding box intersects the query envelope.

      Parameters

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

      Returns Uint32Array