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

    Class PointIndexFast<M>

    Point Index Fast

    An index of cells with radius queries Assumes the data is compatible with https://open-s2.github.io/s2json/types/Properties.html Because of the nature of low level language like Javascript, using u64 is slow. This index uses f64 which Number supports. So it is fast and efficient.

    import { PointIndexFast } from 'gis-tools-ts';
    import { KDMMapSpatialIndex } from 'gis-tools-ts/mmap';

    const pointIndex = new PointIndexFast();
    // or used a mmap based store
    const pointIndex = new PointIndex(KDMMapSpatialIndex);

    // 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(minX, minY, maxX, maxY);
    // or a standard radius search
    const points = await pointIndex.searchRadius(qx, qy, r);
    // or a spherical radius search that wraps around the -180/180 boundary
    const points = await pointIndex.searchRadiusSphere(lon, lat, dist);

    Type Parameters

    • M extends MValue = Properties | RGBA
    Index

    Constructors

    Methods

    • iterate through the points

      Returns Generator<VectorPoint<M>>

      a PointShapeFast

    • Add a properly shaped point with it's x, y, and data values

      Parameters

      • point: VectorPoint<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

      • feature: VectorFeatures<unknown, M, M>

        vector feature (either S2 or WM)

      Returns void

    • Add a lon-lat pair to the cluster

      Parameters

      • lon: number

        longitude in degrees

      • lat: number

        latitude in degrees

      • data: M

        the data associated with the point

      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>

    • Search the index for items within a given radius.

      Parameters

      • qx: number

        the query x coordinate

      • qy: number

        the query y coordinate

      • r: number

        the radius

      • maxResults: number = Infinity

        the maximum number of results

      Returns VectorPoint<M>[]

      • the items that are in range
    • Search the index for items within a given radius using a spherical query. NOTE: Assumes the input points are lon-lat pairs in degrees.

      Parameters

      • lon: number

        longitude

      • lat: number

        latitude

      • dist: number

        max distance in meters

      • maxResults: number = Infinity

        max number of results

      • planetRadius: number = EARTH_RADIUS

        the radius of the planet (Earth by default)

      Returns VectorPoint<M>[]

      • the items that are in range
    • Search the index for items within a given bounding box.

      Parameters

      • minX: number

        the min x coordinate

      • minY: number

        the min y coordinate

      • maxX: number

        the max x coordinate

      • maxY: number

        the max y coordinate

      • maxResults: number = Infinity

        the maximum number of results

      Returns VectorPoint<M>[]

      • the items that are in range
    • Perform indexing of the added points.

      Returns void