Need private packages and team management tools?Check out npm Teams »

dbvis-qt

1.0.1 • Public • Published

dbvis-qt

npm version Build Status codecov dependencies Status devDependencies Status License: MIT

A TypeScript implementation of the quadtree data structure.

The current version does not support overlapping rectangles yet.

Install

Install with npm:

npm install --save dbvis-qt

This package requires module resolution by Node in tsconfig.json:

{
    "compilerOptions": {
        "moduleResolution": "node"
    }
}

Usage

Example:

import { Point, Quadtree, Rectangle } from 'dbvis-qt';
 
// Create a quadtree of size 100x100
const qt = Quadtree.createQuadtree<number>(100, 100);
const r = new Rectangle(0, 10, 5, 5);
const d = 6;
// Insert an object (d) associated with an area (r) 
qt.insert(r, d);
const p = new Point(2, 12);
// Retrieve an object with a point, i.e., return the area and the associated
// object if the tree contains a rectangle that encloses the point
let i = qt.retrieve(p);
// i.object = 6; i.rectangle = Rectangle(0, 10, 5, 5)
= qt.remove(r);
// i.object = 6; i.rectangle = Rectangle(0, 10, 5, 5)
let i = qt.retrieve(p);
// i = undefined;
 
// ...
 
qt.clear();
 

Install

npm i dbvis-qt

DownloadsWeekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

12 kB

Total Files

12

Last publish

Collaborators

  • avatar