Rtree is an implementation of the R-Tree data structure in Elixir. R-Trees are used for indexing multi-dimensional information, such as geographical coordinates. This library provides a robust and efficient way to manage and query spatial data.
If available in Hex, the package can be installed by adding `rtree` to your list of dependencies in `mix.exs`:
def deps do
[
{:rtree, github: "roy-corentin/R-Tree"}
]
endHere is a basic example of how to use the Rtree library:
# Create a new R-Tree node with a limit of 2 objects per node
node = %RNode{limit: 2}
# Insert objects into the R-Tree
node = RTree.insert(node, %RObject{x: 1, y: 1, data: "data1"})
node = RTree.insert(node, %RObject{x: 2, y: 2, data: "data2"})
node = RTree.insert(node, %RObject{x: 3, y: 3, data: "data3"})
# Search for an object in the R-Tree
case RTree.search(node, %{x: 2, y: 2}) do
{:ok, object} -> IO.puts("Found object: #{inspect(object)}")
{:error, "Not Found"} -> IO.puts("Object not found")
endDocumentation can be generated with https://github.com/elixir-lang/ex_doc and published on https://hexdocs.pm. Once published, the docs can be found at https://hexdocs.pm/rtree.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.