1.0.1 • Published 5 years ago

dbvis-qt v1.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

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)
i = qt.remove(r);
// i.object = 6; i.rectangle = Rectangle(0, 10, 5, 5)
let i = qt.retrieve(p);
// i = undefined;

// ...

qt.clear();
1.0.1

5 years ago

1.0.0

5 years ago