Interface IDiskTree

  • All Known Implementing Classes:
    DiskTreeReader, DiskTreeWriter

    public interface IDiskTree
    Interface for DiskTree I/O modules.

    The disktree binary file is defined as follows:

    • 6 bytes containing the chars 'jts'
    • 4 bytes for the jts major version
    • 4 bytes for the jts minor version
    • 8 bytes containing the address at which the quadtree is stored
    • 8 bytes containing the size of the stored quadtree
    • then the WKB-ized geometries are stored
    • after the geometries, the quadtree is stored

    The quadtree stores the envelope of a geometry with the int array of the [position of geom on disk, size of the geom on disk]. It is therefore possible to extract any geometry by knowing the envelope.

    Example write usage:

     WKTReader r = new WKTReader();
     Geometry pol = r.read("POLYGON ((210 350, 230 310, 290 350, 290 350, 210 350))");
     pol.setUserData(1);
     Geometry line = r.read("LINESTRING (50 380, 90 210, 180 160, 240 40, 240 40)");
     line.setUserData(2);
     Geometry point = r.read("POINT (130 120)");
     point.setUserData(3);
    
     DiskTreeWriter writer = new DiskTreeWriter("/home/moovida/TMP/index.bin");
     writer.writeGeometries(new Geometry[]{pol, line, point});
     

    Example read usage:

     DiskTreeReader writer = new DiskTreeReader("/home/moovida/TMP/index.bin");
     Quadtree indexObj = writer.readIndex();
    
     List queryAll = indexObj.queryAll();
    
     for( Object object : queryAll ) {
         if (object instanceof long[]) {
             long[] posSize = (long[]) object;
             Geometry geom = writer.pickGeometry(posSize[0], posSize[1]);
             System.out.println(geom.toText());
         }
     }
     
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Field Detail

      • INDEX_ADDRESS_POSITION

        static final long INDEX_ADDRESS_POSITION
        Position of the index address.
        See Also:
        Constant Field Values
      • INDEX_ADDRESS_SIZE

        static final long INDEX_ADDRESS_SIZE
        Byte size of the index address.
        See Also:
        Constant Field Values
      • INDEX_LENGTH_SIZE

        static final long INDEX_LENGTH_SIZE
        Byte size of the index length.
        See Also:
        Constant Field Values