PRTree, a Priority R-Tree, a spatial index for java code

 
General
About
License
API
GIT

Download
Current version: 1.7
updated: April 17 2023

Java 17+ only
Download:
prtree-1.8.tar.gz - source
prtree-1.8.jar - just binary
Java 7+ only
Download:
prtree-1.7.tar.gz - source
prtree.jar - just binary

C#
Two different versions: prtree_cs.zip
PR-Tree-1.1-cs.7z

Contacts
Robert Olofsson
robo@khelekore.org

  About

PRTree is an implementation of a priority R-Tree, a spatial index. The code is written in java and the jar file is very small, this package does not come with anything extra.

This implementation tries to be memory efficient, one of the things it does it that it does not force you to create an Box or MBR for each object you have in the tree. You provide a class that can provide the bounds of each object when it is needed. This means that you can control how caching of bounds is done.

From version 1.5 it now supports as many dimensions as you want. The example below is for 2D, but PRTree support 3, 4 or even 14 dimensions if you want that.

Example usage:

PRTree<Rectangle2D> tree = new PRTree<Rectangle2D> (new Rectangle2DConverter (), 30); Rectangle2D rx = new Rectangle2D.Double (0, 0, 1, 1); tree.load (Collections.singletonList (rx)); for (Rectangle2D r : tree.find (0, 0, 1, 1)) { System.out.println ("found a rectangle: " + r); } DistanceCalculator<Rectangle2D> dc = new RectDistance (); PointND p = new SimplePointND (2, 3); int maxHits = 5; List<DistanceResult<Rectangle2D>> nnRes = tree.nearestNeighbour (dc, acceptAllFilter, maxHits, p); System.out.println ("Nearest neighbours are: " + nnRes);

There is now also two different C# ports of the code.