Nonlinear Performance Magnification

    fast-point-in-poly

    1.0.0 • Public • Published

    fast-point-in-poly

    Simple API for doing point and polygon checks on large sets of polygons. Most useful when doing MANY checks.

    Usage

    const FastPointInPoly = require('fast-point-in-poly');
    
    const polygons = [...] // List of GeoJSON Polygon Features
    const point { ... } // GeoJSON Point Feature
    
    const index = new FastPointInPoly(polygons);
    
    const poly = index.find(point);

    Speed

    This libraray's speed comes from converting the input polygons to points and putting those points in a wicked fast KDBush index. This index allows us to use geokdbush to sort the polygons points by their distance from the point passed to find. With this sorted list we then do a basic turf.booleanPointInPolygon check and return the first polygon which passes the check. How this index works may change in the future as we build up perf tests and find more robust ways to perform this check.

    API

    constructor(features)

    Constructs an index of the provided features that can be searched.

    find(point)

    Returns the first polygon in the index which contains the passed point.

    Install

    npm i fast-point-in-poly

    DownloadsWeekly Downloads

    17

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    7.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • mcwhittemore