A non-recursive R-Tree library in pure JavaScript with no dependencies. Fork of Jon-Carlos Rivera's fantastic library which sadly seems not to be maintained. MIT Licensed.
var myRTree = RTree(10);
myRTree.insert({x:10, y:10, w:10, h:10}, myObject);
var myDelCount = myRTree.delete({x:10, y:10, w:10, h:10});
var myDelCount = myRTree.delete({x:10, y:10, w:10, h:10}, specific_object);
myRTree.geoJSON({
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[100,1]
},
"properties":{
"prop0":"value0"
}
},
{
"type":"Feature",
"geometry":{
"type":"LineString",
"coordinates":[
[100,0],
[101,1]
]
},
"properties":{
"prop0":"value0"
}
}
]
});
[[x1,y1],[x2,y2]]
, two parameters representing the southwest and northeast corners [x1,y1],[x2,y2]
, or 4 parameters of [x1,y1,x2,y2]
.var myObjects1 = myRTree.bbox([[10,10],[20,20]]);
var myObjects2 = myRTree.bbox([[10,10],[20,20]]);
var myObjects3 = myRTree.bbox([10,10],[20,20]);
var myObjects4 = myRTree.bbox([10,10],[20,20]);
var myObjects5 = myRTree.bbox(10,10,20,20);
var myObjects6 = myRTree.bbox(10,10,20,20);
var myObjects = myRTree.search({x:10, y:10, w:10, h:10});
1 Default max node width is currently 6.
3 A Rectangle is any object with public x, y, w, h properties. The object itself is not saved or used directly but copies are made of its x, y, w, h properties.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.