Comments (5)
Actually probably the simplest way would be to keep a reference to parent for all nodes and iitems. This also helps greatly with item updates and reinsertions.
I have rewritten this library (https://github.com/thisredone/rbush/tree/dev) to support fast updates and removals; providing predicate function similar to #74; raycasting with stack-based, ordered ray traversal algorithm from this paper; finding collisions with the help of box-intersect for cross-leaf overlaps; and polling almost everywhere to avoid pressuring GC.
It's a very opinionated fork but it's there if you need any of those things.
from rbush.
Change the code if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
to if (!goingUp && !node.leaf && (item.id || contains(node, bbox))) { // go down
can solve the problem, but got heavy performance, due to missing range lookup. Suggested use of reference deletion!
from rbush.
After experimenting a little, it seems that remove doesn't work without a matching bbox.
from rbush.
We experienced the same issue when removing, updating, and re-inserting the same item quickly.
We looked at the code and the issue is that contains(node, bbox)
is returning false
.
One thing that got us confused at first is why there needs to be a spatial search prior to removing an element given that the docs say elements are removed by reference. Would it be possible/make sense to have a Map()
and only reference elements in the tree? This way removing would be dead simple, e.g., map.delete(item)
. Anyway, just a random idea.
from rbush.
@thisredone thank you for this fork, this is exactly what I need right now! Testing it immediately :)
from rbush.
Related Issues (20)
- Can you provide a browserify distribution? HOT 1
- How to limit the result count from the query? HOT 11
- how to search by id ? HOT 2
- tree.getById(id) how to get by id? HOT 2
- Why "RTree" is geographically even distribution while "RBush" is NOT? HOT 1
- About evenly geographic distribution when limit the result size HOT 2
- Invalid collision on maxX/Y (pixel-perfect collision false positive) HOT 3
- Does RBUSH supports to use Latitude and Longitude? HOT 5
- Hi i can't figure out how to use this library can anyone help? HOT 3
- Typescript attempts to use missing default constructor HOT 4
- How to search when usiong the extended class for points HOT 1
- is there any quick way to return the bounding box of tree itself? HOT 1
- Questions: Performance Remove + Moving item HOT 1
- Definition of "intersection" could be made more explicit in the readme HOT 2
- Returns all items when bounds provided to search contains center 0,0 HOT 3
- Support esm HOT 1
- search & collides support custom intersects & contains
- Balancing? HOT 1
- Unable to resolve dependency tree
- Performance benchmark vs other libraries HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbush.