PHP code example of josue / spatial-hash-table

1. Go to this page and download the library: Download josue/spatial-hash-table library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

josue / spatial-hash-table example snippets




use SpatialHashTable\BiHashTable;
use SpatialHashTable\SupportedGeometries\Edge;
use SpatialHashTable\SupportedGeometries\Point;

$b = new BiHashTable(1);

$b->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)));