{"id":37009307,"url":"https://github.com/hexogen/kdtree","last_synced_at":"2026-01-14T00:53:01.817Z","repository":{"id":15029478,"uuid":"76764341","full_name":"hexogen/kdtree","owner":"hexogen","description":"PHP K-D Tree implementation with file system binary index","archived":false,"fork":false,"pushed_at":"2024-10-14T13:06:10.000Z","size":1106,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T07:03:43.420Z","etag":null,"topics":["algorithms","cache","data-structures","index","kd-tree","multidimensionality","search-algorithm"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexogen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-18T05:21:46.000Z","updated_at":"2025-04-26T20:26:17.000Z","dependencies_parsed_at":"2024-09-15T23:24:36.243Z","dependency_job_id":"5eda46a0-4335-4a82-83f8-4e95d16ad477","html_url":"https://github.com/hexogen/kdtree","commit_stats":{"total_commits":200,"total_committers":45,"mean_commits":4.444444444444445,"dds":0.625,"last_synced_commit":"9cac3c60fbaec41ae79d6e521a6bf93e1a6a58c7"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/hexogen/kdtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexogen%2Fkdtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexogen%2Fkdtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexogen%2Fkdtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexogen%2Fkdtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexogen","download_url":"https://codeload.github.com/hexogen/kdtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexogen%2Fkdtree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","cache","data-structures","index","kd-tree","multidimensionality","search-algorithm"],"created_at":"2026-01-14T00:53:01.047Z","updated_at":"2026-01-14T00:53:01.798Z","avatar_url":"https://github.com/hexogen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K-D Tree\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Build Status][ico-tests]][link-tests]\n[![codecov][ico-codecov]][link-codecov]\n[![Software License][ico-license]](LICENSE.md)\n[![Total Downloads][ico-downloads]][link-downloads]\n\nPHP multidimensional K-D Tree implementation.\n\nTo receive all benefits from K-D Tree, use file system implementation(FSKDTree). FSKDTree stores tree in binary format and uses lazy loading while traversing through nodes. Current approach provides much higher performance compared\nto deserialization.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require hexogen/kdtree\n```\n\n## Usage\n\n### Tree creation\n``` php\n//Item container with 2 dimensional points\n$itemList = new ItemList(2);\n\n//Adding 2 - dimension items to the list\n$itemList-\u003eaddItem(new Item(1, [1.2, 4.3]));\n$itemList-\u003eaddItem(new Item(2, [1.3, 3.4]));\n$itemList-\u003eaddItem(new Item(3, [4.5, 1.2]));\n$itemList-\u003eaddItem(new Item(4, [5.2, 3.5]));\n$itemList-\u003eaddItem(new Item(5, [2.1, 3.6]));\n\n//Building tree with given item list\n$tree = new KDTree($itemList);\n\n```\n\n### Searching nearest items to the given point\n\n``` php\n//Creating search engine with custom algorithm (currently Nearest Search)\n$searcher = new NearestSearch($tree);\n\n//Retrieving a result ItemInterface[] array with given size (currently 2)\n$result = $searcher-\u003esearch(new Point([1.25, 3.5]), 2);\n\necho $result[0]-\u003egetId(); // 2\necho $result[0]-\u003egetNthDimension(0); // 1.3\necho $result[0]-\u003egetNthDimension(1); // 3.4\n\necho $result[1]-\u003egetId(); // 1\necho $result[1]-\u003egetNthDimension(0); // 1.2\necho $result[1]-\u003egetNthDimension(1); // 4.3\n\n```\n\n### Persist tree to a binary file\n\n``` php\n//Init tree writer\n$persister = new FSTreePersister('/path/to/dir');\n\n//Save the tree to /path/to/dir/treeName.bin\n$persister-\u003econvert($tree, 'treeName.bin');\n\n```\n\n### File system version of the tree\n\n``` php\n//ItemInterface factory\n$itemFactory = new ItemFactory();\n\n//Then init new instance of file system version of the tree\n$fsTree = new FSKDTree('/path/to/dir/treeName.bin', $itemFactory);\n\n//Now use fs kdtree to search\n$fsSearcher = new NearestSearch($fsTree);\n\n//Retrieving a result ItemInterface[] array with given size (currently 2)\n$result = $fsSearcher-\u003esearch(new Point([1.25, 3.5]), 2);\n\necho $result[0]-\u003egetId(); // 2\necho $result[1]-\u003egetId(); // 1\n\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email volodymyrbas@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Volodymyr Basarab][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/hexogen/kdtree.svg?style=flat-square\n[ico-tests]: https://img.shields.io/github/actions/workflow/status/hexogen/kdtree/tests.yml?branch=master\n[ico-codecov]: https://codecov.io/gh/hexogen/kdtree/graph/badge.svg?token=176L4UA0Y1\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/hexogen/kdtree.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/hexogen/kdtree\n[link-tests]: https://github.com/hexogen/kdtree/actions?query=workflow%3ATests\n[link-codecov]: https://codecov.io/gh/hexogen/kdtree\n[link-downloads]: https://packagist.org/packages/hexogen/kdtree\n[link-author]: https://github.com/hexogen\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexogen%2Fkdtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexogen%2Fkdtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexogen%2Fkdtree/lists"}