Refactor strtree to not use lgeos / ctypes#1161
Refactor strtree to not use lgeos / ctypes#1161jorisvandenbossche merged 2 commits intoshapely:shapely-2.0from
Conversation
snorfalorpagus
left a comment
There was a problem hiding this comment.
Added some minor comments.
I like the new query_items function. This is a real pain in the current API.
shapely/strtree.py
Outdated
| else: | ||
| return (STRtree, (self.geometries, )) | ||
|
|
||
| def query(self, geom): |
There was a problem hiding this comment.
This function now returns an np.array instead of a list which is causing the doctest to fail.
There was a problem hiding this comment.
docstring currently has "array or list of geometry objects.". Perhaps it should be updated to say just "array".
There was a problem hiding this comment.
Ah, yes, updated the docstrings.
That's actually already introduced in the main branch (and so will be in shapely 1.8), coming from #1112 / #1064 Related to the missing docstrings and tests, they were also introduced in #1112, so I need to rebase this branch to pull those in (I made this branch with just similar code changes before #1112 was merged). |
3f4e2eb to
4437a92
Compare
1e609f8 to
e0f19bd
Compare
|
I updated the shapely-2.0 branch with the changes of latest master, and so also updated this branch (so docstrings and tests are now already included) |
4437a92 to
6821fb8
Compare
e0f19bd to
4ae55c7
Compare
|
Note that this PR disables the |
mwtoews
left a comment
There was a problem hiding this comment.
Admittedly, I don't know STRTree very well, but I've tested this locally and it seems to be in working order.
Perhaps the docstrings could be updated to say if an array is returned from (e.g.) query. Also, should query and nearest be at least deprecated? (These are still in consideration to be removed for 2.0)
Is there an issue in pygeos for the exclusive keyword? It hopefully shouldn't be too difficult to implement.
Didn't do that yet (will do now). Somewhat related, I did just open an issue about some other API incompatibilities between the pygeos and Shapely STRtree: pygeos/pygeos#398 |
|
Opened pygeos/pygeos#400 for the |
3498c0c to
bc2e464
Compare
4ae55c7 to
c7d6ed5
Compare
Not fully sure (it's indeed duplicating the other method now), but I think that's a separate issue to discuss (and maybe not critical for 1.8? We can also still deprecate it in 2.0) |
11664f5 to
5c04e37
Compare
|
Since this is only replacing the internals of the tree with pygeos (and not changing any API), I am going to merge this, so I can update #1163 |
This is for the shapely-2.0 branch, to do the equivalent of #1112 or #1064 (and ideally only gets done when one of those PRs is merged).
This shows how the
lib.STRtree(the C object) will just contain primary keys, which are mapped to geometries (or other items) in thequerymethod using the returned indices.