atksh / python_prtree Goto Github PK
View Code? Open in Web Editor NEWA Python implementation of Priority R-Tree, an alternative to RTree.
License: MIT License
A Python implementation of Priority R-Tree, an alternative to RTree.
License: MIT License
E.g. as a an array of concatenated idx's and an array of lengths for each query rectangle.
This would speed up software like trimesh where otherwise there is large performance impact in iterating over this list of lists in the python side.
Hi,
Thank you for this nice work.
I love the fact it support batch query (unlike rtree Toblerity/rtree#178).
It would be great if it could support 3 dimensions (or maybe even n dimensions if that does not impact the speed). Does that seem easily feasible ?
This could then potentially be used in the trimesh library to speed thing up and solve issue mikedh/trimesh#1116
Previously parallelization was implemented by open-mp.
However, it is not able to compile with open-mp by cmake on mac and windows platform, and therefore we can't register it to PyPI via Travis CI w/ cibuildwheel with open-mp. So, there is no parallelization support now.
Since std::thread
is a cross-platform multi-thread library, it is expected that we can compile it on any platforms (i.e, gcc, clang and visual studio). Plus, std::async
looks to be good for parallelization with returning some deferrable values.
Now, there is little difference between batch_query
and query
methods; this parallelization would make batch_query
much faster than single query
again.
It was described as follows.
Also, the error described in the above blog has been fixed in v0.5.0.
Hi @atksh!
Thanks for this extremely fast solution! Works fine in Python 3.8, but i have some outdated software with integrated Python 2.7. Is it possible to make version for IronPython 2.7? I can succsessfully use some dlls from other projects, but here we have pybind11. Tried to build it with latest pybind for python 2.7, had many errors. Thanks in advance!
import numpy as np
from python_prtree import PRTree2D
idxes = np.array([1, 2])
rects = np.array([[0.0, 0.0, 1.0, 0.5],
[1.0, 1.5, 1.2, 3.0]])
prtree = PRTree2D(idxes, rects)
q = np.array([[0.5, 0.2, 0.6, 0.3],
[0.8, 0.5, 1.5, 3.5]])
result = prtree.batch_query(q)
print(result)
prtree.insert(3, np.array([1.0, 1.0, 2.0, 2.0]))
q = np.array([[0.5, 0.2, 0.6, 0.3],
[0.8, 0.5, 1.5, 3.5]])
result = prtree.batch_query(q)
print(result)
prtree.erase(2)
result = prtree.batch_query(q)
print(result)
print(prtree.query(0.5, 0.5))
print(prtree.query((0.5, 0.5)))
=============================================
The final output look like as follows:
[[1], [2]]
[[1], [2, 3]]
[[1], [3]]
[]
[]
How do you get the performance graphs you showed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.