** Node.js libspatialindex binding**
- Mac OS Tested
- Linux Should work, not tested
- Windows
libspatialindex/libspatialindex.gyp will require a Windows
version of the
find
command line utility
npm install
npm test
SpatialIndex()
SpatialIndex#open()
SpatialIndex#insert()
SpatialIndex#intersects()
SpatialIndex#bounds()
SpatialIndex#delete()
SpatialIndex()
returns a new SpatialIndex instance. options
is a JSON object containing the following configuration parameters
'type'
: (string, default: "rtree")'storage'
: (string, default: "memory"): If'storage'
is "file" then the'filename'
parameter is required'filename'
: (string): Path to index file if storage is "file"'dimension'
: (integer, default: 2): either 2 (xy) or 3 (xyz)
open()
is an instance method on an existing SpatialIndex object.
The callback
function will be called with no arguments when the database has been successfully opened, or with a single error
argument if the open operation failed for any reason.
'type'
: (string, default: "rtree")'storage'
: (string, default: "memory"): If'storage'
is "file" then the'filename'
parameter is required'filename'
: (string): Path to index file if storage is "file"'dimension'
: (integer, default: 2): either 2 (xy) or 3 (xyz)
insert()
is an instance method on an existing SpatialIndex object. The callback
function will be called with no arguments if the operation is successful or with a single error
argument if the operation failed for any reason.
'id'
: (integer): Identifier for this item'mins'
: (Array): [minx, miny, (minz)]'maxs'
: (Array): [maxx, maxy, (maxz)]'data'
: (Buffer, default: null): Buffer of data to associated with this item
intersects()
is an instance method on an existing SpatialIndex object, used to query the index for items within
a bounding box.
The callback
function will be called with a single error
if the operation failed for any reason.
If successful the first argument will be null
and the second argument will be an array of JSON objects of the form;
{
"id" : someIdInteger,
"data": "someDataBuffer"
}
'mins'
: (Array): [minx, miny, (minz)]'maxs'
: (Array): [maxx, maxy, (maxz)]'resultOffset'
: (Number, default: 0)'resultLimit'
: (Number, default: null)
bounds()
is an instance method on an existing SpatialIndex object, used to fetch the bounding box for the index.
The result will be an Array [minx, miny, (minz), maxx, maxy, (maxz)]
The callback
function will be called with a single error
if the operation failed for any reason.
If successful the first argument will be null
and the second argument will be an Array([minx, miny, (minz), maxx, maxy, (maxz)])
delete()
is an instance method on an existing SpatialIndex object, used to delete items from the index
'id'
: (integer): Identifier for this item'mins'
: (Array): [minx, miny, (minz)]'maxs'
: (Array): [maxx, maxy, (maxz)]
The callback
function will be called with no arguments if the operation is successful or with a single error
argument if the operation failed for any reason.
You can find help in using libspatialindex in Node.js:
- GitHub: you're welcome to open an issue here on this GitHub repository if you have a question.
NodeSidx is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
NodeSidx is licensed under the Apache Software Version 2.0 license.
NodeSidx builds on the excellent work of libspatialindex