RTree is an on-disk, Codable R*-Tree for searching.
RTree is a port of the Rust crate Spade‘s N-Dimentional R*-Tree, modified to store the tree on disk rather than in memory. It only can perform inserts and nearest neighbor queries.
RTree performs nearest neighbor searches at the expected speed of a R*-Tree. RTree uses far more space than expected on disk, and inserts are extemely inefficient. RTree does not currently support deletion or updating of records.
Design
This R*-Tree is designed to use exclusively Swift, and provide a general interface for doing nearest neighbor queries on N-dimensional objects.
Expect to a implement your own SpatialObject-implementing structure and PointN-implementing vector type in order to use RTree. For an example, see RTreeTests.swift or Usage
Usage
Getting started
First, you need a SpatialObject-implementing type to store in the R-Tree. For demonstration purposes, I will implement a 2-dimensional vector and SpatialObject that will store a custom field.
RTree
RTree is an on-disk,
Codable
R*-Tree for searching.RTree is a port of the Rust crate
Spade
‘s N-Dimentional R*-Tree, modified to store the tree on disk rather than in memory. It only can perform inserts and nearest neighbor queries.Contents
Requirements
Installation
Swift Package Manager
Disclaimer & Warnings
RTree performs nearest neighbor searches at the expected speed of a R*-Tree. RTree uses far more space than expected on disk, and inserts are extemely inefficient. RTree does not currently support deletion or updating of records.
Design
This R*-Tree is designed to use exclusively Swift, and provide a general interface for doing nearest neighbor queries on N-dimensional objects.
Expect to a implement your own
SpatialObject
-implementing structure andPointN
-implementing vector type in order to use RTree. For an example, seeRTreeTests.swift
or UsageUsage
Getting started
First, you need a SpatialObject-implementing type to store in the R-Tree. For demonstration purposes, I will implement a 2-dimensional vector and SpatialObject that will store a custom field.
2-dimensional vector:
SpatialObject:
Then, I’m able to create an R*-Tree that stores
Elements
overPoint2D
:Dependencies
None
Contact
Feel free to email questions and comments to emma@emma.sh.
Acknowledgements
Codable
.License
RTree is released under the MIT license. See LICENSE for details.