Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/j05u3/spatial-hash-table
2D hash table for fast edges-or-points-touching-circle retrieval
https://github.com/j05u3/spatial-hash-table
2d-hash-table 2d-tile hash in-memory-database in-memory-storage nearby nearby-locations php spatial spatial-functions spatial-index table
Last synced: about 1 month ago
JSON representation
2D hash table for fast edges-or-points-touching-circle retrieval
- Host: GitHub
- URL: https://github.com/j05u3/spatial-hash-table
- Owner: j05u3
- Created: 2017-03-31T20:58:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-10T02:56:00.000Z (almost 6 years ago)
- Last Synced: 2024-04-19T15:07:24.679Z (8 months ago)
- Topics: 2d-hash-table, 2d-tile, hash, in-memory-database, in-memory-storage, nearby, nearby-locations, php, spatial, spatial-functions, spatial-index, table
- Language: PHP
- Homepage:
- Size: 73.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Installation
Using [Composer](https://getcomposer.org), just add it to your `composer.json` by running:
```
composer require josue/spatial-hash-table
```## Description
You can throw edges and points at it and than make fast proximity queries in a fixed radius (set in the constructor).
## Usage
Example
![Alt Test case graph](docs/sample.png?raw=true "Test case")
```php
addElement(new Edge(new Point(-1.5, -1), new Point( -0.5, -0.5), 100));
$b->addElement(new Edge(new Point(1.25, 1.5), new Point( 0.5, 0.75), 200));
$b->addElement(new Edge(new Point(1.75, 1.75), new Point( 1.75, 1.25), 300));
$b->addElement(new Point(0.5, 0.5, 400));echo json_encode($b->getAllElementsInCircle(new Point(0,0)));
```
And the output is:```json
{
"100": {
"id": 100,
"p1": {
"id": 0,
"x": -1.5,
"y": -1
},
"p2": {
"id": 0,
"x": -0.5,
"y": -0.5
}
},
"200": {
"id": 200,
"p1": {
"id": 0,
"x": 1.25,
"y": 1.5
},
"p2": {
"id": 0,
"x": 0.5,
"y": 0.75
}
},
"400": {
"id": 400,
"x": 0.5,
"y": 0.5
}
}
```