-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
71 lines (44 loc) · 1.74 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Created by PhpStorm.
* User: josue
* Date: 3/30/17
* Time: 9:43 PM
*/
require_once "src/SpatialHashTable/BiHashTable.php";
require_once "src/SpatialHashTable/SupportedGeometries/Edge.php";
require_once "src/SpatialHashTable/SupportedGeometries/Point.php";
use SpatialHashTable\BiHashTable;
use SpatialHashTable\SupportedGeometries\Edge;
use SpatialHashTable\SupportedGeometries\Point;
$b = new BiHashTable(1);
$b->addElement(new Edge(new Point(0.5, 0.5), new Point(2.5, 0.5), 100));
$b->addElement(new Edge(new Point(2.5, 0.5), new Point(0.5, 0.5), 200));
// horizontal
$b->outputHashTable();
echo "\n";
$b = new BiHashTable(1);
$b->addElement(new Edge(new Point( 0.5, 0.5), new Point(0.5, 2.5), 100));
$b->addElement(new Edge(new Point(0.5, 2.5), new Point(0.5, 0.5), 200));
// vertical
$b->outputHashTable();
echo "\n";
$b = new BiHashTable(1);
$b->addElement(new Edge(new Point( 0.5, 0.5), new Point(1.5, 1), 100));
$b->addElement(new Edge(new Point( 0.5, 0.75), new Point(1.25, 1.5), 200));
// tricky one
$b->outputHashTable();
echo "\n";
$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));
$b->addElement(new Edge(new Point(0.5, 0.5), new Point(0.5, 0.5), 500));
// inverted tricky one
$b->outputHashTable();
echo "\n";
echo json_encode($b->getAllElementsInCircle(new Point(0, 0)))."\n";
echo json_encode($b->getAllElementsInCircle(new Point(2,0)))."\n";
echo json_encode($b->getAllElementsInCircle(new Point(2,1)))."\n";
echo json_encode($b->getAllElementsInCircle(new Point(2,2)))."\n";