Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jnidzwetzki/spatial-index-java
Spatial indexing algorithms for java
https://github.com/jnidzwetzki/spatial-index-java
index n-dimensional r-tree spatial-index
Last synced: 2 months ago
JSON representation
Spatial indexing algorithms for java
- Host: GitHub
- URL: https://github.com/jnidzwetzki/spatial-index-java
- Owner: jnidzwetzki
- License: apache-2.0
- Created: 2018-03-30T10:38:27.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-25T09:35:54.000Z (almost 3 years ago)
- Last Synced: 2024-10-12T10:09:57.579Z (3 months ago)
- Topics: index, n-dimensional, r-tree, spatial-index
- Language: Java
- Homepage:
- Size: 55.7 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spatial indexing algorithms for java (sia4j)
Implementation of spatial indexing algorithms in java. At the moment, only an [r-tree](https://en.wikipedia.org/wiki/R-tree) index is implemented by this project.
## Features of the R-tree implementation
* Supports rectangle geometries
* Supports n-dimensional data
* Support serializing to file
* Can be used as in-memory data structure
* R-Tree can be serialized and accessed via _memory mapped io_. This is usefull for very large datasets.## Examples
### Building the r-tree and execute a rane query
```java
// Two entries with a two-dimensional bounding box
final SpatialIndexEntry entry1 = new SpatialIndexEntry(new Hyperrectangle(1d, 2d, 1d, 2d), "abc");
final SpatialIndexEntry entry2 = new SpatialIndexEntry(new Hyperrectangle(10d, 20d, 10d, 20d), "def");final SpatialIndexBuilder index = new RTreeBuilder();
index.bulkInsert(Arrays.asList(entry1, entry2);// Query data
final Hyperrectangle queryBox = new Hyperrectangle(1d, 1.5d, 1d, 1.5d);
final List extends SpatialIndexEntry> resultList = index.getEntriesForRegion(queryBox);
```### Write the r-tree into a file and read into memory
```java
// Write and read to file
final File tempFile = File.createTempFile("rtree-", "-test");
final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
index.writeToFile(raf);
raf.close();final AbstractRTreeReader indexRead = new RTreeMemoryReader();
final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
indexRead.readFromFile(rafRead);
rafRead.close();
```### Write the r-tree into a file and access the file via memory mapped io
```java
// Write and read to file
final File tempFile = File.createTempFile("rtree-", "-test");
final RandomAccessFile raf = new RandomAccessFile(tempFile, "rw");
index.writeToFile(raf);
raf.close();final AbstractRTreeReader indexRead = new RTreeMMFReader();
final RandomAccessFile rafRead = new RandomAccessFile(tempFile, "r");
indexRead.readFromFile(rafRead);
rafRead.close();
```