Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

bentley-ottmann-intersections

rowanwins39MIT0.0.1

A module to check if a polygon self-intersects using the bentley-ottmann algorithm

readme

bentley-ottmann-intersections

A small module using the Bentley-Ottmann algorithm to detection self-intersections

Install

npm install bentley-ottmann-intersections

Documentation

Valid inputs: Geojson Polygon, MultiPolygon

    const findIntersections = require('bentley-ottmann-intersections')

    const box = {type: 'Polygon', coordinates: [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]]}
    findIntersections(box)
    // returns array os intersection points

Benchmarks

Tested against

// Simple Case // gpsi x 246,005 ops/sec ±1.54% (90 runs sampled) // bentleyOttmannIntersections x 464,363 ops/sec ±1.73% (95 runs sampled) // - Fastest is bentleyOttmannIntersections

Further Reading

Geom algorithms website