Name

rtree-json — JSON serialisation of R-trees

DESCRIPTION

The rtree_json_write function writes a simple serialised version of an R-tree to a file in the JSON format. This file can used to rebuild the tree in other programs. These files can be created from CSV files using the rtree-build(1) utility.

State

An object (dictionary, hash) containing information on the tree dimension and the sizes of the various components of the tree (the size of a float, of a rectangle and so-on).

The information in this object are specific to the architecture on which the tree was built: on a 32-bit machine one would find rather different values to on 64-bit machine.

This object is global in scope and present only in the root of the JSON.

Nodes

These are objects have integer entries level, the height (or depth) in the tree, count, the number of branches and an array entry, branches..

"node": {
  "level": 3,
  "count": 34,
  "branches": [
      :
  ]
}

Branches

There are two forms of branch, leaf and internal, the former have a parent node with level zero, the latter with positive level.

Both internal and leaf branches have a rect entry, an array twice as many floats as the dimension of the tree representing a rectangle. The values are the lower values of each dimension, followed by the upper values for each dimension. For leaf nodes these are the input rectangles, for internal nodes they are the envelope, the minimal rectangle containing all of the rectangles of its children.

A leaf branch has an id, an user-defined identifier passed to the rtree_add_rect function.

{
  "rect": [0.155994, 0.058083, 0.156019, 0.866176],
  "id": 1
}

An internal branch has an node in place of the id.

{
  "rect": [0.155994, 0.058083, 0.156019, 0.866176],
  "node": { ... }
}

EXAMPLE

The following example is taken from the library's test-suite, an R-tree consisting of a single rectangle:

{
  "root": {
    "level": 0,
    "count": 1,
    "branch": [
      {
        "rect": [1.0, 2.0, 2.0, 3.0],
        "id": 23
      }
    ]
  },
  "state": {
    "dims": 2,
    "page_size": 4096,
    "float_size": 4,
    "rect_size": 16,
    "branch_size": 32
  }
}

AUTHOR

J. J. Green, .

SEE ALSO

rtree(3) , rtree-build(1) .