Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting items breaks the index #151

Open
flusflas opened this issue Apr 15, 2020 · 3 comments
Open

Deleting items breaks the index #151

flusflas opened this issue Apr 15, 2020 · 3 comments

Comments

@flusflas
Copy link

flusflas commented Apr 15, 2020

I'm new with rtree (and R-trees in general) and I don't know how an R-tree is implemented (I just know the high-level theory), but I've found a weird behavior when trying to delete items from an index.

For an index with a few items, deleting some of them generally doesn't break anything. However, when complexity grows and I delete one item, points that before matched with other items stop doing it.

As I don't understand this behavior, I created a repo with a sample code to illustrate my problem. This code just:

  1. Reads a list of countries geometries from a geojson file.
  2. Adds every polygon bounds to an index (using a UUID for each polygon).
  3. Generates one point for each polygon.
  4. Checks every generated point has at least one match using the index.
  5. Deletes the polygons of only one country.
  6. Checks every generated point again.
  7. Prints the data of every point without matches with its country.

In the example, I'm deleting all USA polygons, but all the points inside USA keeps matching. However, other points from other countries fail, even though I didn't remove its country from the index.

Maybe I'm missing something about R-trees, but I think this doesn't make sense. Chances are I'm using it wrong, but I don't know why. I'm sorry this issue involves some work to check, but would appreciate some help.

@gbrunner
Copy link

@flusflas A coworker and I noticed this issue with deletion recently too. We are thinking it's an issue in libspatialindex. Any insight @mikedh ?

@nicolaspi
Copy link

Is this still an issue?
I have run the example code and the polygons seem to be deleted properly as no matching is found for points in USA:

POINT (-155.44621945363636 19.52346141835088) - United States of America
POINT (-156.61449434552648 20.945348638951337) - United States of America
POINT (-157.2490295045156 21.19656537921698) - United States of America
POINT (-157.80397172328637 21.379848936908118) - United States of America
POINT (-159.45269467626426 21.973077829200907) - United States of America
POINT (-116.9313632010097 45.680309082894034) - United States of America
POINT (-153.4176185266608 57.28947977584915) - United States of America
POINT (-166.02234950826792 59.91506536250986) - United States of America
POINT (-171.3743571862354 63.65961005953684) - United States of America
POINT (-162.98717532183196 68.77121797563544) - United States of America

@gbrunner
Copy link

gbrunner commented Jul 1, 2024

IDK, I haven't tried this in a few years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants