Class SimplifyPath<T, P>

Type Parameters

Constructors

Properties

getSqDist: ((...args) => number) | ((...args) => number)

Square distance between two points

Type declaration

    • (...args): number
    • Parameters

      • Rest ...args: any[]

      Returns number

Type declaration

    • (...args): number
    • Parameters

      Returns number

getSqSegDist: ((...args) => number) | ((...args) => number)

Square distance from a point to a segment

Type declaration

    • (...args): number
    • Parameters

      • Rest ...args: any[]

      Returns number

Type declaration

    • (...args): number
    • Parameters

      Returns number

props: P[]

Properties of the point object as x, y, z, etc. Array of properties of T

Methods

  • Simplify an array of points with an optional tolerance.

    Parameters

    • points: Point<T, P>[]

      Array of points to simplify.

    • tolerance: number = 1

      Tolerance in squared units.

    • highestQuality: boolean = false

      Flag to enable highest quality simplification.

    Returns T[]

    Simplified array of points.

    Example

    const simplified = simplifyPath.simplify([{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }], 1);
    
  • Simplification using optimized Douglas-Peucker algorithm with recursion elimination

    Parameters

    • points: Point<T, P>[]
    • first: number
    • last: number
    • sqTolerance: number
    • simplified: Point<T, P>[]

    Returns void