diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 532e0404e..801a1d07a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -270,6 +270,7 @@ All definitions files include a header with the author and editors, so at some p * [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) * [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov)) * [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [rtree.js] (https://github.com/leaflet-extras/RTree) (by [Omede Firouz](https://github.com/oefirouz)) * [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) * [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong)) diff --git a/rtree/rtree-tests.ts b/rtree/rtree-tests.ts new file mode 100644 index 000000000..67d35a4e6 --- /dev/null +++ b/rtree/rtree-tests.ts @@ -0,0 +1,13 @@ +/// + +var myRTree = RTree(5); +var el = "test"; + +myRTree.insert({x: 0, y: 0, w: 1, h: 1}, el); + +var intersections = myRTree.search({x: 0.5, y: 0.5, w: 1, h: 1}); + +intersections = myRTree.remove({x: 0.5, y: 0.5, w: 1, h: 1}, "notTest!"); + +intersections = myRTree.remove({x: 0.5, y: 0.5, w: 1, h: 1}); + diff --git a/rtree/rtree.d.ts b/rtree/rtree.d.ts new file mode 100644 index 000000000..fa6276c6e --- /dev/null +++ b/rtree/rtree.d.ts @@ -0,0 +1,25 @@ +// Type definitions for rtree 1.4.0 +// Project: https://github.com/leaflet-extras/RTree +// Definitions by: Omede Firouz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Rectangle { + x: number; + y: number; + w: number; + h: number; +} + +interface RTreeStatic { + insert(bounds: Rectangle, element: Object): boolean; + remove(area: Rectangle, element?: Object): any[]; + geoJSON(geoJSON: any): void; + bbox(arg1: any, arg2?: any, arg3?: number, arg4?: number): any[]; + search(area: Rectangle, return_node?: boolean, return_array?: any[]): any[]; +} + +interface RTreeFactory { + (max_node_width?: number): RTreeStatic; +} + +declare var RTree: RTreeFactory;