Giter Site home page Giter Site logo

spatial-index-java's Introduction

Spatial indexing algorithms for java (sia4j)

Implementation of spatial indexing algorithms in java. At the moment, only an r-tree index is implemented by this project.

Build Status

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

// 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

// 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

// 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();

spatial-index-java's People

Contributors

dependabot[bot] avatar jnidzwetzki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ibm-iloom lt-cug

spatial-index-java's Issues

Spatial Index - Hexagon

Instead of using a Hyper Rectangle as the bounding box, if you had to use a Hexagon, how would you do it?
I'm planning on building a similar library, but I would appreciate your take on how you would approach it for hexagonal structures.
If it does make sense, I don't mind contributing to the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.