Skip to content

Seeing weird remove behavior #21

@chaocodes

Description

@chaocodes

Not exactly sure if this is a bug or if I'm doing something wrong:

const d3Quadtree = require("d3-quadtree")

const tree = d3Quadtree.quadtree().x(d => d.x).y(d => d.y);

tree.add({ x: 681, y: 86, width: 12, height: 12 })
tree.add({ x: 713, y: 52, width: 12, height: 12 })
tree.add({ x: 470, y: 103, width: 12, height: 12 })
tree.add({ x: 745, y: 188, width: 12, height: 12 })
tree.add({ x: 671, y: 144, width: 12, height: 12 })
tree.add({ x: 724, y: 128, width: 12, height: 12 })
tree.add({ x: 798, y: 179, width: 12, height: 12 })
tree.add({ x: 671, y: 200, width: 12, height: 12 })
tree.add({ x: 766, y: 221, width: 12, height: 12 })

const find = tree.find(745, 188, 12)

tree.remove(find)

tree.find(745, 188, 12)

Running the above code snippet in https://npm.runkit.com/d3-quadtree causes tree.remove(find) to not properly remove the found data point.

Even weirder: commenting out any one of the 3 lines above the add for coord 745,188 causes the remove to function correctly. (i.e. commenting out tree.add({ x: 681, y: 86, width: 12, height: 12 }))

The only thing that I could determine was different between commenting out one of the top 3 add lines versus not was that the quadtree y0 point was negative, but this is maybe a red herring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions