gis-tools-ts - v0.6.0
    Preparing search index...

    Class PointIndex<M>

    Point Index

    An index of cells with radius queries Assumes the data is compatible with https://open-s2.github.io/s2json/types/Properties.html

    import { PointIndex } from 'gis-tools-ts';
    import { FileVector } from 'gis-tools-ts/file';

    const pointIndex = new PointIndex();
    // or used a file based store
    const pointIndex = new PointIndex(FileVector);

    // insert a lon-lat
    pointIndex.insertLonLat(lon, lat, data);
    // insert an STPoint
    pointIndex.insertFaceST(face, s, t, data);

    // after adding data build the index. NOTE: You don't have to call this, it will be called
    // automatically when making a query
    await pointIndex.sort();

    // you can search a range
    const points = await pointIndex.searchRange(low, high);
    // or a radius
    const points = await pointIndex.searchRadius(center, radius);

    Type Parameters

    • M extends MValue = Properties | RGBA
    Index

    Constructors

    Methods

    • iterate through the points

      Returns AsyncGenerator<PointShape<M>>

      a PointShape

    • Insert a point3D and its corresponding data to the index

      Parameters

      • point: VectorPointM<M>

        the point to be indexed

      Returns void

    • Insert an STPoint to the index

      Parameters

      • face: Face

        the face of the cell

      • s: number

        the s coordinate

      • t: number

        the t coordinate

      • data: M

        the data associated with the point

      Returns void

    • Add a vector feature. It will try to use the M-value first, but if it doesn't exist it will use the feature properties data

      Parameters

      • data: JSONCollection<unknown, M, M>

        any source of data like a feature collection or features themselves

      Returns void

    • Insert a cell with the point and its corresponding data to the index

      Parameters

      • cell: bigint

        the cell id to be indexed

      • point: VectorPointM<M>

        the point to be indexed

      Returns void

    • Add a lon-lat pair to the cluster

      Parameters

      • ll: VectorPoint<M>

        lon-lat vector point in degrees

      Returns void

    • Add all points from a reader. It will try to use the M-value first, but if it doesn't exist it will use the feature properties data

      Parameters

      Returns Promise<void>

    • Find the starting index of a search

      Parameters

      • id: bigint

        input id to seek the starting index of the search

      Returns Promise<number>

      the starting index

    • TODO: Adjust the radius for the WM projection. Really not a massive issue thogh just adjust your calcuation for now Search for points within a given radius of a target point

      Parameters

      • target: VectorPoint

        the point to search

      • radius: number

        the search radius

      • maxResults: number = Infinity

        the maximum number of results

      Returns Promise<PointShape<M>[]>

      the points within the radius

    • Search for points given a range of low and high ids

      Parameters

      • low: bigint

        the lower bound. If high is not provided, the low-high range will be created from the low

      • Optionalhigh: bigint

        the upper bound

      • maxResults: number = Infinity

        the maximum number of results to return

      Returns Promise<PointShape<M>[]>

      the points in the range

    • Sort the index in place if unsorted

      Returns Promise<void>