Skip to content

normanb/nodesidx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeSidx

** Node.js libspatialindex binding**

Tested & supported platforms

  • 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

API


SpatialIndex(options)

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)

SpatialIndex#open(callback)

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)

SpatialIndex#insert(id, mins, maxs, data, callback)

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

SpatialIndex#intersects(mins, maxs, resultOffset, resultLength, callback)

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)

SpatialIndex#bounds(callback)

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)])


SpatialIndex#delete(id, mins, maxs, callback)

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.


Getting support

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.

Contributing

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.

License & copyright

NodeSidx is licensed under the Apache Software Version 2.0 license.

NodeSidx builds on the excellent work of libspatialindex

About

Node wrapper for libspatialindex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published